:root {
    color-scheme: light dark;
    --page-bg: #f7f9fb;
    --surface: #ffffff;
    --surface-subtle: #f1f4f7;
    --surface-strong: #e3eaf0;
    --text: #24313d;
    --text-muted: #5b6b7a;
    --border: #ccd5dd;
    --header: #2c3e50;
    --header-text: #ffffff;
    --header-link: #dbe9f5;
    --hover: #eaf2f8;
    --focus: #2c7be5;
    --input-bg: #ffffff;
    --button: #388e3c;
    --button-hover: #2e7d32;
    --plot-base: #2e8b57;
    --plot-hotfix: #2c7be5;
    --plot-resolved: #8b5cf6;
    --plot-hover: #d97706;
    --shadow: rgba(20, 35, 50, 0.14);
}

@media (prefers-color-scheme: dark) {
    :root {
        --page-bg: #111820;
        --surface: #18232d;
        --surface-subtle: #202d38;
        --surface-strong: #293946;
        --text: #e5edf4;
        --text-muted: #a9bac8;
        --border: #3b4c59;
        --header: #1b2a36;
        --header-text: #f5f8fa;
        --header-link: #c7d9e8;
        --hover: #243541;
        --focus: #79b8ff;
        --input-bg: #101820;
        --button: #3f9145;
        --button-hover: #4ca653;
        --plot-base: #56b881;
        --plot-hotfix: #79b8ff;
        --plot-resolved: #c4a7ff;
        --plot-hover: #f2a93b;
        --shadow: rgba(0, 0, 0, 0.35);
    }
}

* {
    box-sizing: border-box;
}

body {
    background: var(--page-bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
}

header {
    background-color: var(--header);
    color: var(--header-text);
    padding: 20px;
    box-shadow: 0 2px 4px var(--shadow);
}

.top-links {
    margin-top: 10px;
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

.top-links a {
    color: var(--header-link);
    text-decoration: none;
    font-size: 14px;
}

.top-links a:hover,
.top-links a:focus {
    color: var(--header-text);
    text-decoration: underline;
}

.top-links a[aria-current="page"] {
    color: var(--header-text);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
}

h1 {
    margin: 0;
}

h2 {
    color: var(--text);
}

.container {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.sidebar {
    flex: 0 0 350px;
    background-color: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 15px;
    height: auto;
    overflow: visible;
}

.sidebar h2 {
    margin: 0 0 15px 0;
    font-size: 18px;
}

.checkbox-tree {
    --checkbox-tree-hover-color: var(--text);
}

.issue-search {
    width: 100%;
    margin-bottom: 12px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 4px;
    font-size: 13px;
}

.issue-search:focus {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
    border-color: var(--focus);
}

.issue-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 13px;
}

.issue-filters label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
}

.issue-filters input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
}

.content {
    flex: 1;
    min-width: 0;
}

#issues {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

#issues h2 {
    margin: 0 0 10px 0;
    border-bottom: 2px solid var(--header);
    padding-bottom: 8px;
}

.issue-count {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9em;
}

ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#addressed-issues {
    overflow-x: auto;
}

.issues-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    background-color: var(--surface);
    font-size: 14px;
}

.issues-table th,
.issues-table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.issues-table th {
    background-color: var(--surface-strong);
    color: var(--text);
    position: sticky;
    top: 0;
    z-index: 1;
}

.issues-table tbody tr:hover {
    background-color: var(--hover);
}

.issues-table .issue-id-col {
    width: 160px;
    white-space: nowrap;
    font-weight: 600;
}

.issues-table .issue-version-col {
    width: 180px;
}

.issues-table td ul,
.issues-table td ol {
    margin: 8px 0 0;
    padding-left: 20px;
}

.issues-table td ul {
    list-style-type: disc;
}

.issues-table td ol {
    list-style-type: decimal;
}

.issues-table td li {
    padding: 0;
    border: 0;
    margin: 4px 0 0;
    border-radius: 0;
    background: transparent;
}

.issues-table td li:hover {
    background: transparent;
}

li {
    padding: 10px;
    border: 1px solid var(--border);
    margin: 5px 0;
    border-radius: 4px;
    background-color: var(--surface);
}

li:hover {
    background-color: var(--hover);
}

.statistics-container {
    width: min(1800px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.statistics-intro {
    margin: 0 0 28px;
    color: var(--text-muted);
    line-height: 1.5;
}

.issue-plot {
    margin: 0 0 42px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
    background: var(--surface);
}

.issue-plot-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 16px;
}

.issue-plot-heading h2,
.issue-plot-heading p,
.issue-plot-summary {
    margin: 0;
}

.issue-plot-heading p,
.issue-plot-summary {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.issue-plot-controls {
    display: flex;
    flex: 0 0 auto;
    gap: 12px;
}

.issue-plot-controls label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.issue-plot-controls select {
    display: block;
    min-width: 150px;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 7px 28px 7px 9px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.issue-plot-type {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    border: 0;
    padding: 0;
}

.issue-plot-type legend {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.issue-plot-type label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 400;
}

.issue-plot-type input {
    margin: 0;
}

.issue-plot-frame {
    position: relative;
}

#issue-plot-canvas {
    display: block;
    width: 100%;
    height: max(460px, calc(100vh - 260px));
}

.issue-plot-tooltip {
    position: absolute;
    z-index: 1;
    pointer-events: none;
    border-radius: 4px;
    padding: 6px 9px;
    background: var(--header);
    color: var(--header-text);
    font-size: 0.82rem;
    white-space: nowrap;
}

.issue-plot-summary {
    min-height: 1.3em;
    margin-top: 8px;
    text-align: center;
}

.issue-plot-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.issue-plot-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.issue-plot-key {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.issue-plot-key-base {
    background: var(--plot-base);
}

.issue-plot-key-hotfix {
    background: var(--plot-hotfix);
}

.issue-plot-key-resolved {
    background: var(--plot-resolved);
}

.stats-product {
    margin-top: 32px;
}

.stats-product h2 {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 0 0 10px;
}

.stats-product-total {
    color: var(--text-muted);
    font-size: 0.65em;
    font-weight: 400;
}

.stats-table-wrap {
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    background: var(--surface);
}

.stats-table th,
.stats-table td {
    border-bottom: 1px solid var(--border);
    padding: 9px 14px;
    text-align: left;
}

.stats-table thead th {
    background: var(--header);
    color: var(--header-text);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stats-table td {
    width: 180px;
    color: var(--text-muted);
    white-space: nowrap;
}

.stats-table tbody th {
    position: relative;
}

.stats-table tr[hidden] {
    display: none;
}

.stats-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.stats-toggle::before {
    width: 18px;
    color: var(--text-muted);
    content: "▶";
    font-size: 0.65rem;
    transform-origin: center;
    transition: transform 120ms ease;
}

.stats-toggle[aria-expanded="true"]::before {
    transform: rotate(90deg);
}

.stats-toggle:hover .version-label,
.stats-toggle:focus-visible .version-label {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.stats-toggle:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

.stats-major th,
.stats-major td {
    background: var(--surface-strong);
    color: var(--text);
    font-weight: 700;
}

.stats-minor th,
.stats-minor td {
    background: var(--surface-subtle);
    font-weight: 600;
}

.stats-minor .version-label {
    display: inline-block;
    margin-left: 10px;
}

.stats-patch th::before {
    position: absolute;
    color: var(--text-muted);
    content: "└";
}

.stats-patch .version-label {
    display: inline-block;
    margin-left: 58px;
}

.stats-patch th::before {
    left: 44px;
}

@media (max-width: 600px) {
    .statistics-container {
        width: min(100% - 24px, 900px);
        padding-top: 20px;
    }

    .stats-product h2 {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }

    .issue-plot {
        padding: 14px 10px;
    }

    .issue-plot-heading,
    .issue-plot-controls {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .issue-plot-controls select {
        width: 100%;
    }

    .stats-table th,
    .stats-table td {
        padding: 8px 10px;
    }

    .stats-table td {
        width: 120px;
    }
}

@media (max-width: 900px) {
    .container {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .sidebar {
        flex: 1 1 auto;
        width: 100%;
    }

    .checkbox-tree {
        --checkbox-tree-indent: 12px;
    }

    .issues-table {
        font-size: 13px;
    }

    .issues-table th,
    .issues-table td {
        padding: 6px 8px;
    }

    .issues-table .issue-id-col {
        min-width: 120px;
    }

    .issues-table .issue-version-col {
        min-width: 150px;
    }
}

@media (max-width: 600px) {
    header {
        padding: 14px;
    }

    h1 {
        font-size: 1.25rem;
    }

    .top-links {
        gap: 12px;
    }

    .issue-filters {
        flex-wrap: wrap;
        gap: 8px;
    }

    .issue-filters label {
        min-height: 32px;
    }
}

@media (max-width: 700px) {
    #addressed-issues,
    #known-issues {
        overflow-x: visible;
    }

    .issue-list-table {
        border: 0;
        background: transparent;
    }

    .issue-list-table thead {
        display: none;
    }

    .issue-list-table tbody {
        display: grid;
        gap: 10px;
    }

    .issue-list-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
        column-gap: 6px;
        row-gap: 4px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background-color: var(--surface);
        padding: 8px 10px;
    }

    .issue-list-table tbody tr:hover {
        background-color: var(--surface);
    }

    .issue-list-table tbody td {
        display: block;
        border: 0;
        padding: 0;
    }

    .issue-list-table tbody td::before {
        content: none;
    }

    .issue-list-table .issue-id-col,
    .issue-list-table .issue-version-col {
        width: auto;
        min-width: 0;
    }

    .issue-list-table .issue-id-col {
        grid-column: 1;
        grid-row: 1;
        font-weight: 700;
        white-space: nowrap;
    }

    .issue-list-table .issue-version-col {
        grid-column: 2;
        grid-row: 1;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .issue-list-table .issue-version-col::before {
        content: attr(data-label) " ";
        color: var(--text-muted);
        font-weight: 600;
    }

    .issue-list-table tbody td:last-child {
        grid-column: 1 / -1;
        grid-row: 2;
        margin-top: 1px;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .issues-table td ul,
    .issues-table td ol {
        margin: 4px 0 0;
        padding-left: 18px;
    }
}
