:root {
    --bg-top: #f8fbfc;
    --bg-bottom: #edf2f7;
    --surface-color: #ffffff;
    --surface-alt: #f6f9fc;
    --text-primary: #111827;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-color: #d9e3ef;
    --border-strong: #c7d4e3;
    --accent: #0f766e;
    --accent-hover: #0b5e58;
    --accent-soft: #dcf3ef;
    --pb-color: #c2410c;
    --pb-soft: #fff1e8;
    --pb-gradient: linear-gradient(120deg, #ea580c 0%, #f59e0b 100%);
    --shadow-card: 0 10px 28px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.06);
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    line-height: 1.5;
    padding: 2rem 1.25rem 2.75rem;
    background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 999px;
    z-index: 0;
    pointer-events: none;
}

body::before {
    width: 28rem;
    height: 28rem;
    top: -13rem;
    right: -10rem;
    background: radial-gradient(circle, rgba(15, 118, 110, 0.16) 0%, rgba(15, 118, 110, 0) 72%);
}

body::after {
    width: 24rem;
    height: 24rem;
    bottom: -11rem;
    left: -8rem;
    background: radial-gradient(circle, rgba(194, 65, 12, 0.12) 0%, rgba(194, 65, 12, 0) 74%);
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.mono {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.86rem;
}

.site-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1.1rem;
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    background: linear-gradient(160deg, #ffffff 0%, #f9fbff 100%);
    box-shadow: var(--shadow-card);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.title-stack {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.eyebrow {
    font-size: 0.69rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-weight: 700;
}

h1 {
    font-size: clamp(1.75rem, 2.8vw, 2.2rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.toggle-group {
    display: inline-flex;
    gap: 0.2rem;
    padding: 0.22rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-alt);
}

.toggle-btn {
    font-family: 'Space Grotesk', sans-serif;
    background: transparent;
    border: none;
    padding: 0.52rem 0.95rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.toggle-btn:hover {
    color: var(--text-secondary);
}

.toggle-btn.active {
    color: #ffffff;
    background: linear-gradient(120deg, #0f766e 0%, #0b5e58 100%);
    box-shadow: 0 4px 10px rgba(15, 118, 110, 0.28);
}

section {
    margin-bottom: 2.25rem;
}

.section-header {
    font-size: 0.71rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    margin-bottom: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-strong), rgba(199, 212, 227, 0));
}

.history-title {
    margin-bottom: 0;
    white-space: nowrap;
}

.pb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
}

.pb-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-soft);
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        'distance distance'
        'time pace'
        'meta meta';
    gap: 0.55rem 0.8rem;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.pb-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1);
    border-color: #f5bf9f;
}

.pb-distance {
    grid-area: distance;
    justify-self: start;
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #ffffff;
    background: var(--pb-gradient);
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
}

.pb-time {
    grid-area: time;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.pb-pace {
    grid-area: pace;
    justify-self: end;
    align-self: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.pb-meta {
    grid-area: meta;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    border-top: 1px solid #edf2f7;
    padding-top: 0.62rem;
}

.pb-race-name {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pb-race-name a {
    color: inherit;
    text-decoration: none;
}

.pb-race-name a:hover {
    color: var(--accent);
}

.pb-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.pb-date::before {
    content: '•';
    margin-right: 0.35rem;
    color: var(--border-strong);
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 0.85rem;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.filter-chip {
    font-family: 'Space Grotesk', sans-serif;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.43rem 0.78rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.filter-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-chip.active {
    border-color: transparent;
    color: #ffffff;
    background: linear-gradient(120deg, #0f766e 0%, #0b5e58 100%);
}

.data-panel {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed;
}

thead {
    background: #f6f9fc;
}

th {
    padding: 0.82rem 1rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: #fafcff;
}

.col-date {
    width: 14%;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.col-name {
    width: 37%;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.col-dist,
.col-time,
.col-pace {
    width: 12%;
    text-align: right;
    white-space: nowrap;
}

.col-dist,
.col-time,
.col-pace,
.col-date {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
}

.col-pace {
    color: var(--text-secondary);
}

.col-link {
    width: 13%;
    text-align: right;
    white-space: nowrap;
}

tr.is-pb td {
    background: var(--pb-soft);
}

tr.is-pb:hover td {
    background: #ffe8d7;
}

tr.is-pb .col-time {
    color: var(--pb-color);
    font-weight: 600;
}

tr.is-pb .col-time::after {
    content: 'PB';
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #ffffff;
    background: var(--pb-gradient);
    border-radius: 999px;
    margin-left: 0.5rem;
    padding: 0.2rem 0.46rem;
    vertical-align: middle;
}

.icon-link {
    text-decoration: none;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.24rem 0.52rem;
    border: 1px solid #bde6e1;
    border-radius: 999px;
    background: var(--accent-soft);
    margin-left: 0.34rem;
    transition: filter 0.18s ease;
}

.icon-link:hover {
    filter: brightness(0.94);
}

.race-link-primary {
    color: inherit;
    text-decoration: none;
}

.race-link-primary:hover {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.stats-section .table-wrapper {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    background: #ffffff;
    box-shadow: var(--shadow-card);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

.stats-table th,
.stats-table td {
    padding: 0.72rem 0.88rem;
    text-align: center;
    border-bottom: 1px solid #edf2f7;
    font-size: 0.82rem;
}

.stats-table th {
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    background: #f6f9fc;
}

.stats-table th:first-child,
.stats-table td:first-child {
    text-align: left;
    white-space: nowrap;
}

.stats-table td:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table .total-row td {
    font-weight: 700;
    background: #f6f9fc;
    border-top: 2px solid var(--border-color);
}

.stat-number {
    display: inline-block;
    min-width: 20px;
    color: var(--text-muted);
}

.stat-number.highlight {
    color: var(--accent);
    font-weight: 600;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.dashboard-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.1rem 1.15rem;
    box-shadow: var(--shadow-card);
}

.dashboard-card .section-header {
    margin-bottom: 0.55rem;
}

.dashboard-card .section-header::after {
    display: none;
}

.simple-list {
    list-style: none;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid #edf2f7;
}

.list-item:last-child {
    border-bottom: none;
}

.list-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.list-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.35;
}

.list-sub {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.status-badge {
    font-size: 0.64rem;
    padding: 0.28rem 0.56rem;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: #f1f5f9;
    color: #475569;
    white-space: nowrap;
}

.status-badge.countdown {
    background: var(--accent-soft);
    color: var(--accent);
}

.status-badge.tbd {
    background: #f1f5f9;
    color: #475569;
}

.status-badge.in-progress {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-badge.complete,
.status-badge.completed {
    background: #dcfce7;
    color: #166534;
}

.empty-state {
    padding: 1.6rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
}

td.empty-state {
    grid-column: 1 / -1;
}

td.empty-state::before {
    display: none;
}

@keyframes fade-in-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .site-header,
    .pb-section,
    .history-section,
    .stats-section,
    .dashboard-grid {
        animation: fade-in-rise 0.45s ease both;
    }

    .pb-section {
        animation-delay: 0.04s;
    }

    .history-section {
        animation-delay: 0.1s;
    }

    .stats-section {
        animation-delay: 0.16s;
    }

    .dashboard-grid {
        animation-delay: 0.22s;
    }
}

@media (max-width: 980px) {
    body {
        padding: 1.25rem 0.9rem 2rem;
    }

    .site-header {
        padding: 1.1rem 1rem;
        margin-bottom: 1.4rem;
        align-items: center;
    }

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

    .col-link {
        width: 16%;
    }

    .stats-section .table-wrapper {
        overflow-x: auto;
    }
}

@media (max-width: 760px) {
    section {
        margin-bottom: 1.6rem;
    }

    .site-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.9rem;
        border-radius: 18px;
    }

    .subtitle {
        font-size: 0.88rem;
    }

    .toggle-group {
        width: 100%;
        display: flex;
    }

    .toggle-btn {
        flex: 1;
        text-align: center;
    }

    .section-header {
        font-size: 0.64rem;
        margin-bottom: 0.68rem;
    }

    .pb-grid {
        grid-template-columns: 1fr;
        gap: 0.68rem;
    }

    .pb-card {
        padding: 0.9rem;
        border-radius: 14px;
    }

    .pb-time {
        font-size: 1.22rem;
    }

    .pb-race-name {
        font-size: 0.8rem;
    }

    .controls-bar {
        display: block;
        margin-bottom: 0.7rem;
    }

    .controls-bar .section-header {
        margin-bottom: 0.55rem;
    }

    .filter-group {
        flex-wrap: nowrap;
        overflow-x: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
        padding-bottom: 0.28rem;
    }

    .filter-group::-webkit-scrollbar {
        display: none;
    }

    .filter-chip {
        font-size: 0.74rem;
        padding: 0.43rem 0.74rem;
    }

    .data-panel {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
    }

    .table-wrapper {
        overflow: visible;
    }

    table {
        display: block;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 0.68rem;
    }

    tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            'name name'
            'date dist'
            'time pace'
            'links links';
        gap: 0.5rem 0.85rem;
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: 14px;
        box-shadow: var(--shadow-soft);
        padding: 0.95rem;
    }

    td {
        padding: 0;
        border: none;
        width: auto;
        min-width: 0;
    }

    td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.56rem;
        text-transform: uppercase;
        letter-spacing: 0.09em;
        color: var(--text-muted);
        font-weight: 700;
        margin-bottom: 0.2rem;
        line-height: 1.3;
    }

    td.col-name {
        grid-area: name;
        font-size: 0.94rem;
        border-bottom: 1px solid #edf2f7;
        padding-bottom: 0.55rem;
        text-align: left;
        font-family: 'Space Grotesk', sans-serif;
    }

    td.col-name::before {
        display: none;
    }

    td.col-date {
        grid-area: date;
        font-size: 0.8rem;
    }

    td.col-dist {
        grid-area: dist;
    }

    td.col-time {
        grid-area: time;
    }

    td.col-pace {
        grid-area: pace;
    }

    td.col-dist,
    td.col-pace {
        text-align: right;
    }

    td.col-link {
        grid-area: links;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        gap: 0.45rem;
        flex-wrap: wrap;
        border-top: 1px solid #edf2f7;
        padding-top: 0.55rem;
        margin-top: 0.08rem;
        text-align: left;
    }

    td.col-link::before {
        display: none;
    }

    td.empty-state {
        padding: 1rem;
        border: 1px dashed var(--border-color);
        border-radius: 12px;
        background: #ffffff;
    }

    .icon-link {
        margin-left: 0;
        padding: 0.3rem 0.56rem;
        font-size: 0.69rem;
    }

    tr.is-pb {
        border-color: #f7c2a1;
        background: #ffffff;
        position: relative;
    }

    tr.is-pb::after {
        content: 'PB';
        position: absolute;
        top: -1px;
        right: -1px;
        background: var(--pb-gradient);
        color: #ffffff;
        font-size: 0.56rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        border-top-right-radius: 13px;
        border-bottom-left-radius: 9px;
        padding: 0.2rem 0.55rem;
    }

    tr.is-pb .col-time::after {
        display: none;
    }

    tr.is-pb td {
        background: transparent;
    }

    .stats-section .table-wrapper,
    .dashboard-card {
        border-radius: 14px;
    }

    .dashboard-card {
        padding: 0.95rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.95rem 0.7rem 1.65rem;
    }

    .site-header {
        padding: 0.9rem 0.85rem;
    }

    h1 {
        font-size: 1.52rem;
    }

    .subtitle {
        font-size: 0.82rem;
    }

    .pb-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .pb-date::before {
        content: '';
        margin-right: 0;
    }

    td.col-name {
        font-size: 0.9rem;
    }

    .list-item {
        align-items: flex-start;
    }
}
