/* Commerce area: deal rooms, deals, invoices, checkout, subscription, finance.
   Tokens only, logical properties only, every selector scoped to a .cm-* class (see README.txt). */

/* Card title (h3 role) and the back link above a page title */
.cm-title { font-size: 1.125rem; line-height: 1.35; font-weight: 600; margin-block: 0 12px; }
.cm-back { display: inline-flex; align-items: center; gap: 6px; min-block-size: 32px; font-size: .875rem; font-weight: 500; color: var(--tk-ink-2); text-decoration: none; }
.cm-back:active { color: var(--tk-ink); }
.cm-meta { font-size: .875rem; color: var(--tk-ink-2); }
.cm-head-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Label / value list: stacks on phones, two columns from 576px */
.cm-facts { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin: 0; font-size: .875rem; }
.cm-facts dt { font-weight: 500; color: var(--tk-ink-3); }
.cm-facts dd { margin: 0 0 10px; color: var(--tk-ink); }
.cm-facts dd.num { text-align: start; }
@media (min-width: 576px) {
  .cm-facts { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 10px 16px; }
  .cm-facts dd { margin: 0; }
}

/* Quiet inset box inside a card (dispute entry, approval, bank details) */
.cm-inset { background: var(--tk-surface-2); border: 1px solid var(--tk-border); border-radius: var(--tk-r-sm); padding: 12px 14px; font-size: .875rem; }
.cm-inset + .cm-inset { margin-block-start: 8px; }
/* Staff-internal panel: dual approval, internal notes */
.cm-internal { background: var(--tk-violet-soft); border: 1px dashed var(--tk-violet-ink); border-radius: var(--tk-r-md); padding: 16px 20px; color: var(--tk-ink); }
.cm-internal .cm-title, .cm-internal .cm-internal-label { color: var(--tk-violet-ink); }

/* Stacked tables on phones: the first cell is the card heading, empty cells disappear */
@media (max-width: 639.98px) {
  table[data-stack].cm-stack td:not([data-label]) { justify-content: flex-start; text-align: start; font-size: 1rem; font-weight: 600; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
  table[data-stack].cm-stack td:not([data-label])::before { content: none; }
  table[data-stack].cm-stack td:empty { display: none; }
  table[data-stack].cm-stack td > .btn { flex: 1 1 100%; }
  table[data-stack].cm-stack td[data-label] > span, table[data-stack].cm-stack td[data-label] > div { min-inline-size: 0; }
  table[data-stack].cm-stack tr { padding-block: 10px; }
  table[data-stack].cm-stack tbody tr:last-child { border-block-end: 0; }
  /* the title under a leading reference always starts its own line; .small cells keep full-size labels */
  table[data-stack].cm-stack td:not([data-label]) .cm-sub { flex: 1 1 100%; }
  table[data-stack].cm-stack td.small { font-size: inherit; }
  table[data-stack].cm-stack td.small > div { font-size: .875rem; }
}
.cm-stack .cm-sub { display: block; font-size: .875rem; font-weight: 400; color: var(--tk-ink-3); }

/* Deal-room inbox */
.cm-rooms { list-style: none; margin: 0; padding: 0; }
.cm-room { position: relative; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 14px 20px; border-block-end: 1px solid var(--tk-border); }
.cm-room:last-child { border-block-end: 0; }
.cm-room-main { flex: 1 1 260px; min-inline-size: 0; }
.cm-room-title { display: block; font-weight: 600; color: var(--tk-ink); text-decoration: none; overflow-wrap: anywhere; }
.cm-room-title::after { content: ""; position: absolute; inset: 0; }   /* whole row is the target */
.cm-room-title:focus-visible { outline: 0; }
.cm-room:has(.cm-room-title:focus-visible) { outline: 3px solid var(--tk-focus); outline-offset: -3px; border-radius: var(--tk-r-sm); }
.cm-room-side { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: .75rem; color: var(--tk-ink-3); }
.cm-room.is-unread { background: var(--tk-sky-wash); }
.cm-room:active { background: var(--tk-surface-2); }
@media (hover: hover) { .cm-room:hover { background: var(--tk-surface-2); } .cm-back:hover { color: var(--tk-ink); } }
@media (max-width: 575.98px) { .cm-room { padding-inline: 16px; } }

/* Conversation */
.cm-chat { overflow: clip; }
.cm-thread { padding: 20px; background: var(--tk-surface-2); }
.cm-thread .msg:has(form) { inline-size: 100%; max-inline-size: 100%; }
.cm-thread .msg:last-child { margin-block-end: 0; }
.cm-thread .empty-state { padding-block: 32px; }
.cm-msg-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-block-end: 4px; }
.cm-msg-foot { margin-block-start: 4px; }
.cm-relay { border-block-start: 1px solid var(--tk-border); margin-block-start: 10px; padding-block-start: 10px; }
.cm-composer .cm-attach { margin-block-start: 8px; }
.cm-composer .form-text { margin-block: 6px 0; }
@media (max-width: 575.98px) {
  .cm-thread { padding: 16px 12px; min-block-size: 44dvh; }
}

/* Offer revisions inside a timeline */
.cm-rev-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: .875rem; }
.cm-rev-price { font-size: 1.125rem; font-weight: 700; color: var(--tk-ink); font-variant-numeric: tabular-nums lining-nums; }

/* Fee snapshot */
/* labels get the room: without this a long value column squeezes them onto three lines on phones */
.cm-fee th { font-weight: 500; color: var(--tk-ink-2); inline-size: 50%; }
.cm-fee .cm-fee-sub th { font-weight: 400; color: var(--tk-ink-3); padding-inline-start: 24px; }
.cm-fee tr.is-total th { color: var(--tk-ink); }
.cm-fee tr.is-total td { font-size: 1.125rem; }

/* Acceptance: one line per party, state carried by icon + text */
.cm-parties { list-style: none; margin: 0 0 16px; padding: 0; }
.cm-parties li { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; padding-block: 10px; border-block-end: 1px solid var(--tk-border); font-size: .875rem; }
.cm-parties li:last-child { border-block-end: 0; }
.cm-parties:last-child { margin-block-end: 0; }
.cm-ok { color: var(--tk-success-ink); }
.cm-wait { color: var(--tk-ink-3); }

/* Kanban deal card */
.cm-deal-card { font-size: .875rem; margin-block-end: 8px; gap: 4px; }
.cm-deal-card:last-child { margin-block-end: 0; }
/* the whole card opens the deal (same pattern as .cm-room) */
.cm-deal-card { position: relative; }
.cm-deal-card > a:first-child::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.cm-deal-card > a:first-child:focus-visible { outline: 0; }
.cm-deal-card:has(> a:first-child:focus-visible) { outline: 3px solid var(--tk-focus); outline-offset: 2px; }
.cm-deal-card:active { background: var(--tk-surface-2); }
.cm-deal-row { display: flex; justify-content: space-between; gap: 12px; color: var(--tk-ink-2); }
.cm-deal-row .num { color: var(--tk-ink); font-weight: 600; }
.cm-deal-foot { color: var(--tk-ink-3); font-size: .75rem; padding-block-start: 6px; border-block-start: 1px solid var(--tk-border); margin-block-start: 4px; }
.cm-col-empty { font-size: .75rem; color: var(--tk-ink-3); margin: 0; }
/* view switch: two links styled as the segmented control */
.cm-switch { display: inline-flex; gap: 2px; padding: 3px; background: var(--tk-surface-3); border-radius: var(--tk-r-pill); }
.cm-switch a { display: inline-flex; align-items: center; gap: 6px; min-block-size: 34px; padding-inline: 14px; border-radius: var(--tk-r-pill); color: var(--tk-ink-2); font-size: .875rem; font-weight: 600; text-decoration: none; }
.cm-switch a[aria-current] { background: var(--tk-surface); color: var(--tk-ink); box-shadow: var(--tk-shadow-1); }
/* 44px targets on touch devices: view switch, back link, reference links that are the only way into a record */
@media (pointer: coarse) {
  .cm-switch a, .cm-back { min-block-size: var(--tk-touch); }
  .cm-stack a.ref, .cm-reflist a.ref { display: inline-flex; align-items: center; min-block-size: var(--tk-touch); min-inline-size: var(--tk-touch); }
  .cm-details > summary { min-block-size: var(--tk-touch); align-content: center; }
}

/* Filter chips row scrolls sideways on phones instead of wrapping to three lines */
.cm-chips { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; gap: 4px; }
.cm-chips .nav-link { white-space: nowrap; }
/* phones: fade the inline-end edge so a cut-off chip reads as "scroll for more"; the padding lets the last one clear the fade */
@media (max-width: 575.98px) {
  .cm-chips { padding-inline-end: 28px; -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent); mask-image: linear-gradient(to right, black calc(100% - 28px), transparent); }
  [dir="rtl"] .cm-chips { -webkit-mask-image: linear-gradient(to left, black calc(100% - 28px), transparent); mask-image: linear-gradient(to left, black calc(100% - 28px), transparent); }
}

/* Plans */
.cm-plan { block-size: 100%; }
.cm-plan .price { font-size: 2rem; }
.cm-plan .cm-per { font-size: .875rem; font-weight: 400; color: var(--tk-ink-3); }
.cm-plan-name { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; font-size: 1.125rem; font-weight: 600; margin-block: 0 12px; }
/* Quota */
.cm-quota-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: baseline; margin-block-end: 8px; }
.cm-quota-big { font-size: 1.875rem; line-height: 1.1; font-weight: 700; color: var(--tk-ink); font-variant-numeric: tabular-nums lining-nums; }
.cm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-block-start: 16px; }
.cm-stats > div { background: var(--tk-surface-2); border-radius: var(--tk-r-sm); padding: 10px 12px; }
.cm-stats dt { font-size: .75rem; font-weight: 500; color: var(--tk-ink-3); }
.cm-stats dd { margin: 0; font-size: 1.125rem; font-weight: 700; color: var(--tk-ink); font-variant-numeric: tabular-nums lining-nums; }

/* A notice with its action: text at inline-start, button at inline-end, stacked on phones */
.cm-notice { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.cm-notice > :first-child { flex: 1 1 240px; min-inline-size: 0; }
@media (max-width: 575.98px) { .cm-notice > .btn { flex: 1 1 100%; } }

/* Checkout summary and invoice totals */
.cm-lines { list-style: none; margin: 0; padding: 0; font-size: .875rem; }
.cm-lines li { display: flex; justify-content: space-between; gap: 16px; padding-block: 10px; border-block-end: 1px solid var(--tk-border); }
.cm-lines li.is-total { border: 0; margin-block-start: 8px; padding: 12px 14px; background: var(--tk-surface-2); border-radius: var(--tk-r-sm); font-weight: 600; font-size: 1rem; }
.cm-lines .num { white-space: nowrap; }
.cm-pay-title { display: flex; gap: 10px; align-items: center; }
.cm-pay-icon { display: inline-grid; place-items: center; inline-size: 36px; block-size: 36px; border-radius: 50%; background: var(--tk-accent-soft); color: var(--tk-accent-ink); flex: 0 0 auto; }

/* Invoice document: a sheet of paper on the page */
.cm-paper { padding: clamp(16px, 4vw, 40px); }
.invoice-doc .cm-doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; padding-block-end: 20px; margin-block-end: 20px; border-block-end: 1px solid var(--tk-border); }
.invoice-doc .cm-doc-brand { font-size: 1.375rem; font-weight: 700; color: var(--tk-ink); }
.invoice-doc .cm-doc-id { text-align: end; }
.invoice-doc .cm-doc-id h1 { font-size: 1.5rem; font-weight: 700; margin-block-end: 6px; }
.invoice-doc .cm-totals { inline-size: min(100%, 22rem); margin-inline-start: auto; margin-block-start: 12px; }
.invoice-doc .cm-totals th { font-weight: 500; color: var(--tk-ink-2); }
.invoice-doc .cm-totals tr.is-total th { color: var(--tk-ink); font-weight: 600; }
@media (max-width: 575.98px) { .invoice-doc .cm-doc-id { text-align: start; } }

/* Sticky action bar that bleeds to the edges of its card body */
.cm-card-actions { margin-inline: calc(-1 * var(--bs-card-spacer-x)); margin-block-end: calc(-1 * var(--bs-card-spacer-y)); padding-inline: var(--bs-card-spacer-x); border-end-start-radius: calc(var(--tk-r-md) - 1px); border-end-end-radius: calc(var(--tk-r-md) - 1px); align-items: center; }
@media (max-width: 575.98px) { .cm-card-actions > .btn { flex: 1 1 auto; } }

.cm-chart { block-size: 300px; }

/* Composer attachment: folded away until needed so the composer stays one line tall */
.cm-composer details.cm-attach > summary { display: inline-flex; align-items: center; gap: 6px; min-block-size: 32px; font-size: .875rem; font-weight: 600; color: var(--tk-ink-2); cursor: pointer; list-style: none; border-radius: var(--tk-r-xs); }
.cm-composer details.cm-attach > summary::-webkit-details-marker { display: none; }
.cm-composer details.cm-attach > summary label { cursor: pointer; }
.cm-composer details.cm-attach[open] > summary { color: var(--tk-ink); }
@media (pointer: coarse) { .cm-composer details.cm-attach > summary { min-block-size: var(--tk-touch); } }

/* References (bdi dir=ltr from bdi()/aliasHtml) never break at their hyphens; free-text titles (plain bdi) still wrap */
.cm-meta bdi[dir="ltr"], .cm-headline bdi[dir="ltr"], .cm-parties bdi[dir="ltr"] { white-space: nowrap; }
