* { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; height: auto; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f5f5; color: #333; }

/* Navbar */
.navbar { background: #2c3e50; padding: 0.75rem 1rem; padding-top: max(0.75rem, env(safe-area-inset-top)); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.nav-brand { color: white; font-size: 1.3rem; font-weight: bold; text-decoration: none; }
.nav-toggle { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; display: none; }
.nav-links { display: flex; gap: 1rem; align-items: center; }
.nav-links a { color: #ecf0f1; text-decoration: none; font-size: 0.95rem; padding: 0.25rem 0.5rem; border-radius: 4px; }
.nav-links a:hover { background: #34495e; }

/* Minimal navbar (logged-out landing) */
.navbar-minimal { background: transparent; position: absolute; top: 0; left: 0; right: 0; z-index: 500; }
.navbar-minimal .nav-brand { text-shadow: 0 1px 4px rgba(0,0,0,0.4); }
.nav-links-minimal { display: flex; gap: 0.6rem; align-items: center; }
.btn-nav-minimal {
    text-decoration: none; font-size: 0.85rem; font-weight: 600;
    padding: 0.4rem 1rem; border-radius: 20px; transition: transform 0.12s, box-shadow 0.12s;
    white-space: nowrap;
}
.btn-nav-minimal:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,0.2); text-decoration: none; }
.btn-nav-in { background: white; color: #2c3e50; }
.btn-nav-belong { background: transparent; color: white; border: 1.5px solid rgba(255,255,255,0.7); }

@media (max-width: 600px) {
    .nav-toggle { display: block; }
    .nav-links { display: none; width: 100%; flex-direction: column; align-items: flex-start; padding-top: 0.5rem; }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 0.5rem 0; width: 100%; }
    .nav-links-minimal { display: flex !important; flex-direction: row !important; width: auto !important; padding-top: 0 !important; }
    .nav-links-minimal a { padding: 0.4rem 0.75rem !important; width: auto !important; }
}

/* Container */
.container { max-width: 960px; margin: 1.5rem auto; padding: 0 1rem; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Cards */
.card { background: white; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); padding: 1.25rem; margin-bottom: 1rem; }
.card h2 { margin-bottom: 0.5rem; }
.card p { color: #666; font-size: 0.95rem; }
.card-meta { font-size: 0.85rem; color: #999; margin-top: 0.5rem; }

/* Buttons */
.btn { display: inline-block; padding: 0.5rem 1.1rem; border-radius: 6px; border: none; cursor: pointer; font-size: 0.95rem; text-decoration: none; }
.btn-primary { background: #2c3e50; color: white; }
.btn-primary:hover { background: #34495e; }
.btn-danger { background: #e74c3c; color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-secondary { background: #95a5a6; color: white; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #ddd; border-radius: 6px; font-size: 1rem; }
.form-group textarea { resize: vertical; min-height: 100px; }

/* Map */
#map { height: 450px; width: 100%; border-radius: 8px; margin: 1rem 0; }
@media (max-width: 600px) { #map { height: 300px; } }

/* GPX hover tooltip */
.gpx-tooltip { background: rgba(0,0,0,0.78); color: #fff; border: none; border-radius: 5px; padding: 0.3rem 0.6rem; font-size: 0.8rem; line-height: 1.4; box-shadow: 0 2px 6px rgba(0,0,0,0.35); white-space: nowrap; }
.gpx-tooltip::before { display: none; }

/* Track Info panel */
.gpx-info-panel { background: white; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.22); font-size: 0.8rem; max-width: 240px; overflow: hidden; }
.gpx-info-toggle { display: block; width: 100%; background: none; border: none; padding: 0.5rem 0.75rem; font-size: 0.8rem; font-weight: 600; cursor: pointer; text-align: left; color: #2c3e50; }
.gpx-info-toggle:hover { background: #f4f6f7; }
.gpx-info-body { display: none; border-top: 1px solid #eee; padding: 0.5rem 0.75rem; }
.gpx-info-panel.open .gpx-info-body { display: block; }
.gpx-info-row { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.5rem; }
.gpx-info-swatch { flex-shrink: 0; width: 20px; height: 4px; border-radius: 2px; margin-top: 0.45rem; }
.gpx-info-label { color: #2c3e50; line-height: 1.4; }
.gpx-info-time { color: #666; font-size: 0.75rem; }
.gpx-info-dist { color: #888; font-size: 0.75rem; }
.gpx-info-total { border-top: 1px solid #eee; margin-top: 0.35rem; padding-top: 0.35rem; font-weight: 600; color: #2c3e50; }

/* Public join banner (shown to logged-out visitors on trip pages) */
.public-join-banner { background: linear-gradient(135deg, #2c3e50, #3498db); color: white; border-radius: 8px; padding: 0.85rem 1.1rem; margin-bottom: 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.95rem; }
.public-join-banner .btn-primary { background: white; color: #2c3e50; font-weight: 600; }
.public-join-banner .btn-primary:hover { background: #ecf0f1; }

/* ── Explore page ──────────────────────────────────────── */
.explore-hero { background: linear-gradient(135deg, #2c3e50 0%, #3d566e 100%); color: white; border-radius: 12px; padding: 3.5rem 2rem; margin-bottom: 2rem; text-align: center; }
.explore-hero-title { font-size: 2.8rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
.explore-hero-sub { font-size: 1.15rem; opacity: 0.85; }
@media (max-width: 600px) { .explore-hero { padding: 2.5rem 1rem; } .explore-hero-title { font-size: 2rem; } }

.explore-toolbar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
.explore-search { flex: 1; min-width: 200px; padding: 0.6rem 0.9rem; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95rem; }
.explore-filter-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.explore-filter-btn { padding: 0.45rem 0.9rem; border: 1px solid #ddd; border-radius: 20px; background: white; font-size: 0.85rem; cursor: pointer; transition: all 0.15s; color: #555; }
.explore-filter-btn:hover { border-color: #2c3e50; color: #2c3e50; }
.explore-filter-btn.active { background: #2c3e50; color: white; border-color: #2c3e50; }

.explore-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
@media (max-width: 480px) { .explore-grid { grid-template-columns: 1fr; } }

.explore-card { text-decoration: none; color: inherit; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: transform 0.18s, box-shadow 0.18s; display: flex; flex-direction: column; }
.explore-card:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.13); }

.explore-card-visual { position: relative; height: 190px; background: #ecf0f1; overflow: hidden; flex-shrink: 0; }
.explore-card-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.explore-card-svg { position: absolute; bottom: 0; right: 0; width: 80px; height: 52px; background: rgba(255,255,255,0.92); border-top-left-radius: 8px; padding: 4px; }
.explore-card-svg-full { position: static; width: 100%; height: 100%; background: #f8f9fa; border-radius: 0; padding: 8px; }
.explore-card-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3.5rem; background: #ecf0f1; }

.explore-card-badges { position: absolute; top: 0.6rem; left: 0.6rem; display: flex; gap: 0.3rem; flex-wrap: wrap; }
.explore-badge { font-size: 0.7rem; font-weight: 700; padding: 0.2rem 0.5rem; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.explore-badge-live { background: #27ae60; color: white; }
.explore-badge-paused { background: #f39c12; color: white; }
.explore-badge-done { background: #2c3e50; color: white; }

.explore-card-body { padding: 0.9rem 1rem 1rem; flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.explore-card-title { font-size: 1rem; font-weight: 700; color: #2c3e50; line-height: 1.3; }
.explore-card-desc { font-size: 0.82rem; color: #777; line-height: 1.45; flex: 1; }
.explore-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 0.5rem; }
.explore-card-author { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: #555; }
.explore-card-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; border: 1px solid #ddd; }
.explore-card-avatar-placeholder { display: flex; align-items: center; justify-content: center; background: #ecf0f1; font-size: 0.75rem; }
.explore-card-stats { display: flex; gap: 0.6rem; font-size: 0.78rem; color: #999; }

.explore-pagination { display: flex; align-items: center; justify-content: center; gap: 1.5rem; padding: 1.5rem 0 2rem; }

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.photo-thumb { position: relative; overflow: hidden; border-radius: 6px; cursor: pointer; aspect-ratio: 1; }
.photo-thumb img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.photo-thumb:hover img { transform: scale(1.05); }

/* Lightbox */
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9999; justify-content: center; align-items: center; padding: 1rem; }
.lightbox.active { display: flex; flex-direction: column; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 6px; }
.lightbox-caption { color: white; margin-top: 0.75rem; font-size: 1rem; }
.lightbox-close { position: absolute; top: 1rem; right: 1.25rem; color: white; font-size: 2rem; cursor: pointer; line-height: 1; }
.lightbox-menu-wrap { position: absolute; top: 1rem; right: 3.75rem; }
.lightbox-menu-btn { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.35); border-radius: 6px; padding: 0.15rem 0.55rem; cursor: pointer; font-size: 1.3rem; letter-spacing: 1px; line-height: 1.4; }
.lightbox-menu-btn:hover { background: rgba(255,255,255,0.28); }
.lightbox-menu { display: none; position: absolute; top: calc(100% + 0.4rem); right: 0; background: white; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.35); min-width: 190px; overflow: hidden; z-index: 10000; }
.lightbox-menu.open { display: block; }
.lightbox-menu-item { display: block; width: 100%; padding: 0.65rem 1rem; background: none; border: none; text-align: left; cursor: pointer; font-size: 0.9rem; color: #2c3e50; white-space: nowrap; }
.lightbox-menu-item:hover { background: #f5f6f7; }
.lightbox-menu-item.is-cover { color: #f39c12; font-weight: 600; cursor: default; }

/* Marker drop animation (new real-time markers only) */
@keyframes markerDrop {
    0%   { transform: translateY(-28px); opacity: 0; }
    65%  { transform: translateY(5px);   opacity: 1; }
    100% { transform: translateY(0);     opacity: 1; }
}
.marker-drop { animation: markerDrop 0.35s ease-out forwards; }

/* Live member badge */
.live-badge { background: white; padding: 0.35rem 0.65rem; border-radius: 20px; box-shadow: 0 2px 6px rgba(0,0,0,0.2); font-size: 0.8rem; font-weight: 500; white-space: nowrap; line-height: 1.4; }
.live-dot { font-size: 0.65rem; vertical-align: middle; }
.live-dot-sse         { color: #27ae60; }
.live-dot-poll        { color: #f39c12; }
.live-dot-connecting  { color: #bdc3c7; }


/* Comments */
.comment { padding: 0.75rem 0; border-bottom: 1px solid #eee; }
.comment-author { font-weight: bold; font-size: 0.9rem; }
.comment-body { margin-top: 0.25rem; }
.comment-meta { font-size: 0.8rem; color: #999; margin-top: 0.25rem; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.5rem; }
.page-header h1 { font-size: 1.6rem; }

/* Trip two-column layout */
@media (max-width: 700px) {
    .trip-main-content,
    .trip-sidebar {
        grid-column: 1 / -1;
    }
    div[style*="grid-template-columns:1fr 260px"] {
        grid-template-columns: 1fr !important;
    }
}

.trip-sidebar .card {
    margin-bottom: 0.75rem;
}

/* Trip stats page */
#stats-map { height: 250px; width: 100%; border-radius: 8px; margin-bottom: 1rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 0.85rem; margin-bottom: 1rem; }
.stat-card { background: white; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); padding: 1.1rem 0.9rem; text-align: center; }
.stat-emoji { font-size: 1.4rem; line-height: 1; }
.stat-number { font-size: 1.9rem; font-weight: 700; color: #2c3e50; line-height: 1.1; margin: 0.2rem 0 0; }
.stat-label { font-size: 0.75rem; color: #888; margin-top: 0.3rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-sub { font-size: 0.78rem; color: #aaa; margin-top: 0.15rem; }
.stat-card.highlight { border-left: 3px solid #2980b9; }
.word-cloud-wrap { background: white; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); padding: 1.5rem; margin-bottom: 1rem; }
.word-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem 0.85rem; align-items: center; justify-content: center; min-height: 80px; padding: 0.5rem 0; }
.wc-word { font-weight: 600; cursor: default; line-height: 1.2; transition: opacity 0.15s; }
.wc-word:hover { opacity: 0.65; }
.member-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid #f0f0f0; }
.member-row:last-child { border-bottom: none; }
.member-bar-wrap { flex: 1; }
.member-bar { background: #ecf0f1; border-radius: 4px; height: 7px; margin-top: 0.3rem; overflow: hidden; }
.member-bar-fill { background: #2980b9; height: 100%; border-radius: 4px; }
@media (max-width: 600px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

/* ── PWA ──────────────────────────────────────────────────────────────────── */

/* Connection indicator pill (in navbar) */
.connection-pill { display: none; font-size: 0.75rem; padding: 0.2rem 0.6rem; border-radius: 12px; font-weight: 500; white-space: nowrap; }
.conn-offline  { background: #f39c12; color: white; }
.conn-syncing  { background: #3498db; color: white; }
.conn-synced   { background: #27ae60; color: white; }

/* Queue banner — shown inside .container when entries are queued */
#queue-banner { display: none; background: #f39c12; color: white; text-align: center; padding: 0.5rem 1rem; font-size: 0.875rem; margin-bottom: 0.75rem; border-radius: 6px; }

/* Cached-page banner */
#cached-banner { display: none; background: #f39c12; color: white; text-align: center; padding: 0.4rem 1rem; font-size: 0.8rem; margin-bottom: 0.75rem; border-radius: 6px; }

/* Floating sync/queue toast */
.pwa-toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(120px); color: white; padding: 0.65rem 1.25rem; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.25); font-size: 0.9rem; z-index: 9999; transition: transform 0.3s ease; white-space: nowrap; pointer-events: none; }
.pwa-toast.show { transform: translateX(-50%) translateY(0); }

/* iOS install banner (top of page) */
#ios-install-banner { display: none; background: #2c3e50; color: white; padding: 0.75rem 2.5rem 0.75rem 1rem; font-size: 0.85rem; line-height: 1.5; position: relative; text-align: center; }
#ios-install-banner .install-close { position: absolute; top: 50%; right: 0.75rem; transform: translateY(-50%); background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; line-height: 1; padding: 0.25rem; }

/* Android/Chrome install banner (bottom of screen) */
#install-banner { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: white; border-top: 2px solid #ecf0f1; padding: 0.85rem 1rem; align-items: center; justify-content: space-between; gap: 1rem; box-shadow: 0 -4px 12px rgba(0,0,0,0.1); z-index: 1000; font-size: 0.9rem; }
#install-banner .install-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ── Trip Replay Overlay ──────────────────────────────────────────────────── */

/* Overlay: flex column so map and controls stack vertically */
#replay-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 10000; flex-direction: column; }
#replay-overlay.active { display: flex; }

/* Map section: flex:3 = 75% of the space */
#replay-map-wrap { flex: 3; min-height: 0; position: relative; overflow: hidden; }
#replay-map { width: 100%; height: 100%; }

/* Close button — top-right corner of the map section */
#replay-topbar { position: absolute; top: 0; right: 0; padding: 0.75rem; z-index: 10001; }
#replay-close-btn { background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.3); color: white; border-radius: 6px; padding: 0.6rem 0.9rem; cursor: pointer; font-size: 1rem; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
#replay-close-btn:hover { background: rgba(255,255,255,0.2); }

/* Controls section: flex:1 = 25% of the space */
#replay-controls { flex: 1; min-height: 0; background: rgba(0,0,0,0.85); padding: 1rem; display: flex; flex-direction: column; justify-content: center; gap: 0.75rem; color: white; overflow: hidden; }

/* Scrubber */
#replay-scrubber-wrap { padding: 0.5rem 0 0.25rem; cursor: pointer; user-select: none; }
#replay-scrubber-track { position: relative; height: 5px; background: rgba(255,255,255,0.18); border-radius: 3px; margin-top: 1.5rem; }
#replay-scrubber-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #3498db; border-radius: 3px; width: 0%; pointer-events: none; }
#replay-scrubber-thumb { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 18px; height: 18px; background: white; border-radius: 50%; left: 0%; cursor: grab; box-shadow: 0 1px 4px rgba(0,0,0,0.5); z-index: 1; }
#replay-scrubber-thumb:active { cursor: grabbing; }
.replay-day-tick { position: absolute; top: -7px; transform: translateX(-50%); width: 1px; height: 19px; background: rgba(255,255,255,0.28); pointer-events: none; }
.replay-day-label { position: absolute; top: -20px; transform: translateX(-50%); font-size: 0.6rem; color: rgba(255,255,255,0.45); white-space: nowrap; pointer-events: none; }
.replay-ev-dot { position: absolute; top: 50%; transform: translate(-50%,-50%); width: 7px; height: 7px; border-radius: 50%; pointer-events: none; }

/* Transport buttons row — centered */
#replay-transport { display: flex; align-items: center; justify-content: center; gap: 0.6rem; }

/* All control buttons — 44px minimum touch target */
.replay-ctrl-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18); color: white; border-radius: 6px; padding: 0.6rem; cursor: pointer; font-size: 1.4rem; line-height: 1; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.replay-ctrl-btn:hover { background: rgba(255,255,255,0.22); }
.replay-ctrl-btn.active { background: #2980b9; border-color: #3498db; }

/* Speed buttons — same height, smaller text */
.replay-speed-btn { font-size: 0.85rem; padding: 0.6rem 0.5rem; }

/* Bottom row: timestamp + speed */
#replay-bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
#replay-timestamp { color: white; font-size: 1rem; font-weight: 500; opacity: 0.9; }
#replay-speed-wrap { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
#replay-speed-label { font-size: 0.8rem; opacity: 0.6; margin-right: 0.1rem; }

/* Mobile: 65% map / 35% controls when screen height is tight */
@media (max-height: 600px) {
    #replay-map-wrap { flex: 65; }
    #replay-controls { flex: 35; gap: 0.4rem; padding: 0.6rem 1rem; }
    .replay-ctrl-btn { font-size: 1.2rem; }
}

/* Very small phones: stack bottom row */
@media (max-width: 380px) {
    #replay-bottom-row { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
}

/* Loading screen */
#replay-loading { display: none; position: absolute; inset: 0; background: rgba(0,0,0,0.82); z-index: 10002; align-items: center; justify-content: center; flex-direction: column; color: white; gap: 0.85rem; font-size: 1rem; }
#replay-loading.show { display: flex; }
.replay-loading-icon { font-size: 2.8rem; animation: replaySpin 2s linear infinite; }
@keyframes replaySpin { to { transform: rotate(360deg); } }

/* ── Fuel timeline (view_trip sidebar) ── */
.fuel-timeline-item { display: flex; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid #f0f0f0; align-items: flex-start; }
.fuel-timeline-item:last-child { border-bottom: none; }
.fuel-timeline-icon { font-size: 1.4rem; line-height: 1; flex-shrink: 0; margin-top: 0.1rem; }
.fuel-timeline-body { flex: 1; min-width: 0; }
.fuel-timeline-header { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.fuel-timeline-stats { font-size: 0.78rem; color: #777; margin-top: 0.15rem; }
.fuel-type-badge { display: inline-block; background: #fff3e0; color: #e67e22; border: 1px solid #f5cba7; border-radius: 4px; padding: 0.15rem 0.45rem; font-size: 0.72rem; font-weight: 600; vertical-align: middle; }
.fuel-cost-total { font-size: 0.85rem; background: #eafaf1; color: #1e8449; border-radius: 4px; padding: 0.2rem 0.5rem; font-weight: 700; white-space: nowrap; }

/* ── Expense category picker ── */
.expense-category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.4rem; }
.expense-cat-btn { display: flex; align-items: center; justify-content: center; text-align: center; padding: 0.5rem 0.4rem; border: 2px solid #ddd; border-radius: 8px; cursor: pointer; font-size: 0.82rem; line-height: 1.2; transition: border-color 0.15s, background 0.15s; user-select: none; }
.expense-cat-btn input[type=radio] { display: none; }
.expense-cat-btn:hover { border-color: #8e44ad; background: #f9f0ff; }
.expense-cat-btn.selected { border-color: #8e44ad; background: #f0e6f6; font-weight: 600; }
.expense-cat-badge { display: inline-block; background: #f0e6f6; color: #8e44ad; border: 1px solid #d7b8ed; border-radius: 4px; padding: 0.15rem 0.45rem; font-size: 0.72rem; font-weight: 600; }

/* ── Costs page ── */
.costs-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.75rem; }
.costs-stat { display: flex; flex-direction: column; background: #f8f9fa; border-radius: 8px; padding: 0.6rem 0.75rem; }
.costs-stat-val { font-size: 1.15rem; font-weight: 700; color: #2c3e50; line-height: 1.1; }
.costs-stat-lbl { font-size: 0.72rem; color: #888; margin-top: 0.2rem; }

.costs-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.costs-table th { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 2px solid #e0e0e0; color: #555; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.costs-table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.costs-table tr:last-child td { border-bottom: none; }
.costs-table tr:hover td { background: #fafafa; }

/* ── Settle up ── */
.settle-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap; font-size: 0.9rem; }
.settle-row:last-child { border-bottom: none; }
.settle-debtor { font-weight: 600; color: #e74c3c; }
.settle-arrow { color: #aaa; font-size: 0.8rem; }
.settle-creditor { font-weight: 600; color: #27ae60; }
.settle-amount { margin-left: auto; font-weight: 700; color: #2c3e50; }

/* ── Print ── */
@media print {
    .no-print { display: none !important; }
    body { background: white; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── Grand Map ── */

/* View switcher */
.gm-switcher { display: flex; gap: 0.4rem; flex-wrap: wrap; padding: 0.75rem 0 0; margin-bottom: 0.5rem; }
.gm-sw-btn { display: inline-block; padding: 0.35rem 0.85rem; border-radius: 20px; border: 2px solid #ddd; color: #555; font-size: 0.85rem; font-weight: 500; text-decoration: none; background: white; transition: all 0.15s; }
.gm-sw-btn:hover { border-color: #2980b9; color: #2980b9; }
.gm-sw-btn.active { background: #2c3e50; border-color: #2c3e50; color: white; }

/* Page header */
.gm-page-header { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.gm-title { font-size: 1.6rem; font-weight: 800; color: #2c3e50; }
.gm-trip-count { font-size: 0.9rem; color: #999; }

/* Map outer: full-width breakout from .container */
.gm-map-outer {
    position: relative;
    width: 100vw;
    left: 50%;
    transform: translateX(-50%);
    height: 65vh;
    min-height: 340px;
    max-height: 700px;
    margin-bottom: 0;
}
#gm-map { width: 100%; height: 100%; }

/* Legend */
.gm-legend {
    position: absolute; top: 10px; right: 10px; z-index: 1000;
    background: white; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.22);
    max-width: 220px; min-width: 140px; overflow: hidden;
}
.gm-legend-head { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.6rem; border-bottom: 1px solid #eee; gap: 0.3rem; }
.gm-legend-title { font-size: 0.8rem; font-weight: 700; color: #2c3e50; }
.gm-legend-controls { display: flex; align-items: center; gap: 0.25rem; }
.gm-legend-ctrl { background: none; border: none; font-size: 0.7rem; color: #2980b9; cursor: pointer; padding: 0.1rem 0.25rem; border-radius: 3px; }
.gm-legend-ctrl:hover { background: #eaf4fb; }
.gm-legend-toggle { background: none; border: none; font-size: 0.75rem; color: #555; cursor: pointer; padding: 0.15rem 0.3rem; border-radius: 3px; }
.gm-legend-toggle:hover { background: #f0f0f0; }
.gm-legend-body { max-height: 260px; overflow-y: auto; padding: 0.3rem 0; }
.gm-legend-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.65rem; cursor: pointer; transition: background 0.1s; }
.gm-legend-item:hover { background: #f4f6f7; }
.gm-legend-item-hi { background: #eaf4fb !important; }
.gm-legend-swatch { flex-shrink: 0; width: 22px; height: 4px; border-radius: 2px; }
.gm-legend-label { font-size: 0.78rem; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }

/* Heatmap button */
.gm-heat-btn { background: white; border: 2px solid rgba(0,0,0,0.2); border-radius: 4px; padding: 0.4rem 0.7rem; font-size: 0.82rem; cursor: pointer; font-weight: 500; box-shadow: 0 1px 5px rgba(0,0,0,0.2); }
.gm-heat-btn:hover { background: #f0f4f8; }
.gm-heat-btn.active { background: #c0392b; color: white; border-color: #c0392b; }

/* Mobile slide-up trigger */
.gm-show-trips-btn {
    display: none;
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    background: #2c3e50; color: white; border: none; border-radius: 20px;
    padding: 0.5rem 1.25rem; font-size: 0.88rem; cursor: pointer; z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

/* Stats bar */
.gm-stats-bar { display: flex; gap: 0; border-top: 3px solid #2c3e50; border-bottom: 3px solid #2c3e50; background: #2c3e50; }
.gm-stat { flex: 1; text-align: center; padding: 0.75rem 0.5rem; border-right: 1px solid rgba(255,255,255,0.12); }
.gm-stat:last-child { border-right: none; }
.gm-stat-val { font-size: 1.5rem; font-weight: 800; color: white; line-height: 1; }
.gm-stat-lbl { font-size: 0.7rem; color: rgba(255,255,255,0.65); margin-top: 0.2rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Trip panel */
.gm-trip-panel { padding: 1rem 0; }

/* Toolbar */
.gm-toolbar { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid #eee; }
.gm-sort-group, .gm-filter-group { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.gm-toolbar-label { font-size: 0.82rem; color: #888; font-weight: 500; }
.gm-sort-btn, .gm-filter-btn { background: white; border: 1px solid #ddd; border-radius: 14px; padding: 0.25rem 0.7rem; font-size: 0.8rem; cursor: pointer; color: #555; transition: all 0.12s; }
.gm-sort-btn:hover, .gm-filter-btn:hover { border-color: #2980b9; color: #2980b9; }
.gm-sort-btn.active, .gm-filter-btn.active { background: #2980b9; border-color: #2980b9; color: white; font-weight: 600; }

/* Card grid */
.gm-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.gm-card { background: white; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); overflow: hidden; text-decoration: none; color: inherit; transition: transform 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; }
.gm-card:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(0,0,0,0.14); }
.gm-card-hi { transform: translateY(-2px) !important; box-shadow: 0 5px 20px rgba(0,0,0,0.22) !important; outline: 3px solid #2980b9; }
.gm-card-visual { position: relative; height: 120px; background: #ecf0f1; overflow: hidden; }
.gm-card-visual img { width: 100%; height: 100%; object-fit: cover; }
.gm-card-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; background: linear-gradient(135deg, #ecf0f1, #d5dbdb); }
.gm-card-color-bar { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; }
.gm-card-badges { position: absolute; top: 6px; left: 6px; }
.gm-card-badge { font-size: 0.68rem; font-weight: 700; padding: 0.15rem 0.4rem; border-radius: 10px; }
.gm-badge-live { background: #27ae60; color: white; }
.gm-badge-paused { background: #f39c12; color: white; }
.gm-badge-done { background: rgba(0,0,0,0.45); color: white; }
.gm-card-body { padding: 0.6rem 0.75rem; flex: 1; display: flex; flex-direction: column; gap: 0.2rem; }
.gm-card-title { font-weight: 700; font-size: 0.88rem; color: #2c3e50; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gm-card-date { font-size: 0.75rem; color: #888; }
.gm-card-meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 0.35rem; }
.gm-card-author { display: flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; color: #666; }
.gm-card-avatar { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }
.gm-card-avatar-ph { display: inline-flex; align-items: center; justify-content: center; background: #ecf0f1; font-size: 0.65rem; }
.gm-card-stats { display: flex; gap: 0.4rem; font-size: 0.72rem; color: #888; }
.gm-card-no-gpx { font-size: 0.68rem; color: #bbb; margin-top: 0.2rem; }

/* Empty state */
.gm-empty { text-align: center; padding: 4rem 1rem; }
.gm-empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.gm-empty p { color: #777; font-size: 1rem; }

/* Mobile overrides */
@media (max-width: 600px) {
    .gm-map-outer { height: 100svh; max-height: 100svh; }
    .gm-show-trips-btn { display: block; }
    .gm-legend { max-width: 170px; }
    .gm-stat-val { font-size: 1.15rem; }
    .gm-stats-bar { overflow-x: auto; }

    /* Trip panel hidden below map on mobile, revealed by button */
    .gm-trip-panel { display: none; }
    .gm-trip-panel.gm-panel-open { display: block; }
}

/* ── Route Planner ── */

/* Header */
.pl-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; padding: 0.75rem 0 0.5rem; }
.pl-header-left { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.pl-back-btn { font-size: 0.85rem; color: #2980b9; text-decoration: none; }
.pl-back-btn:hover { text-decoration: underline; }
.pl-title { font-size: 1.3rem; font-weight: 800; color: #2c3e50; margin: 0; }

/* Notice bar */
.pl-notice { background: #fff3cd; border: 1px solid #ffc107; border-radius: 6px; padding: 0.65rem 1rem; font-size: 0.85rem; margin-bottom: 0.75rem; }

/* Two-column layout */
.pl-layout { display: grid; grid-template-columns: 1fr 320px; gap: 0; align-items: start; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }

/* Map column */
.pl-map-col { position: relative; }
#pl-map { height: 60vh; min-height: 380px; width: 100%; }

/* Sidebar */
.pl-sidebar { background: #fafafa; border-left: 1px solid #e0e0e0; overflow-y: auto; max-height: 60vh; min-height: 380px; display: flex; flex-direction: column; }
.pl-section { padding: 0.75rem 1rem; border-bottom: 1px solid #eee; }
.pl-section:last-child { border-bottom: none; }
.pl-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.pl-section-title { font-size: 0.78rem; font-weight: 700; color: #666; text-transform: uppercase; letter-spacing: 0.05em; }
.pl-section-body { margin-top: 0.4rem; }

/* Engine buttons */
.pl-engine-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.pl-engine-btn { display: flex; flex-direction: column; align-items: center; padding: 0.6rem 0.4rem; border: 2px solid #ddd; border-radius: 8px; background: white; cursor: pointer; font-size: 0.9rem; font-weight: 600; gap: 0.15rem; transition: all 0.12s; line-height: 1.2; }
.pl-engine-btn small { font-size: 0.68rem; font-weight: 400; color: #888; }
.pl-engine-btn:hover:not(:disabled) { border-color: #2980b9; }
.pl-engine-btn.active { border-color: #2980b9; background: #eaf4fb; color: #2980b9; }
.pl-engine-btn-brouter.active { border-color: #27ae60; background: #eafaf1; color: #27ae60; }
.pl-engine-disabled { opacity: 0.45; cursor: not-allowed; }

/* Waypoint rows */
.pl-add-wp-btn { background: none; border: 1px solid #2980b9; color: #2980b9; border-radius: 12px; padding: 0.2rem 0.6rem; font-size: 0.78rem; cursor: pointer; }
.pl-add-wp-btn:hover { background: #eaf4fb; }
.pl-wp-row { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.45rem 0; border-bottom: 1px solid #f0f0f0; }
.pl-wp-row:last-child { border-bottom: none; }
.pl-wp-dot { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.68rem; font-weight: 700; color: white; flex-shrink: 0; margin-top: 3px; }
.pl-wp-inputs { flex: 1; min-width: 0; }
.pl-wp-search-wrap { position: relative; display: flex; gap: 0.25rem; align-items: center; }
.pl-wp-input { flex: 1; min-width: 0; padding: 0.38rem 0.5rem; border: 1px solid #ddd; border-radius: 5px; font-size: 0.82rem; }
.pl-wp-input:focus { outline: none; border-color: #2980b9; }
.pl-wp-loc-btn, .pl-wp-pick-btn { background: none; border: 1px solid #ddd; border-radius: 4px; padding: 0.3rem 0.35rem; cursor: pointer; font-size: 0.78rem; flex-shrink: 0; }
.pl-wp-pick-btn.active { background: #2980b9; border-color: #2980b9; }
.pl-wp-results { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #ddd; border-radius: 0 0 6px 6px; z-index: 2000; box-shadow: 0 4px 12px rgba(0,0,0,0.15); max-height: 200px; overflow-y: auto; }
.pl-geo-result { padding: 0.45rem 0.6rem; cursor: pointer; border-bottom: 1px solid #f5f5f5; }
.pl-geo-result:hover { background: #f0f7ff; }
.pl-geo-name { display: block; font-size: 0.82rem; font-weight: 500; color: #2c3e50; }
.pl-geo-type { font-size: 0.72rem; color: #888; }
.pl-wp-coords { font-size: 0.7rem; color: #aaa; margin-top: 0.15rem; }
.pl-wp-controls { display: flex; flex-direction: column; gap: 0.15rem; flex-shrink: 0; }
.pl-wp-arrow { background: none; border: 1px solid #ddd; border-radius: 3px; width: 22px; height: 20px; cursor: pointer; font-size: 0.65rem; padding: 0; display: flex; align-items: center; justify-content: center; }
.pl-wp-arrow:hover { background: #eee; }
.pl-wp-arrow-ph { display: block; width: 22px; height: 20px; }
.pl-wp-remove { background: none; border: 1px solid #e74c3c; color: #e74c3c; border-radius: 3px; width: 22px; height: 20px; cursor: pointer; font-size: 0.65rem; padding: 0; display: flex; align-items: center; justify-content: center; margin-top: 2px; }

/* Checkboxes */
.pl-checkbox-group { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }
.pl-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: #444; cursor: pointer; }
.pl-check input { cursor: pointer; }

/* Calculate buttons */
.pl-calc-btn { width: 100%; font-size: 0.92rem; padding: 0.6rem; margin-bottom: 0.4rem; }
.pl-compare-btn { width: 100%; font-size: 0.85rem; padding: 0.5rem; }

/* Summary */
.pl-summary { background: #f0f7ff; }
.pl-summary-body { margin-top: 0.4rem; display: flex; flex-direction: column; gap: 0.25rem; }
.pl-summary-row { font-size: 0.88rem; color: #2c3e50; }
.pl-engine-badge { display: inline-block; border-radius: 4px; padding: 0.1rem 0.45rem; font-size: 0.72rem; font-weight: 700; }
.pl-badge-ors { background: #2980b9; color: white; }
.pl-badge-brouter { background: #27ae60; color: white; }

/* Compare table */
.pl-compare-card { background: #f9fff9; }
.pl-cmp-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 0.4rem; }
.pl-cmp-table th { padding: 0.3rem 0.4rem; border-bottom: 2px solid #eee; text-align: center; font-size: 0.75rem; }
.pl-cmp-table td { padding: 0.35rem 0.4rem; border-bottom: 1px solid #f0f0f0; text-align: center; }
.pl-cmp-lbl { text-align: left !important; color: #666; }
.pl-cmp-win { font-weight: 700; color: #27ae60; }

/* Error */
.pl-error { background: #fdf0ed; border: 1px solid #f5c6cb; border-radius: 5px; padding: 0.55rem 0.7rem; font-size: 0.83rem; color: #c0392b; margin: 0; }

/* Actions */
.pl-actions { display: flex; flex-direction: column; gap: 0.4rem; }
.pl-action-btn { width: 100%; font-size: 0.85rem; padding: 0.5rem; }

/* Save modal */
.pl-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.pl-modal { background: white; border-radius: 10px; padding: 1.5rem; width: 100%; max-width: 420px; box-shadow: 0 8px 32px rgba(0,0,0,0.25); }

/* Loading overlay */
.pl-loading { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 9001; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; color: white; font-size: 1rem; }
.pl-spinner { width: 38px; height: 38px; border: 4px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: plSpin 0.75s linear infinite; }
@keyframes plSpin { to { transform: rotate(360deg); } }

/* Mobile: stack layout */
@media (max-width: 700px) {
    .pl-layout { grid-template-columns: 1fr; }
    #pl-map { height: 50vw; min-height: 260px; }
    .pl-sidebar { max-height: none; border-left: none; border-top: 1px solid #e0e0e0; }
}
