:root {
    --bg: #f7fafc;
    --surface: #ffffff;
    --accent: #2b6cb0;
    --muted: #6b7280;
    --border: #e5e7eb;
    --text: #111827;
    --hover: #eef6ff;
    --green: #93e8b8;
    --red: #cf7072;
    --yellow: #f0ca62;
    --radius: 8px;
    --page-width: 1100px;
    --divider: rgba(25, 55, 45, .34);
    --hour-divider: rgba(17, 24, 39, .48);
    --half-divider: rgba(17, 24, 39, .08);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1e2022;
    --surface: #292c2e;
    --muted: #a3aaad;
    --border: #45494b;
    --text: #e5e7e8;
    --hover: #34383a;
    --divider: rgba(18, 30, 26, .34);
    --hour-divider: rgba(0, 0, 0, .48);
    --half-divider: rgba(0, 0, 0, .10);
}

* { box-sizing: border-box; }

.site-header > p:not(.alert) {
    margin: 15px 0;
    color: var(--muted);
}

.page-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: -8px 0 12px;
}

.theme-options,
.interface-switch {
    display: inline-flex;
    border: 1px solid var(--border);
}

.theme-options { flex: 0 0 auto; }

.theme-options button {
    border: 0;
    padding: 7px 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
}

.theme-options button[aria-pressed="true"],
.interface-switch a[aria-current="page"] {
    background: var(--accent);
    color: #fff;
}

.theme-options button:focus-visible,
.interface-switch a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.interface-switch a {
    padding: 7px 10px;
    color: var(--text);
    text-decoration: none;
    font-size: .85rem;
}

.alert {
    margin: 12px 0;
    padding: 10px 12px;
    border-left: 3px solid var(--accent);
    background: var(--surface);
}

.empty { color: var(--muted); }

body.table-page {
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 24px;
    background: var(--bg);
}

.table-page .wrap {
    width: 100%;
    max-width: var(--page-width);
}

.table-page .site-header h1 {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 1.4rem;
}

.table-page .group-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    margin: 0 0 18px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
}

.table-page .group-menu a {
    flex: 0 0 auto;
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--accent);
    text-decoration: none;
    font-size: .95rem;
    font-weight: 600;
}

.table-page .group-menu a:hover,
.table-page .group-menu a:focus {
    background: var(--hover);
    outline: none;
    box-shadow: 0 0 0 3px rgba(43, 108, 176, .08);
}

.table-page .group-menu a[aria-current="page"] {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.day-card {
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}

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

.day-header .date { font-weight: 600; }
.day-header .generated { display: none; }
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
}

thead th,
tbody td {
    padding: 10px;
    border: 1px solid var(--border);
    vertical-align: middle;
}

thead th {
    background: var(--bg);
    font-weight: 700;
}

tbody tr:nth-child(odd) {
    background: color-mix(in srgb, var(--text) 3%, var(--surface));
}

.intervals {
    color: var(--text);
    text-align: center;
    white-space: normal;
    word-break: break-word;
}

td .value { color: var(--text); }

@media (max-width: 640px) {
    .table-page .group-menu { gap: 6px; }

    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }

    tbody tr {
        display: block;
        margin-bottom: 12px;
        padding: 0;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--surface);
    }

    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px;
        border: none;
        border-bottom: 1px dashed var(--border);
    }

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

    td[data-label]::before {
        flex: 0 0 auto;
        margin-right: 12px;
        color: var(--muted);
        font-weight: 600;
        content: attr(data-label);
    }

    td .value {
        flex: 1 1 auto;
        text-align: right;
    }

    .intervals .value { text-align: center; }
}

body.spiral-page {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    padding: 28px 20px 36px;
    background: var(--bg);
}

.spiral-page .page {
    width: min(100%, 1120px);
    margin: 0 auto;
}

.spiral-page .site-header { margin-bottom: 18px; }

.spiral-page .site-header h1 {
    margin: 0 0 5px;
    font-size: 1.35rem;
    font-weight: 650;
}

.spiral-page .site-header > p:not(.alert) { font-size: .92rem; }
.spiral-page a { color: var(--text); }
.spiral-page .alert { border-left-color: var(--green); }

.spiral-page .group-menu {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    margin: 0 -4px 18px;
    padding: 4px 4px 9px;
    scrollbar-color: var(--border) transparent;
}

.spiral-page .group-menu a {
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: .9rem;
}

.spiral-page .group-menu a:hover,
.spiral-page .group-menu a:focus-visible,
.spiral-page .group-menu a[aria-current="page"] {
    border-color: var(--accent);
    color: var(--accent);
    outline: none;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 0 0 22px;
    color: var(--muted);
    font-size: .9rem;
}

.legend span { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 11px; height: 11px; border-radius: 50%; }
.swatch.on { background: var(--green); }
.swatch.off { background: var(--red); }
.swatch.transition { background: var(--yellow); }

.day-section { margin: 0 0 32px; }

.day-heading {
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: .95rem;
    font-weight: 500;
}

.schedule-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr));
    justify-items: center;
    gap: 20px 28px;
}

.schedule {
    width: min(100%, 440px);
    margin: 0;
    text-align: center;
}

.schedule svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.sector { stroke: none; }
.hour-divider { stroke: var(--hour-divider); stroke-width: 1.4; }
.half-divider { stroke: var(--half-divider); stroke-width: .65; }
.terminal-divider { stroke: var(--text); stroke-width: 1.8; }
.sector.on { fill: var(--green); }
.sector.off { fill: var(--red); }
.sector.transition { fill: var(--yellow); }

.hour-label {
    fill: #12313a;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 22px;
    text-anchor: middle;
    dominant-baseline: central;
}

.center-disc { fill: var(--bg); }

.center-group {
    fill: var(--text);
    font-size: 23px;
    font-weight: 700;
    text-anchor: middle;
}

.center-date {
    fill: var(--muted);
    font-size: 15px;
    font-weight: 650;
    text-anchor: middle;
}

.center-stats {
    font-size: 18px;
    font-weight: 700;
    text-anchor: middle;
}

.stats-red { fill: var(--red); }
.stats-yellow { fill: var(--yellow); }
.stats-green { fill: var(--green); }

.updated {
    margin-top: -3px;
    color: var(--muted);
    font-size: .78rem;
}

.source { margin-top: 26px; font-size: .8rem; }

@media (max-width: 520px) {
    body.spiral-page { padding: 20px 13px 28px; }
    .spiral-page .site-header h1 { font-size: 1.15rem; }
    .spiral-page .group-menu { margin-bottom: 12px; }
    .spiral-page .schedule-grid { gap: 12px; }
}
