* { margin: 0; padding: 0; box-sizing: border-box; }

body, html {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: hidden;
}

#map {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: #0a0a0a;
}

/* Dark map tiles — only when .dark-tiles is on the map container */
.dark-tiles .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.6) contrast(1.2); }
.leaflet-control-attribution { display: none; }

/* Dark layer control */
.leaflet-control-layers {
    background: rgba(10, 10, 15, 0.92) !important;
    color: #ccc !important;
    border: 1px solid rgba(0, 229, 255, 0.15) !important;
    border-radius: 6px !important;
    backdrop-filter: blur(8px);
}
.leaflet-control-layers-toggle {
    filter: invert(0.85);
    width: 30px !important;
    height: 30px !important;
}
.leaflet-control-layers label {
    color: #ccc;
    font-size: 0.82rem;
}
.leaflet-control-layers-separator {
    border-top-color: rgba(0, 229, 255, 0.12) !important;
}

/* Upload overlay */
#upload-overlay {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}
#upload-overlay.hidden { display: none; }

#upload-box {
    text-align: center;
    color: #e0e0e0;
    max-width: 420px;
    padding: 3rem;
}
#upload-icon { width: 5rem; height: 5rem; margin: 0 auto 1rem; display: block; }
#upload-box h1 { font-size: 1.6rem; margin-bottom: 0.5rem; color: #fff; font-weight: 300; text-align: center; line-height: 1.4; }
#upload-box h1 strong { font-weight: 700; }
#app-link { color: #fff; text-decoration: none; }
#app-link:hover { color: #00e5ff; }

#upload-label {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: #00e5ff;
    color: #000;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 0.5rem;
}
#upload-label:hover { background: #00b8d4; }
#upload-label input { display: none; }

/* Progress */
#progress-area { margin-top: 1.5rem; }

#progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00e5ff, #00ffc8);
    border-radius: 3px;
    transition: width 0.15s ease;
}

#progress-text {
    margin-top: 0.6rem;
    color: #aaa;
    font-size: 0.85rem;
}
#progress-text.error { color: #ffa000; }

#recent-files {
    margin-top: 1.5rem;
    text-align: left;
}

.recent-files-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    color: #9ab8c0;
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.recent-clear {
    border: none;
    background: transparent;
    color: #6ea9b2;
    cursor: pointer;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.recent-clear:hover {
    color: #00e5ff;
}

.recent-files-empty {
    color: #6b7f86;
    font-size: 0.82rem;
}

.recent-files-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.recent-file-item {
    display: flex;
    align-items: stretch;
    gap: 0.45rem;
}

.recent-file-load,
.recent-file-remove {
    border: 1px solid rgba(0, 229, 255, 0.1);
    background: rgba(255, 255, 255, 0.035);
    color: #e4eef1;
    border-radius: 8px;
}

.recent-file-load {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.recent-file-load:hover {
    background: rgba(0, 229, 255, 0.08);
    border-color: rgba(0, 229, 255, 0.3);
    transform: translateY(-1px);
}

.recent-file-name,
.recent-file-meta {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-file-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #f3fbfd;
}

.recent-file-meta {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #89a0a6;
}

.recent-file-remove {
    width: 36px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 1rem;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.recent-file-remove:hover {
    color: #ffa000;
    border-color: rgba(255, 160, 0, 0.3);
    background: rgba(255, 160, 0, 0.08);
}

#upload-box.dragover {
    outline: 2px dashed #00e5ff;
    outline-offset: 8px;
    border-radius: 16px;
}

/* Trip panel */
#trip-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 800;
    display: flex;
    transition: transform 0.3s ease;
    transform: translateX(320px);
}
#trip-panel.hidden { display: none; }
#trip-panel.open { transform: translateX(0); }

/* Vertical tab on the left edge of the panel */
#panel-tab {
    flex-shrink: 0;
    width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(10, 10, 15, 0.88);
    border-left: 1px solid rgba(0, 229, 255, 0.15);
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    backdrop-filter: blur(12px);
    transition: background 0.2s;
}
#panel-tab:hover { background: rgba(0, 229, 255, 0.08); }

#panel-tab-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: #00e5ff;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    user-select: none;
}

/* Panel body */
#panel-body {
    width: 320px;
    flex-shrink: 0;
    background: rgba(10, 10, 15, 0.92);
    backdrop-filter: blur(12px);
    border-left: 1px solid rgba(0, 229, 255, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Panel header — fixed at top */
#panel-header {
    flex-shrink: 0;
    background: rgba(10, 10, 15, 0.95);
}

/* Panel footer — fixed at bottom */
#panel-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 229, 255, 0.15);
    background: rgba(10, 10, 15, 0.95);
}

#panel-footer .selected-summary {
    border-bottom: none;
    border-top: 1px solid rgba(255, 160, 0, 0.12);
    background: rgba(255, 160, 0, 0.03);
}
#panel-footer .selected-summary .summary-row {
    color: #997a50;
}
#panel-footer .selected-summary .summary-row span {
    color: #ffa000;
}

/* Inline trip detail (inside each trip item) */
.trip-detail-inline {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0;
}

.trip-item.active .trip-detail-inline {
    max-height: 500px;
    padding-top: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    color: #ccc;
    font-size: 0.78rem;
    padding: 2px 0;
}
.detail-row span:first-child { color: #888; }
.detail-row span:last-child { color: #eee; font-weight: 500; }

/* Trip summary */
.trip-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.12);
    background: rgba(0, 229, 255, 0.03);
}

.summary-row {
    color: #888;
    font-size: 0.78rem;
}
.summary-row span {
    color: #00e5ff;
    font-weight: 600;
}

/* All trips checkbox row */
.all-trips-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.08);
    font-size: 0.82rem;
    color: #aaa;
}
.all-trips-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex: 1;
}
.all-trips-row input[type="checkbox"] {
    accent-color: #00e5ff;
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.tree-actions {
    display: flex;
    gap: 6px;
}
.tree-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    font-size: 0.7rem;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}
.tree-btn:hover {
    background: rgba(0, 229, 255, 0.08);
    color: #00e5ff;
}

/* Year groups */
.year-group {
    border-bottom: 1px solid rgba(0, 229, 255, 0.1);
}

.year-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    background: rgba(0, 229, 255, 0.03);
}
.year-header:hover { background: rgba(0, 229, 255, 0.06); }

.year-check {
    accent-color: #00e5ff;
    cursor: pointer;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.year-label {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    flex: 1;
}

.year-meta {
    color: #555;
    font-size: 0.72rem;
}

.year-chevron {
    color: #555;
    font-size: 0.7rem;
    transition: transform 0.2s;
}
.year-group.expanded .year-chevron {
    transform: rotate(180deg);
}

.year-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.year-group.expanded .year-body {
    max-height: 9999px;
}

/* Month groups */
.month-group {
    border-bottom: 1px solid rgba(0, 229, 255, 0.06);
}

.month-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 8px 24px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.month-header:hover { background: rgba(0, 229, 255, 0.04); }

.month-check {
    accent-color: #00e5ff;
    cursor: pointer;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.month-label {
    color: #00e5ff;
    font-size: 0.82rem;
    font-weight: 600;
    flex: 1;
}

.month-meta {
    color: #555;
    font-size: 0.72rem;
}

.month-chevron {
    color: #555;
    font-size: 0.7rem;
    transition: transform 0.2s;
}
.month-group.expanded > .month-header > .month-chevron {
    transform: rotate(180deg);
}

.month-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.month-group.expanded > .month-body {
    max-height: 9999px;
}

/* Trip list */
#trip-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

#trip-list::-webkit-scrollbar { width: 4px; }
#trip-list::-webkit-scrollbar-track { background: transparent; }
#trip-list::-webkit-scrollbar-thumb { background: #00e5ff33; border-radius: 2px; }

.trip-item {
    padding: 10px 16px 10px 32px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}
.trip-item:hover {
    background: rgba(0, 229, 255, 0.06);
}
.trip-item.active {
    background: rgba(255, 160, 0, 0.1);
    border-left-color: #ffa000;
}

.trip-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.trip-check {
    accent-color: #00e5ff;
    cursor: pointer;
    margin-top: 3px;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.trip-info {
    flex: 1;
    min-width: 0;
}

.trip-date {
    color: #e0e0e0;
    font-size: 0.9rem;
    font-weight: 600;
}

.trip-meta {
    color: #777;
    font-size: 0.78rem;
    margin-top: 2px;
}

.inspect-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    color: #666;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.inspect-btn:hover {
    background: rgba(0, 229, 255, 0.1);
    color: #00e5ff;
}

/* Hover tooltip */
#track-tooltip {
    position: fixed;
    z-index: 1100;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #ffa000;
    font-size: 0.82rem;
    border-radius: 5px;
    border: 1px solid rgba(255, 160, 0, 0.3);
    pointer-events: none;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

/* Color indicator squares */
.clr {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

/* Mini chart */
.chart-wrap {
    position: relative;
    margin-top: 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.trip-chart {
    display: block;
    width: 100%;
    height: 80px;
    cursor: crosshair;
}

.chart-tooltip {
    position: absolute;
    top: 4px;
    left: 10px;
    z-index: 10;
    padding: 5px 8px;
    background: rgba(0, 0, 0, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: #eee;
    font-size: 0.72rem;
    line-height: 1.5;
    pointer-events: none;
    white-space: nowrap;
}

/* Footer nav row: Add more | Main screen */
.footer-nav-row {
    display: flex;
    border-bottom: 1px solid rgba(0, 229, 255, 0.08);
}
.footer-nav-row > * {
    flex: 1;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s;
}
.footer-nav-row > * + * {
    border-left: 1px solid rgba(0, 229, 255, 0.08);
}

.add-more-btn, .main-screen-btn { color: #00e5ff; }
.add-more-btn:hover, .add-more-btn.dragover,
.main-screen-btn:hover { background: rgba(0, 229, 255, 0.06); }

/* Export button */
.export-btn {
    display: block;
    text-align: center;
    padding: 8px 16px;
    color: #ffa000;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, opacity 0.2s;
}
.export-btn:hover { background: rgba(255, 160, 0, 0.06); }

/* Paint toggle button */
.paint-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.3;
    margin-right: 4px;
    vertical-align: middle;
    transition: opacity 0.2s, filter 0.2s;
    line-height: 1;
}
.paint-btn:hover { opacity: 0.7; }
.paint-btn.active { opacity: 1; filter: drop-shadow(0 0 4px currentColor); }

/* Track list popup (map click) */
.track-list-popup .leaflet-popup-content-wrapper {
    background: rgba(10, 10, 15, 0.95);
    color: #e0e0e0;
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.track-list-popup .leaflet-popup-tip {
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid rgba(0, 229, 255, 0.2);
}
.track-list-popup .leaflet-popup-close-button {
    color: #888 !important;
}
.track-popup {
    max-height: 200px;
    overflow-y: auto;
}
.track-popup-item {
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: background 0.15s;
    white-space: nowrap;
}
.track-popup-item:hover {
    background: rgba(0, 229, 255, 0.1);
    color: #00e5ff;
}
.track-popup-item span {
    color: #666;
    font-size: 0.75rem;
    margin-left: 6px;
}

.hidden { display: none !important; }

/* Page footer (GitHub link + build version) */
#page-footer {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 11px;
    font-size: 0.72rem;
    color: rgba(220, 230, 235, 0.7);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: 6px;
    backdrop-filter: blur(8px);
    pointer-events: auto;
    user-select: none;
}
#page-footer a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #00e5ff;
    text-decoration: none;
}
#page-footer a:hover { color: #fff; }
#page-footer svg { display: block; }
#page-version {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    opacity: 0.75;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    padding-left: 10px;
}
