/* Revenue assurance v3: Contracts (library, add contract, one contract). Kit tokens only.
   Patterns: live revenue product (research/live/02, 04, 05), Ramp reconciliation board, Rossum state colours. */

/* ---------- Library ---------- */
.ct-toolbar { margin-top: 24px; }
.ct-toolbar .spacer { flex: 1 1 0; }
.ct-id { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.ct-copy { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted-foreground); cursor: pointer; }
.ct-copy:hover { background: var(--muted); color: var(--foreground); }
.ct-copy svg.lucide { width: 12px; height: 12px; }
.ct-new { margin-left: 6px; }
.ct-leak { color: var(--destructive); font-weight: 500; }
.ct-chev { width: 16px; height: 16px; color: var(--muted-foreground); }
.ct-foot { margin-top: 12px; }
.rx-table tr.selected td { animation: ct-flash 2.4s var(--ease-move) both; }
@keyframes ct-flash { 0% { background: var(--muted-brand); } 100% { background: transparent; } }

/* ---------- Add contract dialog ---------- */
.ct-add { display: flex; flex-direction: column; gap: 16px; }
.ct-add-lead { margin-top: -8px; }
.ct-files { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow: auto; }
.ct-file { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; transition: background var(--motion-quick), border-color var(--motion-quick); }
.ct-file:hover { background: var(--accent); }
.ct-file:has(input:checked) { border-color: var(--border-brand); background: var(--background-brand); }
.ct-file.off { cursor: default; opacity: .6; }
.ct-file.off:hover { background: transparent; }
.ct-file input { accent-color: var(--primary); }
.ct-file-name { display: block; font-weight: 500; }
.ct-pdf { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--radius-md); background: var(--artifact-pdf); color: var(--universal-white); }
.ct-pdf svg.lucide { width: 16px; height: 16px; }
.ct-pdf.inv { background: var(--muted-brand); color: var(--primary); }
.rx-dialog .dialog-foot .grow { align-self: center; }

.ct-run { display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; }
.ct-run-file { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--radius-lg); background: var(--muted); }
.ct-run .rx-live-card.inline { border-radius: var(--radius-lg); }
.ct-run #ct-live-b:empty, .ct-run #ct-human:empty { display: none; }
.ct-confirm { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border)); border-radius: var(--radius-lg); background: var(--warning-foreground); animation: rx-rise var(--motion-deliberate) var(--ease-enter); }
.ct-confirm-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-md); background: var(--background); color: var(--warning); }
.ct-confirm-ic svg.lucide { width: 16px; height: 16px; }
.ct-map { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px; border-radius: var(--radius-md); background: var(--background); border: 1px solid var(--border); }
.ct-map > div { display: flex; flex-direction: column; min-width: 0; }
.ct-map > svg.lucide { width: 16px; height: 16px; color: var(--muted-foreground); }
.ct-map-v { font-weight: 500; }
.ct-conf { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--primary); }
.ct-conf .bar { width: 64px; }
.ct-confirm-act { gap: 8px; }
.ct-confirmed { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-lg); background: var(--muted); font-weight: 500; }
.ct-confirmed svg.lucide { width: 16px; height: 16px; color: var(--success); }

/* ---------- One contract: header chips and tabs ---------- */
.ct-one .rx-head { margin-bottom: 16px; }
.ct-chip-btn { cursor: pointer; font-variant-numeric: tabular-nums; }
.ct-chip-btn:hover { background: var(--accent); }
.ct-chip-btn svg.lucide:last-child { width: 12px; height: 12px; }
.ct-chip-warn { border-color: color-mix(in srgb, var(--warning) 50%, var(--border)); background: var(--warning-foreground); }
.ct-chip-conf { color: var(--muted-foreground); font-weight: 400; }
.rx-chip .ct-ok { color: var(--success); }
.rx-chips .btn.sm { height: 28px; }
.ct-spark { display: inline-grid; place-items: center; }
.ct-spark .fina-spark { width: 14px; height: 14px; }

.ct-tabs { display: flex; gap: 4px; height: 44px; border-bottom: 1px solid var(--border); margin: 0 -40px 24px; padding: 0 28px; overflow-x: auto; }
.ct-tab { height: 44px; font-size: 14px; flex: none; }
.ct-tab:hover { color: var(--foreground); }
.ct-tab[aria-selected="true"]::after { background: var(--primary); }
.ct-tab .count { margin-left: 2px; }

.ct-card-title { font-size: 16px; line-height: 24px; font-weight: 600; }

/* ---------- Overview ---------- */
/* Integration pass (B): match board at full content width; background and next step above, key terms and exceptions below. */
.ct-ov { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.ct-ov-top { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.ct-ov-bottom { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
.ct-ov-top > *, .ct-ov-bottom > * { min-width: 0; }
.ct-bg { display: flex; flex-direction: column; gap: 8px; padding: 16px 20px; border-radius: var(--radius-xl); background: var(--background-brand); border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent); }
.ct-bg .rx-reading { font-size: 15px; line-height: 24px; }
.ct-ai-note { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.ct-ai-note .fina-spark { width: 12px; height: 12px; color: var(--muted-foreground); }

.ct-side-card { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.ct-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); column-gap: 24px; }
/* Label above value: values wrap cleanly in any column width. */
.ct-kv > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.ct-kv dt { color: var(--muted-foreground); font-size: 13px; line-height: 20px; }
.ct-kv dd { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; font-weight: 500; min-width: 0; }
.ct-kv dd > span { min-width: 0; overflow-wrap: anywhere; }
.ct-kv .cite-chip, .ct-kv .cite { flex: none; }

.ct-todo { display: flex; flex-direction: column; gap: 4px; }
.ct-todo-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 8px; border: 0; border-radius: var(--radius-md); background: transparent; text-align: left; cursor: pointer; width: 100%; }
.ct-todo-row:hover { background: var(--accent); }
.ct-todo-row.first { background: var(--background-brand); }
.ct-todo-row svg.lucide { width: 16px; height: 16px; color: var(--muted-foreground); flex: none; }
.ct-todo-row.first svg.lucide:first-child { color: var(--primary); }
.ct-todo-l { display: block; font-weight: 500; }
.ct-todo-row .t-meta { display: block; }
.ct-progress { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.ct-allclear { display: flex; align-items: center; gap: 8px; color: var(--muted-foreground); }
.ct-allclear svg.lucide { width: 16px; height: 16px; color: var(--success); }

.ct-exl { display: flex; flex-direction: column; margin: 0 -8px; }
.ct-ex { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-md); color: inherit; text-decoration: none; }
.ct-ex:hover { background: var(--accent); }
.ct-ex-t { display: block; font-weight: 500; }
.ct-ex .t-meta { display: block; max-width: 200px; }
.ct-ex-amt { font-weight: 600; color: var(--destructive); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ct-ex-amt.over { color: var(--warning); }

/* ---------- Three-way match board ---------- */
.ct-mb { padding: 16px 20px 8px; }
.ct-mb-head { margin-bottom: 16px; gap: 8px; }
.ct-per { width: auto; min-width: 168px; }
.ct-grid { display: grid; grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1fr) 84px minmax(0, 1fr); align-items: stretch; }
.ct-sum { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.ct-col-h { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: var(--radius-lg); background: var(--muted); min-width: 0; }
.ct-leg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .04em; }
.ct-leg svg.lucide { width: 14px; height: 14px; }
.ct-tot { font-size: 20px; line-height: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ct-src { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
/* Source labels in the column headers wrap instead of truncating. */
.ct-col-h .ct-src { align-items: flex-start; }
.ct-col-h .ct-src svg.lucide { margin-top: 2px; }
.ct-col-h .ct-src .truncate { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.ct-src svg.lucide { width: 12px; height: 12px; flex: none; }
.ct-src b { font-weight: 500; color: var(--foreground); }

.ct-lines { display: flex; flex-direction: column; }
.ct-line { padding: 12px 0; border-bottom: 1px solid var(--border); }
.ct-line:last-child { border-bottom: 0; }
.ct-cell { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; min-width: 0; }
.ct-cell-l { font-size: 13px; line-height: 20px; font-weight: 500; overflow-wrap: anywhere; }
.ct-cell-v { font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; }
.ct-cell-v b { font-weight: 600; }
.ct-cell-s { display: flex; align-items: center; gap: 6px; min-height: 24px; min-width: 0; }

.ct-conn { position: relative; display: grid; place-items: center; min-height: 40px; border: 0; background: transparent; padding: 0; font: inherit; }
.ct-conn-line { position: absolute; left: 4px; right: 4px; top: 50%; border-top: 1px dashed var(--border); }
.ct-conn.ok .ct-conn-line { border-top: 1px solid color-mix(in srgb, var(--success) 45%, transparent); }
.ct-conn.bad .ct-conn-line { border-top: 1px solid color-mix(in srgb, var(--destructive) 50%, transparent); }
.ct-conn.warn .ct-conn-line { border-top: 1px solid color-mix(in srgb, var(--warning) 55%, transparent); }
.ct-conn-dot { position: relative; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--success-foreground); color: var(--success); box-shadow: 0 0 0 3px var(--card); }
.ct-conn-dot svg.lucide { width: 14px; height: 14px; }
.ct-conn.pend .ct-conn-dot { background: var(--muted); color: var(--muted-foreground); }
.ct-conn-pill { position: relative; padding: 2px 8px; border-radius: var(--radius-full); font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; box-shadow: 0 0 0 3px var(--card); }
.ct-conn.bad .ct-conn-pill { background: var(--destructive-foreground); color: var(--destructive); border: 1px solid color-mix(in srgb, var(--destructive) 35%, transparent); }
.ct-conn.warn .ct-conn-pill { background: var(--warning-foreground); color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); }
button.ct-conn { cursor: pointer; }
button.ct-conn:hover .ct-conn-pill { box-shadow: 0 0 0 3px var(--card), var(--shadow-sm); }
.ct-line.gap { background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--destructive) 4%, transparent), transparent); }
.ct-reason { display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 6px 10px; border-radius: var(--radius-md); background: var(--background-brand); font-size: 13px; line-height: 20px; }
.ct-reason .fina-spark { width: 12px; height: 12px; }
.ct-reason-go { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; white-space: nowrap; }
.ct-reason-go svg.lucide { width: 14px; height: 14px; }

/* ---------- Terms: list left, document right ---------- */
.ct-one-terms .rx-fina-card { margin-bottom: 16px; }
.ct-terms { display: grid; grid-template-columns: minmax(340px, 40%) minmax(0, 1fr); height: calc(100vh - 312px); min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; }
.ct-tl { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--background); }
.ct-tl-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex: none; }
.ct-tl-head .spacer { flex: 1; }
.ct-tl-list { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 24px; }
.ct-tr { min-height: 0; min-width: 0; }
.ct-viewer { height: 100%; }
.ct-legend { display: inline-flex; gap: 8px; font-size: 12px; color: var(--muted-foreground); }
.ct-legend span { display: inline-flex; align-items: center; gap: 4px; }
.ct-legend span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.ct-legend .st-ai::before { background: color-mix(in srgb, var(--information) 22%, transparent); }
.ct-legend .st-review::before { background: color-mix(in srgb, var(--warning) 30%, transparent); }
.ct-legend .st-confirmed::before { background: color-mix(in srgb, var(--success) 25%, transparent); }

.ct-grp + .ct-grp { margin-top: 12px; }
.ct-grp-h { display: flex; align-items: center; gap: 8px; padding: 8px 4px; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .04em; }
.ct-term { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); cursor: pointer; transition: background var(--motion-quick), border-color var(--motion-quick), box-shadow var(--motion-quick); }
.ct-term + .ct-term { margin-top: 6px; }
.ct-term::before { content: ""; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--information); }
.ct-term.st-review::before { background: var(--warning); }
.ct-term.st-confirmed::before { background: var(--success); }
.ct-term:hover { background: var(--accent); }
.ct-term.on { border-color: var(--border-brand); background: var(--background-brand); box-shadow: 0 0 0 1px var(--border-brand); }
.ct-term:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.ct-term-l { font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.ct-term-v { font-weight: 500; overflow-wrap: anywhere; }
.ct-term-m { gap: 8px; min-height: 32px; }
.ct-term-m .spacer { flex: 1; }
.ct-term-pg { font-size: 12px; color: var(--primary); font-weight: 500; }
.ct-term-ok { display: none; }
.ct-term.on .ct-term-ok, .ct-term:hover .ct-term-ok, .ct-term.st-review .ct-term-ok { display: inline-flex; }

.ct-q { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.ct-q + .ct-q { margin-top: 8px; }
.ct-q-t { font-weight: 500; }
.ct-q-a { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); font-family: var(--font-serif); font-size: 14px; line-height: 22px; }
.ct-q-f .spacer { flex: 1; }

/* passive marks in the document, coloured by state; the active citation stays the cite-viewer green */
mark.ct-tm { color: inherit; border-radius: 2px; padding: 0 1px; cursor: pointer; background: color-mix(in srgb, var(--information) 14%, transparent); border-bottom: 2px solid color-mix(in srgb, var(--information) 55%, transparent); }
mark.ct-tm.st-review { background: color-mix(in srgb, var(--warning) 18%, transparent); border-bottom-color: color-mix(in srgb, var(--warning) 70%, transparent); }
mark.ct-tm.st-confirmed { background: color-mix(in srgb, var(--success) 14%, transparent); border-bottom-color: color-mix(in srgb, var(--success) 60%, transparent); }
mark.ct-tm:hover { filter: brightness(.96); }

.ct-fresh .ct-term, .ct-fresh .ct-q { animation: ct-in var(--motion-deliberate) var(--ease-enter) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes ct-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Billing ---------- */
.ct-gap16 { height: 16px; }
.ct-neg { color: var(--destructive); font-weight: 500; }
.ct-pos { color: var(--warning); font-weight: 500; }

/* ---------- Documents ---------- */
.ct-docs { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; }
.ct-doc { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--border); background: var(--card); text-align: left; cursor: pointer; width: 100%; }
.ct-doc:last-child { border-bottom: 0; }
.ct-doc:hover { background: var(--accent); }
.ct-doc-t { display: block; font-weight: 500; }

/* ---------- Activity ---------- */
.ct-act { padding: 4px 20px; }
.ct-act-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.ct-act-row:last-child { border-bottom: 0; }
.ct-act-ic { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--muted); color: var(--muted-foreground); }
.ct-act-ic svg.lucide { width: 14px; height: 14px; }
.ct-act-w { display: block; font-weight: 500; }
.ct-act-row .t-meta { display: block; }
.ct-act-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; white-space: nowrap; }

@media (max-width: 1180px) {
  .ct-ov-top, .ct-ov-bottom { grid-template-columns: minmax(0, 1fr); }
  .ct-grid { grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr) 64px minmax(0, 1fr); }
}
@media (max-width: 1100px) { .ct-tabs { margin: 0 -24px 24px; padding: 0 12px; } }
@media (prefers-reduced-motion: reduce) { .ct-fresh .ct-term, .ct-fresh .ct-q, .rx-table tr.selected td { animation: none; } }
.ct-map { flex-direction: column; align-items: stretch; gap: 8px; }
.ct-map-row { display: grid !important; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: 8px; flex-direction: row !important; }
.ct-matched-on { display: flex; flex-wrap: wrap; gap: 6px; }
.ct-matched-on .badge { background: var(--background); border: 1px solid var(--border); color: var(--muted-foreground); }
.ct-matched-on .badge svg.lucide { color: var(--success); }
.ct-tot-u { font-size: 14px; font-weight: 500; color: var(--muted-foreground); }
.ct-pending { margin: 0 0 12px; }

/* Round 2: upload a real PDF (U3) */
.ct-drop { position: relative; display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px 16px; border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--muted); cursor: pointer; transition: background var(--motion-quick), border-color var(--motion-quick); }
.ct-drop:hover, .ct-drop.over { border-color: var(--border-brand); background: var(--background-brand); }
.ct-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ct-drop-ic { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: var(--radius-md); background: var(--muted-brand); color: var(--primary); }
.ct-drop-spin { display: none; }
.ct-drop.busy .ct-drop-spin { display: inline-block; }
.ct-drop.busy .btn { display: none; }
.ct-samples-link { display: inline-flex; align-items: center; gap: 4px; }
.ct-samples-link svg.lucide { width: 12px; height: 12px; }
.ct-uploads { margin-top: 32px; }
.ct-up { display: flex; flex-direction: column; gap: 24px; }
.ct-up-terms { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.ct-up-group { padding: 8px 12px; background: var(--muted); font-size: 12px; font-weight: 600; color: var(--muted-foreground); }
.ct-up-term { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-top: 1px solid var(--border); }
.ct-up-pages { display: flex; flex-direction: column; gap: 12px; }
.ct-up-page { position: relative; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--universal-white); box-shadow: var(--shadow-sm); }
.ct-up-page canvas { display: block; }
.ct-up-no { position: absolute; right: 8px; bottom: 8px; padding: 2px 6px; border-radius: var(--radius-full); background: var(--muted); font-size: 11px; color: var(--muted-foreground); }
.ct-sup-title { margin-top: 24px; }
.ct-csv { display: flex; flex-direction: column; gap: 12px; }
.ct-csv-wrap { max-height: 70vh; overflow: auto; }
.ct-src-logo { width: 14px; height: 14px; object-fit: contain; flex: none; }

/* QA fixes (V9): SAP customer candidates under Change */
.ct-sap-list { display: flex; flex-direction: column; gap: 4px; }
.ct-sap-opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); text-align: left; cursor: pointer; transition: background var(--motion-quick), border-color var(--motion-quick); }
.ct-sap-opt:hover { background: var(--accent); }
.ct-sap-opt.on { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: var(--background-brand); }
.ct-sap-opt > svg.lucide { width: 16px; height: 16px; flex: none; color: var(--muted-foreground); }
.ct-sap-opt.on > svg.lucide { color: var(--primary); }
.ct-sap-opt .grow { display: flex; flex-direction: column; min-width: 0; }
.ct-sap-name { font-weight: 500; }
.ct-sap-opt .ct-conf { margin-left: 0; flex: none; }
.ct-tl-list { padding-bottom: 72px; }
