/*
 * CFO HUB table themes
 * This layer changes only presentation. Table structure, spacing contracts,
 * responsive behavior and financial semantics remain owned by app.css/pages.
 */
html[data-cfo-table-theme] {
    --cfo-t-bg: #f7f9fc;
    --cfo-t-surface: #ffffff;
    --cfo-t-surface-alt: #f8fafc;
    --cfo-t-header: #eef2f7;
    --cfo-t-header-text: #344054;
    --cfo-t-text: #172033;
    --cfo-t-muted: #667085;
    --cfo-t-border: #dfe7f2;
    --cfo-t-grid: #e7edf6;
    --cfo-t-hover: #f5f8fc;
    --cfo-t-entry: #087a4b;
    --cfo-t-entry-soft: #f1faf5;
    --cfo-t-expense: #b54708;
    --cfo-t-expense-soft: #fff8ed;
    --cfo-t-tax: #be123c;
    --cfo-t-tax-soft: #fff4f6;
    --cfo-t-balance: #2459ad;
    --cfo-t-balance-soft: #eef5ff;
    --cfo-t-good: #087a4b;
    --cfo-t-bad: #c02626;
    --cfo-semantic-good: #087a4b;
    --cfo-semantic-bad: #c02626;
    --cfo-semantic-neutral: #667085;
    --cfo-t-shadow: 0 4px 14px rgba(18, 32, 68, .055);
    --cfo-t-shadow-open: 0 8px 24px rgba(18, 32, 68, .09);
    --cfo-t-radius: 8px;
    --cfo-t-row-gap: 8px;
    --cfo-t-summary-min: 56px;
    --cfo-t-summary-py: 12px;
    --cfo-t-summary-px: 16px;
    --cfo-t-detail-min: 30px;
    --cfo-t-cell-py: 10px;
    --cfo-t-cell-px: 12px;
    --cfo-t-accent-width: 4px;
    --cfo-t-card-border-width: 1px;
    --cfo-t-header-font: .72rem;
    --cfo-t-header-weight: 800;
    --cfo-t-header-letter: 0;
    --cfo-t-summary-font: .88rem;
    --cfo-t-detail-font: .8rem;
    --cfo-t-summary-weight: 500;
    --cfo-t-value-weight: 500;
    --cfo-t-zebra: transparent;
    --cfo-t-font-family: "Aptos", "Segoe UI", Arial, sans-serif;
}

html[data-cfo-table-theme="executive_navy"] {
    --cfo-t-font-family: "Segoe UI", "Aptos", Arial, sans-serif;
    --cfo-t-bg: #f4f7fb; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #f7f9fc;
    --cfo-t-header: #dfe7f2; --cfo-t-header-text: #17324d; --cfo-t-text: #102a43;
    --cfo-t-muted: #62758a; --cfo-t-border: #cad6e5; --cfo-t-grid: #e1e8f0; --cfo-t-hover: #eef4fa;
    --cfo-t-entry: #087f5b; --cfo-t-entry-soft: #edf9f4; --cfo-t-expense: #c05621; --cfo-t-expense-soft: #fff5eb;
    --cfo-t-tax: #b4234d; --cfo-t-tax-soft: #fff1f5; --cfo-t-balance: #1f4e8c; --cfo-t-balance-soft: #edf3fb;
    --cfo-t-good: #087f5b; --cfo-t-bad: #bd2c2c; --cfo-t-shadow: 0 2px 7px rgba(16, 42, 67, .08);
    --cfo-t-header:#17324d; --cfo-t-header-text:#fff; --cfo-t-radius:4px; --cfo-t-row-gap:4px;
    --cfo-t-summary-min:50px; --cfo-t-detail-min:27px; --cfo-t-cell-py:8px; --cfo-t-accent-width:3px;
    --cfo-t-header-letter:.035em; --cfo-t-zebra:#f6f9fc;
}

html[data-cfo-table-theme="boardroom_teal"] {
    --cfo-t-font-family: "Aptos", Calibri, "Segoe UI", sans-serif;
    --cfo-t-bg: #f3f8f7; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #f6faf9;
    --cfo-t-header: #dcebea; --cfo-t-header-text: #24545a; --cfo-t-text: #173b40;
    --cfo-t-muted: #668086; --cfo-t-border: #c9dedc; --cfo-t-grid: #dfebea; --cfo-t-hover: #edf7f5;
    --cfo-t-entry: #087f5b; --cfo-t-entry-soft: #edf9f4; --cfo-t-expense: #b65d20; --cfo-t-expense-soft: #fff7ed;
    --cfo-t-tax: #b52b4b; --cfo-t-tax-soft: #fff3f5; --cfo-t-balance: #147d83; --cfo-t-balance-soft: #eaf7f7;
    --cfo-t-good: #087f5b; --cfo-t-bad: #c23232; --cfo-t-shadow: 0 7px 18px rgba(18, 60, 67, .07);
    --cfo-t-header:#24545a; --cfo-t-header-text:#fff; --cfo-t-radius:8px; --cfo-t-row-gap:10px;
    --cfo-t-summary-min:62px; --cfo-t-summary-py:15px; --cfo-t-detail-min:32px; --cfo-t-cell-py:12px;
    --cfo-t-summary-font:.9rem; --cfo-t-zebra:#f2f8f7;
}

html[data-cfo-table-theme="graphite_cyan"] {
    --cfo-t-font-family: Arial, "Segoe UI", sans-serif;
    --cfo-t-bg: #f4f6f7; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #f7f8f9;
    --cfo-t-header: #e4e8ec; --cfo-t-header-text: #35434d; --cfo-t-text: #202b33;
    --cfo-t-muted: #687781; --cfo-t-border: #d1d9df; --cfo-t-grid: #e3e8eb; --cfo-t-hover: #eef4f6;
    --cfo-t-entry: #147d64; --cfo-t-entry-soft: #eef8f5; --cfo-t-expense: #c15a24; --cfo-t-expense-soft: #fff5ef;
    --cfo-t-tax: #bd3153; --cfo-t-tax-soft: #fff2f5; --cfo-t-balance: #087ea4; --cfo-t-balance-soft: #ebf7fb;
    --cfo-t-good: #147d64; --cfo-t-bad: #c52d35; --cfo-t-shadow: none; --cfo-t-shadow-open:none;
    --cfo-t-header:#35434d; --cfo-t-header-text:#fff; --cfo-t-radius:2px; --cfo-t-row-gap:0;
    --cfo-t-summary-min:46px; --cfo-t-summary-py:8px; --cfo-t-detail-min:25px; --cfo-t-cell-py:7px;
    --cfo-t-accent-width:3px; --cfo-t-header-letter:.045em; --cfo-t-zebra:#f3f6f7;
}

html[data-cfo-table-theme="forest_performance"] {
    --cfo-t-font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    --cfo-t-bg: #f4f7f5; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #f7faf8;
    --cfo-t-header: #e1ebe5; --cfo-t-header-text: #345347; --cfo-t-text: #18352a;
    --cfo-t-muted: #687a72; --cfo-t-border: #cfddd4; --cfo-t-grid: #e2ebe5; --cfo-t-hover: #eff6f2;
    --cfo-t-entry: #176b4d; --cfo-t-entry-soft: #edf7f1; --cfo-t-expense: #ad5b25; --cfo-t-expense-soft: #fff6ed;
    --cfo-t-tax: #a92e4f; --cfo-t-tax-soft: #fff2f5; --cfo-t-balance: #2d6655; --cfo-t-balance-soft: #edf5f1;
    --cfo-t-good: #176b4d; --cfo-t-bad: #b72d32; --cfo-t-shadow: 0 4px 12px rgba(24, 53, 42, .06);
    --cfo-t-header:#345347; --cfo-t-header-text:#fff; --cfo-t-radius:6px; --cfo-t-row-gap:6px;
    --cfo-t-summary-min:56px; --cfo-t-detail-min:29px; --cfo-t-cell-py:9px; --cfo-t-accent-width:5px;
    --cfo-t-zebra:#f2f8f4;
}

html[data-cfo-table-theme="bordeaux_governance"] {
    --cfo-t-font-family: Calibri, "Aptos", "Segoe UI", sans-serif;
    --cfo-t-bg: #f8f5f6; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #faf7f8;
    --cfo-t-header: #ece5e8; --cfo-t-header-text: #59434c; --cfo-t-text: #35232a;
    --cfo-t-muted: #796a70; --cfo-t-border: #ded1d6; --cfo-t-grid: #ece2e5; --cfo-t-hover: #f7f0f2;
    --cfo-t-entry: #187154; --cfo-t-entry-soft: #eef7f3; --cfo-t-expense: #a95822; --cfo-t-expense-soft: #fff6ed;
    --cfo-t-tax: #9f2447; --cfo-t-tax-soft: #fdf0f4; --cfo-t-balance: #5b4a72; --cfo-t-balance-soft: #f3f0f7;
    --cfo-t-good: #187154; --cfo-t-bad: #ad2d3d; --cfo-t-shadow: 0 5px 15px rgba(53, 35, 42, .07);
    --cfo-t-header:#59434c; --cfo-t-header-text:#fff; --cfo-t-radius:6px; --cfo-t-row-gap:8px;
    --cfo-t-summary-min:58px; --cfo-t-detail-min:30px; --cfo-t-cell-py:10px; --cfo-t-header-letter:.025em;
    --cfo-t-zebra:#faf6f7;
}

html[data-cfo-table-theme="mediterranean_business"] {
    --cfo-t-font-family: "Aptos", "Segoe UI", Arial, sans-serif;
    --cfo-t-bg: #f3f7f9; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #f6f9fa;
    --cfo-t-header: #e3ebf0; --cfo-t-header-text: #315368; --cfo-t-text: #123247;
    --cfo-t-muted: #677d8b; --cfo-t-border: #cfdae1; --cfo-t-grid: #e2eaee; --cfo-t-hover: #edf5f7;
    --cfo-t-entry: #0b7a66; --cfo-t-entry-soft: #edf8f5; --cfo-t-expense: #b45a22; --cfo-t-expense-soft: #fff6ed;
    --cfo-t-tax: #b42850; --cfo-t-tax-soft: #fff1f5; --cfo-t-balance: #176b87; --cfo-t-balance-soft: #ecf5f8;
    --cfo-t-good: #0b7a66; --cfo-t-bad: #bd3037; --cfo-t-shadow: 0 5px 16px rgba(18, 50, 71, .075);
}

html[data-cfo-table-theme="slate_audit"] {
    --cfo-t-font-family: Tahoma, "Segoe UI", sans-serif;
    --cfo-t-bg: #f4f6f8; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #f7f8fa;
    --cfo-t-header: #e5e9ee; --cfo-t-header-text: #425364; --cfo-t-text: #263442;
    --cfo-t-muted: #6d7a87; --cfo-t-border: #d2dae2; --cfo-t-grid: #e3e8ed; --cfo-t-hover: #eff3f6;
    --cfo-t-entry: #20745b; --cfo-t-entry-soft: #eff8f4; --cfo-t-expense: #b45f2a; --cfo-t-expense-soft: #fff7ef;
    --cfo-t-tax: #a73554; --cfo-t-tax-soft: #fff3f6; --cfo-t-balance: #536b82; --cfo-t-balance-soft: #eff3f7;
    --cfo-t-good: #20745b; --cfo-t-bad: #b9343a; --cfo-t-shadow: none; --cfo-t-shadow-open:none;
    --cfo-t-header:#425364; --cfo-t-header-text:#fff; --cfo-t-radius:3px; --cfo-t-row-gap:2px;
    --cfo-t-summary-min:47px; --cfo-t-summary-py:8px; --cfo-t-detail-min:24px; --cfo-t-cell-py:7px;
    --cfo-t-card-border-width:1px; --cfo-t-accent-width:3px; --cfo-t-detail-font:.76rem; --cfo-t-zebra:#f1f4f7;
}

html[data-cfo-table-theme="monochrome_audit"] {
    --cfo-t-font-family: Arial, Helvetica, sans-serif;
    --cfo-t-bg: #f5f5f5; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #f8f8f8;
    --cfo-t-header: #e8eaed; --cfo-t-header-text: #3f454b; --cfo-t-text: #262a2e;
    --cfo-t-muted: #70757a; --cfo-t-border: #d7d9dc; --cfo-t-grid: #e8e9eb; --cfo-t-hover: #f1f2f3;
    --cfo-t-entry: #3f6f5e; --cfo-t-entry-soft: #f2f7f5; --cfo-t-expense: #80604b; --cfo-t-expense-soft: #f8f4f1;
    --cfo-t-tax: #7b4051; --cfo-t-tax-soft: #f8f2f4; --cfo-t-balance: #515b66; --cfo-t-balance-soft: #f1f3f5;
    --cfo-t-good: #3f6f5e; --cfo-t-bad: #8b3f43; --cfo-t-shadow: none; --cfo-t-shadow-open:none;
    --cfo-t-header:#3f454b; --cfo-t-header-text:#fff; --cfo-t-radius:0; --cfo-t-row-gap:0;
    --cfo-t-summary-min:45px; --cfo-t-summary-py:7px; --cfo-t-detail-min:24px; --cfo-t-cell-py:7px;
    --cfo-t-accent-width:2px; --cfo-t-header-letter:.05em; --cfo-t-zebra:#f3f3f3;
}

html[data-cfo-table-theme="high_contrast"] {
    --cfo-t-font-family: Verdana, "Segoe UI", sans-serif;
    --cfo-t-bg: #f2f5f9; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #f6f8fb;
    --cfo-t-header: #dbe3ee; --cfo-t-header-text: #132f4c; --cfo-t-text: #091d34;
    --cfo-t-muted: #536a82; --cfo-t-border: #bfcddd; --cfo-t-grid: #d8e1eb; --cfo-t-hover: #eaf1f8;
    --cfo-t-entry: #006b45; --cfo-t-entry-soft: #e9f7f1; --cfo-t-expense: #a84200; --cfo-t-expense-soft: #fff2e8;
    --cfo-t-tax: #a40032; --cfo-t-tax-soft: #ffedf2; --cfo-t-balance: #004f9e; --cfo-t-balance-soft: #e9f2fc;
    --cfo-t-good: #006b45; --cfo-t-bad: #b00020; --cfo-t-shadow: 0 6px 18px rgba(9, 29, 52, .1);
    --cfo-t-header:#132f4c; --cfo-t-header-text:#fff; --cfo-t-radius:4px; --cfo-t-row-gap:7px;
    --cfo-t-summary-min:62px; --cfo-t-summary-py:14px; --cfo-t-detail-min:33px; --cfo-t-cell-py:12px;
    --cfo-t-card-border-width:2px; --cfo-t-accent-width:6px; --cfo-t-header-font:.76rem;
    --cfo-t-summary-font:.94rem; --cfo-t-detail-font:.84rem; --cfo-t-zebra:#eef3f8;
}

html[data-cfo-table-theme="soft_professional"] {
    --cfo-t-font-family: Calibri, "Aptos", "Segoe UI", sans-serif;
    --cfo-t-bg: #f7f8fa; --cfo-t-surface: #ffffff; --cfo-t-surface-alt: #fafbfc;
    --cfo-t-header: #edf0f4; --cfo-t-header-text: #526173; --cfo-t-text: #344054;
    --cfo-t-muted: #7b8794; --cfo-t-border: #dde2e8; --cfo-t-grid: #eceff3; --cfo-t-hover: #f4f6f8;
    --cfo-t-entry: #34745f; --cfo-t-entry-soft: #f1f8f5; --cfo-t-expense: #a86a3b; --cfo-t-expense-soft: #fcf7f2;
    --cfo-t-tax: #a64f68; --cfo-t-tax-soft: #fbf3f5; --cfo-t-balance: #536fa3; --cfo-t-balance-soft: #f1f4fa;
    --cfo-t-good: #34745f; --cfo-t-bad: #b34d53; --cfo-t-shadow: 0 8px 24px rgba(52, 64, 84, .055);
    --cfo-t-radius:8px; --cfo-t-row-gap:11px; --cfo-t-summary-min:66px; --cfo-t-summary-py:16px;
    --cfo-t-detail-min:34px; --cfo-t-cell-py:13px; --cfo-t-summary-font:.9rem; --cfo-t-detail-font:.82rem;
    --cfo-t-zebra:#fafbfc;
}

html[data-cfo-table-theme="corporate_blue"] {
    --cfo-t-font-family: "Segoe UI", "Aptos", Arial, sans-serif;
    --cfo-t-bg:#f4f7fb; --cfo-t-surface:#fff; --cfo-t-surface-alt:#f7f9fd;
    --cfo-t-header:#1f4f7a; --cfo-t-header-text:#fff; --cfo-t-text:#18324b;
    --cfo-t-muted:#64778a; --cfo-t-border:#cedbe7; --cfo-t-grid:#e0e8f0; --cfo-t-hover:#edf4fa;
    --cfo-t-entry:#08775b; --cfo-t-entry-soft:#edf8f4; --cfo-t-expense:#b4541b; --cfo-t-expense-soft:#fff5eb;
    --cfo-t-tax:#b22d50; --cfo-t-tax-soft:#fff2f5; --cfo-t-balance:#2459ad; --cfo-t-balance-soft:#edf3fc;
    --cfo-t-good:#08775b; --cfo-t-bad:#c12e32; --cfo-t-shadow:0 4px 14px rgba(31,79,122,.08);
}

html[data-cfo-table-theme="ledger_green"] {
    --cfo-t-font-family: "Aptos", Calibri, "Segoe UI", sans-serif;
    --cfo-t-bg:#f5f8f5; --cfo-t-surface:#fff; --cfo-t-surface-alt:#f8faf8;
    --cfo-t-header:#315847; --cfo-t-header-text:#fff; --cfo-t-text:#21372f;
    --cfo-t-muted:#6b7d75; --cfo-t-border:#d2dfd8; --cfo-t-grid:#e2ebe6; --cfo-t-hover:#eff6f2;
    --cfo-t-entry:#126b4f; --cfo-t-entry-soft:#eef8f3; --cfo-t-expense:#a95b25; --cfo-t-expense-soft:#fff6ed;
    --cfo-t-tax:#a82d4d; --cfo-t-tax-soft:#fff2f5; --cfo-t-balance:#3a6675; --cfo-t-balance-soft:#eef5f7;
    --cfo-t-good:#126b4f; --cfo-t-bad:#b72d32; --cfo-t-shadow:0 3px 12px rgba(33,55,47,.07);
}

html[data-cfo-table-theme="copper_finance"] {
    --cfo-t-font-family: Tahoma, "Segoe UI", sans-serif;
    --cfo-t-bg:#f8f6f3; --cfo-t-surface:#fff; --cfo-t-surface-alt:#fbf9f6;
    --cfo-t-header:#5b5149; --cfo-t-header-text:#fff; --cfo-t-text:#342d28;
    --cfo-t-muted:#786e66; --cfo-t-border:#ded7d0; --cfo-t-grid:#ece6e0; --cfo-t-hover:#f8f2ec;
    --cfo-t-entry:#24705a; --cfo-t-entry-soft:#eff8f4; --cfo-t-expense:#a9501f; --cfo-t-expense-soft:#fff4ea;
    --cfo-t-tax:#a52c4c; --cfo-t-tax-soft:#fff1f4; --cfo-t-balance:#4e6383; --cfo-t-balance-soft:#f0f3f8;
    --cfo-t-good:#24705a; --cfo-t-bad:#b62d35; --cfo-t-shadow:0 4px 14px rgba(52,45,40,.07);
}

html[data-cfo-table-theme="nordic_board"] {
    --cfo-t-font-family: "Segoe UI", "Aptos", Arial, sans-serif;
    --cfo-t-bg:#f5f8fa; --cfo-t-surface:#fff; --cfo-t-surface-alt:#f8fafb;
    --cfo-t-header:#3d5d6c; --cfo-t-header-text:#fff; --cfo-t-text:#243b46;
    --cfo-t-muted:#6b7e87; --cfo-t-border:#d3e0e5; --cfo-t-grid:#e4ecef; --cfo-t-hover:#eef5f7;
    --cfo-t-entry:#14775f; --cfo-t-entry-soft:#eef9f5; --cfo-t-expense:#b15b27; --cfo-t-expense-soft:#fff7ee;
    --cfo-t-tax:#aa3653; --cfo-t-tax-soft:#fff3f6; --cfo-t-balance:#36718d; --cfo-t-balance-soft:#eef6fa;
    --cfo-t-good:#14775f; --cfo-t-bad:#ba3438; --cfo-t-shadow:0 6px 18px rgba(36,59,70,.065);
}

/*
 * Layout master lock. Themes may change visual language and font family only:
 * grids, row heights, padding and type scale stay identical in every report.
 */
html[data-cfo-table-theme] {
    --cfo-t-row-gap:8px;
    --cfo-t-summary-min:56px;
    --cfo-t-summary-py:12px;
    --cfo-t-summary-px:16px;
    --cfo-t-detail-min:30px;
    --cfo-t-cell-py:10px;
    --cfo-t-cell-px:12px;
    --cfo-t-accent-width:4px;
    --cfo-t-card-border-width:1px;
    --cfo-t-header-font:.72rem;
    --cfo-t-header-weight:800;
    --cfo-t-header-letter:0;
    --cfo-t-summary-font:.88rem;
    --cfo-t-detail-font:.8rem;
    --cfo-t-summary-weight:500;
    --cfo-t-value-weight:500;
}

html[data-cfo-table-theme] body :is(
    .table, .table-kpi, .pluri-matrix-scroll, .gesteco-year-table,
    .matrix-table-scroll, .financial-preview-scroll, .ce-table, .ce-table-wrap,
    .theme-sample
) {
    font-family:var(--cfo-t-font-family) !important;
    font-variant-numeric:tabular-nums;
}

/* Generic Bootstrap and KPI tables. */
html[data-cfo-table-theme] body .table {
    --bs-table-bg: var(--cfo-t-surface) !important;
    --bs-table-color: var(--cfo-t-text) !important;
    --bs-table-border-color: var(--cfo-t-grid) !important;
    color: var(--cfo-t-text) !important;
}

html[data-cfo-table-theme] body .table > :not(caption) > * > * {
    padding: var(--cfo-t-cell-py) var(--cfo-t-cell-px) !important;
    font-weight: var(--cfo-t-value-weight);
}

html[data-cfo-table-theme] body .table tbody tr:nth-child(even) > * {
    background-color: var(--cfo-t-zebra) !important;
}

html[data-cfo-table-theme] body .table thead th,
html[data-cfo-table-theme] body .table-kpi thead th,
html[data-cfo-table-theme] body .folder-header {
    background: var(--cfo-t-header) !important;
    color: var(--cfo-t-header-text) !important;
    border-color: var(--cfo-t-border) !important;
    font-size: var(--cfo-t-header-font) !important;
    font-weight: var(--cfo-t-header-weight) !important;
    letter-spacing: var(--cfo-t-header-letter) !important;
}

html[data-cfo-table-theme] body .table tbody tr:is(:hover, :focus-within) > * {
    background-color: var(--cfo-t-hover) !important;
}

html[data-cfo-table-theme] body .table-kpi tbody td {
    background: var(--cfo-t-surface) !important;
    color: var(--cfo-t-text) !important;
    box-shadow: var(--cfo-t-shadow);
}

/*
 * Semantic state is independent from the selected visual theme and must win
 * over the neutral table text color. Icons/text always accompany these colors.
 */
html[data-cfo-table-theme] body .cfo-semantic-good,
html[data-cfo-table-theme] body .table-kpi tbody td.pfn-liquidita {
    color: var(--cfo-semantic-good) !important;
}
html[data-cfo-table-theme] body .cfo-semantic-bad,
html[data-cfo-table-theme] body .table-kpi tbody td.pfn-debito {
    color: var(--cfo-semantic-bad) !important;
}
html[data-cfo-table-theme] body .cfo-semantic-neutral,
html[data-cfo-table-theme] body .table-kpi tbody td.pfn-neutra {
    color: var(--cfo-semantic-neutral) !important;
}

/* Expandable CFO matrices: common surfaces, headers and detail rows. */
html[data-cfo-table-theme] body :is(
    .pluri-matrix-card, .gesteco-card, .gesteco-year-card,
    .macro-block, .financial-preview-card, .ce-card
) {
    --cfo-row-surface: var(--cfo-t-surface);
    background: var(--cfo-t-surface) !important;
    border-width: var(--cfo-t-card-border-width) !important;
    border-color: var(--cfo-t-border) !important;
    border-radius: var(--cfo-t-radius) !important;
    box-shadow: var(--cfo-t-shadow) !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-card, .gesteco-card, .gesteco-year-card,
    .macro-block, .financial-preview-card, .ce-card
) > summary {
    min-height: var(--cfo-t-summary-min) !important;
    padding-top: var(--cfo-t-summary-py) !important;
    padding-bottom: var(--cfo-t-summary-py) !important;
    padding-left: var(--cfo-t-summary-px) !important;
    padding-right: var(--cfo-t-summary-px) !important;
    font-size: var(--cfo-t-summary-font) !important;
    font-weight: var(--cfo-t-summary-weight) !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-grid, .gesteco-list, .macro-list, .financial-preview-list
) {
    gap: var(--cfo-t-row-gap) !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-card, .gesteco-card, .gesteco-year-card,
    .macro-block, .financial-preview-card, .ce-card
)[open] {
    box-shadow: var(--cfo-t-shadow-open) !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-header, .gesteco-matrix-header, .gesteco-year-header,
    .matrix-header, .financial-preview-header, .ce-table-head
) {
    background: var(--cfo-t-header) !important;
    color: var(--cfo-t-header-text) !important;
    border-color: var(--cfo-t-border) !important;
    font-size: var(--cfo-t-header-font) !important;
    font-weight: var(--cfo-t-header-weight) !important;
    letter-spacing: var(--cfo-t-header-letter) !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-detail, .gesteco-detail, .macro-details,
    .financial-preview-detail, .ce-detail, .ce-details
) {
    background: var(--cfo-t-surface-alt) !important;
    border-color: var(--cfo-t-grid) !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-detail-row, .gesteco-detail-row, .gesteco-year-detail-row,
    .macro-detail-row, .financial-preview-detail-row, .ce-detail-row
) {
    --cfo-row-surface: var(--cfo-t-surface-alt);
    min-height: var(--cfo-t-detail-min) !important;
    color: var(--cfo-t-text) !important;
    border-color: var(--cfo-t-grid) !important;
    font-size: var(--cfo-t-detail-font) !important;
    font-weight: 400 !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-detail-row, .gesteco-detail-row, .gesteco-year-detail-row,
    .macro-detail-row, .financial-preview-detail-row, .ce-detail-row
):nth-child(even) {
    --cfo-row-surface: var(--cfo-t-zebra);
    background: var(--cfo-t-zebra) !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-detail-row, .gesteco-detail-row, .gesteco-year-detail-row,
    .macro-detail-row, .financial-preview-detail-row, .ce-detail-row
):hover {
    background: var(--cfo-t-hover) !important;
}

html[data-cfo-table-theme] body :is(
    .pluri-matrix-detail-row, .gesteco-detail-row, .gesteco-year-detail-row,
    .macro-detail-row, .financial-preview-detail-row, .ce-detail-row
) :is(span, b, strong, div) {
    color: var(--cfo-t-text) !important;
    font-weight: 400 !important;
}

/* Semantic families. */
html[data-cfo-table-theme] body :is(.pluri-matrix-card.entry, .macro-block.entry, .financial-preview-card.entry, .ce-card.entry, .gesteco-card.revenue, .gesteco-year-card.revenue) {
    border-left-width: var(--cfo-t-accent-width) !important;
    border-left-color: var(--cfo-t-entry) !important;
}
html[data-cfo-table-theme] body :is(.pluri-matrix-card.expense, .macro-block.expense, .financial-preview-card.expense, .ce-card.expense, .gesteco-card.cost, .gesteco-year-card.cost) {
    border-left-width: var(--cfo-t-accent-width) !important;
    border-left-color: var(--cfo-t-expense) !important;
}
html[data-cfo-table-theme] body :is(.pluri-matrix-card.tax, .macro-block.tax, .financial-preview-card.tax, .ce-card.tax, .gesteco-card.tax, .gesteco-year-card.tax) {
    border-left-width: var(--cfo-t-accent-width) !important;
    border-left-color: var(--cfo-t-tax) !important;
}
html[data-cfo-table-theme] body :is(.pluri-matrix-card.balance, .pluri-matrix-card.neutral, .macro-block.balance, .financial-preview-card.balance, .ce-card.balance, .gesteco-card.total, .gesteco-year-card.total) {
    --cfo-row-surface: var(--cfo-t-balance-soft);
    border-left-width: var(--cfo-t-accent-width) !important;
    border-left-color: var(--cfo-t-balance) !important;
    background: var(--cfo-t-balance-soft) !important;
}

html[data-cfo-table-theme] body :is(.entry, .revenue) :is(.pluri-matrix-title span, .macro-title strong, .financial-preview-title span, .ce-title span, .gesteco-name span, .value-budget, .value-actual) {
    color: var(--cfo-t-entry) !important;
}
html[data-cfo-table-theme] body :is(.expense, .cost) :is(.pluri-matrix-title span, .macro-title strong, .financial-preview-title span, .ce-title span, .gesteco-name span, .value-budget, .value-actual) {
    color: var(--cfo-t-expense) !important;
}
html[data-cfo-table-theme] body .tax :is(.pluri-matrix-title span, .macro-title strong, .financial-preview-title span, .ce-title span, .gesteco-name span, .value-budget, .value-actual) {
    color: var(--cfo-t-tax) !important;
}
html[data-cfo-table-theme] body :is(.macro-block.tax, .financial-preview-card.tax) {
    background: #f1f3f5 !important;
}
html[data-cfo-table-theme] body :is(.macro-block.tax, .financial-preview-card.tax) > summary {
    background: #f1f3f5 !important;
}
html[data-cfo-table-theme] body :is(.macro-block.tax, .financial-preview-card.tax) > :is(.macro-detail, .financial-preview-detail) {
    background: #f7f8fa !important;
}
html[data-cfo-table-theme] body :is(.macro-block.tax, .financial-preview-card.tax) :is(
    .macro-title strong,
    .financial-preview-title span,
    .value-budget,
    .value-actual,
    [data-cfo-measure="budget"],
    [data-cfo-measure="actual"],
    [data-cfo-measure="budget"] > .cfo-metric-value,
    [data-cfo-measure="actual"] > .cfo-metric-value
) {
    color: var(--cfo-t-text) !important;
}
html[data-cfo-table-theme] body :is(.balance, .total, .neutral) :is(.pluri-matrix-title span, .macro-title strong, .financial-preview-title span, .ce-title span, .gesteco-name span, .value-budget, .value-actual) {
    color: var(--cfo-t-balance) !important;
}

html[data-cfo-table-theme] body :is(.delta-ok, .eco-good) {
    color: var(--cfo-t-good) !important;
}
html[data-cfo-table-theme] body :is(.delta-ko, .eco-bad) {
    color: var(--cfo-t-bad) !important;
}

/* Totals and supporting panels follow the selected visual language. */
/* Flat total rows contract: theme color and weight communicate hierarchy;
   summary rows never add a dark/double divider of their own. */
html[data-cfo-table-theme] body :is(
    .matrix-total-row, .pluri-matrix-total-row,
    .gesteco-year-card.total > summary,
    .financial-preview-card.balance > summary,
    .ce-card.balance > summary
) {
    border-top: 0 !important;
    outline: 0 !important;
}

html[data-cfo-table-theme] body :is(.matrix-total-row.entry, .metric-margin, .metric-profit) {
    background: var(--cfo-t-entry-soft) !important;
    border-color: var(--cfo-t-entry) !important;
}
html[data-cfo-table-theme] body :is(.matrix-total-row.expense, .metric-cost) {
    background: var(--cfo-t-expense-soft) !important;
    border-color: var(--cfo-t-expense) !important;
}
html[data-cfo-table-theme] body :is(
    .pluri-matrix-total-row, .financial-preview-total, .gesteco-year-total,
    .pluri-matrix-annual-cell
) {
    --cfo-row-surface: var(--cfo-t-balance-soft);
    background: var(--cfo-t-balance-soft) !important;
    border-color: var(--cfo-t-balance) !important;
}
html[data-cfo-table-theme] body :is(
    .pluri-year-total-head, .financial-preview-total-header,
    .gesteco-year-total-header
) {
    color: var(--cfo-t-balance) !important;
    border-color: var(--cfo-t-balance) !important;
}
html[data-cfo-table-theme] body :is(.metric-debt, .metric-equity, .metric-ratio) {
    background: var(--cfo-t-balance-soft) !important;
}

html[data-cfo-table-theme] body .metric-revenue td { background: var(--cfo-t-balance-soft) !important; }
html[data-cfo-table-theme] body .metric-cost td { background: var(--cfo-t-expense-soft) !important; }
html[data-cfo-table-theme] body .metric-margin td,
html[data-cfo-table-theme] body .metric-profit td { background: var(--cfo-t-entry-soft) !important; }
html[data-cfo-table-theme] body .metric-equity td,
html[data-cfo-table-theme] body .metric-debt td,
html[data-cfo-table-theme] body .metric-ratio td { background: var(--cfo-t-balance-soft) !important; }

/* Annual economic detail: one readable section per cost center. */
html[data-cfo-table-theme] body .gesteco-year-center-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 36px;
    margin: 6px 0 2px;
    padding: 7px 10px;
    color: var(--cfo-t-header-text);
    background: var(--cfo-t-header);
    border-block: 1px solid var(--cfo-t-grid);
}
html[data-cfo-table-theme] body .gesteco-year-center-heading > span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    font-size: .76rem;
    font-weight: 850;
    line-height: 1.2;
    letter-spacing: .025em;
    text-transform: uppercase;
}
html[data-cfo-table-theme] body .gesteco-year-center-heading > small {
    flex: 0 0 auto;
    padding: 2px 7px;
    color: var(--cfo-t-text);
    background: var(--cfo-t-surface);
    border: 1px solid var(--cfo-t-grid);
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 800;
    line-height: 1.25;
}

@media print {
    html[data-cfo-table-theme] {
        --cfo-t-shadow: none;
        --cfo-t-shadow-open: none;
    }
    html[data-cfo-table-theme] body .gesteco-year-center-heading {
        min-height: 24px;
        margin-top: 3px;
        padding: 4px 7px;
        break-after: avoid;
    }
}

/*
 * Table theme contract v2. Each selectable theme owns both visual language
 * and table structure. Application chrome and financial values are untouched.
 */
html[data-cfo-table-theme="executive_ledger"],
html[data-cfo-table-theme="boardroom_bands"],
html[data-cfo-table-theme="bilancio_editoriale"],
html[data-cfo-table-theme="variance_heatmap"],
html[data-cfo-table-theme="modular_cards"],
html[data-cfo-table-theme="audit_compact"],
html[data-cfo-table-theme="orizzonte_pluriennale"],
html[data-cfo-table-theme="minimal_finance"],
html[data-cfo-table-theme="control_room"],
html[data-cfo-table-theme="focus_colonne"] {
    --cfo-t-font-family: "Aptos", "Segoe UI", Arial, sans-serif;
    --cfo-t-bg:#f5f7fb; --cfo-t-surface:#fff; --cfo-t-surface-alt:#f8fafc;
    --cfo-t-header:#e8eef6; --cfo-t-header-text:#233652; --cfo-t-text:#17243a;
    --cfo-t-muted:#64748b; --cfo-t-border:#d6e0ec; --cfo-t-grid:#e4ebf3; --cfo-t-hover:#eef4fb;
    --cfo-t-entry:#087a4b; --cfo-t-entry-soft:#eef9f4;
    --cfo-t-expense:#b45309; --cfo-t-expense-soft:#fff7ed;
    --cfo-t-tax:#be123c; --cfo-t-tax-soft:#fff1f4;
    --cfo-t-balance:#2459ad; --cfo-t-balance-soft:#edf4ff;
    --cfo-t-good:#087a4b; --cfo-t-bad:#c02626;
    --cfo-semantic-good:#087a4b; --cfo-semantic-bad:#c02626; --cfo-semantic-neutral:#64748b;
    --cfo-t-shadow:0 3px 12px rgba(18,32,68,.06); --cfo-t-shadow-open:0 8px 22px rgba(18,32,68,.1);
    --cfo-t-radius:6px; --cfo-t-row-gap:5px; --cfo-t-summary-min:52px;
    --cfo-t-summary-py:10px; --cfo-t-summary-px:13px; --cfo-t-detail-min:28px;
    --cfo-t-cell-py:8px; --cfo-t-cell-px:10px; --cfo-t-accent-width:4px;
    --cfo-t-card-border-width:1px; --cfo-t-header-font:.72rem; --cfo-t-header-weight:850;
    --cfo-t-header-letter:.025em; --cfo-t-summary-font:.86rem; --cfo-t-detail-font:.78rem;
    --cfo-t-summary-weight:650; --cfo-t-value-weight:600; --cfo-t-zebra:#f8fafc;
}

html[data-cfo-table-theme="executive_ledger"] {
    --cfo-theme-signature: executive-ledger;
    --cfo-t-header:#162b4d; --cfo-t-header-text:#fff; --cfo-t-text:#14243d;
    --cfo-t-border:#cbd7e7; --cfo-t-balance:#1d4f91; --cfo-t-balance-soft:#eaf2fd;
    --cfo-t-radius:4px; --cfo-t-row-gap:3px; --cfo-t-shadow:0 2px 8px rgba(20,36,61,.07);
}
html[data-cfo-table-theme="boardroom_bands"] {
    --cfo-theme-signature: boardroom-bands;
    --cfo-t-bg:#f3f8f7; --cfo-t-surface-alt:#f5faf9; --cfo-t-header:#164e55; --cfo-t-header-text:#fff;
    --cfo-t-text:#183d42; --cfo-t-border:#c8dddc; --cfo-t-grid:#dfebea; --cfo-t-hover:#eaf6f4;
    --cfo-t-balance:#147d83; --cfo-t-balance-soft:#e8f7f7; --cfo-t-radius:10px;
    --cfo-t-row-gap:10px; --cfo-t-summary-min:62px; --cfo-t-summary-py:14px;
}
html[data-cfo-table-theme="bilancio_editoriale"] {
    --cfo-theme-signature: bilancio-editoriale;
    --cfo-t-font-family:Georgia, "Times New Roman", serif; --cfo-t-bg:#faf9f6; --cfo-t-surface:#fffefb;
    --cfo-t-surface-alt:#faf8f3; --cfo-t-header:#f2eee5; --cfo-t-header-text:#3b352d; --cfo-t-text:#29251f;
    --cfo-t-muted:#716a60; --cfo-t-border:#d8d0c2; --cfo-t-grid:#e8e1d6; --cfo-t-hover:#f7f2e9;
    --cfo-t-balance:#514b42; --cfo-t-balance-soft:#f2eee7; --cfo-t-radius:0; --cfo-t-row-gap:0;
    --cfo-t-shadow:none; --cfo-t-shadow-open:none; --cfo-t-header-letter:.06em;
}
html[data-cfo-table-theme="variance_heatmap"] {
    --cfo-theme-signature: variance-heatmap;
    --cfo-t-bg:#f5f7fa; --cfo-t-header:#334155; --cfo-t-header-text:#fff; --cfo-t-text:#1e293b;
    --cfo-t-border:#cbd5e1; --cfo-t-grid:#e2e8f0; --cfo-t-hover:#edf2f7; --cfo-t-radius:6px;
    --cfo-t-good:#047857; --cfo-t-bad:#be123c; --cfo-semantic-good:#047857; --cfo-semantic-bad:#be123c;
}
html[data-cfo-table-theme="modular_cards"] {
    --cfo-theme-signature: modular-cards;
    --cfo-t-bg:#f2f6fb; --cfo-t-header:#365b87; --cfo-t-header-text:#fff; --cfo-t-text:#203752;
    --cfo-t-border:#d1ddeb; --cfo-t-hover:#edf4fb; --cfo-t-radius:12px; --cfo-t-row-gap:12px;
    --cfo-t-summary-min:64px; --cfo-t-summary-py:15px; --cfo-t-shadow:0 7px 18px rgba(32,55,82,.09);
}
html[data-cfo-table-theme="audit_compact"] {
    --cfo-theme-signature: audit-compact;
    --cfo-t-font-family:Tahoma, "Segoe UI", sans-serif; --cfo-t-bg:#f4f5f6; --cfo-t-header:#3f4b59;
    --cfo-t-header-text:#fff; --cfo-t-text:#242d36; --cfo-t-muted:#66717c; --cfo-t-border:#bfc7cf;
    --cfo-t-grid:#d5dbe1; --cfo-t-hover:#e9edf1; --cfo-t-radius:0; --cfo-t-row-gap:0;
    --cfo-t-summary-min:42px; --cfo-t-summary-py:6px; --cfo-t-summary-px:8px;
    --cfo-t-detail-min:23px; --cfo-t-cell-py:5px; --cfo-t-cell-px:7px; --cfo-t-shadow:none; --cfo-t-shadow-open:none;
    --cfo-t-summary-font:.8rem; --cfo-t-detail-font:.73rem; --cfo-t-zebra:#eef1f4;
}
html[data-cfo-table-theme="orizzonte_pluriennale"] {
    --cfo-theme-signature: orizzonte-pluriennale;
    --cfo-t-bg:#f4f7fb; --cfo-t-header:#234b72; --cfo-t-header-text:#fff; --cfo-t-text:#18324b;
    --cfo-t-border:#c9d8e7; --cfo-t-grid:#dce7f1; --cfo-t-hover:#eaf2f9; --cfo-t-balance:#2f6f8f;
    --cfo-t-balance-soft:#eaf4f8; --cfo-t-radius:5px; --cfo-t-row-gap:4px;
}
html[data-cfo-table-theme="minimal_finance"] {
    --cfo-theme-signature: minimal-finance;
    --cfo-t-bg:#fff; --cfo-t-surface:#fff; --cfo-t-surface-alt:#fff; --cfo-t-header:#fff;
    --cfo-t-header-text:#334155; --cfo-t-text:#1f2937; --cfo-t-muted:#718096; --cfo-t-border:#d7dde5;
    --cfo-t-grid:#edf0f3; --cfo-t-hover:#f8fafc; --cfo-t-balance:#334155; --cfo-t-balance-soft:#f8fafc;
    --cfo-t-radius:0; --cfo-t-row-gap:5px; --cfo-t-summary-min:58px; --cfo-t-summary-py:13px;
    --cfo-t-shadow:none; --cfo-t-shadow-open:none;
}
html[data-cfo-table-theme="control_room"] {
    --cfo-theme-signature: control-room;
    --cfo-t-bg:#111827; --cfo-t-surface:#172033; --cfo-t-surface-alt:#1d293d; --cfo-t-header:#0b1220;
    --cfo-t-header-text:#e6f3ff; --cfo-t-text:#e5edf7; --cfo-t-muted:#9fb0c5; --cfo-t-border:#34445a;
    --cfo-t-grid:#2c3a4d; --cfo-t-hover:#22314a; --cfo-t-entry:#34d399; --cfo-t-entry-soft:#153a36;
    --cfo-t-expense:#fbbf24; --cfo-t-expense-soft:#3b3020; --cfo-t-tax:#fb7185; --cfo-t-tax-soft:#442331;
    --cfo-t-balance:#60a5fa; --cfo-t-balance-soft:#1d3557; --cfo-t-good:#34d399; --cfo-t-bad:#fb7185;
    --cfo-semantic-good:#34d399; --cfo-semantic-bad:#fb7185; --cfo-semantic-neutral:#c0cad8;
    --cfo-t-radius:6px; --cfo-t-shadow:0 4px 16px rgba(3,7,18,.25); --cfo-t-zebra:#1b263a;
}
html[data-cfo-table-theme="focus_colonne"] {
    --cfo-theme-signature: focus-colonne;
    --cfo-t-bg:#f6f8fc; --cfo-t-header:#2d4770; --cfo-t-header-text:#fff; --cfo-t-text:#1d3150;
    --cfo-t-border:#c9d6e7; --cfo-t-grid:#dce5f0; --cfo-t-hover:#e6effb; --cfo-t-balance:#275da6;
    --cfo-t-balance-soft:#e8f1ff; --cfo-t-radius:5px; --cfo-t-row-gap:4px;
}

html[data-cfo-table-theme="executive_ledger"] body :is(.matrix-total-row,.pluri-matrix-total-row,.gesteco-year-card.total>summary,.financial-preview-card.balance>summary,.ce-card.balance>summary),
html[data-cfo-table-theme="focus_colonne"] body :is(.matrix-total-row,.pluri-matrix-total-row,.gesteco-year-card.total>summary,.financial-preview-card.balance>summary,.ce-card.balance>summary) {
    border-top:0 !important; font-weight:850 !important;
}
html[data-cfo-table-theme="boardroom_bands"] body :is(.table tbody tr,.pluri-matrix-card,.gesteco-year-card,.financial-preview-card,.ce-card),
html[data-cfo-table-theme="modular_cards"] body :is(.table tbody tr,.pluri-matrix-card,.gesteco-year-card,.financial-preview-card,.ce-card) {
    box-shadow:var(--cfo-t-shadow) !important;
}
html[data-cfo-table-theme="bilancio_editoriale"] body :is(.table,.table-kpi,.pluri-matrix-card,.gesteco-year-card,.financial-preview-card,.ce-card) {
    border-inline:0 !important;
}
html[data-cfo-table-theme="bilancio_editoriale"] body :is(.matrix-total-row,.pluri-matrix-total-row,.gesteco-year-card.total>summary,.financial-preview-card.balance>summary,.ce-card.balance>summary),
html[data-cfo-table-theme="minimal_finance"] body :is(.matrix-total-row,.pluri-matrix-total-row,.gesteco-year-card.total>summary,.financial-preview-card.balance>summary,.ce-card.balance>summary) {
    border-top:0 !important;
}
html[data-cfo-table-theme="variance_heatmap"] body :is(.delta-ok,.delta-ko,.eco-good,.eco-bad,.pluri-cell-delta,.gesteco-cell-delta,.financial-preview-cell-delta) {
    display:inline-flex !important; min-width:62px; min-height:24px; padding:3px 7px; align-items:center;
    justify-content:center; border-radius:999px; font-weight:850 !important;
}
html[data-cfo-table-theme="variance_heatmap"] body :is(.delta-ok,.eco-good) {background:#dcfce7 !important;color:#047857 !important}
html[data-cfo-table-theme="variance_heatmap"] body :is(.delta-ko,.eco-bad) {background:#ffe4e6 !important;color:#be123c !important}
html[data-cfo-table-theme="audit_compact"] body :is(.table,.table-kpi) > :not(caption) > * > *,
html[data-cfo-table-theme="audit_compact"] body :is(.pluri-matrix-card,.gesteco-year-card,.financial-preview-card,.ce-card) {border-color:var(--cfo-t-border) !important}
html[data-cfo-table-theme="orizzonte_pluriennale"] body :is(.pluri-matrix-header,.pluri-matrix-row,.pluri-matrix-detail-row,.gesteco-year-header,.gesteco-year-card>summary,.financial-preview-header,.financial-preview-card>summary) > :nth-child(4n+2) {
    background:rgba(36,89,173,.055) !important; border-left:1px solid var(--cfo-t-border) !important;
}
html[data-cfo-table-theme="minimal_finance"] body :is(.table,.table-kpi,.pluri-matrix-card,.gesteco-year-card,.financial-preview-card,.ce-card) {box-shadow:none !important}
html[data-cfo-table-theme="minimal_finance"] body :is(.table,.table-kpi) {border-inline:0 !important}
html[data-cfo-table-theme="control_room"] body :is(.table,.table-kpi,.pluri-matrix-scroll,.gesteco-year-table,.financial-preview-wrap,.ce-table-wrap,.viewer-dto-table) {
    color:var(--cfo-t-text) !important; background:var(--cfo-t-bg) !important;
}
html[data-cfo-table-theme="control_room"] body :is(.table,.table-kpi) > :not(caption) > * > * {color:var(--cfo-t-text) !important}
html[data-cfo-table-theme="focus_colonne"] body :is(.pluri-matrix-annual-cell,.gesteco-year-annual-cell,.financial-preview-annual,.annual-total) {
    background:var(--cfo-t-balance-soft) !important; box-shadow:inset 1px 0 var(--cfo-t-balance),inset -1px 0 var(--cfo-t-balance) !important;
}
html[data-cfo-table-theme="focus_colonne"] body :is(.table,.table-kpi,.viewer-dto-table) :is(th,td):hover,
html[data-cfo-table-theme="focus_colonne"] body :is(.pluri-matrix-cell,.gesteco-month-cell,.financial-preview-month,.macro-value,.ce-value):hover {
    background:#dceaff !important;
}

/*
 * Universal table adapter.
 *
 * Every semantic HTML table, including legacy and dynamically generated
 * tables without Bootstrap classes, consumes the same theme tokens. A page
 * may opt out only with the explicit cfo-theme-opt-out class. This rule is
 * also transformed into :host-context selectors for the Viewer Shadow DOM.
 */
html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) {
    color: var(--cfo-t-text) !important;
    background: var(--cfo-t-surface) !important;
    border-color: var(--cfo-t-border) !important;
    font-family: var(--cfo-t-font-family) !important;
    font-variant-numeric: tabular-nums lining-nums;
}

html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) > :not(caption) > * > * {
    color: var(--cfo-t-text) !important;
    background-color: var(--cfo-t-surface) !important;
    border-color: var(--cfo-t-grid) !important;
}

html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) > thead > tr > * {
    color: var(--cfo-t-header-text) !important;
    background: var(--cfo-t-header) !important;
    border-color: var(--cfo-t-border) !important;
    font-size: var(--cfo-t-header-font) !important;
    font-weight: var(--cfo-t-header-weight) !important;
    letter-spacing: var(--cfo-t-header-letter) !important;
}

html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) > tbody > tr:nth-child(even) > * {
    background-color: var(--cfo-t-zebra) !important;
}

html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) > tbody > tr:is(:hover, :focus-within) > * {
    background-color: var(--cfo-t-hover) !important;
}

html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) > tfoot > tr > *,
html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) > tbody > tr:is(.total,.totale,.subtotal,.subtotale,.metric-margin,.metric-profit) > * {
    color: var(--cfo-t-text) !important;
    background: var(--cfo-t-balance-soft) !important;
    border-top: 0 !important;
    font-weight: 850 !important;
}

/* A structural signature for every theme, independent of page-specific CSS. */
html[data-cfo-table-theme="executive_ledger"] body table:not(.cfo-theme-opt-out) > :is(tbody,tfoot) > tr:is(.total,.totale,.subtotal,.subtotale):last-child > *,
html[data-cfo-table-theme="executive_ledger"] body table:not(.cfo-theme-opt-out) > tfoot:last-child > tr:last-child > * {
    border-bottom: 0 !important;
}

html[data-cfo-table-theme="boardroom_bands"] body table:not(.cfo-theme-opt-out),
html[data-cfo-table-theme="modular_cards"] body table:not(.cfo-theme-opt-out) {
    border-collapse: separate !important;
    border-spacing: 0 var(--cfo-t-row-gap) !important;
    background: transparent !important;
}

html[data-cfo-table-theme="boardroom_bands"] body table:not(.cfo-theme-opt-out) > tbody > tr > :first-child,
html[data-cfo-table-theme="modular_cards"] body table:not(.cfo-theme-opt-out) > tbody > tr > :first-child {
    border-left: var(--cfo-t-accent-width) solid var(--cfo-t-balance) !important;
    border-radius: var(--cfo-t-radius) 0 0 var(--cfo-t-radius) !important;
}

html[data-cfo-table-theme="boardroom_bands"] body table:not(.cfo-theme-opt-out) > tbody > tr > :last-child,
html[data-cfo-table-theme="modular_cards"] body table:not(.cfo-theme-opt-out) > tbody > tr > :last-child {
    border-radius: 0 var(--cfo-t-radius) var(--cfo-t-radius) 0 !important;
}

html[data-cfo-table-theme="modular_cards"] body table:not(.cfo-theme-opt-out) > tbody > tr > * {
    box-shadow: 0 5px 12px rgba(32,55,82,.08) !important;
}

html[data-cfo-table-theme="bilancio_editoriale"] body table:not(.cfo-theme-opt-out) > :not(caption) > * > * {
    border-inline: 0 !important;
}

html[data-cfo-table-theme="bilancio_editoriale"] body table:not(.cfo-theme-opt-out) > :is(tbody,tfoot) > tr:is(.total,.totale,.subtotal,.subtotale,.metric-margin,.metric-profit) > *,
html[data-cfo-table-theme="bilancio_editoriale"] body table:not(.cfo-theme-opt-out) > tfoot > tr > * {
    border-top: 0 !important;
}

html[data-cfo-table-theme="variance_heatmap"] body table:not(.cfo-theme-opt-out) :is(
    .delta-ok,.delta-good,.eco-good,.is-improving,.cfo-semantic-good
) {
    color: var(--cfo-semantic-good) !important;
    background: var(--cfo-t-entry-soft) !important;
    border-radius: 999px;
    font-weight: 850 !important;
}

html[data-cfo-table-theme="variance_heatmap"] body table:not(.cfo-theme-opt-out) :is(
    .delta-ko,.delta-bad,.eco-bad,.is-worsening,.cfo-semantic-bad
) {
    color: var(--cfo-semantic-bad) !important;
    background: var(--cfo-t-tax-soft) !important;
    border-radius: 999px;
    font-weight: 850 !important;
}

html[data-cfo-table-theme="audit_compact"] body table:not(.cfo-theme-opt-out) > :not(caption) > * > * {
    padding: 5px 7px !important;
    border-width: 1px !important;
}

html[data-cfo-table-theme="orizzonte_pluriennale"] body table:not(.cfo-theme-opt-out) > :is(tbody,tfoot) > tr > :nth-child(4n+2):not(:first-child) {
    background: var(--cfo-t-balance-soft) !important;
    border-inline: 1px solid var(--cfo-t-border) !important;
}

html[data-cfo-table-theme="minimal_finance"] body table:not(.cfo-theme-opt-out) {
    border-inline: 0 !important;
    box-shadow: none !important;
}

html[data-cfo-table-theme="minimal_finance"] body table:not(.cfo-theme-opt-out) > :not(caption) > * > * {
    border-inline: 0 !important;
    background: var(--cfo-t-surface) !important;
}

html[data-cfo-table-theme="control_room"] body table:not(.cfo-theme-opt-out),
html[data-cfo-table-theme="control_room"] body table:not(.cfo-theme-opt-out) > :not(caption) > * > * {
    color: var(--cfo-t-text) !important;
    background: var(--cfo-t-surface) !important;
    border-color: var(--cfo-t-grid) !important;
}

html[data-cfo-table-theme="control_room"] body table:not(.cfo-theme-opt-out) > thead > tr > * {
    color: var(--cfo-t-header-text) !important;
    background: var(--cfo-t-header) !important;
}

html[data-cfo-table-theme="control_room"] body table:not(.cfo-theme-opt-out) > tbody > tr:nth-child(even) > * {
    background: var(--cfo-t-zebra) !important;
}

html[data-cfo-table-theme="focus_colonne"] body table:not(.cfo-theme-opt-out) > :is(tbody,tfoot) > tr > :last-child {
    color: var(--cfo-t-balance) !important;
    background: var(--cfo-t-balance-soft) !important;
    box-shadow: inset 1px 0 var(--cfo-t-balance), inset -1px 0 var(--cfo-t-balance) !important;
}

html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="executive_ledger"] {--cfo-layout-radius:4px;--cfo-layout-row-gap:3px;--cfo-layout-shadow:0 2px 8px rgba(20,36,61,.07);--cfo-layout-row-py:8px;--cfo-layout-row-px:10px;--cfo-layout-summary-min:50px;--cfo-layout-detail-min:27px}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="boardroom_bands"] {--cfo-layout-radius:10px;--cfo-layout-row-gap:10px;--cfo-layout-shadow:0 7px 18px rgba(18,60,67,.08);--cfo-layout-row-py:14px;--cfo-layout-row-px:15px;--cfo-layout-summary-min:62px;--cfo-layout-detail-min:32px}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="bilancio_editoriale"] {--cfo-layout-radius:0;--cfo-layout-row-gap:0;--cfo-layout-shadow:none;--cfo-layout-row-py:10px;--cfo-layout-row-px:11px;--cfo-layout-summary-min:54px;--cfo-layout-detail-min:28px;--cfo-layout-header-transform:none;--cfo-layout-header-letter:.05em}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="variance_heatmap"] {--cfo-layout-radius:6px;--cfo-layout-row-gap:5px;--cfo-layout-shadow:0 3px 10px rgba(30,41,59,.07);--cfo-layout-row-py:9px;--cfo-layout-row-px:11px;--cfo-layout-summary-min:54px;--cfo-layout-detail-min:29px}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="modular_cards"] {--cfo-layout-radius:12px;--cfo-layout-row-gap:12px;--cfo-layout-shadow:0 7px 18px rgba(32,55,82,.09);--cfo-layout-row-py:15px;--cfo-layout-row-px:16px;--cfo-layout-summary-min:64px;--cfo-layout-detail-min:34px}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="audit_compact"] {--cfo-layout-radius:0;--cfo-layout-row-gap:0;--cfo-layout-shadow:none;--cfo-layout-row-py:5px;--cfo-layout-row-px:7px;--cfo-layout-summary-min:42px;--cfo-layout-detail-min:23px;--cfo-layout-font-scale:.92}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="orizzonte_pluriennale"] {--cfo-layout-radius:5px;--cfo-layout-row-gap:4px;--cfo-layout-shadow:0 3px 10px rgba(24,50,75,.07);--cfo-layout-row-py:9px;--cfo-layout-row-px:10px;--cfo-layout-summary-min:52px;--cfo-layout-detail-min:28px}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="minimal_finance"] {--cfo-layout-radius:0;--cfo-layout-row-gap:5px;--cfo-layout-shadow:none;--cfo-layout-row-py:13px;--cfo-layout-row-px:10px;--cfo-layout-summary-min:58px;--cfo-layout-detail-min:31px}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="control_room"] {--cfo-layout-radius:6px;--cfo-layout-row-gap:5px;--cfo-layout-shadow:0 4px 16px rgba(3,7,18,.25);--cfo-layout-row-py:9px;--cfo-layout-row-px:11px;--cfo-layout-summary-min:54px;--cfo-layout-detail-min:29px}
html[data-cfo-table-layout="theme_v2"][data-cfo-table-theme="focus_colonne"] {--cfo-layout-radius:5px;--cfo-layout-row-gap:4px;--cfo-layout-shadow:0 3px 10px rgba(29,49,80,.07);--cfo-layout-row-py:9px;--cfo-layout-row-px:10px;--cfo-layout-summary-min:52px;--cfo-layout-detail-min:28px}

/* Semantic cell colors must remain authoritative after the universal adapter
   and the theme-specific table rules, including control_room. */
html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) :is(th, td).cfo-semantic-good {
    color: var(--cfo-semantic-good) !important;
}

html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) :is(th, td).cfo-semantic-bad {
    color: var(--cfo-semantic-bad) !important;
}

html[data-cfo-table-theme] body table:not(.cfo-theme-opt-out) :is(th, td).cfo-semantic-neutral {
    color: var(--cfo-semantic-neutral) !important;
}

@media print {
    html[data-cfo-table-theme="control_room"] {
        --cfo-t-bg:#fff; --cfo-t-surface:#fff; --cfo-t-surface-alt:#fff; --cfo-t-header:#e5e7eb;
        --cfo-t-header-text:#111827; --cfo-t-text:#111827; --cfo-t-muted:#4b5563; --cfo-t-border:#9ca3af; --cfo-t-grid:#d1d5db;
    }
}
