/* Shared Design System for Route Tracker - Matching myTools Style */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --border-radius: 8px;
    --transition: all 0.3s ease;
    
    /* Layer-Based Color System - Light Theme (default) */
    --global-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --boxes-bg: #ffffff;
    --boxes-bg-secondary: #fafbfc;
    --button-bg: #3498db;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.15);
}

/* Dark Theme */
[data-theme="dark"] {
    --global-bg: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    --boxes-bg: #4a5568;
    --boxes-bg-secondary: #2d3748;
    --button-bg: #3498db;
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --border-color: #4a5568;
    --shadow: 0 2px 10px rgba(0,0,0,0.4);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.5);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--global-bg);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* Layout */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: var(--boxes-bg);
    padding: 2rem;
    margin: 2rem 2rem 1rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    flex-shrink: 0;
    color: var(--text-primary);
    min-height: 60px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-self: start;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-self: center;
    text-align: center;
    white-space: nowrap;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-self: end;
    min-width: 200px;
    justify-content: flex-end;
}

.app-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.brand-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.brand-version {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.dev-badge {
    background: #ff4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.08em;
    border: none;
    cursor: default;
    line-height: 1;
    vertical-align: middle;
}

button.dev-badge {
    cursor: pointer;
}

/* Sidebar/Navigation */
.sidebar {
    background: var(--boxes-bg);
    padding: 1rem;
    margin: 0 2rem 1rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.nav-icon {
    font-style: normal;
    display: none;
}
.nav-label {
    /* visible on desktop */
}

/* Main Content */
.main-content {
    flex: 1;
    margin: 0 2rem 2rem 2rem;
    display: flex;
    flex-direction: column;
}

/* Cards */
.card {
    background: var(--boxes-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-header {
    text-align: center;
    margin-bottom: 2rem;
}

.card-header h2 {
    color: var(--text-primary);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.card-header h3 {
    color: var(--text-primary);
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.card-header p {
    color: var(--text-secondary);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-input, .form-textarea, .form-select,
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--boxes-bg-secondary);
    color: var(--text-primary);
}

.form-input:focus, .form-textarea:focus, .form-select:focus,
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--secondary-color);
    background: var(--boxes-bg);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Buttons - Text Only, No Icons */
.btn {
    background: var(--button-bg);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-block;
    text-decoration: none;
    color: white;
}

.btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    text-decoration: none;
    color: white;
}

.btn-primary {
    background: var(--button-bg);
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: #219a52;
}

.btn-warning {
    background: var(--warning-color);
}

.btn-warning:hover {
    background: #d68910;
}

.btn-danger {
    background: var(--error-color);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-large {
    width: 100%;
    font-size: 1.1rem;
    padding: 1.25rem 2rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Navigation */
.nav {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.nav-link, .nav-btn {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    background: transparent;
    border: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
}

.nav-link:hover, .nav-btn:hover {
    background: rgba(52, 152, 219, 0.1);
    color: var(--secondary-color);
    text-decoration: none;
    border-color: var(--secondary-color);
}

.nav-link.active, .nav-btn.active {
    background: var(--secondary-color);
    color: white;
}

/* Status Messages */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    margin-bottom: 1rem;
}

.alert-success, .success-message {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error, .error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin: 1rem 0;
}

.table,
/* User card list */
.user-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-card {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    background: var(--boxes-bg-secondary);
}

.user-card-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-card-row-1 {
    margin-bottom: 0.25rem;
}

.user-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-row-2 {
    font-size: 0.78rem;
    color: var(--text-muted);
    gap: 0.6rem;
    flex-wrap: wrap;
}

.user-card-id {
    font-family: monospace;
}

.user-card-email {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-admin {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    white-space: nowrap;
}

.badge-user {
    background: rgba(74, 158, 255, 0.15);
    color: #4a9eff;
    border: 1px solid rgba(74, 158, 255, 0.3);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    white-space: nowrap;
}

.badge-linked-user {
    background: rgba(160, 174, 192, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(160, 174, 192, 0.3);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    white-space: nowrap;
}

.user-default-badge {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Desktop: user cards in 2-column grid */
@media (min-width: 769px) {
    .user-card-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 0.5rem;
    }
}

.users-table {
    width: 100%;
    background: var(--boxes-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th,
.table-header {
    background: var(--light-bg);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
}

.table td,
.table-row {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.table tr:last-child td,
.table-row:last-child {
    border-bottom: none;
}

.table tr:hover,
.table-row:hover {
    background: var(--boxes-bg-secondary);
}

/* Grid layout for table rows */
.table-header,
.table-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 1rem;
    align-items: center;
}

.users-table-with-actions .table-header,
.users-table-with-actions .table-row {
    grid-template-columns: 2fr 1fr 1fr 1.5fr 1fr;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Customer list rows */
.customer-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.customer-list-item {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.55rem 0.75rem;
    background: var(--boxes-bg-secondary);
}

.customer-row-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.2rem;
}

.customer-title {
    font-size: 0.9rem;
    color: var(--text-color);
    word-break: break-word;
}

.customer-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.customer-row-stats {
    font-size: 0.82rem;
    line-height: 1.1;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Token list rows */
.tokens-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.token-item {
    display: grid;
    grid-template-columns: 1.2fr 1.8fr 1fr 0.8fr 1.2fr;
    gap: 0.75rem;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.4rem 0.65rem;
    background: var(--boxes-bg-secondary);
}

.token-cell {
    font-size: 0.85rem;
    line-height: 1.1;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.token-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    justify-content: flex-start;
}

.token-actions .btn-small {
    padding: 0.2rem 0.45rem;
    font-size: 0.75rem;
    line-height: 1;
    white-space: nowrap;
}

.token-status {
    font-size: 0.82rem;
    line-height: 1.1;
    font-weight: 600;
    white-space: nowrap;
}

.token-status.used {
    color: var(--warning-color);
}

.token-status.available {
    color: var(--success-color);
}

/* Device List */
.device-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.device-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.device-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.device-row-1 {
    margin-bottom: 0.25rem;
}

.device-row-2,
.device-row-3 {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.device-id-badge {
    font-family: monospace;
    font-size: 0.78rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    white-space: nowrap;
}

.device-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.device-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

/* Route Management */
.device-route-header {
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
}

.device-route-header p {
    margin: 0.25rem 0;
}

.route-month {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.65rem;
    background: var(--boxes-bg-secondary);
}

.route-month summary {
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
}

.route-day-list {
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid var(--border-color);
}

.route-day-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    margin-bottom: 0.45rem;
    background: var(--boxes-bg);
}

/* Desktop: grid tiles, mobile keeps list */
@media (min-width: 769px) {
    .route-day-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 0.5rem;
        padding: 0.75rem;
    }
    .route-day-item {
        margin-bottom: 0;
    }
}

/* Route preview tooltip (desktop hover) */
.route-preview-tooltip {
    display: none;
    position: fixed;
    z-index: 9999;
    width: 300px;
    height: 210px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
    padding: 4px;
    pointer-events: auto;
    overflow: hidden;
}
.route-preview-tooltip canvas {
    display: block;
    border-radius: 5px;
}
.route-preview-loading,
.route-preview-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.route-day-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.route-day-row-1 {
    margin-bottom: 0.3rem;
}

.route-day-row-2 {
    gap: 0.35rem;
    margin-bottom: 0.3rem;
}

.route-day-row-3 {
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 1.3em;
}

.route-day-perms-inline {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Keep legacy .route-day-perms and .route-day-actions selectors inert */
.route-day-perms { display: none; }
.route-day-actions { display: none; }

.route-mgmt-header {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.route-mgmt-header > .route-mgmt-select {
    width: 100%;
}

.route-mgmt-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.route-mgmt-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    margin: 0;
}

.route-mgmt-select {
    font-size: 0.8rem !important;
    padding: 0.2rem 0.5rem !important;
    height: auto;
    width: auto;
    flex: 1;
    min-width: 0;
    border-radius: var(--border-radius);
}

.route-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.route-header-action-btn {
    width: 2.25rem;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
}

.btn-route-action {
    min-width: 6rem;
    text-align: center;
    background: var(--button-bg);
}

.route-action-btn {
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
}

.btn-route-action:hover {
    background: #2980b9;
}

.btn-route-action.btn-grant {
    background: var(--success-color);
}

.btn-route-action.btn-grant:hover {
    background: #219a52;
}

.btn-route-action.btn-revoke {
    background: var(--error-color);
}

.btn-route-action.btn-revoke:hover {
    background: #c0392b;
}

.btn-route-action.btn-delete {
    background: #e74c3c;
}

.btn-route-action.btn-delete:hover {
    background: #c0392b;
}

.btn.route-gpx-link {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.route-day-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.route-distance {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--boxes-bg-secondary);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
}

/* User dashboard compact shared-routes layout */
.compact-help {
    margin-bottom: 0.45rem;
}

.compact-routes-card {
    padding: 0.8rem 1rem;
}

.shared-routes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem 1rem;
    align-items: end;
}

.compact-form-group {
    margin-bottom: 0;
}

.route-select-inline {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.45rem;
    align-items: center;
}

.btn-refresh-days {
    padding: 0.5rem 0.65rem;
    font-size: 1rem;
    line-height: 1;
    min-width: 2rem;
}

.route-download-row {
    margin-top: 0.45rem;
}

.route-download-row .btn {
    width: 100%;
}

.compact-route-info {
    display: inline-block;
    margin-top: 0.45rem;
    font-size: 0.82rem;
}

.dashboard-route-map {
    height: 840px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--boxes-bg-secondary);
}

/* Address badges on start/end map markers */
.addr-tooltip.leaflet-tooltip {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}
.addr-tooltip.leaflet-tooltip::before { display: none; }

.addr-badge {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: rgba(255,255,255,0.96);
    border-radius: 7px;
    padding: 5px 9px;
    max-width: 220px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.22);
    border-left: 4px solid #28a745;
    font-size: 0.75rem;
    line-height: 1.35;
    color: #222;
}
.addr-badge-end { border-left-color: #dc3545; }
.addr-badge strong { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.6; }
.addr-time { font-weight: 600; font-size: 0.82rem; color: #333; }
.addr-text { color: #111; word-break: break-word; }
.addr-coords { font-family: monospace; font-size: 0.68rem; opacity: 0.5; }

/* Dynamic floating map labels */
.dyn-label {
    position: absolute;
    z-index: 650;
    pointer-events: auto;
    cursor: default;
    max-width: 240px;
}
.dyn-label .addr-badge {
    white-space: nowrap;
}

.map-wrapper {
    position: relative;
    margin-top: 0.8rem;
}

/* Map expanded to full browser window */
.map-wrapper.map-maximized {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    margin: 0 !important;
    z-index: 5000;
    border-radius: 0;
}
.map-wrapper.map-maximized .dashboard-route-map {
    height: 100% !important;
    border-radius: 0;
    border: none;
}

body.map-only-mode {
    overflow: hidden !important;
    height: 100dvh !important;
}

/* Fullscreen map should show only map + map overlays */
body.map-only-mode header,
body.map-only-mode .sidebar,
body.map-only-mode .main-content > :not(#dashboard),
body.map-only-mode #dashboard > :not(.card),
body.map-only-mode #dashboard .card > :not(.map-wrapper) {
    display: none !important;
}

#mapLoadingBar {
    position: absolute;
    top: 0; left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6);
    background-size: 200% 100%;
    animation: mapBarShimmer 1.4s linear infinite;
    z-index: 1000;
    pointer-events: none;
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.55);
}
@keyframes mapBarShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.leaflet-control-zoom-fit {
    font-size: 1rem !important;
    line-height: 34px !important;
    display: block;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border-top: none !important;
}

/* ── Map left toolbar: match app card style ─────────────── */
.dashboard-route-map .leaflet-top.leaflet-left {
    margin: 8px 0 0 8px;
}

.dashboard-route-map .leaflet-control-zoom.leaflet-bar {
    background: var(--boxes-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--shadow) !important;
    overflow: hidden;
}

.dashboard-route-map .leaflet-bar a {
    background: transparent !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    border-top: none !important;
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    font-size: 15px;
    border-radius: 0 !important;
}

.dashboard-route-map .leaflet-bar a:last-child {
    border-bottom: none !important;
}

.dashboard-route-map .leaflet-bar a:hover {
    background: var(--boxes-bg-secondary) !important;
    color: var(--text-primary) !important;
}

.dashboard-route-map .leaflet-bar a.leaflet-disabled {
    opacity: 0.4;
}

.map-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted, #888);
    padding: 3px 0 1px;
    user-select: none;
}
.map-hint kbd {
    display: inline-block;
    font-size: 0.68rem;
    font-family: inherit;
    background: var(--boxes-bg-secondary, #e8e8e8);
    border: 1px solid var(--border-color, #ccc);
    border-radius: 3px;
    padding: 0 4px;
    line-height: 1.5;
}

.route-info-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 12px;
    padding: 10px 15px;
    border: 1px solid rgba(0,0,0,0.10);
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
    pointer-events: auto;
    min-width: 130px;
    line-height: 1.5;
}

.route-info-body {
    pointer-events: none;
}

.route-info-toggle {
    margin-top: 6px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    padding: 2px 0 0;
}

.route-info-overlay.collapsed {
    min-width: 44px;
    padding: 7px 10px;
}

.route-info-overlay.collapsed .route-info-body {
    display: none;
}

.map-arrow-config {
    top: auto;
    bottom: 46px;
    pointer-events: all;
    min-width: 110px;
    padding: 8px 12px;
}

#mapRefreshBtn {
    position: absolute;
    bottom: 34px;
    left: 12px;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 20px;
    padding: 4px 12px 4px 9px;
    font-size: 0.76rem;
    color: var(--text-secondary, #555);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.14);
    user-select: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
#mapRefreshBtn:hover {
    background: rgba(255,255,255,0.97);
    color: var(--text-primary, #111);
}
#mapRefreshBtn .refresh-icon {
    font-size: 0.82rem;
    line-height: 1;
    transition: transform 0.4s;
}
#mapRefreshBtn.spinning .refresh-icon {
    animation: refreshSpin 0.5s linear;
}
@keyframes refreshSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
[data-theme="dark"] #mapRefreshBtn {
    background: rgba(26,32,44,0.85);
    border-color: rgba(255,255,255,0.14);
    color: #bbb;
}
[data-theme="dark"] #mapRefreshBtn:hover {
    background: rgba(40,48,64,0.97);
    color: #eee;
}

.map-config-input {
    width: 60px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0 2px;
    outline: none;
    -moz-appearance: textfield;
}
.map-config-input::-webkit-inner-spin-button,
.map-config-input::-webkit-outer-spin-button { opacity: 0.5; }
[data-theme="dark"] .map-config-input {
    color: #e0e0e0;
    border-bottom-color: rgba(255,255,255,0.25);
}

[data-theme="dark"] .route-info-overlay {
    background: rgba(26, 32, 44, 0.82);
    border-color: rgba(255,255,255,0.12);
}

.route-info-overlay .stat-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
}

.route-info-overlay .stat-row:last-child {
    margin-bottom: 0;
}

.route-info-overlay .stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    opacity: 0.85;
}

.route-info-overlay .stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.elevation-profile-container {
    margin-top: 4px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--boxes-bg-secondary);
    height: 280px;
}

#elevationProfile {
    display: block;
    width: 100%;
    height: 100%;
}

@media (max-width: 768px) {
    .shared-routes-grid {
        grid-template-columns: 1fr;
    }

    /* User-level mobile: reclaim vertical space above the map card */
    body[data-can-manage="false"] #dashboard > h2,
    body[data-can-manage="false"] #dashboard > p[data-i18n="dash.subtitle"] {
        display: none;
    }

    .dashboard-route-map {
        height: 600px;
    }
}

@media (max-width: 768px) {
    .customer-row-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .token-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Badge/Pills */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-danger {
    background: var(--error-color);
    color: white;
}

.badge-info {
    background: var(--secondary-color);
    color: white;
}

/* Login/Register pages */
.login-container,
.register-container,
.success-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-form,
.register-form,
.success-card {
    background: var(--boxes-bg);
    padding: 3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
    width: 100%;
    color: var(--text-primary);
    max-width: 450px;
}

.register-link,
.login-link {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Action buttons container */
.quick-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* Content sections */
.content-section {
    display: none;
    background: var(--boxes-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    color: var(--text-primary);
}

/* Show correct section before JS runs (no flash) */
html[data-section="dashboard"] #dashboard,
html[data-section="users"] #users,
html[data-section="routes"] #routes,
html[data-section="devices"] #devices,
html[data-section="settings"] #settings {
    display: block;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* User greeting and controls */
.header-user {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.user-greeting {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1rem;
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--boxes-bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--button-bg);
    color: white;
    border-color: var(--button-bg);
}

.logout-btn {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 0.9rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: var(--boxes-bg-secondary);
    color: var(--secondary-color);
    text-decoration: none;
}

.btn-switch-account {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: var(--transition);
}
.btn-switch-account:hover {
    background: var(--boxes-bg-secondary);
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* Empty state for lists */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
    font-style: italic;
}

/* Footer */
.app-footer {
    margin: 0 2rem 1.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--text-primary);
}

.footer-copy {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-left: auto;
}

.footer-download-row {
    margin: 0 2rem 0.65rem;
    display: flex;
    justify-content: flex-end;
}

.footer-download-row .btn {
    min-width: 220px;
}

@media (max-width: 768px) {
    .footer-download-row {
        margin: 0 0.5rem 0.5rem;
    }

    .footer-download-row .btn {
        width: 100%;
        min-width: 0;
    }
}

/* Changelog list */
.changelog-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.changelog-item {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    gap: 0.5rem 0.75rem;
    align-items: baseline;
    padding: 0.55rem 0.75rem;
    border-radius: var(--border-radius);
    background: var(--bg-color);
}

.changelog-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
    white-space: nowrap;
}

.changelog-hash {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: monospace;
    opacity: 0.7;
}

.changelog-msg {
    font-size: 0.88rem;
    color: var(--text-primary);
    word-break: break-word;
}

.changelog-body {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border-color);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* Section headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Grid layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Language switcher */
.language-switch {
    display: flex;
    gap: 0.5rem;
}

/* Language Switch */
.language-switch {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.lang-option {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
    background: var(--boxes-bg);
}

.lang-option:hover {
    border-color: var(--secondary-color);
}

.lang-option.active {
    border-color: var(--secondary-color);
    border-width: 3px;
    background: var(--boxes-bg);
    box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.2);
}

.lang-option.active img {
    /* Keep the flag visible, just add border highlighting */
}

.lang-option img {
    width: 20px;
    height: auto;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    
    .header {
        padding: 1rem;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand controls"
            "user user";
        align-items: center;
        gap: 0.4rem;
        text-align: left;
        margin: 1rem 1rem 0.5rem 1rem;
    }

    /* Line 1 left: brand + version */
    .header-brand {
        grid-area: brand;
        justify-self: stretch;
        align-items: baseline;
        gap: 0.35rem;
        min-width: 0;
        flex-wrap: nowrap;
    }
    .brand-name {
        font-size: 1.05rem;
        line-height: 1.15;
    }
    .brand-version {
        font-size: 0.92rem;
        white-space: nowrap;
    }
    .brand-version::before {
        content: "- ";
        opacity: 0.8;
    }

    /* Line 2: user + logout */
    .header-user {
        grid-area: user;
        justify-self: stretch;
        justify-content: space-between;
        width: 100%;
        min-width: 0;
        white-space: nowrap;
    }
    .user-greeting {
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100% - 110px);
    }

    /* Line 1 right: scheme + language */
    .header-controls {
        grid-area: controls;
        justify-self: end;
        width: auto;
        min-width: 0;
        justify-content: flex-end;
        gap: 0.45rem;
        white-space: nowrap;
    }
    .header-controls .theme-toggle { order: 1; }
    .header-controls .language-switch { order: 2; }
    .header-controls .btn-help,
    .header-controls #promoteBtn {
        display: none;
    }
    .theme-toggle {
        padding: 0.35rem 0.65rem;
        font-size: 0.9rem;
    }
    .lang-option {
        width: 30px;
        height: 30px;
    }
    
    .sidebar {
        margin: 0 1rem 0.5rem 1rem;
        justify-content: center;
        padding: 0.5rem;
        gap: 0.25rem;
        flex-wrap: nowrap;
    }
    .nav-label { display: none; }
    .nav-icon { display: inline; }
    .nav-btn { padding: 0.45rem 0.7rem; font-size: 1.2rem; min-width: 0; }
    
    .main-content {
        margin: 0 1rem 1rem 1rem;
    }
    
    .grid-2, .grid-3, .content-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .nav, .quick-actions {
        flex-direction: column;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .table-container {
        overflow-x: scroll;
    }
    
    .btn-large {
        font-size: 1rem;
        padding: 1rem 1.5rem;
    }

    .route-action-btn {
        width: 1.9rem;
        min-width: 1.9rem;
        height: 1.9rem;
        font-size: 0.9rem;
    }

    .route-header-action-btn {
        width: 2.1rem;
        min-width: 2.1rem;
        height: 2.1rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .sidebar {
        margin: 0 0.5rem 0.5rem 0.5rem;
        padding: 0.4rem;
        gap: 0.2rem;
    }
    
    .main-content {
        margin: 0 0.5rem 0.5rem 0.5rem;
    }
    
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .form-input, .form-textarea, .form-select, .btn {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 7000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background: var(--boxes-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.modal .form-group {
    margin-bottom: 1.25rem;
}

/* Help button */
.btn-help {
    background: none;
    border: 1.5px solid var(--text-secondary);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 700;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.btn-help:hover {
    background: var(--text-secondary);
    color: var(--boxes-bg);
}

/* Wide modal variant for help manual */
.modal-wide .modal-content {
    max-width: 700px;
}

/* Manual content styling */
.manual-content h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.6rem;
}

.manual-section {
    margin-bottom: 1rem;
    padding: 0.9rem 1.1rem;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    border-left: 3px solid var(--accent-primary, #e67e22);
}

.manual-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
    color: var(--text-primary);
}

.manual-section p {
    margin: 0 0 0.5rem;
    line-height: 1.6;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.manual-section ul {
    margin: 0.25rem 0 0.25rem 1.2rem;
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.9rem;
}

.manual-section strong {
    color: var(--text-primary);
}

.modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal input[type="text"],
.modal input[type="email"],
.modal input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--boxes-bg);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.modal input[type="text"]:focus,
.modal input[type="email"]:focus,
.modal input[type="password"]:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.modal input[type="checkbox"] {
    margin-right: 0.5rem;
    transform: scale(1.1);
}

/* Modal Error Styles */
.modal-error {
    padding: 0 1.5rem 0.5rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: rgba(231, 76, 60, 0.05);
}

.modal-error .error-message {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    line-height: 1.4;
}

[data-theme="dark"] .modal-error .error-message {
    color: #ff6b6b;
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.3);
}

.mb-3 { margin-bottom: 1.5rem; }
/* ---- Combined Routes ---------------------------------------------------- */
.date-preset-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.wt-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 6px;
}
.wt-tab {
    flex: 1;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: var(--boxes-bg-secondary);
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.wt-tab:last-child { border-right: none; }
.wt-tab:hover { background: var(--boxes-bg); color: var(--text-primary); }
.wt-tab--active {
    background: var(--button-bg);
    color: #fff;
    font-weight: 600;
}
.preset-x-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}
.preset-x-input {
    width: 52px;
    padding: 2px 6px;
    font-size: 0.82rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--input-bg, var(--card-bg));
    color: var(--text-color);
    text-align: center;
}
.btn-tiny {
    padding: 2px 8px;
    font-size: 0.78rem;
    border-radius: 12px;
    line-height: 1.4;
}
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.btn-ghost:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

.combined-route-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-bottom: 0.6rem;
    background: var(--card-bg);
}
/* ===== Combined routes list (new route-day-item style) ===== */
.combined-routes-list-inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--boxes-bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem 0.75rem;
}
@media (min-width: 769px) {
    .combined-routes-list-inner {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 0.65rem;
        padding: 0.75rem;
    }
}
.combined-route-item {
    margin-bottom: 0 !important;
}
.combined-route-item.combined-pinned {
    border-left: 3px solid var(--primary-color);
}
.combined-route-item.cr-dragging {
    opacity: 0.45;
}
.combined-route-item.cr-drag-over {
    outline: 2px solid var(--primary-color);
    outline-offset: -1px;
}
.combined-drag-handle {
    cursor: grab;
    padding: 0 3px;
    color: var(--text-muted);
    font-size: 1.15rem;
    line-height: 1;
    user-select: none;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.combined-drag-handle.unpinned {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}
.combined-drag-handle:not(.unpinned):active { cursor: grabbing; }
.combined-pin-btn {
    opacity: 0.35;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.combined-pin-btn.active {
    opacity: 1;
}
.combined-route-name-label {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.combined-route-summary {
    flex: 1;
    color: var(--text-muted);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.combined-perm-row {
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 2px;
}
.combined-route-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.combined-route-name {
    font-weight: 600;
    font-size: 0.95rem;
    flex: 1;
}
.combined-route-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.combined-route-sources {
    margin-bottom: 4px;
}
.combined-route-perms {
    font-size: 0.85rem;
}
.combined-source-item {
    font-size: 0.82rem;
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 2px 0;
}
/* Route select mode */
.route-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 0;
}
.route-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}
.route-day-item.route-selected {
    background: rgba(29, 111, 217, 0.08);
    border-radius: var(--border-radius);
}
#btnSelectMode.active {
    background: var(--primary-color);
    color: #fff;
}

/* ===== Media Pins ===== */
.pin-map-icon {
    width: 44px; height: 44px;
    border-radius: 6px 6px 0 6px;
    border: 3px solid #e57c1e;
    background: #fff;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    transform: rotate(0deg);
}
.pin-map-icon img { width: 100%; height: 100%; object-fit: cover; }

/* Small GPS anchor dot for photo pins */
.pin-dot-anchor {
    width: 10px; height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}

/* Photo thumbnail label (shown via dyn-label deconfliction) */
.pin-photo-label {
    width: 54px; height: 54px;
    border-radius: 6px 6px 0 6px;
    border: 3px solid #e57c1e;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}
.pin-photo-label:hover { transform: scale(1.08); box-shadow: 0 4px 14px rgba(0,0,0,0.45); }
.pin-photo-label img { width: 100%; height: 100%; object-fit: cover; display: block; }

#pinAddPanel {
    position: absolute;
    top: 10px; left: 50%; transform: translateX(-50%);
    z-index: 900;
    display: flex; gap: 6px;
    background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
    border-radius: 24px; padding: 6px 10px;
}

@media (max-width: 768px) {
    body[data-can-manage="false"] #pinAddPanel,
    body[data-can-manage="false"] #arrowConfigOverlay {
        display: none !important;
    }
}
.pin-add-btn {
    background: none; border: none; cursor: pointer;
    font-size: 20px; padding: 4px 6px; border-radius: 50%;
    line-height: 1; transition: transform 0.15s, background 0.15s;
    color: #fff;
}
.pin-add-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.15); }
.pin-add-btn.pin-add-btn-active { background: rgba(255,255,255,0.3); box-shadow: 0 0 0 2px #fff; }

/* Map photo drop zone */
#mapDropOverlay {
    position: absolute;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.12);
    border: 2.5px dashed #3b82f6;
    border-radius: 4px;
    pointer-events: none;
    animation: dropOverlayIn 0.15s ease;
}
@keyframes dropOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.map-drop-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.92);
    border-radius: 14px;
    padding: 14px 22px;
    box-shadow: 0 4px 16px rgba(59,130,246,0.25);
    color: #1d4ed8;
    font-weight: 600;
    font-size: 0.9rem;
    pointer-events: none;
}
.map-drop-hint .drop-icon { font-size: 2rem; line-height: 1; }
[data-theme="dark"] #mapDropOverlay { background: rgba(59,130,246,0.18); border-color: #60a5fa; }
[data-theme="dark"] .map-drop-hint { background: rgba(15,23,42,0.93); color: #93c5fd; box-shadow: 0 4px 16px rgba(0,0,0,0.5); }

#mapPinModeHint {
    position: absolute;
    bottom: 54px; left: 50%; transform: translateX(-50%);
    z-index: 900;
    background: rgba(0,0,0,0.72); color: #fff;
    padding: 6px 14px; border-radius: 20px;
    font-size: 0.8rem; pointer-events: none; white-space: nowrap;
}

.pin-lightbox-content { max-width: 90vw; width: auto; }
.pin-lightbox-body { display: flex; flex-direction: column; align-items: center; padding: 1rem; gap: 0.5rem; }
/* ===== End Media Pins ===== */

