:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #172033;
    --muted: #5b6475;
    --line: #dce3ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #138a61;
    --success-bg: #eaf8f2;
    --pending: #8a5a12;
    --pending-bg: #fff4d6;
    --danger: #b42318;
    --danger-bg: #fff1f0;
    --shadow: 0 16px 38px rgba(25, 41, 66, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(19, 138, 97, 0) 310px),
        var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.page-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 56px;
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    min-height: 170px;
    padding: 6px 0 22px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 12px;
    font-size: clamp(38px, 7vw, 72px);
    line-height: 0.95;
    letter-spacing: 0;
}

.subtitle {
    max-width: 720px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.7;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin: 12px 0 24px;
}

.status-card {
    min-height: 82px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 8px 22px rgba(25, 41, 66, 0.05);
}

.status-card span,
.status-card strong {
    display: block;
}

.status-card span {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 14px;
}

.status-card strong {
    font-size: 16px;
}

.status-card.supported strong {
    color: var(--success);
}

.status-card.pending strong {
    color: var(--pending);
}

.status-card.partial strong {
    color: var(--primary);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.18fr);
    gap: 20px;
    align-items: start;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.aggregate-panel {
    padding: 22px;
    margin-bottom: 20px;
}

.section-copy {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.query-panel,
.contest-panel {
    padding: 22px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-heading h2 {
    margin: 0;
    font-size: 22px;
}

.count-label {
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.query-form {
    display: grid;
    gap: 14px;
}

.aggregate-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.aggregate-form button {
    align-self: end;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}

select,
input,
button {
    width: 100%;
    min-height: 44px;
    border-radius: 8px;
    font: inherit;
}

select,
input {
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--text);
    padding: 0 12px;
}

select:focus,
input:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(37, 99, 235, 0.15);
}

button {
    border: 0;
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--primary-dark);
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.message {
    min-height: 24px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.message.error {
    padding: 10px 12px;
    border: 1px solid rgba(180, 35, 24, 0.2);
    border-radius: 8px;
    background: var(--danger-bg);
    color: var(--danger);
}

.notice {
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 8px;
    background: #eef4ff;
    color: #24418f;
    font-size: 14px;
    line-height: 1.6;
}

.result-area {
    margin-top: 12px;
}

.aggregate-result {
    margin-top: 14px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.metric {
    min-height: 74px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.metric span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 13px;
}

.metric strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 18px;
}

.problem-list,
.contest-list {
    display: grid;
    gap: 10px;
}

.subheading {
    margin: 2px 0 10px;
    color: var(--muted);
    font-size: 15px;
}

.problem-item,
.contest-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.problem-item h3,
.contest-item h3 {
    margin: 0 0 8px;
    font-size: 16px;
    line-height: 1.45;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e9efff;
    color: #24418f;
    font-size: 12px;
    font-weight: 700;
}

.empty-state {
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--muted);
}

.aggregate-top {
    display: grid;
    grid-template-columns: minmax(190px, 0.35fr) minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
}

.total-box {
    display: grid;
    align-content: center;
    min-height: 190px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.total-box span {
    color: var(--muted);
    font-size: 14px;
}

.total-box strong {
    margin-top: 8px;
    font-size: 42px;
    line-height: 1;
}

.chart-wrap {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.donut-chart {
    position: relative;
    width: 180px;
    aspect-ratio: 1;
    border-radius: 50%;
}

.donut-center {
    position: absolute;
    inset: 34px;
    display: grid;
    place-items: center;
    align-content: center;
    border-radius: 50%;
    background: var(--panel);
    box-shadow: inset 0 0 0 1px var(--line);
}

.donut-center span {
    color: var(--muted);
    font-size: 12px;
}

.donut-center strong {
    font-size: 24px;
}

.chart-legend {
    display: grid;
    gap: 8px;
}

.legend-row {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.legend-row strong {
    color: var(--text);
    font-weight: 700;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.aggregate-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.aggregate-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.aggregate-card.failed {
    border-color: rgba(180, 35, 24, 0.28);
}

.aggregate-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.aggregate-card-heading h3 {
    margin: 0;
    font-size: 17px;
}

.aggregate-card-heading span {
    min-width: 64px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--success-bg);
    color: var(--success);
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

.aggregate-card.failed .aggregate-card-heading span {
    background: var(--danger-bg);
    color: var(--danger);
}

.mini-metrics {
    display: grid;
    gap: 8px;
}

.mini-metrics div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.mini-metrics strong {
    color: var(--text);
    overflow-wrap: anywhere;
    text-align: right;
}

@media (max-width: 860px) {
    .page-shell {
        width: min(100% - 24px, 720px);
        padding-top: 28px;
    }

    .hero {
        min-height: auto;
        padding-bottom: 16px;
    }

    .status-grid,
    .aggregate-form,
    .aggregate-top,
    .chart-wrap,
    .aggregate-cards,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .status-grid {
        gap: 10px;
    }

    .status-card {
        min-height: 70px;
    }

    .donut-chart {
        margin: 0 auto;
    }
}

@media (max-width: 540px) {
    .query-panel,
    .contest-panel,
    .aggregate-panel {
        padding: 16px;
    }

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

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}
