:root {
    --primary: #1d3557;
    --primary-dark: #0d1b2a;
    --bg: #f9fafb;
    --text: #111827;
    --text-muted: #4b5563;
    --border: #e5e7eb;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --error-text: #b91c1c;
    --card-bg: #ffffff;
}

* {
    box-sizing: border-box;
}

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

/* Site header */
.site-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 2rem 1.5rem 1.5rem;
}

.site-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 2.25rem;
    line-height: 1;
}

.site-header h1 {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 700;
}

.tagline {
    margin: 0.25rem 0 0;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
}

.days-nav {
    display: flex;
    gap: 0.5rem;
}

.days-nav a {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}

.days-nav a:hover {
    background: rgba(255, 255, 255, 0.28);
}

.days-nav a.active {
    background: #fff;
    color: var(--primary-dark);
}

.slow-hint {
    font-weight: 400;
    opacity: 0.75;
    font-size: 0.8em;
}

.header-meta {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.75);
}

.header-meta a {
    color: #fff;
    text-decoration: underline;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 3rem 0;
}

.loading-inner {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-weight: 600;
    color: var(--primary);
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    border: 3px solid rgba(29, 53, 87, 0.25);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error box */
.error-box {
    border-radius: 0.375rem;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    padding: 1rem;
    display: flex;
    gap: 0.75rem;
}

.error-box svg {
    width: 1.25rem;
    height: 1.25rem;
    color: #f87171;
    flex-shrink: 0;
}

.error-box h3 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--error-text);
}

.error-box p {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    color: var(--error-text);
}

.hidden {
    display: none !important;
}

/* Table of contents */
.toc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin: 1.5rem 0 2rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toc-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    border: 1px solid var(--border);
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.toc-link:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-1px);
}

/* Toll savings calculator */
.calculator {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.calculator h2 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
}

.calculator > p {
    margin: 0 0 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.calculator-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.calculator-controls label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    flex: 1 1 240px;
}

.calculator-controls select,
.calculator-controls input[type="time"] {
    padding: 0.5rem 0.65rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    background: #fff;
    color: var(--text);
}

.calc-result {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.calc-summary {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.calc-summary strong {
    color: var(--text);
}

.calc-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.calc-table thead th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.calc-table tbody td {
    padding: 0.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

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

.calc-cell-time {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    color: var(--text-muted);
    white-space: nowrap;
}

.calc-cell-avg {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-weight: 600;
}

.calc-cell-samples {
    color: var(--text-muted);
    text-align: right;
}

.calc-cell-status {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calc-cell-bar {
    width: 40%;
}

.calc-bar-track {
    position: relative;
    display: block;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.calc-bar-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

/* Highlighted rows use a left accent rail rather than a full color fill,
   for a subtler "best/worst" cue than a solid colored box. */
tr.is-best {
    box-shadow: inset 3px 0 0 0 #16a34a;
}

tr.is-best .calc-cell-time,
tr.is-best .calc-cell-avg {
    color: #15803d;
}

tr.is-best .calc-bar-fill {
    background: #16a34a;
}

tr.is-best .calc-cell-status {
    color: #15803d;
}

tr.is-worst {
    box-shadow: inset 3px 0 0 0 #dc2626;
}

tr.is-worst .calc-cell-time,
tr.is-worst .calc-cell-avg {
    color: #b91c1c;
}

tr.is-worst .calc-bar-fill {
    background: #dc2626;
}

tr.is-worst .calc-cell-status {
    color: #b91c1c;
}

/* Route "shield" icon badge */
.route-shield {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.35rem;
    border-radius: 0.375rem;
    background: #16a34a;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.route-shield.interstate {
    border-radius: 0.25rem 0.25rem 0.6rem 0.6rem;
    background: var(--primary);
}

/* Charts */
.route-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 2.5rem;
    scroll-margin-top: 1rem;
}

.direction-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 1.25rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.direction-title::-webkit-details-marker {
    display: none;
}

.direction-title::before {
    content: '+';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 0.3rem;
    border: 1px solid var(--border);
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
}

.direction-block[open] > .direction-title::before {
    content: '-';
}

.direction-title:hover::before {
    border-color: var(--primary);
}

.direction-title:hover {
    color: var(--text);
}

.direction-arrow {
    display: inline-flex;
    color: var(--primary);
    font-weight: 700;
}

.route-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

@media (min-width: 768px) {
    .route-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.chart-card {
    background: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    height: 400px;
    width: 100%;
}
