/* Market area (buyer RFQs, provider opportunities/offers, broker queue). Tokens only; dark is a token swap. */

/* Panels: a .card with a titled head */
.mk-panel { padding: 20px; }
.mk-h { font-size: 1.125rem; line-height: 1.35; font-weight: 600; margin: 0; }
[dir="rtl"] .mk-h { font-size: 1.1875rem; line-height: 1.55; }
.mk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-block-end: 12px; }
.mk-head > a { font-size: .875rem; white-space: nowrap; }
.mk-h + p, .mk-head + p { margin-block-start: 0; }
.mk-h:not(.mk-head .mk-h) { margin-block-end: 12px; }
.mk-note { font-size: .875rem; color: var(--tk-ink-3); }
.mk-meta { font-size: .8125rem; color: var(--tk-ink-3); }
@media (max-width: 575.98px) { .mk-panel { padding: 16px; } }

/* Row lists: one line of work per row, tappable title, status at the end */
.mk-list { list-style: none; padding: 0; margin: 0; }
.mk-list > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; min-block-size: var(--tk-touch); padding-block: 10px; border-block-end: 1px solid var(--tk-border); font-size: .875rem; }
[dir="rtl"] .mk-list > li { font-size: .9375rem; }
.mk-list > li:last-child { border-block-end: 0; padding-block-end: 0; }
.mk-list > li:first-child { padding-block-start: 0; }
.mk-list-main { flex: 1 1 13rem; min-inline-size: 0; display: grid; gap: 2px; overflow-wrap: anywhere; }
.mk-list-title { font-weight: 600; color: var(--tk-ink); }
a.mk-list-title, .mk-list-main > a { text-decoration: none; }
.mk-list-end { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; text-align: end; }
.mk-list-end > a { white-space: nowrap; }
.mk-ico { flex: 0 0 auto; display: inline-grid; place-items: center; inline-size: 32px; block-size: 32px; border-radius: 50%; background: var(--tk-sky-soft); color: var(--tk-sky-ink); }
.mk-ico-attention { background: var(--tk-warning-soft); color: var(--tk-warning-ink); }
.mk-list > li.mk-list-start { justify-content: flex-start; flex-wrap: nowrap; }
.mk-list > li.mk-list-start .mk-list-main { flex-basis: 0; }
.mk-list > li.is-unread .mk-list-main > a { font-weight: 600; }
.mk-check-done { color: var(--tk-success); }
.mk-check-todo { color: var(--tk-border-strong); }
.mk-count { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--tk-ink); }

/* Route motif: hollow origin port, dashed leg, filled destination port */
.mk-route { display: inline-flex; align-items: center; gap: 8px; max-inline-size: 100%; font-weight: 600; color: var(--tk-ink); }
/* break-word, not anywhere: a narrow table cell must not split country names letter by letter */
.mk-route > bdi { min-inline-size: 0; overflow-wrap: break-word; }
.mk-port { flex: 0 0 auto; inline-size: 10px; block-size: 10px; border-radius: 50%; border: 2px solid var(--tk-sky); background: var(--tk-surface); }
.mk-port.is-dest { border-color: var(--tk-accent); background: var(--tk-accent); }
.mk-leg { flex: 1 0 20px; inline-size: 20px; border-block-start: 1px dashed var(--tk-border-strong); }
.mk-route-wide { display: flex; }
.mk-route-wide .mk-leg { flex-grow: 1; }
.mk-route-sm { font-weight: 400; gap: 6px; }
.mk-route-sm .mk-port { inline-size: 8px; block-size: 8px; }
.mk-route-sm .mk-leg { flex: 0 0 14px; }

/* Request-type chip: colour + icon + text */
.mk-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--tk-r-pill); font-size: .75rem; font-weight: 600; line-height: 1.4; white-space: nowrap; background: var(--tk-neutral-soft); color: var(--tk-neutral-ink); }
[dir="rtl"] .mk-chip { font-size: .8125rem; line-height: 1.65; }
.mk-chip-goods { background: var(--tk-accent-soft); color: var(--tk-accent-ink); }
.mk-chip-trade { background: var(--tk-sky-soft); color: var(--tk-sky-ink); }
.mk-chip-freight { background: var(--tk-warning-soft); color: var(--tk-warning-ink); }
.mk-chip-violet { background: var(--tk-violet-soft); color: var(--tk-violet-ink); }

/* Facts: label / value rows; key facts: the four numbers people scan for */
.mk-facts { display: grid; grid-template-columns: minmax(112px, 34%) 1fr; margin: 0; font-size: .875rem; }
[dir="rtl"] .mk-facts { font-size: .9375rem; }
.mk-facts > dt, .mk-facts > dd { margin: 0; padding-block: 8px; border-block-end: 1px solid var(--tk-border); min-inline-size: 0; overflow-wrap: anywhere; }
.mk-facts > dt { font-weight: 400; color: var(--tk-ink-3); padding-inline-end: 12px; }
.mk-facts > dd { color: var(--tk-ink); }
.mk-facts > dt:last-of-type, .mk-facts > dd:last-of-type { border-block-end: 0; padding-block-end: 0; }
.mk-facts-plain { grid-template-columns: 1fr auto; }
.mk-facts-plain > dt, .mk-facts-plain > dd { border-block-end: 0; padding-block: 3px; }
.mk-facts-plain > dd { text-align: end; }
.mk-keyfacts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; border: 1px solid var(--tk-border); border-radius: var(--tk-r-sm); background: var(--tk-border); overflow: hidden; }
.mk-keyfacts > div { background: var(--tk-surface-2); padding: 10px 14px; min-inline-size: 0; }
.mk-keyfacts dt { font-size: .75rem; font-weight: 500; color: var(--tk-ink-3); }
[dir="rtl"] .mk-keyfacts dt { font-size: .8125rem; }
.mk-keyfacts dd { margin: 0; font-weight: 600; color: var(--tk-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* four across only when the summary itself is wide enough (it also sits in half-width columns) */
.rfq-summary { container-type: inline-size; }
@container (min-width: 560px) { .mk-keyfacts-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mk-prose { max-inline-size: 68ch; overflow-wrap: anywhere; }
.mk-box { padding: 12px 14px; border-radius: var(--tk-r-sm); background: var(--tk-surface-2); border: 1px solid var(--tk-border); font-size: .875rem; }
.mk-box + .mk-box { margin-block-start: 8px; }

/* Head line under an h1: ref, status, who */
.mk-headline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-block-start: 6px; font-size: .875rem; color: var(--tk-ink-2); }
.mk-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 575.98px) {
  .mk-actions-row { inline-size: 100%; }
  .mk-actions-row > *, .mk-actions-row > form > .btn { flex: 1 1 auto; }
  .mk-actions-row > form > .btn, .mk-actions-row > .btn { inline-size: 100%; }
}

/* Filters and scrolling tab pills */
.mk-filters { padding: 16px; }
.mk-filters .btn { min-block-size: var(--tk-touch); }
.mk-pills { gap: 4px; }
.mk-pills .nav-link { white-space: nowrap; display: flex; align-items: center; gap: 6px; min-block-size: 40px; }
@media (pointer: coarse) { .mk-pills .nav-link { min-block-size: var(--tk-touch); } }
@media (max-width: 767.98px) {
  .mk-pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-inline: contain; margin-inline: -16px; padding: 5px 16px; }
  .mk-pills::-webkit-scrollbar { display: none; }
}

/* Stacked tables on phones: extends table[data-stack] from app.css */
.mk-table td.num { white-space: nowrap; }
.mk-table .mk-cell-title { font-weight: 600; color: var(--tk-ink); min-inline-size: 180px; }
.mk-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.mk-table th[scope="row"] { min-inline-size: 176px; }
.mk-table td.mk-cell-nowrap { white-space: nowrap; }
.mk-table tr.is-best > :first-child { border-inline-start: 3px solid var(--tk-success); }
@media (max-width: 639.98px) {
  table[data-stack].mk-table tr { padding: 12px 0; }
  table[data-stack].mk-table tbody tr:last-child { border-block-end: 0; }
  table[data-stack].mk-table th[scope="row"] { display: block; border: 0; padding: 6px 16px; }
  table[data-stack].mk-table td, table[data-stack].mk-table th { overflow-wrap: anywhere; }
  table[data-stack].mk-table td.num { white-space: normal; }
  table[data-stack].mk-table .mk-badges { justify-content: flex-end; }
  table[data-stack].mk-table td > * { min-inline-size: 0; }
  table[data-stack].mk-table .mk-cell-title { display: block; text-align: start; font-size: 1rem; min-inline-size: 0; }
  table[data-stack].mk-table .mk-cell-title::before { content: none; }
  table[data-stack].mk-table .mk-cell-block { display: block; text-align: start; }
  table[data-stack].mk-table .mk-cell-block::before { display: block; margin-block-end: 4px; }
  table[data-stack].mk-table .mk-cell-actions:not(:has(*)) { display: none; }
  table[data-stack].mk-table .mk-cell-actions .btn { inline-size: 100%; }
  table[data-stack].mk-table tr.is-best > :first-child { border-inline-start: 0; }
  table[data-stack].mk-table tr.is-best { box-shadow: inset 3px 0 0 transparent; background: var(--tk-success-soft); }
}

/* Match score: number plus meter */
.mk-score { display: inline-grid; gap: 4px; justify-items: end; min-inline-size: 64px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-score .progress { inline-size: 64px; }
.match-reasons li { display: flex; gap: 6px; align-items: baseline; padding-block: 1px; }
.match-reasons .mk-pts { margin-inline-start: auto; padding-inline-start: 8px; color: var(--tk-ink-3); font-variant-numeric: tabular-nums; }
.match-reasons .is-plus .bi { color: var(--tk-success); }
.match-reasons .is-zero { color: var(--tk-ink-3); }
.match-reasons .is-minus { color: var(--tk-danger-ink); }

/* Opportunity cards */
.mk-opp { position: relative; display: flex; flex-direction: column; gap: 12px; block-size: 100%; padding: 18px 20px; transition: border-color var(--tk-dur-1) var(--tk-ease), box-shadow var(--tk-dur-1) var(--tk-ease); }
.mk-opp:focus-within { border-color: var(--tk-accent); box-shadow: var(--tk-shadow-2); }
.mk-opp:active { background: var(--tk-surface-2); }
.mk-opp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mk-opp-title { font-size: 1.0625rem; line-height: 1.35; font-weight: 600; margin: 0; }
[dir="rtl"] .mk-opp-title { line-height: 1.55; }
.mk-opp-title a { color: var(--tk-ink); text-decoration: none; }
.mk-opp-foot { margin-block-start: auto; padding-block-start: 12px; border-block-start: 1px solid var(--tk-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8125rem; color: var(--tk-ink-2); }
.mk-opp-foot .bi { color: var(--tk-accent); }
@media (hover: hover) {
  .mk-opp:hover { border-color: var(--tk-accent); box-shadow: var(--tk-shadow-2); }
  .mk-choice:hover { background: var(--tk-surface-2); }
  .mk-choice:has(:checked):hover { background: var(--tk-accent-soft); }
}

/* RFQ wizard: choice cards, numbered sections, action bar */
.mk-choice { position: relative; display: flex; gap: 12px; align-items: flex-start; block-size: 100%; padding: 14px 16px; border: 1px solid var(--tk-border-strong); border-radius: var(--tk-r-md); background: var(--tk-surface); }
.mk-choice .form-check-input { flex: 0 0 auto; margin: 2px 0 0; }
.mk-choice label { font-weight: 600; color: var(--tk-ink); cursor: pointer; }
.mk-choice label::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.mk-choice:has(:checked) { border-color: var(--tk-accent); background: var(--tk-accent-soft); box-shadow: inset 0 0 0 1px var(--tk-accent); }
.mk-choice:has(:focus-visible) { outline: 3px solid var(--tk-focus); outline-offset: 2px; }
.mk-choice .form-check-input:focus-visible { outline: 0; }
.mk-choice-ico { flex: 0 0 auto; margin-inline-start: auto; font-size: 1.25rem; color: var(--tk-ink-3); }
.mk-choice:has(:checked) .mk-choice-ico { color: var(--tk-accent-ink); }
.mk-step { padding: 20px; scroll-margin-block-start: calc(var(--tk-topbar-h) + 16px); }
.mk-step > .eyebrow { display: block; margin-block-end: 2px; color: var(--tk-accent-ink); }
.mk-step > .mk-h { margin-block-end: 16px; }
@media (min-width: 768px) { .mk-step { padding: 24px; } }
@media (max-width: 575.98px) { .mk-step { padding: 16px; } }
.mk-actions { justify-content: flex-end; align-items: center; border-radius: var(--tk-r-md) var(--tk-r-md) 0 0; }
.mk-actions > .mk-actions-start { margin-inline-end: auto; }
@media (max-width: 991.98px) {
  .mk-actions { margin-inline: -16px; border-radius: 0; }
  .mk-actions > .btn-primary, .mk-actions > .btn-outline-primary { flex: 1 1 auto; }
}

/* Repeating input rows (line items, milestones): a table on desktop, stacked rows on phones */
.mk-inputs td { vertical-align: middle; }
.mk-inputs td:first-child { inline-size: 28px; color: var(--tk-ink-3); font-size: .8125rem; }
.mk-inputs .mk-col-sm { inline-size: 22%; }
.mk-disclosure > summary { font-weight: 600; min-block-size: var(--tk-touch); display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--tk-ink); list-style: none; }
.mk-disclosure > summary::-webkit-details-marker { display: none; }
.mk-disclosure > summary::before { content: "\f64d"; font-family: "bootstrap-icons"; color: var(--tk-accent); }
.mk-disclosure[open] > summary::before { content: "\f63b"; }
.mk-disclosure { border-block-start: 1px solid var(--tk-border); }
@media (max-width: 575.98px) {
  .mk-inputs thead { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
  .mk-inputs tr { display: grid; grid-template-columns: 24px 1fr 1fr; gap: 6px 8px; padding-block: 10px; border-block-end: 1px solid var(--tk-border); }
  .mk-inputs tbody tr:last-child { border-block-end: 0; }
  .mk-inputs td { display: block; padding: 0 !important; border: 0; inline-size: auto !important; }
  .mk-inputs td:first-child { grid-row: span 2; align-self: start; padding-block-start: 12px !important; }
  .mk-inputs td:nth-child(2) { grid-column: 2 / -1; }
  .mk-inputs td:nth-child(3):last-child { grid-column: 2 / -1; }
}

/* Offer versions on a timeline */
.mk-version { padding: 14px 16px; border: 1px solid var(--tk-border); border-radius: var(--tk-r-sm); background: var(--tk-surface); }
.mk-version.is-current { border-color: var(--tk-accent); box-shadow: inset 0 0 0 1px var(--tk-accent); }
.mk-version-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-block-end: 8px; }
.mk-version-price { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--tk-ink); }

/* Broker screening decision */
.mk-decision { display: flex; flex-direction: column; gap: 8px; block-size: 100%; padding: 14px 16px; border: 1px solid var(--tk-border); border-radius: var(--tk-r-sm); background: var(--tk-surface-2); }
.mk-decision .btn { align-self: flex-start; }
.mk-decision > form { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.mk-decision > form > .btn { margin-block-start: auto; }
@media (max-width: 575.98px) { .mk-decision .btn { align-self: stretch; } }
.mk-inline-reject > summary { min-block-size: 32px; display: inline-flex; align-items: center; cursor: pointer; font-size: .875rem; color: var(--tk-danger-ink); }
@media (pointer: coarse) { .mk-inline-reject > summary { min-block-size: var(--tk-touch); min-inline-size: var(--tk-touch); } }

/* Broker KPI strip: six across on wide screens */
.mk-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 768px) { .mk-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1600px) { .mk-kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (min-width: 992px) { .mk-kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mk-kpis .kpi { min-inline-size: 0; }
.mk-kpis .kpi-label { display: flex; align-items: baseline; gap: 6px; }
.mk-kpis .kpi-value a { display: block; color: inherit; text-decoration: none; }
.mk-kpis .kpi-value { white-space: normal; }

@media (forced-colors: active) { .mk-choice:has(:checked), .mk-version.is-current { outline: 2px solid Highlight; } .mk-keyfacts > div, .mk-box, .mk-decision { background: Canvas; } }

/* Action bar inside a panel: bleed to the panel edges */
.mk-actions-inset { margin-inline: -20px; margin-block-end: -20px; border-radius: 0 0 calc(var(--tk-r-md) - 1px) calc(var(--tk-r-md) - 1px); }
@media (max-width: 991.98px) { .mk-actions-inset { margin-inline: -36px; border-radius: 0; } }
@media (max-width: 575.98px) { .mk-actions-inset { margin-inline: -32px; margin-block-end: -16px; } }

/* Broker detail: side panels sit beside the tables only on very wide screens, otherwise in a row below */
.mk-aside-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; align-items: start; align-content: start; }
@media (min-width: 640px) { .mk-table .match-reasons { min-inline-size: 240px; } .mk-table .mk-cell-actions .btn { white-space: nowrap; } }
@media (max-width: 639.98px) { [data-density="compact"] table[data-stack].mk-table td { padding-block: 3px; } }

/* user-entered Latin titles keep their own bidi run but align with the page, not with their own direction */
.page-head h1[dir="auto"], .mk-list-title[dir="auto"], .mk-auto { text-align: -webkit-match-parent; text-align: match-parent; }

/* after the dl resets above so the gap wins over their margin: 0 */
.mk-stack-gap > * + * { margin-block-start: 16px; }

/* text links in panel heads and rows: 44px tap height on touch devices without moving the text */
@media (pointer: coarse) {
  .mk-head > a, .mk-list a:not(.btn), .mk-cell-title > a { padding-block: 11px; margin-block: -11px; }
  .mk-kpis .kpi-value a { padding-block: 6px; margin-block: -6px; }
}
