/* Management follows the client-management mockup. All layout and type changes
   stay inside this view so the report and finance screens retain their styling. */

.ui-card .ui-cardbar { justify-content: space-between; }
.ui-cardbar .ui-search.mg-client-search { max-width: 460px; }

.mg-portal-preview { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 24px; background: var(--orange-pale); color: var(--orange-dark); font-size: 13px; }
.mg-portal-preview > span { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mg-preview-tag { padding: 2px 7px; border: 1px solid currentColor; border-radius: 99px; font-size: 11px; }
.mg-preview-return { color: inherit; font-weight: 600; white-space: nowrap; }
@media (max-width: 620px) { .mg-portal-preview { padding: 10px 16px; align-items: flex-start; } .mg-portal-preview > span { gap: 4px 8px; } .mg-preview-name { flex-basis: 100%; } }

.mg-status-error { color: var(--red); }

.mg-relations-table { min-width: 640px; table-layout: fixed; }
.mg-client-table { --table-min-width:960px; }
.mg-client-table th:nth-child(1), .mg-client-table th:nth-child(2) { width:24%; }
.mg-client-table th:nth-child(3) { width:20%; }
.mg-client-table th:nth-child(4), .mg-client-table th:nth-child(5) { width:8%; }
.mg-client-table th:nth-child(6) { width:16%; }
.mg-client-table .mg-contract-line { flex-wrap:wrap; gap:2px 8px; white-space:normal; }
.mg-client-table .mg-contract-line .ui-small { flex-basis:100%; padding-left:66px; }
.mg-client-table .ui-badge { max-width:100%; white-space:normal; }
.mg-relations-table th:nth-child(1) { width: 80%; }
.mg-relations-table th:nth-child(2) { width: 20%; }
.mg-relations-table td { overflow-wrap: anywhere; }
.mg-relation-clients-table { min-width: 480px; table-layout: fixed; }
.mg-relation-clients-table th:nth-child(1) { width: 65%; }
.mg-relation-clients-table th:nth-child(2) { width: 35%; }
.mg-relation-clients-table td { overflow-wrap: anywhere; }

.ui-table .mg-access-actions-heading, .mg-access-actions { text-align: right; }
.mg-access-actions .ui-actions { justify-content: flex-end; flex-wrap: wrap; }
.mg-access-actions .btn-ghost { white-space: nowrap; }
.btn-ghost.mg-remove-access { color: var(--red); border-color: transparent; }
.btn-ghost.mg-remove-access:hover:not(:disabled) { color: var(--red); border-color: var(--red); background: var(--red-pale); }
.mg-access-person { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-warm); overflow-wrap: anywhere; }
.mg-access-modal .ui-modal-body > p { margin: 16px 0 0; overflow-wrap: anywhere; }
.mg-access-modal .ui-notice { margin-top: 16px; }
.btn-primary.mg-remove-confirm { background: var(--red); border-color: var(--red); }
.btn-primary.mg-remove-confirm:hover:not(:disabled) { background: var(--red); filter: brightness(.9); }

.mg-channel-heading > div { flex: 1 1 420px; min-width: 0; }
.ui-modal.mg-channel-modal { width: 600px; max-height: calc(100dvh - 40px); display: flex; flex-direction: column; }
.mg-channel-modal > form { display: flex; flex-direction: column; min-height: 0; }
.mg-channel-modal .ui-modal-body { overflow-y: auto; }
.mg-channel-modal .ui-modal-header, .mg-channel-modal .ui-modal-footer, .mg-channel-modal .ui-modal-error { flex-shrink: 0; }
.mg-channel-editor { display: grid; gap: 20px; }
.mg-channel-identity { display: grid; gap: 14px; }
.mg-channel-editor .field { margin-bottom: 0; }
.mg-channel-editor #mg-channel-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.mg-channel-labels { border-top: 1px solid var(--border); padding-top: 18px; }
.mg-channel-labels h3 { margin: 0; font-size: 13px; }
.mg-channel-labels > .ui-small { margin: 5px 0 14px; }
.mg-channel-optional { font-weight: 400; color: var(--ink-light); }
.mg-channel-label-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.mg-channel-label-heading h4 { margin: 0; font-size: 12px; font-weight: 600; color: var(--ink-mid); }
.mg-channel-label-heading .btn-ghost { padding: 5px 9px; font-size: 12px; }
.mg-channel-label-list { display: grid; gap: 8px; }
.mg-channel-label-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 170px) auto; align-items: start; gap: 8px; margin-top: 8px; }
.mg-channel-label-row > * { min-width: 0; }
.mg-channel-label-row > .btn-ghost { padding: 7px 8px; font-size: 12px; }
.mg-channel-advanced { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-warm); }
.mg-channel-advanced summary { padding: 12px 14px; cursor: pointer; color: var(--ink-mid); font-size: 12px; font-weight: 600; }
.mg-channel-advanced summary:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: var(--radius-sm); }
.mg-channel-match-status { display: inline-block; margin-left: 8px; color: var(--amber); }
.mg-channel-matching { padding: 0 14px 14px; }
.mg-channel-matching label { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; font-weight: 600; }
.mg-channel-matching input[type=checkbox] { flex: none; width: 16px; height: 16px; margin: 2px 0 0; }
.mg-channel-matching .ui-small { margin: 6px 0 0 25px; }
@media (max-width: 520px) {
  .mg-channel-label-row { grid-template-columns: minmax(0, 1fr) auto; }
  .mg-channel-label-row > input { grid-column: 1 / -1; }
}
.mg-channel-table { min-width: 940px; table-layout: fixed; }
.mg-channel-table th:nth-child(1) { width: 25%; }
.mg-channel-table th:nth-child(2) { width: 19%; }
.mg-channel-table th:nth-child(3) { width: 21%; }
.mg-channel-table th:nth-child(4) { width: 20%; }
.mg-channel-table th:nth-child(5) { width: 15%; }
.mg-channel-table td { overflow-wrap: anywhere; }
.mg-channel-table td > small { margin-top: 4px; }
.mg-channel-values { margin: 0; padding: 0; list-style: none; }
.mg-channel-values .ui-badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.mg-channel-checks { display: flex; gap: 4px; align-items: center; }
.mg-channel-indicator { position: relative; flex: none; font: inherit; cursor: help; }
.mg-channel-indicator.is-confirmed, .mg-channel-indicator.is-confirmed:hover { color: var(--green); background: var(--green-pale); }
.mg-channel-indicator.is-missing, .mg-channel-indicator.is-missing:hover { color: var(--amber); background: var(--amber-pale); }
.mg-channel-indicator.is-unknown, .mg-channel-indicator.is-unknown:hover { color: var(--ink-light); background: var(--surface-warm); }
.mg-channel-indicator:is(:hover, :focus-visible) { border-color: var(--border-dark); }
.mg-channel-indicator:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.mg-channel-check-mark { position: absolute; right: 1px; bottom: 1px; display: grid; place-items: center; width: 10px; height: 10px; border-radius: 99px; background: inherit; font-size: 9px; font-weight: 600; line-height: 1; }
.mg-channel-check-tooltip { position: fixed; z-index: 1200; width: min(280px, calc(100vw - 16px)); padding: 10px 12px; border: 1px solid var(--border-dark); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); background: var(--surface); color: var(--ink); font-size: 13px; line-height: 1.5; pointer-events: none; text-align: left; white-space: normal; }
.mg-channel-check-tooltip strong, .mg-channel-check-tooltip > span { display: block; }
.mg-channel-check-tooltip > span { margin-top: 3px; color: var(--ink-mid); }

.mg-rules-table { min-width: 800px; table-layout: fixed; }
.mg-rules-table th:nth-child(1) { width: 22%; }
.mg-rules-table th:nth-child(2) { width: 38%; }
.mg-rules-table th:nth-child(3) { width: 30%; }
.mg-rules-table th:nth-child(4) { width: 10%; }
.mg-rules-table td { vertical-align: top; overflow-wrap: anywhere; }
.mg-rule-condition-group + .mg-rule-condition-group { margin-top: 8px; }
.mg-rule-condition-heading { display: block; margin-bottom: 4px; color: var(--ink-mid); font-size: 12px; }
.mg-rule-condition-heading::first-letter { text-transform: uppercase; }
.mg-rule-values { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0; padding: 0; list-style: none; }
.mg-rule-values li { min-width: 0; max-width: 100%; padding: 2px 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-warm); font-size: 13px; }
.mg-rule-condition-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.mg-rules-table .mg-rule-toggle { font-size: 12px; font-weight: 600; white-space: nowrap; }

.ui-modal.mg-audit-modal { width: 740px; max-height: calc(100dvh - 100px); display: flex; flex-direction: column; }
.mg-audit-modal .ui-modal-body { overflow-y: auto; }
.mg-audit-modal .ui-modal-header, .mg-audit-modal .ui-modal-footer { flex-shrink: 0; }
.mg-audit-subject { margin: 0 0 16px; color: var(--ink); font-size: 18px; font-weight: 650; }
.mg-audit-meta { margin: 0 0 20px; }
.mg-audit-modal h3 { margin: 20px 0 10px; font-size: 13px; }
.mg-audit-changes { table-layout: fixed; }
.mg-audit-changes td, .mg-audit-modal dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.mg-audit-changes th { white-space: normal; }
.mg-audit-old { color: var(--ink-light); }
.mg-audit-context-row { display: contents; }
@media (max-width: 760px) { .ui-modal.mg-audit-modal { max-height: calc(100dvh - 40px); } }
.mg-contract-modal { width: 680px; max-height: calc(100dvh - 80px); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.mg-contract-modal form { display: flex; flex-direction: column; min-height: 0; }
.mg-contract-modal .ui-modal-header,
.mg-contract-modal .ui-modal-error,
.mg-contract-modal .ui-modal-footer { flex-shrink: 0; }
.mg-contract-modal .ui-modal-header { padding: 18px 22px 12px; }
.mg-contract-client { margin: 8px 0 0; color: var(--ink-light); font-size: 14px; }
.mg-contract-modal .ui-modal-body { padding: 18px 22px; overflow-y: auto; }
.contract-editor-body { gap: 12px; }
.contract-editor-body .field { margin-bottom: 0; }
.contract-editor-body .field label { margin-bottom: 7px; }
.contract-editor-body .contract-term-type { width: min(290px, 100%); }
.contract-editor-body .contract-fixed-fee { max-width: 180px; }
.contract-editor-body .contract-fixed-share { max-width: 90px; }
.contract-editor-body .contract-optional-field { max-width: 360px; }
.contract-editor-body .contract-add-tier { display: block; margin: 12px auto 0; }
.contract-editor-body .contract-add-tier,
.contract-editor-body .contract-optional-toggle { border-color: transparent; color: var(--ink-light); }
.contract-editor-body .contract-optional-toggle { color: var(--blue); padding-left: 8px; }
.contract-editor-body .contract-money-input .price-input { width: 138px; }
.contract-editor-body .contract-month-input .price-input { width: 76px; }
.contract-editor-body .contract-suffix-input .price-input { width: 72px; }
.contract-editor-body .ui-checks { margin: 0; }
.contract-editor-body .contract-tier-actions .btn-ghost { padding: 5px; border-color: transparent; }
@media (max-width: 620px) {
  .contract-editor-body .contract-tier-head,
  .contract-editor-body .contract-tier-row { grid-template-columns: minmax(0, 1fr) 86px; }
  .contract-editor-body .contract-tier-actions { grid-column: 1 / -1; }
  .contract-editor-body .contract-tier-actions .btn-ghost:first-child { display: inline-flex; }
  .contract-editor-body .contract-money-input .price-input { width: 100%; min-width: 0; }
  .contract-editor-body .contract-month-input .price-input { width: 65px; }
}
.ui-modal.mg-rule-modal { width: 720px; max-height: calc(100dvh - 64px); display: flex; flex-direction: column; }
.mg-rule-modal form { display: flex; flex-direction: column; min-height: 0; }
.mg-rule-modal .ui-modal-body { overflow-y: auto; }
.mg-rule-modal .ui-modal-header, .mg-rule-modal .ui-modal-footer, .mg-rule-modal .ui-modal-error { flex-shrink: 0; }
.mg-rule-editor .ui-grid { margin-bottom: 0; }
.mg-rule-match { max-width: 320px; }
.mg-rule-condition-list { display: grid; gap: 12px; margin: 16px 0; }
.mg-rule-condition { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.mg-rule-condition-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; align-items: start; gap: 8px; margin-bottom: 12px; }
.mg-rule-remove { padding: 7px 10px; color: var(--ink-light); border-color: transparent; }
.mg-rule-texts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--border-dark); border-radius: var(--radius-sm); background: var(--surface); cursor: text; }
.mg-rule-texts:focus-within { outline: 2px solid var(--orange); outline-offset: 1px; }
.mg-rule-pill { display: inline-flex; align-items: center; max-width: 100%; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-warm); }
.mg-rule-pill.is-editing { border-color: var(--orange); background: var(--orange-pale); }
.mg-rule-pill button { border: 0; background: none; font: inherit; font-size: 13px; cursor: pointer; }
.mg-rule-pill-edit { min-width: 0; padding: 5px 4px 5px 8px; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
.mg-rule-pill-remove { flex-shrink: 0; padding: 5px 7px; color: var(--ink-light); }
.mg-rule-pill-remove:hover { color: var(--red); }
.mg-rule-texts input { flex: 1 1 220px; width: 0; min-width: min(180px, 100%); padding: 5px 3px; border: 0; border-radius: 0; box-shadow: none; background: transparent; font-size: 13px; }
.mg-rule-texts input:focus { outline: 0; box-shadow: none; }
.mg-rule-text-add { padding: 5px; }
.mg-rule-condition-footer { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.mg-rule-condition-footer .ui-small { flex: 1 1 260px; margin: 0; }
.mg-rule-case { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-mid); font-size: 12px; white-space: nowrap; }
.mg-rule-case input { width: auto; margin: 0; }

@media (max-width: 980px) {

  .ui-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {

  .ui-content { max-width: none; padding: 20px 16px 48px; }
  .ui-grid { grid-template-columns: 1fr; }
  .ui-facts { grid-template-columns: 110px minmax(0, 1fr); }
  .ui-overlay { padding: 20px 10px; }
  .ui-modal.mg-rule-modal { max-height: calc(100dvh - 40px); }
  .mg-rule-condition { padding: 10px; }
  .mg-rule-condition-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; gap: 6px; }
}
@media (max-width: 440px) {
  .ui-facts { grid-template-columns: 1fr; gap: 2px; }
  .ui-facts dd { margin-bottom: 7px; }
  .ui-modal-header, .ui-modal-body, .ui-modal-footer { padding-right: 14px; padding-left: 14px; }
}

/* Finance settings share the Management content width on every screen size. */
.mg-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 20px; }

.mg-target-form { display: flex; align-items: flex-end; gap: 12px; margin: 18px 0; }
.mg-target-form .field { flex: 1; margin: 0; }
.mg-target-candidates { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.mg-target-overlay { padding: 24px 16px; }
.ui-modal.mg-target-modal { width: 900px; max-height: calc(100dvh - 48px); display: flex; flex-direction: column; }
.mg-target-modal .ui-modal-body { min-height: 0; overflow-y: auto; }
.mg-target-modal .ui-modal-header, .mg-target-modal .ui-modal-footer { flex-shrink: 0; }
.ui-modal.mg-resolution-modal { width: 640px; }
.mg-resolution-modal > form { min-height: 0; display: flex; flex-direction: column; }
.mg-resolution-fields { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.mg-resolution-fields legend { font-weight: 600; margin-bottom: 12px; }
.mg-resolution-fields > .field { margin-bottom: 14px; }
.mg-resolution-fields > p { margin: 8px 0; }
.mg-resolution-fields .styled-dropdown { width: 100%; margin-bottom: 12px; }
.mg-target-subject { margin: 0 0 16px; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.mg-target-review { padding: 14px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.mg-target-review p { margin: 8px 0; }
.mg-target-review h3 { margin: 0 0 8px; font-size: 14px; }
.mg-target-modal .ui-modal-footer { flex-wrap: wrap; }
.mg-target-modal .ui-modal-footer > p { flex: 1 1 240px; margin: 0; }
.mg-target-review .ui-badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.mg-target-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.mg-target-heading > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; min-width: 0; }
.mg-target-caption, .mg-target-fields dt { color: var(--ink-light); font-size: 12px; font-weight: 500; }
.mg-target-asset-id { font-size: 14px; overflow-wrap: anywhere; }
.mg-target-context { margin: 10px 0 18px; }
.mg-target-result .ui-badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.mg-target-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mg-target-comparison-single { grid-template-columns: 1fr; }
.mg-target-panel { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.mg-target-panel h3 { margin: 0 0 14px; font-size: 13px; font-weight: 650; }
.mg-target-fields { display: grid; gap: 12px; margin: 0; }
.mg-target-fields > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: baseline; gap: 8px; }
.mg-target-fields dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.mg-target-evidence { margin: 14px 0 0; }
.mg-target-rules { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 14px; margin: 16px 0; }
.mg-sync-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mg-sync-kpis > .ui-kpi:nth-last-child(2) { grid-column: auto; }
.mg-sync-kpi-status { grid-column: 1 / -1; padding: 12px 18px; background: var(--surface); color: var(--ink-light); font-size: 12px; line-height: 1.5; }
.mg-sync-kpi-button { display: block; font: inherit; font-size: 24px; font-weight: 700; color: inherit; }
.mg-sync-refresh { order: 1; margin-left: auto; }
.mg-review-identity { margin-top: 8px; }
.mg-sync-evidence { margin-top: 8px; }
.mg-sync-attribution { margin-bottom: 12px; overflow-wrap: anywhere; }
.mg-sync-attribution > div + div { margin-top: 5px; }
.mg-target-attribution { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 18px; }
.mg-review-table .ui-badge { white-space: normal; }
.mg-sync-table.mg-review-table th:nth-child(1) { width: 56%; }
.mg-sync-table.mg-review-table th:nth-child(2) { width: 26%; }
.mg-sync-table.mg-review-table th:nth-child(3) { width: 18%; }
@media (max-width: 760px) {
  .mg-sync-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-sync-kpis > .ui-kpi:nth-last-child(2) { grid-column: auto; }
  .mg-target-comparison { grid-template-columns: 1fr; }

}

.mg-sync-table { position: relative; min-width: 700px; table-layout: fixed; }
.mg-sync-table th:nth-child(1) { width: 50%; }
.mg-sync-table th:nth-child(2) { width: 32%; }
.mg-sync-table th:nth-child(3) { width: 18%; }
.mg-sync-table td { overflow-wrap: anywhere; }
.mg-sync-context { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px; margin-top: 8px; }
.mg-sync-context .ui-badge, .mg-sync-labels .ui-badge { margin: 0; }
.mg-sync-id { font-size: 11px; color: var(--ink-light); }
.mg-sync-field { display: flex; align-items: baseline; gap: 8px; }
.mg-sync-field + .mg-sync-field { margin-top: 8px; }
.mg-sync-field > .ui-small { flex: 0 0 auto; }
.mg-sync-changed-id { font-weight: 650; }
.mg-sync-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.mg-sync-retry { margin-top: 8px; }
.mg-sync-table .ui-badge + div { margin-top: 6px; }
@media (max-width: 760px) {
  .mg-sync-table { --table-min-width:0; min-width: 0; table-layout: auto; }
  .mg-sync-table thead { display: none; }
  .mg-sync-table tbody, .mg-sync-table tr, .mg-sync-table td { display: block; width: 100%; }
  .mg-sync-table tr { padding: 6px 0; border-bottom: 1px solid var(--border); }
  .mg-sync-table tr:last-child { border-bottom: 0; }
  .mg-sync-table td { height: auto; border: 0; padding: 8px 14px; }
  .mg-sync-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--ink-light); font-size: 11px; font-weight: 650; text-transform: uppercase; }
}
@media (max-width: 640px) { .mg-target-form { align-items: stretch; flex-direction: column; } }

/* AdSales settings: lookup tables edit in place; click a row to edit it. */
.mg-settings-grid .ui-card .ui-grid { margin-bottom: 0; gap: 14px 16px; }
.mg-settings-grid .field label { font-size: 12px; font-weight: 600; color: var(--ink-mid); }
.lookup-data-scroll { height: auto; min-height: 0; overflow: auto; }
.lookup-table { table-layout: fixed; min-width: 760px; }
.lookup-table thead th { position: sticky; top: 0; z-index: 1; }
.lookup-table td:not(:first-child), .lookup-table th { white-space: nowrap; }
.lookup-table .lookup-bureau-col span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lookup-table tr.is-editing td { background: var(--orange-pale); }
.lookup-table .lookup-pct-col { width: 150px; text-align: right; font-variant-numeric: tabular-nums; }
.lookup-table .lookup-rule-check-col { width: 160px; text-align: center; }
/* The edit column stays in view when a wide table scrolls sideways. */
.lookup-table .lookup-actions-col { position: sticky; right: 0; width: 100px; text-align: right; white-space: nowrap; background: var(--surface); box-shadow: inset 1px 0 0 var(--border); }
.lookup-table th.lookup-actions-col { z-index: 2; background: var(--surface-warm); }
.lookup-table tbody tr:hover td.lookup-actions-col { background: var(--surface-warm); }
.lookup-table tr.is-editing td.lookup-actions-col { background: var(--orange-pale); }
.lookup-table .lookup-row-actions { justify-content: flex-end; flex-wrap: nowrap; }
.lookup-table .ui-icon-button { flex: 0 0 32px; vertical-align: middle; }
.lookup-table .lookup-save-button { background: var(--orange); color: #fff; }
.lookup-table .lookup-save-button:hover { background: var(--orange-dark); color: #fff; }
.lookup-table .lookup-text-input,
.lookup-table .lookup-percent-input { width: 100%; padding: 5px 8px; border: 1px solid var(--border-dark); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.lookup-table .lookup-input-code { width: 64px; }
.lookup-table .lookup-percent-input-wrap { display: inline-flex; align-items: center; gap: 4px; }
.lookup-table .lookup-percent-input { width: 72px; text-align: right; }
.lookup-table .lookup-relation { min-width: 220px; }
.lookup-table .lookup-checkbox { width: 16px; height: 16px; accent-color: var(--orange); }
.mg-contract-cell { min-width: 220px; }
.mg-contract-summary { display: flex; flex-direction: column; gap: 7px; }
.mg-contract-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--ink-mid); font-size: 12px; }
.mg-contract-inactive { padding: 1px 6px; font-size: 10px; }
.mg-contract-bands { display: flex; flex-wrap: wrap; gap: 8px 0; }
.mg-contract-band { display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.mg-contract-band strong { font-size: 15px; line-height: 1.2; }
.mg-contract-range { color: var(--ink-light); font-size: 11px; line-height: 1.4; white-space: nowrap; }
.mg-contract-bands-tiered { flex-wrap: nowrap; }
.mg-contract-bands-tiered .mg-contract-band { padding: 0 12px; border-left: 1px solid var(--border); }
/* Clients list: one line per service, service names in a fixed column so the shares align. */
.mg-contract-line { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mg-contract-line + .mg-contract-line { margin-top: 4px; }
.mg-contract-service { flex: none; width: 58px; color: var(--ink-light); font-size: 13px; }
.mg-contract-line.ui-muted strong { font-weight: 500; }
/* Contract tab: the full schedule, one row per band. */
.mg-contract-details { column-gap: 40px; }
.mg-contract-schedule h3 { margin: 0 0 2px; color: var(--ink-light); font-size: 13px; font-weight: 500; }
.mg-contract-schedule .ui-receipt { padding: 0; }
.mg-contract-schedule .ui-receipt > div { padding: 9px 0; border-bottom: 1px solid var(--border); }
.mg-contract-schedule .ui-receipt dt small { display: block; color: var(--ink-light); font-size: 12px; }
.mg-contract-schedule .ui-receipt dd { font-weight: 650; }
.mg-contract-schedule .ui-small { margin: 10px 0 0; }
.ui-facts .mg-contract-bands-tiered { flex-wrap: wrap; }
@media (max-width: 640px) { .mg-contract-details .ui-facts { grid-template-columns: 1fr; } }
.mg-contract-bands-tiered .mg-contract-band:first-of-type { padding-left: 0; border-left: 0; }


/* Resolve keeps the decision form and relevant evidence in one flat flow. */
.mg-resolution-subject { display: grid; gap: 6px; overflow-wrap: anywhere; }
.mg-resolution-card { display: grid; gap: 16px; margin-top: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 8px; overflow-wrap: anywhere; }
.mg-resolution-card h3, .mg-resolution-card h4, .mg-resolution-card p { margin: 0; }
.mg-resolution-card h3 { font-size: 16px; }
.mg-resolution-card h4 { font-size: 13px; }
.mg-resolution-card-heading, .mg-resolution-alternatives { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.mg-resolution-card .mg-target-fields { margin: 0; gap: 8px; }
.mg-resolution-changes, .mg-resolution-fields { display: grid; gap: 12px; }
.mg-resolution-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.mg-resolution-fields > div > label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.mg-resolution-action-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.mg-resolution-action-choices button { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--ink-mid); background: var(--white, #fff); font: inherit; font-size: 13px; cursor: pointer; }
.mg-resolution-action-choices button[aria-pressed="true"] { border-color: var(--orange); background: var(--orange-pale); color: var(--orange-dark); }
.mg-resolution-fields > legend { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mg-resolution-alternatives:empty { display: none; }
.mg-resolution-card .mg-resolution-claimed { display: grid; gap: 8px; }
.mg-resolution-linked-scroll { max-height: min(320px, 25dvh); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; }
.mg-resolution-linked-scroll:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.mg-resolution-channel-list { padding: 0; margin: 0; list-style: none; }
.mg-resolution-card .mg-resolution-channel { gap: 8px; padding: 12px 0; }
.mg-resolution-card .mg-resolution-channel-heading { gap: 6px 8px; }
.mg-resolution-channel-heading > a, .mg-resolution-channel-heading > strong { flex: 1 1 100px; font-size: 13px; }
.mg-resolution-kind { color: var(--ink-light); font-size: 11px; font-weight: 500; }
.mg-resolution-video-list { display: grid; gap: 10px; padding: 0 0 0 12px; margin: 0; border-left: 2px solid var(--border); list-style: none; }
.mg-resolution-video-title { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: baseline; gap: 8px; font-size: 13px; }
.mg-resolution-video-list .ui-small { padding-left: 40px; }
.mg-resolution-card .mg-resolution-scope { margin: 0; }
.mg-resolution-card .mg-channel-ignore-scope { margin: 12px 0 0; }
.mg-resolution-card .mg-channel-ignore-scope p + p { margin-top: 8px; }
.mg-resolution-card a { color: var(--orange-dark); text-underline-offset: 2px; }
#mg-resolution-ignore-channel { width: 100%; }
.mg-resolution-context { margin-top: 16px; overflow-wrap: anywhere; }
.mg-resolution-assignment { display: grid; gap: 16px; }
.mg-resolution-assignment h3, .mg-resolution-assignment p { margin: 0; }
.mg-resolution-assignment .mg-target-fields { gap: 8px; }
.mg-resolution-assignment-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.mg-resolution-context > p:last-child { margin-bottom: 0; }
.mg-resolution-channel { display: grid; gap: 6px; padding: 10px 0; }
.mg-resolution-channel + .mg-resolution-channel { border-top: 1px solid var(--border); }
.mg-resolution-channel-heading > a { font-weight: 650; }
.mg-resolution-claim { display: grid; gap: 3px; padding-left: 12px; }
.mg-resolution-modal .ui-modal-footer { flex-wrap: wrap; }
.mg-resolution-context a { color: var(--orange-dark); text-underline-offset: 2px; }
.mg-resolution-context a:hover { color: var(--orange); }

.mg-ignore-channel { justify-self: start; max-width: 100%; white-space: normal; text-align: left; }
.mg-channel-ignore-scope { margin: 14px 0; }
.mg-channel-ignore-scope p { margin-top: 8px; }
.as-channel-rules { margin-top: 24px; }

.mg-resolution-channel-heading, .mg-resolution-video-facts { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
.mg-resolution-channel-heading > a { min-width: 0; overflow-wrap: anywhere; }
.mg-resolution-channel-heading .ui-badge, .mg-resolution-video-facts .ui-badge { white-space: normal; }
.mg-resolution-claim { margin-top: 4px; padding: 6px 0 6px 12px; border-left: 2px solid var(--border); }
.mg-resolution-channel .mg-ignore-channel { margin-top: 6px; font-size: 12px; }
.mg-resolution-video-match > a { display: inline-block; margin-top: 12px; }
.mg-resolution-fields > legend { margin-top: 20px; }
.mg-resolution-effect { color: var(--ink-mid); font-size: 13px; line-height: 1.6; }
.mg-resolution-modal > form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.mg-resolution-refresh { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 12px 0; }
.mg-resolution-metadata { margin-top: 14px; }
.mg-resolution-metadata .mg-target-fields { margin: 0 0 4px; gap: 6px; }
.mg-resolution-metadata .mg-target-fields > div { gap: 6px 16px; }
.mg-resolution-claimed { border-top: 1px solid var(--border); padding-top: 14px; }
.mg-resolution-claimed > h3 { margin: 0; font-size: 14px; }
.mg-resolution-video-match { border-left: 3px solid var(--orange); }
.mg-resolution-video-match h3 { margin-bottom: 8px; }
.mg-resolution-video-match > a { margin-top: 0; }
.mg-resolution-video-match > button { margin-top: 8px; }
