/* Monthly review: on screen, the review is a paper report floating on the
   workspace; on paper, a plain document. The print rules below hide the CRM
   chrome and keep the document black on white. */
.review-view, .review-print { width: 100%; max-width: 1080px; margin: 0 auto; padding-bottom: 48px; color: var(--cx-ink); font-size: var(--fs-md); line-height: 1.55; }
.review-heading { margin-bottom: 8px; }
.review-heading p { margin: 0; color: var(--cx-muted); }
.review-help { display: block; color: var(--cx-muted); font-size: var(--fs-sm); line-height: 1.55; max-width: 76ch; }
.review-view .btn, .review-view .input, .review-view .select, .review-print .btn { min-height: 44px; height: auto; white-space: normal; }
.review-view .btn, .review-print .btn { padding: 0 16px; font-weight: 550; transition: transform var(--cx-dur) var(--cx-ease); }
.review-view .btn:active, .review-print .btn:active { transform: scale(0.98); }
.review-view .input, .review-view .select, .review-view .textarea { font-size: 16px; padding: 10px 12px; border-radius: var(--cx-r-ctl); }
.review-view .field { margin: 0 0 20px; display: flex; flex-direction: column; gap: 8px; }
.review-view .field-label { font: inherit; color: var(--cx-ink); font-size: var(--fs-sm); font-weight: 600; letter-spacing: normal; text-transform: none; }
.review-view .textarea { min-height: 88px; resize: vertical; }
.review-block { font-family: var(--font-mono); font-size: 13px !important; }
.review-feedback { min-height: 22px; margin: 12px 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.review-feedback:empty { min-height: 0; margin: 4px 0; }
.review-feedback.is-error { color: var(--cx-coral-text); }
.review-notice { padding: 16px 18px; margin: 16px 0; border-radius: 14px; background: var(--cx-card-2); box-shadow: inset 0 0 0 1px var(--cx-line-strong); }
.review-card { padding: 24px; margin-top: 20px; border: 1px solid var(--cx-line); border-radius: var(--cx-r-card); background: var(--cx-card); box-shadow: var(--cx-shadow-card); }
.review-card > h2 { font-size: var(--fs-xl); line-height: 1.25; letter-spacing: -0.02em; margin-bottom: 16px; }
.review-controls, .review-actions, .review-doc-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin: 8px 0 16px; }
.review-controls .field { margin: 0; min-width: 200px; }
.review-doc-actions { align-items: center; justify-content: space-between; margin-top: 0; }
.review-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.review-link {
  width: 100%; min-height: 56px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; text-align: left;
  padding: 10px 16px; border: 0; border-radius: 12px; background: var(--cx-card-2); color: var(--cx-ink); box-shadow: inset 0 0 0 1px var(--cx-line);
  font: inherit; font-weight: 600; cursor: pointer; transition: background var(--cx-dur) var(--cx-ease), box-shadow var(--cx-dur) var(--cx-ease);
}
.review-link:hover { background: var(--cx-card); box-shadow: inset 0 0 0 1px var(--cx-line-strong), var(--cx-shadow-card); }
.review-link small { color: var(--cx-muted); font-weight: 400; }
.review-link.is-active { background: var(--cx-card); box-shadow: inset 0 0 0 1.5px var(--cx-ink); }
.review-state { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 500; white-space: nowrap; background: transparent; box-shadow: inset 0 0 0 1px var(--cx-line-strong); color: var(--cx-muted); }
.review-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.review-state.is-draft { color: var(--cx-muted); }
.review-state.is-approved { color: var(--cx-ink); box-shadow: inset 0 0 0 1px var(--cx-ink); }
.review-state.is-delivered { color: var(--cx-ink); background: var(--cx-paper-2); box-shadow: none; }
.review-scroll { overflow-x: auto; max-width: 100%; }

/* Tables: sentence-case heads, tabular numbers, this month in ink. */
.review-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.review-table caption { text-align: left; color: var(--cx-muted); font-size: var(--fs-xs); font-weight: 500; padding: 0 0 10px; }
.review-table th, .review-table td { padding: 9px 12px; border-bottom: 1px solid var(--cx-line); text-align: right; vertical-align: top; }
.review-table th[scope="row"], .review-table thead th:first-child { text-align: left; font-weight: 500; }
.review-table thead th { color: var(--cx-muted); font-size: var(--fs-xs); font-weight: 500; border-bottom-color: var(--cx-line-strong); }
.review-table tbody td:nth-of-type(1) { color: var(--cx-ink); font-weight: 650; }
.review-table td small { display: block; color: var(--cx-muted); font-size: var(--fs-2xs); font-weight: 400; }
.review-table tbody th[scope="rowgroup"] { text-align: left; font-weight: 600; padding-top: 20px; color: var(--cx-ink); font-size: var(--fs-xs); border-bottom-color: var(--cx-line-strong); }
.review-branch th[scope="row"] { padding-left: 28px; color: var(--cx-muted); }
.review-total th, .review-total td { font-weight: 650; border-top: 1.5px solid var(--cx-ink); }
.review-funnel tr[data-measure] th[scope="row"] { position: relative; padding-bottom: 14px; }
/* Each step's meter wears its stage colour, the same as the pipeline's. */
.review-funnel tr[data-measure] th[scope="row"]::after {
  content: ""; position: absolute; left: 12px; bottom: 6px; height: 3px; border-radius: 3px;
  width: calc((100% - 24px) * var(--share, 0)); min-width: 3px; background: var(--stage-c, var(--cx-ink));
}
.review-funnel tr.review-branch th[scope="row"]::after { left: 28px; width: calc((100% - 40px) * var(--share, 0)); opacity: 0.55; }
.review-change { color: var(--cx-muted); }
.review-change.is-up { color: var(--cx-ink); font-weight: 600; }
/* The honest bucket: hatched and labelled, never a series colour. */
.review-unattributed th[scope="row"] { background: var(--hatch); }
.review-missing td { color: var(--cx-muted); text-align: left; }
.review-status { display: inline-flex; align-items: center; gap: 6px; min-height: 22px; padding: 1px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 500; white-space: nowrap; }
.review-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.review-status.is-live { background: var(--cx-paper-2); color: var(--cx-ink); }
.review-status.is-testing { box-shadow: inset 0 0 0 1px var(--cx-ink); color: var(--cx-ink); }
.review-status.is-in_setup { box-shadow: inset 0 0 0 1px var(--cx-line-strong); color: var(--cx-ink); }
.review-status.is-not_started { box-shadow: inset 0 0 0 1px var(--cx-line); color: var(--cx-muted); }
.review-systems td { text-align: left; }
.review-systems tbody td:nth-of-type(1) { font-weight: 400; }

/* The document itself. */
.review-doc { padding: 48px 56px; margin-top: 16px; border: 1px solid var(--cx-line); border-radius: 20px; background: var(--cx-card); box-shadow: var(--cx-shadow-card); }
/* The document is the card: the section around it steps back to the paper. */
.review-card:has(> .review-doc) { padding: 0; border: 0; background: none; box-shadow: none; }
.review-card:has(> .review-doc) > .review-doc-actions { margin: 0 4px 4px; }
.review-doc-head { padding-bottom: 24px; margin-bottom: 8px; border-bottom: 1px solid var(--cx-line-strong); }
.review-doc h1 { font-size: var(--fs-3xl); line-height: 1.05; letter-spacing: -0.035em; font-weight: 700; margin: 8px 0 10px; text-wrap: balance; }
.review-doc section { display: grid; grid-template-columns: minmax(150px, 200px) minmax(0, 1fr); gap: 8px 32px; padding: 24px 0; border-bottom: 1px solid var(--cx-line); }
.review-doc section > h2 { grid-column: 1; margin: 2px 0 0; font-size: var(--fs-md); font-weight: 650; letter-spacing: -0.01em; }
.review-doc section > :not(h2) { grid-column: 2; min-width: 0; }
/* Sections that carry a table take the full width, heading above. */
.review-doc section:has(.review-scroll) { grid-template-columns: minmax(0, 1fr); }
.review-doc section:has(.review-scroll) > h2, .review-doc section:has(.review-scroll) > :not(h2) { grid-column: 1; }
.review-doc section:has(.review-scroll) > h2 { font-size: var(--fs-lg); }
/* The document's one kicker is the foundation's .kicker; only its spacing is local. */
.review-kicker { margin: 0; }
.review-doc-meta { color: var(--cx-muted); margin: 0; }
.review-words { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 68ch; font-size: var(--fs-lg); line-height: 1.6; }
.review-doc .review-help { margin-top: 4px; font-size: var(--fs-xs); }
.review-doc-foot { margin-top: 24px; color: var(--cx-muted); font-size: var(--fs-xs); }
.review-print-toolbar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin: 16px 0; }
.review-view :focus-visible, .review-print :focus-visible { outline: 2px solid var(--cx-volt); outline-offset: 2px; box-shadow: 0 0 0 2px var(--cx-ink); }

/* Print view: only the document, on screen and on paper. */
body.review-print-mode .rail, body.review-print-mode .topbar { display: none !important; }
body.review-print-mode .app { grid-template-columns: minmax(0, 1fr) !important; }

@media (max-width: 900px) {
  .review-doc { padding: 32px 28px; }
  .review-doc section { grid-template-columns: minmax(0, 1fr); }
  .review-doc section > h2, .review-doc section > :not(h2) { grid-column: 1; }
}
@media (max-width: 720px) {
  .review-controls .field, .review-controls .btn, .review-actions .btn { width: 100%; }
  .review-link { grid-template-columns: minmax(0, 1fr) auto; }
  .review-link small { grid-column: 1 / -1; grid-row: 2; }
  .review-card { padding: 18px 16px; }
  .review-table th, .review-table td { padding: 8px 6px; }
  .review-branch th[scope="row"] { padding-left: 16px; }
  .review-funnel tr[data-measure] th[scope="row"]::after { left: 6px; width: calc((100% - 12px) * var(--share, 0)); }
  .review-funnel tr.review-branch th[scope="row"]::after { left: 16px; width: calc((100% - 22px) * var(--share, 0)); }
  .review-doc { padding: 24px 16px; border-radius: 16px; }
  .review-doc h1 { font-size: var(--fs-2xl); }
}
@media (prefers-reduced-motion: reduce) {
  .review-view .btn, .review-print .btn, .review-link { transition: none; }
}

@media print {
  body.review-print-mode .rail, body.review-print-mode .topbar, .review-print-toolbar, .review-print .review-feedback { display: none !important; }
  .review-print { max-width: none; padding: 0; font-size: 11pt; color: #000; }
  /* Paper never animates: the view's entrance would print as a blank page. */
  body.review-print-mode .view.is-active > .view-body, .review-print, .review-doc { animation: none !important; opacity: 1 !important; transform: none !important; }
  .review-doc { border: 0; border-radius: 0; box-shadow: none; padding: 0; margin: 0; background: #fff; color: #000; }
  .review-doc section { display: block; padding: 12pt 0; border-bottom-color: #ccc; }
  .review-doc h1 { font-size: 22pt; }
  .review-doc h2 { break-after: avoid; margin-bottom: 6pt; }
  .review-doc section, .review-table tr { break-inside: avoid; }
  .review-scroll { overflow: visible; }
  .review-table th, .review-table td { border-bottom-color: #999; color: #000; }
  .review-funnel tr[data-measure] th[scope="row"]::after { display: none; }
  .review-status { background: none !important; box-shadow: none !important; color: #000 !important; }
  .review-unattributed th[scope="row"] { background: none; text-decoration: underline dotted; text-underline-offset: 3px; }
}
.review-view [tabindex="-1"]:focus, .review-print [tabindex="-1"]:focus { outline: none; box-shadow: none; }
