/*
 * Editorial Structured Content — EDS v2.4.3 Official Document Fidelity & Presentation Hardening
 * Reusable semantics for long-form accounting content.
 * Loaded after editorial-content.css in TinyMCE, Bản Tin and Thư Viện.
 *
 * Ownership:
 * - tables (simple/complex, fit-only wrapper, nested-table hardening, bare legacy tables);
 * - meaningful positional structures (official-document headers and signature grids);
 * - official-document contextual table presentation (formal-neutral, no semantic reclassification);
 * - key-lines (process chains, formulas, final results);
 * - accounting entries and groups;
 * - definition lists;
 * - fact lists.
 *
 * Table contract:
 * - every editorial table must fit its containing viewport on desktop, tablet and mobile;
 * - horizontal scrolling is never used for editorial tables;
 * - complex means semantic/density complexity, not wider canvas;
 * - ordinary simple tables use the deep-teal header treatment;
 * - ordinary complex tables use a light hierarchical header treatment so multi-row headers stay readable;
 * - tables inside ct-official-document keep the same simple/complex semantics but use a more formal-neutral document palette;
 * - CSS reduces font-size/padding progressively for wide matrices;
 * - density/span/form heuristics inspect only each table's own direct rows/cells, never nested descendants;
 * - segmented form-slot grids require blank-slot evidence and have their own readable row density;
 * - text wraps instead of expanding table width;
 * - sticky columns are intentionally disabled;
 * - rowspan/colspan matrices use a collapsed grid-border model so DOM-child order cannot erase effective-column separators;
 * - nested tables are classified before flattening, but all preserved nested tables also fit their parent cell;
 * - one-row 2–3-cell support relations may stack on mobile;
 * - accounting entries use dedicated semantic markup, not table.
 *
 * Positional contract:
 * - official header/signature grouping is semantic structure, not a generic layout hack;
 * - official documents use a restrained neutral frame so the embedded formal document remains visually bounded;
 * - desktop keeps meaningful parties side-by-side when space allows;
 * - a source-backed single signer anchored to the right may use a one-party signature grid; CSS keeps that party on the right half at larger widths;
 * - a signature grid that belongs directly to an official document gets only a subtle separator/rhythm, never a nested card frame;
 * - mobile may stack groups in source order without dissolving their semantic wrappers;
 * - styling is formal-neutral and intentionally does not reuse legal-callout presentation.
 */

/* ========================================================================== 
 * TABLES
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) table,
:where(.ct-prose, body.mce-content-body) table.ct-data-table {
  display: table;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0 0 22px;
  overflow: visible;
  border: 1px solid var(--ct-border-cool);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 8px;
  background: var(--ct-surface);
  color: #303632;
  font-size: 14px;
  line-height: 1.5;
  table-layout: fixed;
}

:where(.ct-prose, body.mce-content-body) table caption,
:where(.ct-prose, body.mce-content-body) table.ct-data-table caption {
  padding: 8px;
  color: var(--ct-slate);
  font-weight: 700;
  text-align: left;
}

:where(.ct-prose, body.mce-content-body) table th,
:where(.ct-prose, body.mce-content-body) table td,
:where(.ct-prose, body.mce-content-body) table.ct-data-table th,
:where(.ct-prose, body.mce-content-body) table.ct-data-table td {
  min-width: 0;
  padding: 10px 12px;
  border: 0;
  border-right: 1px solid #d9e3de;
  border-bottom: 1px solid #e2e9e5;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

:where(.ct-prose, body.mce-content-body) table tr > :last-child,
:where(.ct-prose, body.mce-content-body) table.ct-data-table tr > :last-child {
  border-right: 0;
}

:where(.ct-prose, body.mce-content-body) table tbody tr:last-child > td,
:where(.ct-prose, body.mce-content-body) table tfoot tr:last-child > td,
:where(.ct-prose, body.mce-content-body) table.ct-data-table tbody tr:last-child > td,
:where(.ct-prose, body.mce-content-body) table.ct-data-table tfoot tr:last-child > td {
  border-bottom: 0;
}

/*
 * Span-safe gridlines.
 * IMPORTANT: detect spans only in the current table's own direct row groups.
 * A rowspan/colspan inside a nested child table must never switch the parent
 * table to the collapsed-border model or restyle the parent's unrelated cells.
 */
:where(.ct-prose, body.mce-content-body) table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[rowspan]),
:where(.ct-prose, body.mce-content-body) table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[colspan]),
:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[rowspan]),
:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[colspan]) {
  border-collapse: collapse;
}

:where(.ct-prose, body.mce-content-body) table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[rowspan]) > :is(thead, tbody, tfoot) > tr > :is(th, td),
:where(.ct-prose, body.mce-content-body) table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[colspan]) > :is(thead, tbody, tfoot) > tr > :is(th, td),
:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[rowspan]) > :is(thead, tbody, tfoot) > tr > :is(th, td),
:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[colspan]) > :is(thead, tbody, tfoot) > tr > :is(th, td) {
  border: 1px solid #d9e3de;
}

/* Table cells own compact internal prose rhythm. */
:where(.ct-prose, body.mce-content-body) table :is(th, td) > p,
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > p {
  margin: 0;
}

:where(.ct-prose, body.mce-content-body) table :is(th, td) > p + p,
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > p + p {
  margin-top: 0.62em;
}

:where(.ct-prose, body.mce-content-body) table :is(th, td) > :is(ul, ol),
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > :is(ul, ol) {
  margin: 0.55em 0;
  padding-inline-start: 1.2em;
}

:where(.ct-prose, body.mce-content-body) table :is(th, td) > :last-child,
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > :last-child {
  margin-bottom: 0;
}

/* Simple-table / bare-table header: fresh deep teal slate. */
:where(.ct-prose, body.mce-content-body) table th,
:where(.ct-prose, body.mce-content-body) table.ct-data-table th {
  background: var(--ct-slate);
  color: #fff;
  font-weight: 700;
}

:where(.ct-prose, body.mce-content-body) table thead tr:first-child th:first-child,
:where(.ct-prose, body.mce-content-body) table.ct-data-table thead tr:first-child th:first-child {
  border-top-left-radius: 7px;
}

:where(.ct-prose, body.mce-content-body) table thead tr:first-child th:last-child,
:where(.ct-prose, body.mce-content-body) table.ct-data-table thead tr:first-child th:last-child {
  border-top-right-radius: 7px;
}

:where(.ct-prose, body.mce-content-body) table tbody tr:nth-child(even) td,
:where(.ct-prose, body.mce-content-body) table.ct-data-table tbody tr:nth-child(even) td {
  background: var(--ct-surface-muted);
}

@media (hover: hover) {
  :where(.ct-prose, body.mce-content-body) table tbody tr:hover td,
  :where(.ct-prose, body.mce-content-body) table.ct-data-table tbody tr:hover td {
    background: #eef6f1;
  }
}

/* Simple and complex are semantic variants only. Both fit the viewport. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-simple,
:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-complex {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  table-layout: fixed;
}

/*
 * Progressive density for wide matrices.
 * Count only cells in this table's own row groups; a wide nested child must not
 * accidentally shrink its parent table.
 */
:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(5)) {
  font-size: 12px;
  line-height: 1.38;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(5)) :is(th, td) {
  padding: 6px;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(8)) {
  font-size: 10.5px;
  line-height: 1.3;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(8)) :is(th, td) {
  padding: 4px;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(11)) {
  font-size: 9px;
  line-height: 1.24;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(11)) :is(th, td) {
  padding: 3px 2px;
}

/*
 * Segmented form-slot grid.
 * Require both high cell count AND direct blank-slot evidence so an ordinary
 * populated one-row 10+ column matrix is not mistaken for a form field.
 */
:where(.ct-prose, body.mce-content-body) table.ct-data-table:not(:has(> thead)):has(> tbody > tr:only-child > td:first-child:not(:empty)):has(> tbody > tr:only-child > :nth-child(10)):has(> tbody > tr:only-child > td:nth-child(2):empty):has(> tbody > tr:only-child > td:nth-child(3):empty):has(> tbody > tr:only-child > td:nth-child(10):empty) {
  font-size: 13px;
  line-height: 1.35;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table:not(:has(> thead)):has(> tbody > tr:only-child > td:first-child:not(:empty)):has(> tbody > tr:only-child > :nth-child(10)):has(> tbody > tr:only-child > td:nth-child(2):empty):has(> tbody > tr:only-child > td:nth-child(3):empty):has(> tbody > tr:only-child > td:nth-child(10):empty) > tbody > tr:only-child > td {
  height: 38px;
  padding: 7px 0;
  vertical-align: middle;
  text-align: center;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table:not(:has(> thead)):has(> tbody > tr:only-child > td:first-child:not(:empty)):has(> tbody > tr:only-child > :nth-child(10)):has(> tbody > tr:only-child > td:nth-child(2):empty):has(> tbody > tr:only-child > td:nth-child(3):empty):has(> tbody > tr:only-child > td:nth-child(10):empty) > tbody > tr:only-child > :first-child {
  width: 32%;
  padding: 7px 10px;
  text-align: left;
  white-space: nowrap;
}

/* ========================================================================== 
 * NESTED TABLES — structural preservation, fit-only presentation
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0.62em 0 0.72em;
  border: 1px solid #dfe7e3;
  border-radius: 6px;
  background: #fbfcfb;
  color: inherit;
  font-size: 0.94em;
  line-height: 1.42;
  table-layout: fixed;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table th,
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table td {
  min-width: 0;
  padding: 7px 9px;
  border-right: 1px solid #e1e8e4;
  border-bottom: 1px solid #e7ece9;
  background: transparent;
  color: inherit;
  vertical-align: top;
  overflow-wrap: anywhere;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table tr > :last-child {
  border-right: 0;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table tbody tr:last-child > td,
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table tfoot tr:last-child > td {
  border-bottom: 0;
}

/* Nested simple-table header remains a quiet support-table header. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple thead th {
  background: #eef4f1;
  color: var(--ct-slate);
  font-size: 0.96em;
  font-weight: 700;
}

/*
 * Complex-table light hierarchical header — EDS v2.3.9+.
 * Multi-level complex headers can occupy a large vertical area; a dark fill on
 * every level becomes visually heavy and obscures hierarchy. Complex tables
 * therefore use light tonal steps while simple tables keep the deep-teal header.
 */
:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-complex > thead > tr > th {
  background: #fff;
  color: #33433d;
  border-color: #c8d6cf;
  font-weight: 600;
  line-height: 1.3;
  vertical-align: middle;
}

/* Level 1 — major column groups. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-complex > thead > tr:first-child > th {
  background: #eaf2ee;
  color: #244d45;
  font-weight: 700;
}

/* Intermediate hierarchy levels. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-complex > thead > tr:not(:first-child):not(:last-child) > th {
  background: #f5f8f6;
  color: #30463f;
  font-weight: 600;
}

/* Terminal leaf header row defaults to clean white + bold dark text. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-complex > thead > tr:not(:first-child):last-child > th {
  background: #fff;
  color: #33433d;
  font-weight: 700;
}

/* Very deep (4+ row) administrative headers may use a subtle terminal accent. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-complex > thead:has(> tr:nth-child(4)) > tr:last-child > th {
  background: #eef4f1;
  color: #315a50;
  font-weight: 700;
}

/* Complex-table row headers and totals stay light as well. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-complex > tbody > tr > th {
  background: #f5f8f6;
  color: #30463f;
  border-color: #c8d6cf;
  font-weight: 700;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table.is-complex > tfoot > tr > th {
  background: #eaf2ee;
  color: #244d45;
  border-color: #c8d6cf;
  font-weight: 700;
}

/* Type B support relation: exactly one body row, 2–3 cells, no header/footer/span. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:not(:has(> thead)):not(:has(> tfoot)):not(:has([rowspan])):not(:has([colspan])):has(> tbody > tr:only-child > :nth-child(2)):not(:has(> tbody > tr:only-child > :nth-child(4))) {
  table-layout: fixed;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:not(:has(> thead)):not(:has(> tfoot)):not(:has([rowspan])):not(:has([colspan])):has(> tbody > tr:only-child > :nth-child(2)):not(:has(> tbody > tr:only-child > :nth-child(3))) > tbody > tr:only-child > :first-child {
  width: 34%;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:not(:has(> thead)):not(:has(> tfoot)):not(:has([rowspan])):not(:has([colspan])):has(> tbody > tr:only-child > :nth-child(2)):not(:has(> tbody > tr:only-child > :nth-child(3))) > tbody > tr:only-child > :last-child {
  color: var(--ct-text-soft);
  background: #f7f9f7;
}

/* Multi-row/header nested matrices remain true tables and simply fit the cell. */
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:has(> tbody > tr:nth-child(2)),
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:has(> thead),
:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-complex {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  table-layout: fixed;
}

:where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:has(> tbody > tr:nth-child(2)) tbody tr:nth-child(even) td {
  background: #f7f9f7;
}

@media (hover: hover) {
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table tbody tr:hover td {
    background: inherit;
  }
}

/* ========================================================================== 
 * TABLE WRAPPER — compatibility only, never a scroll owner
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) .ct-table-scroll {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0 0 22px;
  overflow: clip;
  border-radius: 8px;
  scrollbar-width: none;
}

:where(.ct-prose, body.mce-content-body) .ct-table-scroll::-webkit-scrollbar {
  display: none;
}

:where(.ct-prose, body.mce-content-body) .ct-table-scroll > table {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 0;
  table-layout: fixed;
}

/* Explicitly neutralize any historical sticky behavior. */
:where(.ct-prose, body.mce-content-body) .ct-table-scroll table > :is(thead, tbody, tfoot) > tr > :first-child {
  position: static;
  left: auto;
  z-index: auto;
  box-shadow: none;
}

/* ========================================================================== 
 * MEANINGFUL POSITIONAL STRUCTURES — EDS v2.4.3
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) .ct-official-document {
  box-sizing: border-box;
  margin: 1.8em 0 2.1em;
  padding: clamp(22px, 3.5vw, 32px);
  border: 1px solid #cfd8d3;
  border-radius: 3px;
  background: #fff;
}

:where(.ct-prose, body.mce-content-body) .ct-official-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(18px, 4vw, 44px);
  align-items: start;
  margin: 0 0 1.6em;
  padding: 0 0 1.15em;
  border-bottom: 1px solid var(--ct-border-cool);
}

:where(.ct-prose, body.mce-content-body) :is(.ct-official-header__issuer, .ct-official-header__authority) {
  min-width: 0;
  text-align: center;
}

:where(.ct-prose, body.mce-content-body) :is(.ct-official-header__issuer, .ct-official-header__authority) > :first-child {
  margin-top: 0;
}

:where(.ct-prose, body.mce-content-body) :is(.ct-official-header__issuer, .ct-official-header__authority) > :last-child {
  margin-bottom: 0;
}

:where(.ct-prose, body.mce-content-body) .ct-official-header strong {
  color: var(--ct-ink);
  font-weight: 700;
}

:where(.ct-prose, body.mce-content-body) .ct-signature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: clamp(22px, 5vw, 56px);
  align-items: start;
  margin: 2em 0 1.6em;
  padding-top: 0.35em;
}

/*
 * A one-party signature grid is reserved for source-backed single-signature
 * layouts whose signer is meaningfully anchored to the right (for example a
 * blank left companion cell + centered signer in the right source cell).
 * The party stays centered inside its own region, while the region itself is
 * anchored right instead of becoming centered across the whole document.
 */
:where(.ct-prose, body.mce-content-body) .ct-signature-grid > .ct-signature-party:only-child {
  width: min(52%, 380px);
  margin-left: auto;
}

:where(.ct-prose, body.mce-content-body) .ct-signature-party {
  min-width: 0;
  text-align: center;
}

:where(.ct-prose, body.mce-content-body) .ct-signature-party > :first-child {
  margin-top: 0;
}

:where(.ct-prose, body.mce-content-body) .ct-signature-party > :last-child {
  margin-bottom: 0;
}

:where(.ct-prose, body.mce-content-body) .ct-signature-party strong {
  color: var(--ct-ink);
  font-weight: 700;
}

/* Signature area is a document zone, not a nested card. */
:where(.ct-prose, body.mce-content-body) .ct-official-document > .ct-signature-grid {
  margin-top: 2.2em;
  padding-top: 1.35em;
  border-top: 1px solid #e0e5e2;
}

/* ========================================================================== 
 * OFFICIAL DOCUMENT TABLE PRESENTATION — EDS v2.4.3
 * Same semantic table classes; context alone changes presentation.
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) .ct-official-document table,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table {
  border-color: #c9d2cd;
  border-radius: 2px;
  background: #fff;
  color: #293730;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document .ct-table-scroll {
  border-radius: 2px;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table th,
:where(.ct-prose, body.mce-content-body) .ct-official-document table td,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table th,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table td {
  border-right-color: #c9d2cd;
  border-bottom-color: #cfd7d3;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[rowspan]) > :is(thead, tbody, tfoot) > tr > :is(th, td),
:where(.ct-prose, body.mce-content-body) .ct-official-document table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[colspan]) > :is(thead, tbody, tfoot) > tr > :is(th, td),
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[rowspan]) > :is(thead, tbody, tfoot) > tr > :is(th, td),
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :is(th, td)[colspan]) > :is(thead, tbody, tfoot) > tr > :is(th, td) {
  border-color: #c9d2cd;
}

/* Simple tables inside a formal document use paper-like neutral headers. */
:where(.ct-prose, body.mce-content-body) .ct-official-document table th,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table.is-simple thead th {
  background: #e8eeeb;
  color: #293730;
  font-weight: 700;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table thead tr:first-child th:first-child,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table thead tr:first-child th:first-child {
  border-top-left-radius: 1px;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table thead tr:first-child th:last-child,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table thead tr:first-child th:last-child {
  border-top-right-radius: 1px;
}

/* Complex official-document headers keep hierarchy but reduce brand tint. */
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table.is-complex > thead > tr > th {
  background: #fafbfa;
  color: #293730;
  border-color: #c9d2cd;
  font-weight: 600;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table.is-complex > thead > tr:first-child > th {
  background: #e8eeeb;
  color: #293730;
  font-weight: 700;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table.is-complex > thead > tr:not(:first-child):not(:last-child) > th {
  background: #f1f4f2;
  color: #293730;
  font-weight: 600;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table.is-complex > thead > tr:not(:first-child):last-child > th {
  background: #fafbfa;
  color: #293730;
  font-weight: 700;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table.is-complex > thead:has(> tr:nth-child(4)) > tr:last-child > th {
  background: #f1f4f2;
  color: #293730;
  font-weight: 700;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table.is-complex > tbody > tr > th,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table.is-complex > tfoot > tr > th {
  background: #eef1ef;
  color: #293730;
  border-color: #c9d2cd;
  font-weight: 700;
}

/* A printed form reads more faithfully without editorial zebra/hover treatment. */
:where(.ct-prose, body.mce-content-body) .ct-official-document table tbody td,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table tbody td,
:where(.ct-prose, body.mce-content-body) .ct-official-document table tfoot td,
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table tfoot td {
  background: #fff;
}

@media (hover: hover) {
  :where(.ct-prose, body.mce-content-body) .ct-official-document table tbody tr:hover td,
  :where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table tbody tr:hover td {
    background: #fff;
  }
}

/* Nested tables inside the same document inherit the formal paper treatment. */
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table :is(th, td) > table.ct-data-table {
  border-color: #c9d2cd;
  border-radius: 2px;
  background: #fff;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table :is(th, td) > table.ct-data-table.is-simple thead th {
  background: #eef1ef;
  color: #293730;
}

/* Form-slot rows stay plain: label slightly separated, slots remain paper-white. */
:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table:not(:has(> thead)):has(> tbody > tr:only-child > td:first-child:not(:empty)):has(> tbody > tr:only-child > :nth-child(10)):has(> tbody > tr:only-child > td:nth-child(2):empty):has(> tbody > tr:only-child > td:nth-child(3):empty):has(> tbody > tr:only-child > td:nth-child(10):empty) > tbody > tr:only-child > :first-child {
  background: #fafbfa;
}

:where(.ct-prose, body.mce-content-body) .ct-official-document table.ct-data-table:not(:has(> thead)):has(> tbody > tr:only-child > td:first-child:not(:empty)):has(> tbody > tr:only-child > :nth-child(10)):has(> tbody > tr:only-child > td:nth-child(2):empty):has(> tbody > tr:only-child > td:nth-child(3):empty):has(> tbody > tr:only-child > td:nth-child(10):empty) > tbody > tr:only-child > td:not(:first-child) {
  background: #fff;
}

/* ========================================================================== 
 * KEY LINES
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) .ct-key-line {
  display: block;
  margin: 1.35em 0 1.55em;
  padding: 11px 14px 11px 16px;
  border: 0;
  border-radius: 7px;
  color: #343b3d;
  font-size: 0.98em;
  font-weight: 500;
  line-height: 1.62;
}

:where(.ct-prose, body.mce-content-body) .ct-key-line.is-process {
  border-left: 3px solid var(--ct-info);
  background: linear-gradient(90deg, rgba(79, 141, 184, .13), rgba(79, 141, 184, .03));
}

:where(.ct-prose, body.mce-content-body) .ct-key-line.is-formula {
  border-left: 3px solid var(--ct-gold);
  background: linear-gradient(90deg, rgba(208, 161, 58, .14), rgba(208, 161, 58, .035));
}

:where(.ct-prose, body.mce-content-body) .ct-key-line.is-result {
  color: #144734;
  border-left: 3px solid var(--ct-green);
  background: linear-gradient(90deg, rgba(23, 107, 77, .12), rgba(23, 107, 77, .025));
  font-weight: 600;
}

:where(.ct-prose, body.mce-content-body) .ct-key-line strong {
  color: inherit;
  font-weight: 700;
}

/* ========================================================================== 
 * ACCOUNTING ENTRY
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) p:has(+ .ct-accounting-entry) {
  margin-bottom: 0;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry {
  margin: 1em 0 1.4em;
  padding: 14px 18px;
  border: 1px solid var(--ct-border-cool);
  border-radius: 8px;
  background: #fbfefc;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry__title {
  margin: 0 0 10px;
  color: var(--ct-slate);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry__line {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  font-size: 15px;
  line-height: 1.6;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry__line + .ct-accounting-entry__line {
  border-top: 1px solid #e8f0eb;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry__side {
  flex: 0 0 auto;
  min-width: 28px;
  color: var(--ct-slate);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry__line.is-debit .ct-accounting-entry__side {
  color: var(--ct-green);
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry__line.is-credit .ct-accounting-entry__side {
  color: var(--ct-gold-dark);
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry__line > span {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ct-text);
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-entry + .ct-accounting-entry {
  margin-top: 10px;
}

/* ========================================================================== 
 * ACCOUNTING GROUP
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) .ct-accounting-group {
  margin: 1.8em 0 2em;
  padding: 16px 18px;
  border: 1px solid #dce9e0;
  border-radius: 10px;
  background: #f7fbf8;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-group > .ct-accounting-entry {
  margin-top: 0;
  margin-bottom: 0;
  border: 1px solid var(--ct-border-cool);
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-group > .ct-accounting-entry + .ct-accounting-entry {
  margin-top: 10px;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-group > .ct-accounting-entry:nth-child(even of .ct-accounting-entry) {
  background: #f2f8f4;
  border-color: #cfe0d4;
}

:where(.ct-prose, body.mce-content-body) .ct-accounting-group > p:first-child,
:where(.ct-prose, body.mce-content-body) .ct-accounting-group > .ct-accounting-group__title {
  margin: 0 0 12px;
  color: var(--ct-slate);
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.45;
}

/* ========================================================================== 
 * DEFINITION LIST
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) .ct-definition-list {
  margin: 1.4em 0 1.6em;
  padding: 0;
}

:where(.ct-prose, body.mce-content-body) .ct-definition-list dt {
  margin: 0;
  padding: 10px 0 4px;
  color: var(--ct-green);
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.45;
  border-top: 1px solid var(--ct-border);
}

:where(.ct-prose, body.mce-content-body) .ct-definition-list dt:first-child {
  border-top: 0;
  padding-top: 0;
}

:where(.ct-prose, body.mce-content-body) .ct-definition-list dd {
  margin: 0 0 2px;
  padding: 0 0 10px;
  color: var(--ct-text);
  font-size: 15px;
  line-height: 1.68;
}

:where(.ct-prose, body.mce-content-body) .ct-definition-list dt:nth-of-type(even) {
  background: #f5faf6;
  margin-inline: -8px;
  padding-inline: 8px;
  border-radius: 4px 4px 0 0;
}

:where(.ct-prose, body.mce-content-body) .ct-definition-list dt:nth-of-type(even) + dd {
  background: #f5faf6;
  margin-inline: -8px;
  padding-inline: 8px;
  border-radius: 0 0 4px 4px;
}

/* ========================================================================== 
 * FACT LIST
 * ========================================================================== */

:where(.ct-prose, body.mce-content-body) .ct-fact-list {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 0;
  margin: 1.4em 0 1.6em;
  padding: 12px 16px;
  border: 1px solid #eadcad;
  border-radius: 8px;
  background: #fffaf0;
}

:where(.ct-prose, body.mce-content-body) .ct-fact-list dt {
  grid-column: 1;
  padding: 8px 12px 8px 0;
  color: #6f602f;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  border-bottom: 1px solid #eee1bd;
}

:where(.ct-prose, body.mce-content-body) .ct-fact-list dd {
  grid-column: 2;
  margin: 0;
  padding: 8px 0;
  color: var(--ct-ink);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.5;
  border-bottom: 1px solid #eee1bd;
}

:where(.ct-prose, body.mce-content-body) .ct-fact-list dt:last-of-type,
:where(.ct-prose, body.mce-content-body) .ct-fact-list dd:last-of-type {
  border-bottom: 0;
}

/* ========================================================================== 
 * RESPONSIVE — mobile
 * ========================================================================== */

@media (max-width: 640px) {
  :where(.ct-prose, body.mce-content-body) table,
  :where(.ct-prose, body.mce-content-body) table.ct-data-table {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    table-layout: fixed;
    font-size: 12.5px;
    line-height: 1.4;
  }

  :where(.ct-prose, body.mce-content-body) table th,
  :where(.ct-prose, body.mce-content-body) table td,
  :where(.ct-prose, body.mce-content-body) table.ct-data-table th,
  :where(.ct-prose, body.mce-content-body) table.ct-data-table td {
    min-width: 0;
    padding: 7px 6px;
    overflow-wrap: anywhere;
  }

  /* Progressively compress each matrix from its own rows only. */
  :where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(5)) {
    font-size: 9.5px;
    line-height: 1.28;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(5)) :is(th, td) {
    padding: 4px 3px;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(8)) {
    font-size: 8.5px;
    line-height: 1.22;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(8)) :is(th, td) {
    padding: 3px 2px;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(11)) {
    font-size: 7.5px;
    line-height: 1.18;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table:has(> :is(thead, tbody, tfoot) > tr > :nth-child(11)) :is(th, td) {
    padding: 2px 1px;
  }

  /* Segmented form slots override generic 11+ density on mobile too. */
  :where(.ct-prose, body.mce-content-body) table.ct-data-table:not(:has(> thead)):has(> tbody > tr:only-child > td:first-child:not(:empty)):has(> tbody > tr:only-child > :nth-child(10)):has(> tbody > tr:only-child > td:nth-child(2):empty):has(> tbody > tr:only-child > td:nth-child(3):empty):has(> tbody > tr:only-child > td:nth-child(10):empty) {
    font-size: 10.5px;
    line-height: 1.25;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table:not(:has(> thead)):has(> tbody > tr:only-child > td:first-child:not(:empty)):has(> tbody > tr:only-child > :nth-child(10)):has(> tbody > tr:only-child > td:nth-child(2):empty):has(> tbody > tr:only-child > td:nth-child(3):empty):has(> tbody > tr:only-child > td:nth-child(10):empty) > tbody > tr:only-child > td {
    height: 32px;
    padding: 5px 0;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table:not(:has(> thead)):has(> tbody > tr:only-child > td:first-child:not(:empty)):has(> tbody > tr:only-child > :nth-child(10)):has(> tbody > tr:only-child > td:nth-child(2):empty):has(> tbody > tr:only-child > td:nth-child(3):empty):has(> tbody > tr:only-child > td:nth-child(10):empty) > tbody > tr:only-child > :first-child {
    width: 36%;
    padding: 5px 6px;
    font-size: 11px;
    white-space: normal;
  }

  /* Type B only: stack one-row support cells. */
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:not(:has(> thead)):not(:has(> tfoot)):not(:has([rowspan])):not(:has([colspan])):has(> tbody > tr:only-child > :nth-child(2)):not(:has(> tbody > tr:only-child > :nth-child(4))) {
    display: block;
    width: 100%;
    margin: 0.55em 0 0.65em;
    font-size: 11px;
    line-height: 1.36;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:not(:has(> thead)):not(:has(> tfoot)):not(:has([rowspan])):not(:has([colspan])):has(> tbody > tr:only-child > :nth-child(2)):not(:has(> tbody > tr:only-child > :nth-child(4))) > tbody,
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:not(:has(> thead)):not(:has(> tfoot)):not(:has([rowspan])):not(:has([colspan])):has(> tbody > tr:only-child > :nth-child(2)):not(:has(> tbody > tr:only-child > :nth-child(4))) > tbody > tr {
    display: block;
    width: 100%;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:not(:has(> thead)):not(:has(> tfoot)):not(:has([rowspan])):not(:has([colspan])):has(> tbody > tr:only-child > :nth-child(2)):not(:has(> tbody > tr:only-child > :nth-child(4))) > tbody > tr > :is(th, td) {
    display: block;
    width: 100%;
    padding: 6px 7px;
    border-right: 0;
    border-bottom: 0;
    background: transparent;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:not(:has(> thead)):not(:has(> tfoot)):not(:has([rowspan])):not(:has([colspan])):has(> tbody > tr:only-child > :nth-child(2)):not(:has(> tbody > tr:only-child > :nth-child(4))) > tbody > tr > :is(th, td) + :is(th, td) {
    border-top: 1px solid #e1e8e4;
    color: var(--ct-text-soft);
    background: #f7f9f7;
  }

  /* Type C/D remain tabular and fit the parent; no parent widening. */
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:has(> tbody > tr:nth-child(2)),
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-simple:has(> thead),
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table.is-complex {
    display: table;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    table-layout: fixed;
    font-size: 9px;
    line-height: 1.24;
  }

  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table :is(th, td) {
    min-width: 0;
    padding: 3px 2px;
    overflow-wrap: anywhere;
  }

  /* Depth >1 remains conservative and fit-only; skill still flags it for review. */
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table :is(th, td) > table.ct-data-table {
    display: table;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    table-layout: fixed;
  }

  :where(.ct-prose, body.mce-content-body) table :is(th, td) > p + p,
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > p + p {
    margin-top: 0.52em;
  }

  /* Positional semantics remain grouped; mobile stacks only presentation. */
  :where(.ct-prose, body.mce-content-body) .ct-official-header,
  :where(.ct-prose, body.mce-content-body) .ct-signature-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-official-document {
    padding: 16px 14px;
    border-radius: 3px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-official-header {
    padding-bottom: 1em;
  }

  :where(.ct-prose, body.mce-content-body) .ct-signature-grid {
    margin-top: 1.65em;
  }

  :where(.ct-prose, body.mce-content-body) .ct-official-document > .ct-signature-grid {
    padding-top: 1.1em;
  }

  :where(.ct-prose, body.mce-content-body) .ct-signature-grid > .ct-signature-party:only-child {
    width: 100%;
    margin-left: 0;
  }

  :where(.ct-prose, body.mce-content-body) .ct-key-line {
    margin: 1.2em 0 1.4em;
    padding: 10px 12px 10px 14px;
    font-size: 0.96em;
  }

  :where(.ct-prose, body.mce-content-body) .ct-accounting-entry {
    padding: 12px 14px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-accounting-entry__line {
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 14.5px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-accounting-entry__side {
    font-size: 13px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-accounting-group {
    padding: 12px 14px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-definition-list dt {
    font-size: 15px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-definition-list dd {
    font-size: 14.5px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-fact-list {
    grid-template-columns: 1fr;
    padding: 10px 14px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-fact-list dt {
    grid-column: 1;
    padding: 8px 0 2px;
    border-bottom: 0;
    font-size: 12.5px;
  }

  :where(.ct-prose, body.mce-content-body) .ct-fact-list dd {
    grid-column: 1;
    padding: 0 0 8px;
    font-size: 14px;
  }
}

/* ========================================================================== 
 * PRINT
 * ========================================================================== */

@media print {
  :where(.ct-prose, body.mce-content-body) .ct-table-scroll {
    overflow: visible;
  }

  :where(.ct-prose, body.mce-content-body) .ct-table-scroll > table.ct-data-table,
  :where(.ct-prose, body.mce-content-body) table.ct-data-table :is(th, td) > table.ct-data-table {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    table-layout: fixed;
  }

  :where(.ct-prose, body.mce-content-body) .ct-official-header,
  :where(.ct-prose, body.mce-content-body) .ct-signature-grid,
  :where(.ct-prose, body.mce-content-body) .ct-accounting-entry,
  :where(.ct-prose, body.mce-content-body) .ct-accounting-group,
  :where(.ct-prose, body.mce-content-body) .ct-definition-list,
  :where(.ct-prose, body.mce-content-body) .ct-fact-list {
    break-inside: avoid;
  }
}
