* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background: #002b5c; }
.live-wrap { display: flex; height: 100vh; height: 100dvh; width: 100vw; min-height: 0; }
.live-side {
    width: 340px;
    min-width: 280px;
    max-width: 340px;
    background: #fff;
    border-right: 4px solid #ffdd00;
    display: flex;
    flex-direction: column;
    z-index: 500;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}
.live-panel-content { display: flex; flex-direction: column; flex-shrink: 0; }
.bus-marker {
    background: #0A3D91;
    color: #fff;
    border: 2px solid #ffdd00;
    border-radius: 6px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 600;
    font-size: 10px;
    text-align: center;
    line-height: 1.15;
    padding: 2px 3px;
    min-width: 30px;
    min-height: 24px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.live-head { background: #002b5c; color: #ffdd00; padding: 14px 16px; font-weight: 700; letter-spacing: 0.5px; flex-shrink: 0; text-align: center; }
.live-head-title { font-size: 1em; letter-spacing: 0.5px; }
.live-copy { margin-top: 8px; font-size: 0.72em; font-weight: 500; color: #fff; letter-spacing: 0; line-height: 1.35; text-align: center; }
.live-bus-count {
    margin: 10px auto 0;
    display: block;
    width: fit-content;
    background: #ffdd00;
    color: #002b5c;
    font-size: 1.08em;
    font-weight: 800;
    padding: 7px 12px;
    border-radius: 8px;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.live-demo-note {
    margin: 8px 14px 0;
    padding: 8px 10px;
    background: #fff8e1;
    border: 1px solid #ffdd00;
    border-radius: 8px;
    color: #002b5c;
    font-size: 0.78em;
    line-height: 1.4;
    flex-shrink: 0;
}
.live-demo-note a { color: #0A3D91; font-weight: 700; }
.live-meta { padding: 10px 14px; background: #e7f1ff; color: #002b5c; font-size: 0.88em; line-height: 1.45; border-bottom: 1px solid #b6d4fe; flex-shrink: 0; }
.live-meta a { color: #0A3D91; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.map-tools { flex-shrink: 0; }
.map-tools summary { list-style: none; cursor: pointer; }
.map-tools summary::-webkit-details-marker { display: none; }
.fleet-box {
    padding: 12px 14px;
    background: #fff8e1;
    border-bottom: 2px solid #ffdd00;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fleet-box label { font-weight: 700; color: #002b5c; font-size: 0.9em; }
.fleet-box input, .filter-box input, .filter-box select {
    width: 100%; padding: 10px 12px; border: 2px solid #0A3D91; border-radius: 8px; font-size: 0.95em;
}
.fleet-box button, .btn-find {
    width: 100%; padding: 12px; background: #0A3D91; color: #fff; border: none;
    border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 0.95em;
    min-height: 44px;
}
.fleet-box button:hover, .btn-find:hover { background: #002b5c; }
.filter-box {
    padding: 12px 14px;
    background: #e7f1ff;
    border-bottom: 2px solid #0A3D91;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
.filter-box h3 {
    margin: 0;
    font-size: 0.9em;
    color: #002b5c;
    letter-spacing: 0.2px;
}
.filter-box label { font-weight: 700; color: #002b5c; font-size: 0.9em; }
.filter-box .filter-hint {
    margin: 0;
    font-size: 0.78em;
    color: #0A3D91;
    line-height: 1.35;
}
.live-detail {
    padding: 12px 14px;
    background: #f8f9fa;
    border-top: 2px solid #0A3D91;
    font-size: 0.88em;
    line-height: 1.5;
    min-height: 120px;
    flex-shrink: 0;
}
.map-area { flex: 1; position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.map-canvas {
    flex: 1;
    position: relative;
    min-height: 0;
    min-width: 0;
}
#map { position: absolute; inset: 0; z-index: 1; }
.leaflet-control-zoom {
    border: 2px solid #ffdd00 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}
.leaflet-control-zoom a {
    background: #002b5c !important;
    color: #ffdd00 !important;
    border-color: #ffdd00 !important;
    font-size: 22px !important;
    font-weight: 800 !important;
    width: 42px !important;
    height: 42px !important;
    line-height: 38px !important;
    text-align: center;
}
.leaflet-control-zoom a:hover,
.leaflet-control-zoom a:focus {
    background: #0A3D91 !important;
    color: #fff !important;
}
.leaflet-touch .leaflet-control-zoom-in,
.leaflet-touch .leaflet-control-zoom-out {
    font-size: 24px !important;
    line-height: 40px !important;
}
.leaflet-bottom.leaflet-right .leaflet-control-zoom {
    margin-bottom: calc(14px + env(safe-area-inset-bottom, 0));
    margin-right: 12px;
}
.mobile-map-controls {
    display: none;
    flex-shrink: 0;
    z-index: 850;
    background: rgba(0, 43, 92, 0.96);
    color: #fff;
    padding: 10px 10px calc(10px + env(safe-area-inset-top, 0));
    border-bottom: 3px solid #ffdd00;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.mobile-map-controls .mobile-title {
    font-weight: 800;
    color: #ffdd00;
    font-size: 0.92em;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}
.mobile-map-controls .mobile-row-type {
    margin-bottom: 8px;
}
.mobile-map-controls .mobile-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.mobile-map-controls select,
.mobile-map-controls input {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border: 2px solid #ffdd00;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    color: #002b5c;
}
.mobile-map-controls .route-input { flex: 0.8; }
.mobile-map-controls .btn-apply {
    flex: 0 0 auto;
    padding: 10px 14px;
    background: #ffdd00;
    color: #002b5c;
    border: none;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.88em;
    min-height: 44px;
    cursor: pointer;
}
.mobile-map-controls .mobile-meta {
    margin-top: 8px;
    font-size: 0.72em;
    line-height: 1.35;
    color: #e7f1ff;
}
.mobile-map-controls .mobile-meta a {
    color: #ffdd00;
    font-weight: 700;
    text-decoration: none;
}
.mobile-bus-card {
    display: none;
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0));
    z-index: 860;
    background: #fff;
    border: 3px solid #0A3D91;
    border-radius: 10px;
    padding: 12px 36px 12px 12px;
    font-size: 0.86em;
    line-height: 1.45;
    color: #002b5c;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    max-height: 38vh;
    overflow-y: auto;
}
.mobile-bus-card.open { display: block; }
.mobile-bus-card-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: #002b5c;
    color: #ffdd00;
    border-radius: 6px;
    font-size: 1.2em;
    line-height: 1;
    cursor: pointer;
    font-weight: 700;
}
.bus-detail-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3100;
    background: rgba(0, 43, 92, 0.82);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.bus-detail-modal-overlay.open { display: flex; }
.bus-detail-modal {
    width: min(680px, 94vw);
    max-height: min(88vh, 820px);
    background: #fff;
    border: 4px solid #ffdd00;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}
.bus-detail-modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #002b5c;
    color: #ffdd00;
    padding: 12px 16px;
    font-weight: 700;
}
.bus-detail-modal-head h2 {
    margin: 0;
    flex: 1;
    font-size: 0.95em;
    letter-spacing: 0.3px;
}
.bus-detail-modal-head button {
    padding: 7px 12px;
    border: 2px solid #ffdd00;
    border-radius: 8px;
    background: #0A3D91;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.82em;
}
.bus-detail-modal-head button:hover { background: #ffdd00; color: #002b5c; }
.bus-detail-modal-body-wrap {
    flex: 1;
    overflow: auto;
    padding: 14px 16px;
    color: #002b5c;
    font-size: 0.88em;
    line-height: 1.45;
}
.bus-detail-modal-detail {
    padding: 10px 12px;
    background: #e7f1ff;
    border-left: 4px solid #0A3D91;
    border-radius: 4px;
    margin-bottom: 12px;
}
.bus-detail-modal-gps,
.bus-detail-modal-location {
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #b6d4fe;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 0.92em;
}
.bus-detail-modal-map-wrap {
    margin-top: 4px;
}
.bus-detail-modal-map-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #002b5c;
    border: 2px solid #0A3D91;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}
.bus-detail-map-layer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 2px solid #ffdd00;
    border-radius: 8px;
    background: #0A3D91;
    color: #fff;
    cursor: pointer;
}
.bus-detail-map-layer:hover,
.bus-detail-map-layer.active {
    background: #ffdd00;
    color: #002b5c;
}
.bus-detail-map-layer-icon {
    width: 22px;
    height: 22px;
    fill: currentColor;
    stroke: currentColor;
}
.bus-detail-modal-map {
    height: 260px;
    border: 2px solid #0A3D91;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}
.bus-detail-modal-pin {
    width: 18px;
    height: 18px;
    border: 3px solid #ffdd00;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.live-error { display: none; position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 900; background: #f8d7da; border: 1px solid #f5c2c7; color: #842029; padding: 10px 14px; border-radius: 8px; max-width: 90%; font-size: 0.9em; }
.direction-legend {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 750;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: rgba(0, 43, 92, 0.9);
    border: 2px solid #ffdd00;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}
.direction-legend-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.direction-legend-bus {
    display: inline-block;
    border: 2px solid #ffdd00;
    border-radius: 6px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 600;
    font-size: 9px;
    line-height: 1.1;
    padding: 3px 5px;
    min-width: 30px;
    min-height: 22px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    -webkit-font-smoothing: antialiased;
}
.direction-legend-bus.inbound { background: #2B6CB8; color: #fff; }
.direction-legend-bus.outbound { background: #1b5e20; color: #fff; }
.direction-legend-bus.deadhead { background: #5c636a; color: #fff; }
.direction-legend-label {
    font-size: 0.72em;
    font-weight: 800;
    color: #ffdd00;
    letter-spacing: 0.45px;
}
.bus-marker.deadhead {
    font-size: 8px;
    min-width: 34px;
    min-height: 32px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.1;
}
.bus-marker.deadhead .fleet-num {
    display: block;
    font-size: 8px;
    font-weight: 500;
    line-height: 1.1;
    margin-top: 1px;
}
.bus-marker small { font-size: 7px; font-weight: 500; line-height: 1.05; }
.map-area .leaflet-marker-icon,
.map-canvas .leaflet-marker-icon {
    overflow: visible !important;
}
.bus-marker.selected {
    background: #ffdd00 !important;
    color: #000 !important;
    border: 3px solid #002b5c !important;
    transform: scale(2);
    transform-origin: 50% 50%;
    box-shadow: 0 0 0 4px rgba(255,221,0,0.55), 0 3px 10px rgba(0,0,0,0.45);
    z-index: 2;
}
.bus-marker.selected small { color: #000 !important; }
@media (min-width: 901px) {
    .mobile-map-controls { display: none !important; }
}
@media (max-width: 900px) {
    .live-wrap { flex-direction: column; }
    .live-side { display: none !important; }
    .map-area {
        flex: 1 1 auto;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
    }
    .mobile-map-controls { display: block; }
    .leaflet-bottom.leaflet-right .leaflet-control-zoom {
        margin-bottom: calc(72px + env(safe-area-inset-bottom, 0));
    }
    .live-error { top: 12px; max-width: calc(100% - 20px); }
    .bus-marker { font-size: 9px; min-width: 28px; }
}
