/* QA pass over the money and risk screens: Transactions, Payment failures, Float, Finance, Merchants, Fraud review,
   Transaction monitoring and System. Everything is scoped to those views (and the two transaction drawers). */

/* --- Row actions read as underlined links, as in the dense tables, not as pill buttons. --- */
:is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #txnView, #floatView, #fraudView, #fraudCaseView) td .row-action-btn,
.dp .ov-kv .row-action-btn{
  height: auto; min-height: 24px; padding: 0; border: 0; border-radius: 2px; background: none; color: var(--ink);
  font-size: 13px; line-height: 18px; text-align: left; white-space: normal; overflow-wrap: break-word;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--edge);
}
:is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #txnView, #floatView, #fraudView, #fraudCaseView) td .row-action-btn:hover,
.dp .ov-kv .row-action-btn:hover{ background: none; text-decoration-color: currentColor; }
:is(#floatView, #fraudView) td .row-action-btn.danger{ color: var(--critical); }
:is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #txnView, #fraudView, #fraudCaseView) td .row-action-btn.mono{ font-size: 12px; }
:is(#ov_monitor, #floatView) td .row-action-btn + .row-action-btn{ margin-left: 8px; }

/* A wide table scrolls inside its own box; without this, screen-reader-only text in far columns widens the whole page. */
:is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #ov_system, #txnView, #floatView, #fraudView, #fraudCaseView) .table-wrap{ position: relative; }

/* --- Wide tables wrap their words instead of pushing the last columns and actions off screen. --- Above phone width only; phones stack the rows. */
@media (min-width: 640px){
  :is(.qa-search, .qa-watch, .qa-held) td .row-action-btn.mono{ display: inline-block; max-width: 25ch; overflow-wrap: normal; vertical-align: middle; }
  .qa-search .sub-line, #txnQueueTable .sub-line{ white-space: nowrap; }
  .qa-search :is(th, td), .qa-held :is(th, td), .qa-channels :is(th, td), .qa-merchants :is(th, td){ padding-left: 10px; padding-right: 10px; }
  .qa-search td:nth-child(3){ white-space: normal; min-width: 96px; }
  .qa-search td:nth-child(n+6){ white-space: normal; min-width: 130px; max-width: 190px; }
  .qa-watch td:nth-child(2){ white-space: normal; min-width: 280px; overflow-wrap: anywhere; line-height: 18px; }
  .qa-watch td:nth-child(4){ min-width: 190px; }
  .qa-watch td:nth-child(5){ white-space: normal; min-width: 200px; max-width: 260px; }
  .qa-watch td:nth-child(6){ min-width: 96px; white-space: normal; }
  .qa-held td:nth-child(3), .qa-held td:nth-child(6){ white-space: normal; }
  .qa-held td:nth-child(5){ white-space: normal; min-width: 150px; max-width: 220px; }
  .qa-held td:nth-child(7) .row-action-btn{ white-space: nowrap; }
  .qa-search td:nth-child(2) .ov-chip{ display: table; margin-top: 2px; }
  .qa-channels td:first-child{ white-space: normal; min-width: 170px; max-width: 210px; }
  .qa-channels .sub-line{ white-space: normal; }
  .qa-channels .ov-bar{ width: 44px; }
  .qa-merchants td:first-child{ white-space: normal; min-width: 200px; max-width: 300px; }
  :is(.qa-recon, .qa-recon-provider) td:first-child, .qa-providers td:nth-child(2), .qa-recon-provider td:nth-child(3),
  .qa-checks td:first-child, .qa-checks td:nth-child(3){ white-space: normal; min-width: 160px; }
  .qa-recon td:first-child{ max-width: 260px; }
  .qa-matrix td:first-child{ white-space: normal; min-width: 220px; }
  /* Fraud tables: causes sit side by side, long ids and reasons wrap. */
  :is(#fraudView, #fraudCaseView) td.cause-cell{ min-width: 300px; max-width: none; white-space: normal; }
  :is(#fraudView, #fraudCaseView) td.cause-cell .chip{ margin: 2px 0; }
  #fraudQueueTable td:first-child, #fraudSearchTable td:first-child{ min-width: 150px; }
  #fraudQueueTable td:first-child .sub-line, #fraudSearchTable td:first-child .sub-line{ white-space: normal; }
  #riskWatchTable td:nth-child(2){ white-space: normal; overflow-wrap: anywhere; min-width: 130px; }
  #riskWatchTable td:nth-child(3){ white-space: normal; min-width: 240px; line-height: 18px; }
  #riskCheckResult td:first-child{ white-space: normal; min-width: 160px; }
  #fraudView #riskCheckResult .lede{ margin-bottom: 8px; }
  #fcReviewHistoryTable td:last-child{ white-space: normal; overflow-wrap: anywhere; }
  #fcRelatedTable td:nth-child(2){ white-space: normal; min-width: 220px; }
  #faConcentrations td:nth-last-child(2){ white-space: normal; overflow-wrap: anywhere; min-width: 140px; }
  #faConcentrations :is(th, td){ padding-left: 10px; padding-right: 10px; }
  #floatRecipientsTable td:first-child{ white-space: normal; min-width: 180px; }
  .fold-lite + .d-sec, .d-sec + .fold-lite{ margin-top: 16px; }
}

/* The two label and value tables on a case have no header row, so they wrap at every width. */
#fcDeviceTable td:last-child, #fcIdentityTable td:last-child{ white-space: normal; overflow-wrap: anywhere; }

/* --- Long sentences in the failure drawer read left-aligned under their label. --- */
.qa-stack dl.kv > div{ display: block; }
.qa-stack dl.kv dd{ text-align: left; margin: 2px 0 0; }

/* --- Long system messages and ids never push a drawer sideways. --- */
.dp .d-sec p, .dp .ov-check{ overflow-wrap: anywhere; }

/* --- Banners --- */
#txnSignals .warn-banner > span{ flex: 1 1 360px; min-width: 0; }
/* These chips carry their own sentence-case wording. */
:is(#ov_held, #ov_system, #ov_merchants) .ov-chip{ text-transform: none; }
#faTuReasons .ov-chip{ text-transform: none; white-space: normal; overflow-wrap: anywhere; }

/* --- Charts --- */
.qa-period{ height: 130px; }
.qa-axis{ display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin-top: 4px; font-size: 12px; color: var(--ink-faint); text-align: center; }
#floatTabDashboard .chart-y-axis{ align-self: flex-start; height: 130px; }

/* --- Float balances: account boxes side by side while they fit. --- */
#floatView .float-accts{ grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* --- Phones and touch --- */
@media (max-width: 640px), (pointer: coarse){
  :is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #txnView, #floatView, #fraudView, #fraudCaseView) td .row-action-btn,
  .dp .ov-kv .row-action-btn{ min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; }
  :is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #floatView) th .th-sort{ min-height: 44px; }
  :is(#fraudCaseView, .dp) summary{ min-height: 44px; box-sizing: border-box; padding-block: 12px; }
}
@media (max-width: 640px){
  .qa-axis span:nth-child(even){ visibility: hidden; }
}

/* --- Stacked rows: a second line (id, time, phone) sits under its value, not beside it. --- */
@media (max-width: 639.98px){
  :is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #txnView, #floatView, #fraudView, #fraudCaseView) table.stack td{ flex-wrap: wrap; justify-content: flex-end; gap: 2px 8px; }
  :is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #txnView, #floatView, #fraudView, #fraudCaseView) table.stack td::before{ margin-right: auto; }
  :is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #txnView, #floatView, #fraudView, #fraudCaseView) table.stack td > :is(.sub-line, .ov-sub, .lede){ flex: 0 0 100%; text-align: right; white-space: normal; }
  :is(#ov_monitor, #ov_merchants, #ov_finance, #ov_held, #txnView, #floatView, #fraudView, #fraudCaseView) table.stack td > .row-action-btn{ margin-left: auto; text-align: right; justify-content: flex-end; }
  #fcRelatedTable table.stack td .chip, #fraudView table.stack td.cause-cell .chip{ margin: 0; }
  :is(#ov_monitor, #ov_merchants) .table-card.scroll{ max-height: none; overflow: visible; }
  #ov_finance .filter-row .ov-caption{ margin: 0 !important; text-align: left !important; }
}

/* --- Live board tiles fill their rows: three over two on a tablet, one row on a wide screen. Phones keep the strip. --- */
@media (min-width: 641px){
  body #ov_monitor .kpi-grid.qa-live{ display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  body #ov_monitor .kpi-grid.qa-live > *{ grid-column: span 3; }
  body #ov_monitor .kpi-grid.qa-live > :first-child:nth-last-child(5),
  body #ov_monitor .kpi-grid.qa-live > :first-child:nth-last-child(5) ~ :nth-child(-n+3){ grid-column: span 2; }
}
@media (min-width: 1100px){
  body #ov_monitor .kpi-grid.qa-live{ grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  body #ov_monitor .kpi-grid.qa-live > *{ grid-column: auto !important; }
}

/* --- Finance: money moved and net lead; the other figures sit under them, three to a row. --- */
@media (min-width: 641px){
  body #ov_finance .kpi-grid.qa-lead{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: var(--space-4); }
  body #ov_finance .kpi-grid.qa-lead .kpi-value{ font-size: 34px; line-height: 42px; }
  body #ov_finance .kpi-grid.qa-rest{ display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px){
  body #ov_finance .kpi-grid.qa-lead > *{ flex: 1 0 43%; }
}

/* --- Merchants: narrow screens drop the Outlets column. --- */
@media (max-width: 899.98px){
  body #ov_merchants .qa-merchants table.stack tbody tr > td:nth-child(3), body #ov_merchants .qa-merchants table tr > :nth-child(3){ display: none; }
}

.held-acts{ display: inline-flex; flex-wrap: wrap; gap: var(--space-2); }
