* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 0; }

/* Panel — mobile: full width bottom sheet style */
#panel {
    position: absolute; top: 8px; left: 8px; right: 8px; z-index: 1000;
    background: white; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    max-height: 50vh; display: flex; flex-direction: column;
    overflow: hidden;
}
#panel-header {
    padding: 14px 16px; border-bottom: 1px solid #e0e0e0;
    font-size: 17px; font-weight: 600; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    min-height: 48px;
}
#panel-header:hover { background: #f5f5f5; }
#panel-toggle { font-size: 14px; color: #888; }
#panel-body { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

.city-group-header {
    padding: 12px 16px; background: #f0f0f0; font-size: 16px; font-weight: 600;
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #e0e0e0; position: sticky; top: 0; z-index: 1;
    min-height: 48px;
}
.city-group-header:hover { background: #e5e5e5; }
.city-group-header .toggle { font-size: 12px; color: #888; }
.city-group-header.active { background: #d0e0f0; }

.district-item {
    padding: 12px 16px 12px 32px; cursor: pointer; border-bottom: 1px solid #f0f0f0;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 15px; min-height: 48px;
}
.district-item:hover { background: #f0f7ff; }
.district-item.active { background: #e3f0ff; font-weight: 600; }
.district-item .meta { color: #888; font-size: 13px; }

.city-districts { display: none; }
.city-districts.open { display: block; }

.collapsed #panel-body, .collapsed #panel-search { display: none; }

#panel-search {
    padding: 10px 12px; border-bottom: 1px solid #e0e0e0;
    display: flex; gap: 8px; align-items: center;
}
#search-input {
    flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid #ddd;
    border-radius: 6px; font-size: 16px; outline: none;
    -webkit-appearance: none;
}
#search-input:focus { border-color: #4a90d9; }

#btn-dashboard {
    white-space: nowrap; padding: 10px 12px; border: 1px solid #ddd;
    border-radius: 6px; background: #f8f8f8; font-size: 14px;
    cursor: pointer; color: #555; flex-shrink: 0;
}
#btn-dashboard:hover { background: #e8e8e8; }
#btn-dashboard.has-tracks { color: #e67e22; border-color: #e67e22; font-weight: 600; }

/* Segment navigation */
#segment-nav {
    position: absolute; bottom: 16px; left: 8px; right: 8px;
    z-index: 1000; background: white; border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25); padding: 12px 14px;
    display: none; align-items: center; justify-content: center;
    gap: 10px; font-size: 15px; flex-wrap: wrap;
}
#segment-nav button {
    border: none; background: #4a90d9; color: white; border-radius: 6px;
    padding: 10px 16px; cursor: pointer; font-size: 15px;
    min-height: 44px;
}
#segment-nav button:hover { background: #3a7bc8; }
#segment-nav button:disabled { background: #ccc; cursor: default; }
#segment-info { min-width: 100px; text-align: center; font-size: 14px; }
#btn-export-route { background: #8e44ad; padding: 10px 12px; font-size: 16px; }
#btn-export-route:hover { background: #7d3c98; }

/* Export menu */
#export-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 3000; background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
}
#export-menu {
    background: white; border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25); padding: 12px 14px;
    display: flex; flex-direction: column; gap: 8px; min-width: 200px;
}
.export-menu-title {
    font-size: 14px; font-weight: 600; text-align: center;
    padding-bottom: 6px; border-bottom: 1px solid #e0e0e0;
}
#export-menu button {
    border: none; border-radius: 6px; padding: 10px 16px;
    cursor: pointer; font-size: 15px; min-height: 44px; width: 100%;
}
#export-menu .export-opt { background: #4a90d9; color: white; }
#export-menu .export-opt:hover { background: #3a7bc8; }
#export-menu .export-cancel { background: #eee; color: #555; }
#export-menu .export-cancel:hover { background: #ddd; }

/* Tracking bar */
#tracking-bar {
    position: absolute; bottom: 16px; left: 8px; right: 8px;
    z-index: 1000; background: white; border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25); padding: 10px 14px;
    display: none; align-items: center; gap: 10px; font-size: 15px;
    flex-wrap: wrap; justify-content: center;
}
#tracking-bar button {
    border: none; border-radius: 6px; padding: 10px 18px;
    cursor: pointer; font-size: 15px; color: white;
    min-height: 44px;
}
#btn-track-start { background: #2ecc40; }
#btn-track-start:hover { background: #27ae36; }
#btn-track-stop { background: #e74c3c; }
#btn-track-stop:hover { background: #c0392b; }
#btn-recenter { background: #3498db; }
#btn-recenter:hover { background: #2980b9; }
#tracking-stats {
    font-size: 14px; color: #555; text-align: center; width: 100%;
}
#segment-tracks {
    width: 100%; border-top: 1px solid #e0e0e0; margin-top: 4px;
    padding-top: 6px; display: none;
}
#segment-tracks .seg-track-title {
    font-size: 12px; color: #888; margin-bottom: 6px; text-align: center;
}
#segment-tracks .seg-track-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 4px; border-bottom: 1px solid #f0f0f0; gap: 8px;
}
#segment-tracks .seg-track-info {
    font-size: 13px; color: #333; flex: 1; min-width: 0;
}
#segment-tracks .seg-track-info span { display: block; }
#segment-tracks .seg-track-meta { font-size: 11px; color: #888; }
#segment-tracks .seg-track-btn {
    border: none; border-radius: 6px; padding: 6px 12px;
    font-size: 13px; cursor: pointer; color: white;
    background: #2ecc40; min-height: 36px; flex-shrink: 0;
}
#segment-tracks .seg-track-btn:hover { background: #27ae36; }

/* Dashboard modal */
#dashboard-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2000; background: rgba(0,0,0,0.4);
    display: flex; align-items: flex-end; justify-content: center;
    padding: 0;
}
#dashboard {
    background: white; border-radius: 14px 14px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
    width: 100%; max-height: 80vh;
    display: flex; flex-direction: column; overflow: hidden;
}
#dashboard-header {
    padding: 16px 18px; border-bottom: 1px solid #e0e0e0;
    font-size: 18px; font-weight: 600;
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0; min-height: 52px;
}
#dashboard-header button {
    border: none; background: none; font-size: 22px; cursor: pointer;
    color: #888; padding: 4px 8px; min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
}
#dashboard-header button:hover { color: #333; }
#dashboard-list { padding: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

.dashboard-empty {
    padding: 32px 16px; text-align: center; color: #999; font-size: 15px;
}

/* Dashboard summary */
.dashboard-summary {
    padding: 16px; background: #f7f9fc; border-bottom: 2px solid #e0e0e0;
}
.summary-title {
    font-size: 14px; font-weight: 600; color: #666; margin-bottom: 10px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.summary-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.summary-stat { text-align: center; }
.summary-value {
    display: block; font-size: 20px; font-weight: 700; color: #1a3a6b;
}
.summary-label {
    display: block; font-size: 12px; color: #888; margin-top: 2px;
}

/* Track items */
.track-item {
    padding: 0; border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
}
.track-item:hover { background: #fafafa; }
.track-item-header {
    padding: 14px 16px; display: flex; justify-content: space-between;
    align-items: center; cursor: pointer; min-height: 52px;
}
.track-item-toggle {
    border: none; background: none; font-size: 14px; color: #888;
    cursor: pointer; padding: 4px 8px; min-width: 40px; min-height: 40px;
    display: flex; align-items: center; justify-content: center;
}
.track-item-title { font-weight: 600; font-size: 15px; }
.track-item-meta { color: #888; font-size: 13px; margin-top: 2px; }

.track-item-details { padding: 0 16px 14px; }
.track-details-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    margin-bottom: 12px; background: #f8f8f8; border-radius: 8px; padding: 12px;
}
.detail-cell { text-align: center; }
.detail-value {
    display: block; font-size: 16px; font-weight: 600; color: #333;
}
.detail-label {
    display: block; font-size: 11px; color: #888; margin-top: 2px;
}

.track-item-actions { display: flex; gap: 8px; }
.track-item-actions button {
    border: none; border-radius: 6px; padding: 8px 16px;
    font-size: 14px; cursor: pointer; color: white;
    min-height: 40px;
}
/* Progress bar */
.track-progress {
    margin-bottom: 10px;
}
.summary-progress {
    margin-bottom: 12px;
}
.progress-bar {
    height: 8px; background: #e0e0e0; border-radius: 4px;
    overflow: hidden; margin-bottom: 4px;
}
.progress-fill {
    height: 100%; background: #2ecc40; border-radius: 4px;
    transition: width 0.3s ease;
}
.progress-text {
    font-size: 12px; color: #666;
}

.track-btn-continue { background: #2ecc40; }
.track-btn-continue:hover { background: #27ae36; }
.track-btn-export { background: #3498db; }
.track-btn-export:hover { background: #2980b9; }
.track-btn-delete { background: #e74c3c; }
.track-btn-delete:hover { background: #c0392b; }

/* Desktop overrides */
@media (min-width: 640px) {
    #panel {
        width: 320px; right: auto; max-height: calc(100vh - 20px);
        top: 10px; left: 10px; border-radius: 8px;
    }
    #segment-nav {
        left: 50%; right: auto; transform: translateX(-50%);
        width: auto; max-width: 500px; bottom: 20px;
        border-radius: 8px;
    }
    #tracking-bar {
        left: 50%; right: auto; transform: translateX(-50%);
        width: auto; max-width: 420px;
        border-radius: 8px;
    }
    #dashboard-modal {
        align-items: center; padding: 0;
    }
    #dashboard {
        width: 440px; max-width: calc(100vw - 40px);
        max-height: calc(100vh - 80px);
        border-radius: 12px;
    }
}
