/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #D84E55;
    --primary-dark: #B83A40;
    --primary-light: #F87171;
    --header-bg: #1A1A2E;
    --header-bg-2: #16213E;
    --header-text: #EAEAEA;
    --bg: #F0F2F8;
    --card-bg: #FFFFFF;
    --text: #1E1E2E;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --accent-green: #10B981;
    --accent-green-bg: #ECFDF5;
    --accent-yellow: #F59E0B;
    --accent-yellow-bg: #FFFBEB;
    --accent-blue: #3B82F6;
    --accent-blue-bg: #EFF6FF;
    --accent-purple: #8B5CF6;
    --accent-purple-bg: #F5F3FF;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Animations === */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes countUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 500px; }
}

@keyframes progressPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(216, 78, 85, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(216, 78, 85, 0); }
}

.animate-in {
    animation: fadeInUp 0.4s var(--transition) both;
}

/* === Header === */
.header {
    background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg-2) 100%);
    color: var(--header-text);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(0,0,0,0.2);
}

.header-inner {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    color: var(--primary-light);
    filter: drop-shadow(0 0 8px rgba(216, 78, 85, 0.4));
    transition: transform var(--transition);
}

.brand:hover .brand-icon {
    transform: scale(1.1);
}

.brand h1 {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.4px;
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 13px;
    color: #9CA3AF;
    letter-spacing: 0.3px;
}

/* === Container === */
.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 28px 24px;
}

/* === Route Selector === */
.route-selector-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.route-selector-section:hover {
    box-shadow: var(--shadow-md);
}

.route-selector-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.route-selector-section h3::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
}

.route-form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.route-select, .route-date {
    padding: 11px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    background: white;
    transition: all var(--transition);
    font-family: inherit;
}

.route-select {
    flex: 1;
    cursor: pointer;
    appearance: none;
    background-image: 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='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.route-date {
    width: 170px;
}

.route-select:focus, .route-date:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(216, 78, 85, 0.1);
}

.btn-route-scrape {
    padding: 11px 22px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(216, 78, 85, 0.3);
}

.btn-route-scrape:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(216, 78, 85, 0.4);
}

.btn-route-scrape:active {
    transform: translateY(0);
}

.btn-route-scrape:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-route-delete {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: #9CA3AF;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-route-delete:hover {
    background: #FEE2E2;
    color: var(--primary);
    border-color: var(--primary);
    transform: scale(1.05);
}

.route-divider {
    text-align: center;
    margin-top: 16px;
    position: relative;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.route-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.route-divider span {
    background: var(--card-bg);
    padding: 0 16px;
    position: relative;
}

/* === Search === */
.search-section {
    margin-bottom: 24px;
}

.search-form {
    width: 100%;
}

.input-group {
    display: flex;
    gap: 12px;
}

.input-group input {
    flex: 1;
    padding: 13px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    transition: all var(--transition);
    font-family: inherit;
    background: var(--card-bg);
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(216, 78, 85, 0.1);
}

.input-group input::placeholder {
    color: #B0B8C4;
}

.input-group button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 28px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(216, 78, 85, 0.3);
}

.input-group button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(216, 78, 85, 0.4);
}

.input-group button:active {
    transform: translateY(0);
}

.input-group button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.error-text {
    color: var(--primary);
    font-size: 13px;
    margin-top: 8px;
    font-weight: 500;
}

/* === Progress === */
.progress-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    animation: fadeInUp 0.3s var(--transition);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #E5E7EB;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 5px;
    transition: width 0.4s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.3) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

.progress-fill.complete {
    background: linear-gradient(90deg, #10B981, #34D399);
}

.progress-fill.complete::after {
    animation: none;
}

.progress-fill.failed {
    background: linear-gradient(90deg, var(--primary), #EF4444);
}

/* === Route Info === */
.route-info {
    margin-bottom: 24px;
    animation: fadeInUp 0.3s var(--transition);
}

.route-info h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.route-meta {
    display: flex;
    gap: 20px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.route-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* === Summary Cards === */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.summary-card {
    padding: 22px 20px;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.summary-card:nth-child(1)::before { background: var(--accent-blue); }
.summary-card:nth-child(2)::before { background: var(--accent-purple); }
.summary-card:nth-child(3)::before { background: var(--accent-green); }
.summary-card:nth-child(4)::before { background: var(--accent-yellow); }
.summary-card:nth-child(5)::before { background: var(--primary); }

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.card-icon svg {
    width: 20px;
    height: 20px;
}

.card-icon.blue { background: var(--accent-blue-bg); color: var(--accent-blue); }
.card-icon.purple { background: var(--accent-purple-bg); color: var(--accent-purple); }
.card-icon.green { background: var(--accent-green-bg); color: var(--accent-green); }
.card-icon.yellow { background: var(--accent-yellow-bg); color: var(--accent-yellow); }
.card-icon.red { background: #FEF2F2; color: var(--primary); }

.summary-card .card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
}

.summary-card .card-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -1px;
    line-height: 1.2;
}

.summary-card .card-value.accent {
    color: var(--accent-green);
}

.summary-card.highlight {
    background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg-2) 100%);
    border-color: rgba(255,255,255,0.08);
}

.summary-card.highlight::before {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.summary-card.highlight .card-label {
    color: #9CA3AF;
}

.summary-card.highlight .card-value {
    color: #F9FAFB;
    background: linear-gradient(135deg, #fff 0%, #ddd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.summary-card.highlight .card-icon {
    background: rgba(216, 78, 85, 0.15);
    color: var(--primary-light);
}

/* === Charts === */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    padding: 24px;
}

.chart-card h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container {
    position: relative;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-container-bar {
    height: 300px;
}

/* === Export Bar === */
.export-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.export-bar h3 {
    font-size: 17px;
    font-weight: 700;
}

.export-actions {
    display: flex;
    gap: 8px;
}

.btn-export {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
    transition: all var(--transition);
    font-family: inherit;
}

.btn-export:hover {
    background: #F3F4F6;
    border-color: #D1D5DB;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-export:active {
    transform: translateY(0);
}

/* === Tables === */
.table-section {
    margin-bottom: 24px;
}

.table-section > h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 14px;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.filter-input {
    padding: 9px 14px 9px 36px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    width: 280px;
    transition: all var(--transition);
    font-family: inherit;
    background: var(--card-bg) 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='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='M21 21l-4.35-4.35'%3E%3C/path%3E%3C/svg%3E") no-repeat 12px center;
}

.filter-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(216, 78, 85, 0.1);
}

.table-wrapper {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 14px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: color var(--transition);
}

.data-table th:hover {
    color: var(--text);
}

.data-table th.sort-asc::after {
    content: " \25B2";
    font-size: 9px;
    color: var(--primary);
}

.data-table th.sort-desc::after {
    content: " \25BC";
    font-size: 9px;
    color: var(--primary);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #F1F5F9;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: #F8FAFC;
}

.data-table tbody tr:nth-child(even) {
    background: #FCFCFE;
}

.data-table tbody tr:nth-child(even):hover {
    background: #F8FAFC;
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.data-table .bold {
    font-weight: 600;
}

.data-table .green {
    color: var(--accent-green);
    font-weight: 700;
}

.data-table .muted {
    color: var(--text-muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-ac {
    background: #DBEAFE;
    color: #1D4ED8;
}

.badge-sleeper {
    background: #EDE9FE;
    color: #7C3AED;
}

.badge-seater {
    background: #FEF3C7;
    color: #B45309;
}

.badge-scheduled {
    background: #D1FAE5;
    color: #065F46;
    margin-left: 6px;
}

/* Occupancy bar in table cells */
.occ-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.occ-bar-track {
    flex: 1;
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    overflow: hidden;
    min-width: 40px;
}

.occ-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.occ-bar-label {
    font-weight: 700;
    font-size: 12px;
    min-width: 38px;
    text-align: right;
}

/* === History === */
.history-section {
    margin-top: 36px;
    margin-bottom: 24px;
}

.history-section > h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-empty {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 32px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
}

.history-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition);
}

.history-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-color: #D1D5DB;
}

.history-item-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.history-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}

.history-status.completed { background: var(--accent-green); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
.history-status.running { background: var(--accent-yellow); animation: pulse 1.5s infinite; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15); }
.history-status.failed { background: var(--primary); box-shadow: 0 0 0 3px rgba(216, 78, 85, 0.15); }
.history-status.pending { background: #D1D5DB; box-shadow: 0 0 0 3px rgba(209, 213, 219, 0.15); }

.history-route {
    font-weight: 600;
    font-size: 14px;
}

.history-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.history-item-right {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.history-buses {
    font-weight: 700;
    color: var(--text);
    background: #F1F5F9;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
}

.history-status-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    padding: 4px 10px;
    border-radius: 20px;
}

.history-status-label.completed { background: var(--accent-green-bg); color: #059669; }
.history-status-label.running { background: var(--accent-yellow-bg); color: #D97706; }
.history-status-label.failed { background: #FEF2F2; color: var(--primary); }
.history-status-label.pending { background: #F3F4F6; color: var(--text-muted); }

/* === Footer === */
.footer {
    text-align: center;
    padding: 24px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 32px;
}

.footer p {
    opacity: 0.7;
}

/* === Responsive === */
@media (max-width: 1024px) {
    .summary-cards {
        grid-template-columns: repeat(3, 1fr);
    }

    .summary-cards > :nth-child(4),
    .summary-cards > :nth-child(5) {
        grid-column: auto;
    }
}

@media (max-width: 768px) {
    .header-subtitle { display: none; }

    .container {
        padding: 16px;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-cards > :last-child {
        grid-column: span 2;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .input-group {
        flex-direction: column;
    }

    .route-form-row {
        flex-wrap: wrap;
    }

    .route-select {
        flex-basis: 100%;
    }

    .route-date {
        flex: 1;
        width: auto;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .filter-input {
        width: 100%;
    }

    .export-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .summary-card .card-value {
        font-size: 24px;
    }
}
