/* Bảng hạch toán (renderCases, renderReviewRow, bảng dạng thẻ trên điện thoại). Dùng token trong styles.css (:root); không viết mã màu trực tiếp. */

/* Header: title and scope on the left, the two secondary actions on the right; filters get their own row. */
.review-toolbar { align-items:flex-end; margin-bottom:12px; }
.review-toolbar h2 { margin:0; }
.review-scope-label { margin:2px 0 0; color:var(--muted); font-size:var(--fs-sm); }
.review-toolbar-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; }
.review-toolbar-actions .btn { display:inline-flex; align-items:center; gap:6px; }
.review-filter-bar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:0 0 12px; }
.review-filter-bar .review-scope-select { min-height:36px; }
.review-search { flex:1 1 320px; min-width:min(320px, 100%); max-width:560px; min-height:36px; padding:7px 12px; border:1px solid var(--line); border-radius:var(--radius-sm); background:var(--card); color:var(--ink); font:inherit; }

/* "Xuất" menu: the MISA import file (with its "?"), Excel, CSV and the 331/141 balances. */
.review-export-menu { position:relative; }
.review-export-menu > summary { list-style:none; cursor:pointer; }
.review-export-menu > summary::-webkit-details-marker { display:none; }
.review-export-list { position:absolute; z-index:6; top:calc(100% + 4px); right:0; display:grid; min-width:240px; padding:4px; border:1px solid var(--line); border-radius:var(--radius); background:var(--card); box-shadow:var(--shadow); }
.review-export-list > a, .review-export-list > button, .review-export-misa > a { display:block; padding:8px 10px; border:0; border-radius:var(--radius-sm); background:none; color:var(--ink); font:inherit; font-size:var(--fs-sm); text-align:left; text-decoration:none; white-space:nowrap; cursor:pointer; }
.review-export-list > a:hover, .review-export-list > button:hover, .review-export-misa > a:hover { background:var(--pale); }
.review-export-misa { display:flex; align-items:center; gap:4px; padding-right:6px; }
.review-export-misa > a { flex:1 1 auto; }
/* The menu opens at the right edge of the toolbar, so the explanation opens leftwards. */
.review-export-misa details.help > p { right:-8px; left:auto; }
#reviewExcelDownload[aria-disabled="true"], #reviewMisaDownload[aria-disabled="true"] { opacity:.55; cursor:not-allowed; }

.review-policy-banner { display:flex; flex-wrap:wrap; align-items:center; gap:4px 8px; margin:0 0 10px; padding:8px 12px; border-left:3px solid var(--amber); border-radius:var(--radius-sm); color:var(--amber); background:var(--amberbg); font-size:var(--fs-sm); }
.review-policy-banner .review-row-details { flex-basis:100%; margin:0; }
.review-ai-failure-filter { display:flex; flex-wrap:wrap; align-items:center; gap:6px 12px; margin:8px 0; padding:8px 12px; border-left:4px solid var(--amber); border-radius:var(--radius-sm); background:var(--amberbg); color:var(--amber); font-size:var(--fs-sm); }
.review-run { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; }
/* A "?" inside a banner opens across the banner's width, wherever the line wrapped it. */
.review-policy-banner, .review-run { position:relative; }
.review-policy-banner details.help, .review-run details.help { position:static; }
.review-policy-banner details.help > p, .review-run details.help > p { top:calc(100% + 4px); right:0; left:0; width:auto; max-width:560px; }
/* The AI action of the month: how many transactions have no proposal and the button that asks the AI, or why it
   cannot run yet. AI purple, like every value the AI proposed. */
.review-ai-banner { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; margin:0 0 10px; padding:8px 12px; border-left:3px solid var(--ai); border-radius:var(--radius-sm); color:var(--ink); background:var(--aibg); font-size:var(--fs-sm); position:relative; }
.review-ai-banner > .icon { color:var(--ai); }
.review-ai-banner details.help { position:static; }
.review-ai-banner details.help > p { top:calc(100% + 4px); right:0; left:0; width:auto; max-width:560px; }
.review-ai-banner.missing > span { color:var(--muted); }
.review-tabs { margin:0 0 10px; }

/* The table: no minimum width and no sticky column (B1). Fixed column shares, cells wrap. */
.review-table-wrap { border:1px solid var(--line); border-radius:var(--radius); background:var(--card); box-shadow:var(--shadow); }
.review-table-wrap.loading .review-table, .review-table-wrap.loading .review-pager, .review-table-wrap.loading .review-bulk-bar { opacity:.5; pointer-events:none; transition:opacity .15s; }
.review-scope-loading { padding:10px 14px; font-weight:600; }
.review-table { width:100%; margin:0; border:0; border-collapse:separate; border-spacing:0; table-layout:fixed; font-size:var(--fs-sm); line-height:1.4; }
.review-table th, .review-table td { padding:8px 10px; vertical-align:top; overflow-wrap:anywhere; }
.review-table thead th { position:sticky; top:0; z-index:3; border-bottom:1px solid var(--line); background:var(--pale); color:var(--muted); font-size:var(--fs-xs); font-weight:600; text-transform:none; letter-spacing:normal; }
.review-table thead th:first-child { border-top-left-radius:var(--radius); }
.review-table thead th:last-child { border-top-right-radius:var(--radius); }
.review-col-code { width:11%; }
.review-col-date { width:8%; }
.review-col-vendor { width:21%; }
.review-col-amount { width:11%; }
.review-col-journal { width:21%; }
.review-col-result { width:13%; }
.review-col-check { width:15%; }
.review-table th.review-col-amount, .review-amount-cell { text-align:right; }
.review-select-all { display:flex; align-items:center; gap:8px; }
.review-select-all input, .review-code input { margin:0; accent-color:var(--teal); }
.review-sort { display:inline-flex; align-items:center; gap:4px; padding:0; border:0; background:none; color:inherit; font:inherit; font-weight:600; cursor:pointer; }
.review-sort:hover, th[aria-sort] .review-sort { color:var(--ink); }
.review-sort .sort-mark { color:var(--muted); opacity:.55; }
th[aria-sort] .sort-mark { color:var(--teal); opacity:1; }
.review-col-check details.help > p { right:-8px; left:auto; }

/* Rows: the whole row opens the transaction; J/K move a highlight. */
.review-row { cursor:pointer; }
.review-row > td { background:var(--card); }
.review-row:hover > td { background:var(--pale); }
.review-row.is-cursor > td { background:var(--teal2); }
.review-row.is-cursor > td:first-child { box-shadow:inset 3px 0 0 var(--teal); }
.review-row:focus-visible { outline:2px solid var(--teal); outline-offset:-2px; }
.review-code input { margin-right:6px; vertical-align:-2px; }
.transaction-code { padding:0; border:0; background:none; color:var(--ink); font:inherit; font-weight:700; text-align:left; cursor:pointer; overflow-wrap:anywhere; }
.transaction-code:hover { color:var(--teal); text-decoration:underline; }
.review-date { font-variant-numeric:tabular-nums; }
.review-date-alt { margin-left:4px; color:var(--amber); font-weight:700; cursor:help; }
.review-party { display:block; font-weight:600; }
.review-transaction-title { display:-webkit-box; overflow:hidden; color:var(--muted); -webkit-box-orient:vertical; -webkit-line-clamp:1; }
.review-meta { display:flex; flex-wrap:wrap; gap:0 8px; margin-top:2px; color:var(--muted); font-size:var(--fs-xs); }
.review-source-link { max-width:100%; overflow:hidden; padding:0; border:0; background:none; color:var(--blue); font:inherit; text-align:left; text-overflow:ellipsis; white-space:nowrap; cursor:pointer; }
.review-source-link:hover { text-decoration:underline; }
.review-amount { font-weight:600; font-variant-numeric:tabular-nums; }
.review-journal-entry { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:0 8px; align-items:baseline; }
.review-journal-entry + .review-journal-entry { margin-top:3px; }
.review-journal-entry > strong { font-weight:600; text-align:right; font-variant-numeric:tabular-nums; }
.review-journal-description { grid-column:1 / -1; display:-webkit-box; overflow:hidden; color:var(--muted); font-size:var(--fs-xs); -webkit-box-orient:vertical; -webkit-line-clamp:1; }
.review-journal.ai-value .review-journal-entry > span, .review-journal.ai-value .review-journal-entry > strong { color:var(--ai); }
.review-journal .currency-notice { margin-bottom:4px; padding:4px 8px; }
.review-journal .rule-label { display:inline-block; margin-top:4px; }
.review-journal .rule-label.guess-label, .result-guess { color:var(--ai); background:var(--aibg); }
.review-warning-summary, .review-reason { display:-webkit-box; overflow:hidden; margin-top:4px; color:var(--muted); font-size:var(--fs-xs); -webkit-box-orient:vertical; -webkit-line-clamp:2; }
.review-warning-summary { color:var(--amber); }
.review-check-actions { display:flex; flex-wrap:wrap; align-items:center; gap:4px 6px; }
.review-check-toggle { color:var(--muted); }
.review-check-toggle:disabled { opacity:.45; cursor:not-allowed; }
.review-check-actions .check-badge { padding:2px 6px; }
.review-main-action { white-space:normal; }
.review-row-menu { position:relative; margin-left:auto; }
.review-row-menu > summary { list-style:none; }
.review-row-menu > summary::-webkit-details-marker { display:none; }
.review-row-menu-list { position:absolute; z-index:4; top:calc(100% + 4px); right:0; min-width:190px; padding:4px; border:1px solid var(--line); border-radius:var(--radius); background:var(--card); box-shadow:var(--shadow); }
.review-row-menu-list > button { display:block; width:100%; padding:8px 10px; border:0; border-radius:var(--radius-sm); background:none; color:var(--ink); font:inherit; font-size:var(--fs-sm); text-align:left; cursor:pointer; }
.review-row-menu-list > button:hover { background:var(--pale); }

.review-bulk-bar { position:sticky; z-index:4; top:0; display:flex; flex-wrap:wrap; align-items:center; gap:8px 10px; padding:8px 12px; border-bottom:1px solid var(--line); border-radius:var(--radius) var(--radius) 0 0; background:var(--teal2); }
/* "AI đề xuất lại" for a group (issue #10): the AI colour, outlined beside the teal check action. */
.review-bulk-bar .btn.btn-ai, .review-ai-failure-filter .btn.btn-ai { border-color:var(--ai); background:var(--aibg); color:var(--ai); }
.review-bulk-bar .btn-link#reviewRerunFilter { color:var(--ai); }
.review-table-wrap .review-pager { flex-wrap:wrap; gap:8px; padding:10px 12px; }
.review-table-wrap .review-pager .actions { align-items:center; }

.review-shortcut-list { display:grid; grid-template-columns:max-content 1fr; gap:8px 16px; margin:0 0 16px; }
.review-shortcut-list dt, .review-shortcut-list dd { margin:0; }
.review-shortcut-list kbd { display:inline-block; min-width:24px; padding:2px 6px; border:1px solid var(--line); border-bottom-width:2px; border-radius:var(--radius-sm); background:var(--pale); font:600 var(--fs-xs)/1.4 var(--font); text-align:center; }

/* Narrow screens (C14): below 1000px the content column is too narrow for seven columns, so each row
   becomes a card. Below 720px the journal is left to the transaction page. The page never scrolls sideways. */
@media (max-width: 1000px) {
  .review-table, .review-table tbody { display:block; }
  .review-table thead { display:none; }
  .review-row { display:grid; grid-template-columns:minmax(0,1fr) auto; grid-template-areas:"code amount" "date amount" "tx tx" "journal journal" "result check"; gap:4px 12px; padding:10px 12px; border-bottom:1px solid var(--line); background:var(--card); }
  .review-row:hover, .review-row.is-cursor { background:var(--pale); }
  .review-row > td, .review-row:hover > td, .review-row.is-cursor > td { display:block; padding:0; border:0; background:none; box-shadow:none; }
  .review-code { grid-area:code; }
  .review-date { grid-area:date; color:var(--muted); font-size:var(--fs-xs); }
  .review-transaction { grid-area:tx; }
  .review-amount-cell { grid-area:amount; align-self:start; }
  .review-journal { grid-area:journal; }
  .review-result { grid-area:result; align-self:center; }
  .review-check { grid-area:check; align-self:center; }
}
@media (max-width: 720px) {
  .review-row { grid-template-areas:"code amount" "date amount" "tx tx" "result result" "check check"; }
  .review-row .review-journal { display:none; }
  .review-filter-bar > * { flex:1 1 100%; max-width:none; }
  .review-toolbar-actions { justify-content:flex-start; }
  /* On a phone the export choices open in the flow instead of over the edge of the screen. */
  .review-export-menu[open] { flex-basis:100%; }
  .review-export-list { position:static; margin-top:4px; }
}
