*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    color-scheme: light;
    --bg: #f6f8f9;
    --ink: #142126;
    --muted: #5d6b72;
    --line: #d8e1e5;
    --line-strong: #b8c8cf;
    --surface: #ffffff;
    --surface-alt: #eef4f6;
    --accent: #146a73;
    --accent-dark: #0c4349;
    --focus: #db7b2b;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--accent-dark);
}

.page-shell {
    width: min(88rem, calc(100% - 1rem));
    margin: 0 auto;
    padding: 1.25rem 0 3rem;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.top-nav a {
    color: var(--ink);
}

.case-header {
    padding: 3rem 0 2rem;
}

h1, h2, p {
    margin-top: 0;
}

h1 {
    max-width: 52rem;
    margin-bottom: 0.9rem;
    font-size: 3rem;
    line-height: 1.04;
    letter-spacing: 0;
}

.intro {
    max-width: 48rem;
    margin-bottom: 1.35rem;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.6;
}

.download-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0 1rem;
    border: 1px solid var(--accent-dark);
    border-radius: 0.375rem;
    background: var(--accent-dark);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
}

.download-link:focus-visible,
.sheet-tab:focus-visible,
.search-label input:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: var(--line);
}

.metrics div {
    min-height: 7rem;
    padding: 1.1rem;
    background: var(--surface);
}

.metrics strong {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 2rem;
    line-height: 1;
}

.metrics span {
    color: var(--muted);
    font-size: 0.95rem;
}

.workbook-panel {
    margin-top: 2rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: var(--surface);
}

.workbook-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--line);
}

.workbook-header h2 {
    margin-bottom: 0.25rem;
    font-size: 1.2rem;
}

.workbook-header p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.search-label {
    display: grid;
    gap: 0.35rem;
    min-width: min(18rem, 100%);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.search-label input {
    width: 100%;
    min-height: 2.35rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.375rem;
    padding: 0 0.75rem;
    color: var(--ink);
    font: inherit;
    text-transform: none;
}

.sheet-tabs {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface-alt);
}

.sheet-tab {
    flex: 0 0 auto;
    min-height: 2rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.375rem;
    padding: 0 0.75rem;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
}

.sheet-tab[aria-selected="true"] {
    border-color: var(--accent-dark);
    background: var(--accent-dark);
    color: #ffffff;
    font-weight: 700;
}

.status {
    padding: 1.25rem;
    color: var(--muted);
}

.grid-wrap {
    max-height: 70vh;
    overflow: auto;
}

.sheet-grid {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
}

.sheet-grid th,
.sheet-grid td {
    min-width: 7.5rem;
    max-width: 20rem;
    height: 2rem;
    padding: 0.35rem 0.55rem;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    text-align: left;
    vertical-align: top;
}

.sheet-grid thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    min-width: 3.5rem;
    background: #e6eef1;
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.sheet-grid tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 3.5rem;
    background: #e6eef1;
    color: var(--muted);
    font-weight: 700;
    text-align: right;
}

.sheet-grid thead th:first-child {
    left: 0;
    z-index: 3;
}

.sheet-grid td.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sheet-grid td.empty {
    background: #fbfcfc;
}

@media screen and (max-width: 48rem) {
    .page-shell {
        width: min(100% - 1rem, 72rem);
        padding-top: 0.75rem;
    }

    h1 {
        font-size: 2.15rem;
    }

    .intro {
        font-size: 1rem;
    }

    .metrics {
        grid-template-columns: 1fr;
    }

    .metrics div {
        min-height: 5.25rem;
    }

    .workbook-header {
        display: grid;
    }
}
