* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    background: transparent;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
}

.header h1 {
    font-size: 1rem;
    font-weight: 600;
    color: #1d1d1f;
}

.header h1 span {
    color: #0071e3;
}

/* Map */
.map-container {
    position: relative;
    height: 50vh;
    min-height: 350px;
}

#map {
    width: 100%;
    height: 100%;
}

.map-legend {
    position: absolute;
    bottom: 24px;
    left: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    font-size: 0.8125rem;
}

.map-legend h4 {
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: #86868b;
}

.legend-line {
    width: 20px;
    height: 4px;
    border-radius: 2px;
}

/* Content */
.content {
    max-width: 980px;
    margin: 0 auto;
    padding: 2rem;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.view-toggle {
    display: flex;
    background: #e8e8ed;
    border-radius: 980px;
    padding: 3px;
}

.toggle-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    border-radius: 980px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #86868b;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: white;
    color: #1d1d1f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.month-select {
    padding: 0.5rem 2rem 0.5rem 0.875rem;
    font-size: 0.875rem;
    border: none;
    border-radius: 8px;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.5rem center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    color: #1d1d1f;
    appearance: none;
}

/* Train Tiles */
.train-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.train-tile {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.train-tile:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.train-tile-number {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.train-tile-route {
    font-size: 0.8125rem;
    color: #86868b;
    margin-bottom: 0.75rem;
}

.train-tile-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
}

.train-tile-ontime { font-weight: 600; }
.train-tile-ontime.good { color: #34c759; }
.train-tile-ontime.warning { color: #ff9f0a; }
.train-tile-ontime.danger { color: #ff3b30; }
.train-tile-trips { color: #86868b; }

/* Back Button */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    background: #f5f5f7;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
}

.back-button:hover {
    background: #e8e8ed;
}

/* Cards */
.card {
    background: white;
    border-radius: 18px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.card-title {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.card-subtitle {
    font-size: 1rem;
    color: #86868b;
    margin-top: 0.375rem;
}

.card-meta {
    font-size: 0.75rem;
    color: #86868b;
    margin-top: 0.25rem;
}

/* Schedule Days */
.schedule-days {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.day-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    font-size: 0.6875rem;
    font-weight: 500;
    background: #e8e8ed;
    color: #86868b;
}

.day-pill.active {
    background: #0071e3;
    color: white;
}

.day-badge.daily {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 980px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #0071e3;
    color: white;
}

/* Badge */
.badge {
    background: #34c759;
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 980px;
    font-weight: 600;
    font-size: 0.9375rem;
}

.badge.warning { background: #ff9f0a; }
.badge.danger { background: #ff3b30; }

@media (max-width: 640px) {
    .badge {
        padding: 0.375rem 0.875rem;
        font-size: 0.8125rem;
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat {
    text-align: center;
    padding: 1.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.stat-value.highlight { color: #0071e3; }

.stat-detail {
    font-size: 0.9375rem;
    color: #86868b;
    margin-top: 0.25rem;
}

/* Benchmarks */
.benchmarks {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.benchmarks-title {
    font-size: 0.75rem;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
    font-weight: 500;
}

.benchmarks-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 640px) {
    .benchmarks-grid {
        grid-template-columns: 1fr;
    }
}

.benchmark {
    background: #f5f5f7;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.benchmark-name {
    font-size: 0.75rem;
    color: #86868b;
    margin-bottom: 0.5rem;
}

.benchmark-time {
    font-size: 1.25rem;
    font-weight: 600;
}

.benchmark-speed {
    font-size: 0.8125rem;
    color: #86868b;
    margin-top: 0.25rem;
}

.benchmark-savings {
    font-size: 0.75rem;
    color: #34c759;
    margin-top: 0.375rem;
    font-weight: 500;
}

/* Stations Track */
.stations-track {
    display: flex;
    align-items: flex-start;
    overflow-x: auto;
    padding: 1rem 0;
}

.station {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    cursor: pointer;
    padding: 0 0.25rem;
    position: relative;
}

.station:hover { opacity: 0.8; }

.station-connector {
    position: absolute;
    top: 15px;
    right: calc(50% + 20px);
    width: calc(100% - 40px);
    height: 2px;
    background: #d1d1d6;
}

.station:first-child .station-connector { display: none; }

.station-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: white;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.station-name {
    font-size: 0.6875rem;
    color: #86868b;
    text-align: center;
    max-width: 65px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.625rem;
}

.station-speed {
    font-size: 0.625rem;
    color: #aeaeb2;
    margin-top: 0.125rem;
}

/* Journey Selector */
.journey-selector {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.journey-selector select {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1.0625rem;
    border: none;
    border-radius: 12px;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 1rem center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    appearance: none;
}

.journey-arrow {
    color: #86868b;
    font-size: 1.5rem;
}

@media (max-width: 640px) {
    .journey-selector {
        grid-template-columns: 1fr;
    }
    .journey-arrow {
        text-align: center;
        transform: rotate(90deg);
    }
}

/* Train Options */
.train-option {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: #f5f5f7;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    align-items: center;
}

.train-option.best {
    background: rgba(0, 113, 227, 0.08);
    border: 1px solid rgba(0, 113, 227, 0.2);
}

@media (max-width: 640px) {
    .train-option {
        grid-template-columns: 1fr 1fr;
    }
}

/* Loading & Empty States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #86868b;
    gap: 0.75rem;
}

/* HTMX Loading Indicator */
.htmx-indicator {
    display: none;
}

.htmx-indicator.htmx-request {
    display: flex;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e8e8ed;
    border-top-color: #0071e3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty {
    text-align: center;
    padding: 4rem 2rem;
    color: #86868b;
}

/* Popup */
.popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
}

.popup-overlay.active { display: block; }

.popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 18px;
    padding: 1.75rem;
    z-index: 2001;
    min-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.popup.active { display: block; }

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.popup-title {
    font-size: 1.1875rem;
    font-weight: 600;
}

.popup-close {
    background: #f5f5f7;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    color: #86868b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-close:hover { background: #e8e8ed; }

.popup-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.popup-stat:last-child { border-bottom: none; }

.popup-stat-label { color: #86868b; }
.popup-stat-value { font-weight: 600; }

/* Utilities */
.hidden { display: none !important; }
.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 1.5rem;
}
