body {
    margin: 0;
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
    color: #111827;
    background: #f5f5f5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
/* Global link styles */
a {
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
    text-underline-offset: 2px;
}
a:hover {
    text-decoration: underline;
}
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}
.title {
    font-size: 18px;
    font-weight: 600;
}
.nav {
    display: flex;
    gap: 16px;
}
.nav a {
    color: inherit;
    text-decoration: none;
    text-underline-offset: 2px;
    transition: color 150ms ease, text-decoration-color 150ms ease;
}
.nav a:hover {
    text-decoration: underline;
}
.nav a:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
    border-radius: 4px;
}
.nav a[aria-current="page"] {
    font-weight: 700;
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 4px;
}
main {
    max-width: 1140px;
    margin: 0 auto;
    padding: 16px 32px;
}
main h1 {
    font-size: 24px;
    margin: 24px 0 16px;
}
main h2 {
    font-size: 18px;
    margin: 16px 0 8px;
}
main p {
    margin: 0;
    line-height: 1.6;
}
main p + p {
    margin-top: 8px;
}

.card {
    margin: 20px 0;
    padding: 24px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    text-align: center;
}
.stat-value {
    font-size: 48px;
    font-weight: 700;
    line-height: 1.1;
}
.stat-subtitle {
    margin-top: 8px;
    font-size: 14px;
    font-weight: 700;
}

.card.card--small {
    padding: 16px;
}
.card.card--small .stat-value {
    font-size: 32px;
}
.card.card--small .stat-subtitle {
    font-size: 12px;
}

.table-card {
    margin: 20px 0;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
}
.table-card__header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}
.table-card table {
    width: 100%;
    border-collapse: collapse;
}
.table-card th, .table-card td {
    padding: 10px 12px;
    font-size: 14px;
    /* border-top: 1px solid #f3f4f6; */
    text-align: left;
}
.table-card tbody tr:nth-child(even) td {
    background: #fafbfc;
}
.table-card tbody tr:hover td {
    /* background: #f5f7fa; */
    background: color-mix(in srgb, #fafbfc 97%, black)
}
.table-card table th:nth-child(2),
.table-card table td:nth-child(2),
.table-card table th:nth-child(3),
.table-card table td:nth-child(3) {
    text-align: right;
}
.table-card th {
    background: #f9fafb;
    font-weight: 600;
}

/* Results Per Stratum numeric alignment */
.results-per-stratum-table table th:nth-child(2),
.results-per-stratum-table table td:nth-child(2),
.results-per-stratum-table table th:nth-child(3),
.results-per-stratum-table table td:nth-child(3),
.results-per-stratum-table table th:nth-child(4),
.results-per-stratum-table table td:nth-child(4),
.results-per-stratum-table table th:nth-child(5),
.results-per-stratum-table table td:nth-child(5) {
    text-align: right;
}

.table-card tbody tr td.bg-gonzalez-name {
    background-color: rgba(80, 158, 227, 0.65);
}
.table-card tbody tr:hover td.bg-gonzalez-name {
    background-color: color-mix(in srgb, rgba(80, 158, 227, 0.65) 97%, black)
}
.table-card tbody tr td.bg-gonzalez-share {
    background-color: rgba(80, 158, 227, 0.2);
}
.table-card tbody tr:hover td.bg-gonzalez-share {
    background-color: color-mix(in srgb, rgba(80, 158, 227, 0.2) 97%, black)
}
.table-card tbody tr td.bg-maduro-name {
    background-color: rgba(239, 140, 140, 0.65);
}
.table-card tbody tr:hover td.bg-maduro-name {
    background-color: color-mix(in srgb, rgba(239, 140, 140, 0.65) 97%, black)
}
.table-card tbody tr td.bg-maduro-share {
    background-color: rgba(239, 140, 140, 0.2);
}
.table-card tbody tr:hover td.bg-maduro-share {
    background-color: color-mix(in srgb, rgba(239, 140, 140, 0.2) 97%, black)
}

.table-card td .mini-bar {
    height: 8px;
    width: 100%;
    background: rgba(80, 158, 227, 0.2);
    border-radius: 9999px;
    overflow: hidden;
}
.table-card td .mini-bar__fill {
    height: 100%;
    background: rgb(80, 158, 227);
}

/* Results layout */
.results-grid {
    display: block;
}

@media (min-width: 992px) {
    .results-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(4, auto);
        gap: 16px;
        align-items: stretch;
    }

    /* Define the grid areas per the 4x4 spec */
    .results-grid {
        grid-template-areas:
            "table gshare mshare diff"
            "table gshare mshare samples"
            "table gmoe   mmoe   samples"
            "part  part   part   part";
    }

    /* Assign areas */
    .results-table { grid-area: table; }
    .card--gonzalez-share { grid-area: gshare; }
    .card--maduro-share { grid-area: mshare; }
    .card--diff { grid-area: diff; }
    .card--gonzalez-moe { grid-area: gmoe; }
    .card--maduro-moe { grid-area: mmoe; }
    .card--samples { grid-area: samples; }
    .card--participation { grid-area: part; }

    /* Remove top/bottom margins inside grid to rely on gap */
    .results-grid > .card,
    .results-grid > .table-card {
        margin: 0;
        display: flex;
        flex-direction: column;
    }
    .results-grid > .card {
        justify-content: center;
    }
    .results-grid > .table-card {
        justify-content: start;
    }
}


/* Results table headers with download icon */
.results-per-stratum-table .table-card__header,
.original-source-table .table-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.table-card__download {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    padding: 6px;
    border-radius: 8px;
}
.table-card__download:hover {
    background: #f3f4f6;
}
.table-card__download svg {
    display: block;
}


/* Results Per Stratum responsive layout */
.results-per-stratum {
    display: block;
    margin-top: 24px;
}
.results-per-stratum__content {
    margin: 20px 0;
}

@media (min-width: 992px) {
    .results-per-stratum {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
        align-items: start;
    }
    .results-per-stratum__content {
        margin: 0;
    }
    .results-per-stratum .results-per-stratum-table,
    .results-per-stratum .results-per-stratum__content {
        width: 100%;
    }
}


/* Scrollable table utility (scoped to the verification table) */
.table-card__scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 546px;
    -webkit-overflow-scrolling: touch;
}
.table-card--scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f9fafb;
}
.table-card--scroll table {
    width: 100%;
    min-width: max-content;
}
.table--nowrap th,
.table--nowrap td {
    white-space: nowrap;
}

/* Original Source Data for Verification numeric alignment */
.original-source-table table th:nth-child(3),
.original-source-table table td:nth-child(3),
.original-source-table table th:nth-child(4),
.original-source-table table td:nth-child(4),
.original-source-table table th:nth-child(5),
.original-source-table table td:nth-child(5),
.original-source-table table th:nth-child(6),
.original-source-table table td:nth-child(6),
.original-source-table table th:nth-child(7),
.original-source-table table td:nth-child(7),
.original-source-table table th:nth-child(8),
.original-source-table table td:nth-child(8),
.original-source-table table th:nth-child(16),
.original-source-table table td:nth-child(16) {
    text-align: right;
}

