.table-v2-shell {
    --table-v2-border: var(--table-v2-section-border, #d4dee5);
    --table-v2-header-bg: var(--table-v2-section-header-bg, var(--table-v2-section-accent, #315f7f));
    --table-v2-header-fg: var(--table-v2-section-header-fg, #fff);
    --table-v2-subheader-bg: var(--table-v2-section-soft, color-mix(in srgb, var(--table-v2-accent) 16%, #fff));
    --table-v2-subheader-fg: var(--table-v2-section-dark, #243c49);
    --table-v2-row-alt: var(--table-v2-section-row-alt, #f5f7f8);
    --table-v2-accent: var(--table-v2-section-accent, #2f7588);
    --table-v2-first-width: 120px;
    margin: 1.25rem 0 2rem;
    max-width: 100%;
}

.table-v2-first-w--80 { --table-v2-first-width: 80px; }
.table-v2-first-w--100 { --table-v2-first-width: 100px; }
.table-v2-first-w--120 { --table-v2-first-width: 120px; }
.table-v2-first-w--140 { --table-v2-first-width: 140px; }
.table-v2-first-w--160 { --table-v2-first-width: 160px; }
.table-v2-first-w--180 { --table-v2-first-width: 180px; }
.table-v2-first-w--220 { --table-v2-first-width: 220px; }
.table-v2-first-w--260 { --table-v2-first-width: 260px; }
.table-v2-first-w--320 { --table-v2-first-width: 320px; }

.table-v2-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid var(--table-v2-border);
    background: #f6f8f9;
}

.table-v2-filters__title {
    align-self: center;
    color: #344a55;
    font-size: 0.9rem;
    font-weight: 700;
}

.table-v2-filter {
    display: grid;
    gap: 4px;
    min-width: 150px;
    color: #586a72;
    font-size: 0.78rem;
}

.table-v2-filter select {
    min-height: 36px;
    padding: 5px 32px 5px 10px;
    border: 1px solid #bccbd2;
    border-radius: 3px;
    background: #fff;
    color: #25323a;
}

.table-v2-search {
    display: grid;
    gap: 4px;
    min-width: 220px;
    color: #586a72;
    font-size: 0.78rem;
}

.table-v2-search__control {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    min-height: 36px;
    border: 1px solid #bccbd2;
    border-radius: 3px;
    background: #fff;
}

.table-v2-search__control i {
    color: #637680;
    font-size: 17px;
    text-align: center;
}

.table-v2-search__control input {
    min-width: 0;
    height: 34px;
    padding: 5px 10px 5px 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #25323a;
}

.table-v2-filter-reset {
    min-height: 36px;
    padding: 5px 13px;
    border: 1px solid var(--table-v2-accent);
    border-radius: 3px;
    background: #fff;
    color: var(--table-v2-accent);
    font-weight: 700;
}

.table-v2-filter-empty {
    margin: 12px 0 0;
    padding: 16px;
    background: #f6f8f9;
    color: #66767e;
    text-align: center;
}

.table-v2-scroll {
    border: 1px solid var(--table-v2-border);
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-color: var(--table-v2-accent) #edf1f3;
    scrollbar-width: thin;
}

.table-v2-scroll:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--table-v2-accent) 38%, transparent);
    outline-offset: 2px;
}

.table-v2-table {
    background: #fff;
    border-collapse: separate;
    border-spacing: 0;
    color: #25323a;
    font-size: 0.925rem;
    line-height: 1.55;
    min-width: 100%;
    table-layout: fixed;
    width: max-content;
}

.table-v2-col--80 { width: 80px; }
.table-v2-col--100 { width: 100px; }
.table-v2-col--120 { width: 120px; }
.table-v2-col--140 { width: 140px; }
.table-v2-col--160 { width: 160px; }
.table-v2-col--180 { width: 180px; }
.table-v2-col--220 { width: 220px; }
.table-v2-col--260 { width: 260px; }
.table-v2-col--320 { width: 320px; }

.table-v2-cell {
    background: #fff;
    border-bottom: 1px solid var(--table-v2-border);
    border-right: 1px solid var(--table-v2-border);
    font-weight: 400;
    min-width: 80px;
    padding: 0.7rem 0.75rem;
    text-align: left;
    vertical-align: middle;
}

.table-v2-cell:last-child { border-right: 0; }
.table-v2-row:last-child .table-v2-cell { border-bottom: 0; }
.table-v2-row--header .table-v2-cell {
    background: var(--table-v2-header-bg);
    color: var(--table-v2-header-fg);
    font-weight: 700;
    text-align: center;
}
.table-v2-row-style--muted .table-v2-cell,
:where(tbody) > .table-v2-row:nth-child(even) .table-v2-cell { background: var(--table-v2-row-alt); }
.table-v2-row-style--group .table-v2-cell,
.table-v2-row-style--accent .table-v2-cell { background: color-mix(in srgb, var(--table-v2-accent) 14%, #fff); }
.table-v2-row--subtotal .table-v2-cell,
.table-v2-row-style--subtotal .table-v2-cell { background: color-mix(in srgb, var(--table-v2-accent) 9%, #fff); font-weight: 700; }
.table-v2-row--total .table-v2-cell,
.table-v2-row-style--total .table-v2-cell { background: color-mix(in srgb, var(--table-v2-accent) 18%, #fff); font-weight: 700; }
/* Keep nested column headings independent from data-row striping. */
.table-v2-row--header + .table-v2-row--header .table-v2-cell {
    background: var(--table-v2-subheader-bg);
    color: var(--table-v2-subheader-fg);
}
.table-v2-row--header + .table-v2-row--header .table-v2-unit {
    color: inherit;
}
.table-v2-align--left { text-align: left; }
.table-v2-align--center { text-align: center; }
.table-v2-align--right { text-align: right; }
.table-v2-cell.is-nowrap,
.table-v2-cell.is-nowrap * { white-space: nowrap; }
.table-v2-cell.is-bold { font-weight: 700; }
.table-v2-unit { color: #5e6d76; font-size: 0.86em; }
.table-v2-note {
    color: #58666e;
    font-size: 0.84rem;
    line-height: 1.7;
    margin-top: 0.65rem;
}

.table-v2-cell.is-sticky-left,
.table-v2-cell.is-sticky-right {
    position: sticky;
    z-index: 2;
}
.table-v2-row--header .table-v2-cell.is-sticky-left,
.table-v2-row--header .table-v2-cell.is-sticky-right { z-index: 4; }
.table-v2-sticky-index--0 { left: 0; }
.table-v2-sticky-index--1 { left: var(--table-v2-first-width); }
.table-v2-cell.is-sticky-right { right: 0; }

.table-v2-template--stakeholder-teal {
    --table-v2-border: #9bc9c7;
    --table-v2-header-bg: #93c9c7;
    --table-v2-header-fg: #203f42;
    --table-v2-subheader-bg: #e3f1f0;
    --table-v2-subheader-fg: #285c5a;
    --table-v2-row-alt: #f3f7f6;
    --table-v2-accent: #4b9997;
}
.table-v2-template--stakeholder-teal .table-v2-scroll { border-radius: 6px; }
.table-v2-template--stakeholder-teal .table-v2-table { min-width: 1090px; }
.table-v2-template--stakeholder-teal .table-v2-cell { vertical-align: top; }

.table-v2-template--waste-olive {
    --table-v2-border: #99aa45;
    --table-v2-header-bg: #c7d083;
    --table-v2-header-fg: #28321c;
    --table-v2-subheader-bg: #ecefd1;
    --table-v2-subheader-fg: #46541f;
    --table-v2-row-alt: #fff;
    --table-v2-accent: #8da13b;
}
.table-v2-template--waste-olive .table-v2-scroll { border: 2px solid var(--table-v2-border); border-radius: 7px; }
.table-v2-template--waste-olive .table-v2-table { min-width: 1315px; }
.table-v2-template--waste-olive .table-v2-row:not(.table-v2-row--header) .table-v2-cell { border-bottom-style: dotted; }
.table-v2-template--waste-olive .table-v2-row-style--group .table-v2-cell { background: #ecefd1; color: #28321c; }
.table-v2-template--waste-olive .table-v2-row--total .table-v2-cell { background: #eef0d5; }

.table-v2-template--workforce-coral {
    --table-v2-border: #fff;
    --table-v2-header-bg: #f49673;
    --table-v2-header-fg: #3b2820;
    --table-v2-subheader-bg: #fce6de;
    --table-v2-subheader-fg: #6b3e2d;
    --table-v2-row-alt: #fff9f6;
    --table-v2-accent: #ef7850;
}
.table-v2-template--workforce-coral .table-v2-scroll { border: 0; }
.table-v2-template--workforce-coral .table-v2-table { min-width: 970px; }
.table-v2-template--workforce-coral .table-v2-cell { border-bottom: 6px solid #fff; padding: 0.4rem 0.5rem; }
.table-v2-template--workforce-coral .table-v2-row--header .table-v2-cell { border-bottom-width: 2px; }
.table-v2-template--workforce-coral .table-v2-row--total .table-v2-cell { background: #f69572; color: #33241e; }

.table-v2-template--appendix-blue {
    --table-v2-border: #bcc6cc;
    --table-v2-header-bg: #2f5e88;
    --table-v2-header-fg: #fff;
    --table-v2-subheader-bg: #e5edf4;
    --table-v2-subheader-fg: #244866;
    --table-v2-row-alt: #f0f2f3;
    --table-v2-accent: #2f5e88;
}
.table-v2-template--appendix-blue .table-v2-scroll { border: 0; }
.table-v2-template--appendix-blue .table-v2-table { min-width: 1195px; }
.table-v2-template--appendix-blue .table-v2-cell { padding-block: 0.55rem; }
.table-v2-template--appendix-blue .table-v2-cell:nth-child(4) { border-right: 18px solid #fff; }

/* Palette cascade: chapter fallback < special template < explicit table tone. */
.table-v2-tone--neutral { --table-v2-tone-key: neutral; }
.table-v2-tone--teal {
    --table-v2-border: #c8e1e8;
    --table-v2-header-bg: #126f89;
    --table-v2-header-fg: #fff;
    --table-v2-subheader-bg: #edf8fa;
    --table-v2-subheader-fg: #24566b;
    --table-v2-row-alt: #f7fbfc;
    --table-v2-accent: #1687a6;
}
.table-v2-tone--olive {
    --table-v2-border: #cbd6a1;
    --table-v2-header-bg: #657a24;
    --table-v2-header-fg: #fff;
    --table-v2-subheader-bg: #eef2d9;
    --table-v2-subheader-fg: #3f4c20;
    --table-v2-row-alt: #f8faef;
    --table-v2-accent: #8da13b;
}
.table-v2-tone--coral {
    --table-v2-border: #f0d2b6;
    --table-v2-header-bg: #b85a24;
    --table-v2-header-fg: #fff;
    --table-v2-subheader-bg: #fff0e3;
    --table-v2-subheader-fg: #7a431e;
    --table-v2-row-alt: #fffbf7;
    --table-v2-accent: #f08537;
}
.table-v2-tone--blue {
    --table-v2-border: #bed9ec;
    --table-v2-header-bg: #0f75bb;
    --table-v2-header-fg: #fff;
    --table-v2-subheader-bg: #edf5fb;
    --table-v2-subheader-fg: #244e8d;
    --table-v2-row-alt: #f7fafc;
    --table-v2-accent: #0f75bb;
}

/* Cell tones are intentionally last so semantic cells win over rows and tables. */
.table-v2-row .table-v2-cell.table-v2-cell-tone--header { background: var(--table-v2-header-bg); color: var(--table-v2-header-fg); }
.table-v2-row .table-v2-cell.table-v2-cell-tone--subheader { background: var(--table-v2-subheader-bg); color: var(--table-v2-subheader-fg); }
.table-v2-row .table-v2-cell.table-v2-cell-tone--muted { background: #f3f5f6; color: #4f6068; }
.table-v2-row .table-v2-cell.table-v2-cell-tone--accent { background: color-mix(in srgb, var(--table-v2-accent) 24%, #fff); color: var(--table-v2-subheader-fg); }
.table-v2-row .table-v2-cell.table-v2-cell-tone--highlight { background: color-mix(in srgb, var(--table-v2-accent) 32%, #fff); color: var(--table-v2-subheader-fg); }
.table-v2-row .table-v2-cell.table-v2-cell-tone--total { background: color-mix(in srgb, var(--table-v2-accent) 22%, #fff); color: var(--table-v2-subheader-fg); font-weight: 700; }
.table-v2-row .table-v2-cell.table-v2-cell-tone--male { color: #718629; }
.table-v2-row .table-v2-cell.table-v2-cell-tone--female { color: #d65335; }

/* Workforce uses source-specific semantic cell colors above the shared palette. */
.table-v2-template--workforce-coral .table-v2-cell.table-v2-cell-tone--header { background: #efb168; color: #34271f; }
.table-v2-template--workforce-coral .table-v2-cell.table-v2-cell-tone--subheader { background: #aebcd1; color: #25303c; }
.table-v2-template--workforce-coral .table-v2-cell.table-v2-cell-tone--accent { background: #b3a6bf; color: #302a38; }
.table-v2-template--workforce-coral .table-v2-cell.table-v2-cell-tone--highlight { background: #f7b8a3; color: #3e2821; }
.table-v2-template--workforce-coral .table-v2-cell.table-v2-cell-tone--male { color: #8aa238; }
.table-v2-template--workforce-coral .table-v2-cell.table-v2-cell-tone--female { color: #ec6542; }

.table-v2-longtext__content {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;
}

.table-v2-longtext.is-expanded .table-v2-longtext__content {
    display: block;
    overflow: visible;
}

.table-v2-longtext__toggle {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    margin-top: 8px;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: var(--table-v2-accent);
    font-weight: 700;
}

.table-v2-longtext__toggle:hover {
    text-decoration: underline;
}

.table-v2-style--compact .table-v2-table { font-size: 0.84rem; }
.table-v2-style--compact .table-v2-cell { padding: 0.38rem 0.45rem; }
.table-v2-style--airy .table-v2-cell { padding-block: 0.85rem; }

.table-v2-empty { color: #6c7880; padding: 1.5rem; text-align: center; }

@media (max-width: 767px) {
    .table-v2-shell { margin-block: 1rem 1.5rem; }
    .table-v2-scroll { max-width: calc(100vw - 30px); }
    .table-v2-table { font-size: 0.88rem; }
    .table-v2-cell { padding: 0.6rem 0.65rem; }
    .table-v2-note { font-size: 0.8rem; }
    .table-v2-filters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 12px;
    }
    .table-v2-filters__title { grid-column: 1 / -1; }
    .table-v2-filter { min-width: 0; }
    .table-v2-search { grid-column: 1 / -1; min-width: 0; }
    .table-v2-filter-reset { width: 100%; }
    .table-v2-mobile--priority .table-v2-cell.is-sticky-left { box-shadow: 6px 0 10px rgb(31 50 59 / 8%); }
    .table-v2-template--waste-olive .table-v2-row-style--group .table-v2-cell[colspan],
    .table-v2-template--workforce-coral .table-v2-row--total .table-v2-cell[colspan] {
        padding-left: 1rem;
        text-align: left;
    }

    .table-v2-mobile--stack .table-v2-scroll { border: 0; overflow: visible; }
    .table-v2-mobile--stack .table-v2-table,
    .table-v2-mobile--stack tbody,
    .table-v2-mobile--stack tr,
    .table-v2-mobile--stack td,
    .table-v2-mobile--stack th { display: block; width: 100%; }
    .table-v2-mobile--stack thead { display: none; }
    .table-v2-mobile--stack .table-v2-row { border: 1px solid var(--table-v2-border); margin-bottom: 0.75rem; }
    .table-v2-mobile--stack .table-v2-cell { border: 0; border-bottom: 1px solid var(--table-v2-border); padding-left: 42%; position: relative; text-align: left; white-space: normal; }
    .table-v2-mobile--stack .table-v2-cell::before {
        color: #596970;
        content: attr(data-label);
        font-weight: 700;
        left: 0.7rem;
        max-width: 36%;
        position: absolute;
        top: 0.6rem;
    }
    .table-v2-mobile--stack .table-v2-cell:last-child { border-bottom: 0; }
}
