:root {
    --primary: #295f86;
    --primary-dark: #1f4f73;
    --bg: #f3f0e8;
    --surface: #fffdf8;
    --text: #182127;
    --text-muted: #5c6b74;
    --border: #d8d0c0;
    --danger: #b2432f;
    --success: #3d7250;
    --warning: #b67a19;
    --rail: #22313b;
}

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

body {
    font-family: 'IBM Plex Sans', 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: radial-gradient(circle at top left, rgba(160, 109, 44, 0.14), transparent 28%),
        linear-gradient(180deg, #f7f3ea 0%, var(--bg) 60%, #ece6d7 100%);
    color: var(--text);
    line-height: 1.5;
}

.rm-layout {
    min-height: 100vh;
}

.rm-update-banner {
    position: sticky;
    top: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 0.5rem 1rem;
    background: #d97706;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

.top-bar {
    background: linear-gradient(90deg, #22313b 0%, #2a414e 60%, #304b5c 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0 1.5rem;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 200;
}

.top-bar-brand {
    display: inline-flex;
    flex-direction: column;
    gap: 0.05rem;
    color: #f7f2e7;
    text-decoration: none;
}

.top-bar-brand-eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(247, 242, 231, 0.68);
}

.top-bar-brand-title {
    font-family: 'Barlow Condensed', 'Bahnschrift SemiCondensed', 'Arial Narrow', sans-serif;
    font-size: 1.35rem;
    letter-spacing: 0.02em;
    font-weight: 700;
}

.top-bar-right {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
}

.rm-version-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(247, 242, 231, 0.38);
    color: rgba(247, 242, 231, 0.94);
    border-radius: 999px;
    padding: 0.2rem 0.58rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.rm-version-chip--local {
    border-color: rgba(190, 206, 218, 0.58);
    color: #d4e0ea;
    background: rgba(130, 151, 167, 0.14);
}

.rm-version-chip--development {
    border-color: rgba(214, 168, 96, 0.64);
    color: #efcf9d;
    background: rgba(168, 111, 43, 0.18);
}

.rm-version-chip--staging {
    border-color: rgba(110, 177, 177, 0.64);
    color: #bde1dd;
    background: rgba(48, 111, 110, 0.2);
}

.rm-version-chip--production {
    border-color: rgba(122, 184, 142, 0.64);
    color: #c3e2cb;
    background: rgba(43, 107, 70, 0.2);
}

.top-bar-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.top-bar-nav a {
    color: rgba(247, 242, 231, 0.76);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.24rem 0.42rem;
    border: 1px solid transparent;
    border-radius: 999px;
    transition: all 0.15s;
}

.top-bar-nav a:hover, .top-bar-nav a.active {
    color: #f7f2e7;
    background: rgba(211, 157, 86, 0.17);
    border-color: rgba(211, 157, 86, 0.34);
}

.main-content {
    padding: 1.5rem;
    max-width: 1900px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover { background: var(--primary-dark); }

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

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

.route-row-actions {
    white-space: nowrap;
}

.route-row-actions .btn + .btn {
    margin-left: 0.45rem;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table th {
    background: var(--bg);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

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

.data-table tr:hover td { background: #f1f5f9; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

.generate-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.generate-form input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    width: 200px;
}

.editor-layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 1rem;
    height: calc(100dvh - 56px - 3rem);
    min-height: 0;
}

.editor-sidebar {
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    overscroll-behavior: contain;
}

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

.editor-sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.comparison-sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
}

.comparison-header-main {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.comparison-trip-id {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.comparison-trip-meta {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.comparison-meta-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
}

.comparison-meta-value {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 600;
}

.comparison-nav-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
}

.comparison-nav-btn {
    justify-content: flex-start;
    border-radius: 8px;
    border-color: #cbd5e1;
    background: #f8fafc;
    padding: 0.42rem 0.52rem;
}

.comparison-nav-btn:hover:not(:disabled) {
    border-color: #94a3b8;
    background: #f1f5f9;
}

.comparison-nav-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.comparison-nav-arrow {
    width: 1rem;
    text-align: center;
    font-weight: 700;
    color: #334155;
}

.comparison-nav-text {
    flex: 1 1 auto;
    text-align: left;
}

.comparison-nav-trip-id {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.comparison-loading-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.comparison-map-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: rgba(248, 250, 252, 0.68);
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(1px);
    z-index: 20;
}

.comparison-initial-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.superstation-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr) 380px;
    gap: 1rem;
    height: calc(100vh - 56px - 3rem - 40px);
}

.superstation-panel,
.superstation-map-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.superstation-map-panel {
    padding: 0.75rem;
}

.superstation-map-panel .route-map {
    width: 100%;
    height: 100%;
    min-height: 520px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.superstation-map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.superstation-map-legend {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.25rem;
    vertical-align: middle;
}

.dot-gray { background: #64748b; }
.dot-blue { background: #1d4ed8; }
.dot-amber { background: #d97706; }
.dot-red { background: #dc2626; }

.superstation-section-title {
    font-size: 0.83rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
}

.superstation-search-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.superstation-search-row input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
}

.superstation-list {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: auto;
    min-height: 150px;
    flex: 1 1 auto;
    background: #f8fafc;
}

.superstation-list.compact {
    flex: 0 0 220px;
}

.superstation-list-item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #e5edf7;
    background: transparent;
    text-align: left;
    padding: 0.52rem 0.6rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.superstation-list-item:hover {
    background: #edf4ff;
}

.superstation-list-item.selected {
    background: #dbeafe;
}

.superstation-station-name {
    font-size: 0.86rem;
    color: #0f172a;
    font-weight: 600;
}

.superstation-station-meta {
    font-size: 0.74rem;
    color: #64748b;
}

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

.superstation-editor-box {
    margin-top: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem;
    background: #f8fafc;
}

.superstation-editor-line {
    margin-bottom: 0.35rem;
    font-size: 0.86rem;
}

.superstation-actions {
    display: flex;
    gap: 0.45rem;
    margin: 0.5rem 0 0.6rem;
    flex-wrap: wrap;
}

.superstation-members {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 240px;
    overflow: auto;
}

.superstation-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.82rem;
}

.superstation-nearby-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.55rem 0 0.65rem;
}

.superstation-nearby-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.48rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
}

.nearby-badge-group {
    background: #dbeafe;
    color: #1d4ed8;
}

.nearby-badge-other {
    background: #fef3c7;
    color: #b45309;
}

.nearby-badge-none {
    background: #e2e8f0;
    color: #334155;
}

.superstation-nearby-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 320px;
    overflow: auto;
}

.superstation-nearby-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.55rem;
    border: 1px solid #dbe5f1;
    border-radius: 8px;
    background: #ffffff;
}

.superstation-nearby-text {
    min-width: 0;
    flex: 1 1 auto;
}

.superstation-nearby-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 1400px) {
    .superstation-layout {
        grid-template-columns: 320px minmax(0, 1fr);
        height: auto;
    }

    .superstation-panel:last-child {
        grid-column: 1 / -1;
    }

    .superstation-list.compact {
        flex: 0 0 180px;
    }
}

@media (max-width: 900px) {
    .superstation-layout {
        grid-template-columns: 1fr;
    }

    .superstation-map-panel {
        min-height: 420px;
    }

    .superstation-nearby-row {
        flex-direction: column;
        align-items: stretch;
    }

    .superstation-nearby-actions {
        justify-content: flex-start;
    }
}

.comparison-spinner {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.2);
    border-top-color: #2563eb;
    animation: comparison-spin 0.8s linear infinite;
    flex: 0 0 auto;
}

.comparison-spinner-sm {
    width: 0.85rem;
    height: 0.85rem;
    border-width: 2px;
}

@keyframes comparison-spin {
    to { transform: rotate(360deg); }
}

.railway-coverage-summary {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.railway-coverage-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
}

.railway-coverage-badges {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.railway-coverage-missing {
    width: 100%;
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.35;
}

@media (max-width: 1200px) {
    .main-content {
        max-width: 100%;
    }

    .editor-layout {
        grid-template-columns: 340px minmax(0, 1fr);
    }
}

@media (max-width: 520px) {
    .comparison-nav-actions {
        grid-template-columns: 1fr;
    }
}

.station-list {
    flex: 1;
    overflow-y: auto;
    /* Keep a stable gutter so right-side actions never sit under the scrollbar. */
    scrollbar-gutter: stable;
    padding: 0.5rem 0.75rem 0.5rem 0.5rem;
}

.station-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.station-item:hover { background: #f1f5f9; }

.station-item.selected {
    background: #eff6ff;
    border-color: var(--primary);
}

.station-item.has-failure {
    background: #fff7ed;
    border-color: #fdba74;
}

.station-item.has-missing-gap {
    background: #fffaf0;
    border-color: #fcd34d;
}

.station-item.focused-gap {
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.station-item.move-source {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
    background: #eaf2ff;
    border-color: #93c5fd;
}

.station-item .order {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.station-item .name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.station-warning {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--warning);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.station-gap-warning {
    border-radius: 9999px;
    background: #fef3c7;
    color: #92400e;
    padding: 0.12rem 0.45rem;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.station-item .drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.station-reorder-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
}

.reorder-btn {
    width: 1.7rem;
    height: 1.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.reorder-btn:hover:not(:disabled) {
    color: var(--primary);
    border-color: var(--primary);
    background: #eff6ff;
}

.reorder-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.station-item .remove-btn {
    color: var(--danger);
    cursor: pointer;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    margin-left: 0.1rem;
    border: 0;
    background: transparent;
    line-height: 1;
    min-width: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.station-item:hover .remove-btn { opacity: 1; }

.station-item .remove-btn:disabled {
    cursor: default;
    opacity: 0.8;
}

.station-item .remove-btn.busy {
    color: #92400e;
    font-weight: 700;
}

.station-item-details {
    margin: 0.15rem 0 0.4rem 2.2rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px dashed #bfdbfe;
    background: #f8fbff;
}

.station-item-full-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: #1e3a8a;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.station-item-id {
    margin-top: 0.1rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.diagnostics-panel {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.diagnostic-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.9rem;
    padding: 0.35rem 0.25rem;
    border-radius: 6px;
    cursor: pointer;
}

.diagnostic-item.focused {
    background: rgba(255, 255, 255, 0.35);
    outline: 1px solid rgba(146, 64, 14, 0.25);
}

.diagnostic-distance {
    color: #a16207;
    font-size: 0.82rem;
}

.diagnostic-actions {
    margin-top: 0.25rem;
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.insert-hint {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.insert-hint.move-hint {
    background: #eef2ff;
    color: #3730a3;
}

.reorder-hint {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.insert-between {
    position: relative;
    height: 18px;
    margin: 0.1rem 0 0.2rem;
}

.insert-between::before {
    content: "";
    position: absolute;
    left: 2.05rem;
    right: 1rem;
    top: 50%;
    border-top: 1px dashed #cbd5e1;
    transform: translateY(-50%);
}

.insert-gap-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 22px;
    border-radius: 9999px;
    border: 1px solid #cbd5e1;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.insert-gap-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: #eff6ff;
    transform: translate(-50%, -50%) scale(1.05);
}

.station-item.dragging {
    opacity: 0.5;
    background: #e2e8f0;
}

.station-item.drag-over {
    border-top: 2px solid var(--primary);
}

.station-item.drag-over-before {
    border-top: 2px solid var(--primary);
    background: #eff6ff;
}

.station-item.drag-over-after {
    border-bottom: 2px solid var(--primary);
    background: #eff6ff;
}

.editor-actions {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.map-container {
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.map-container .map {
    width: 100%;
    height: 100%;
}

.route-map-context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 180px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
    padding: 0.3rem;
}

.route-map-context-menu-item {
    width: 100%;
    display: block;
    text-align: left;
    border: 0;
    background: transparent;
    color: #0f172a;
    border-radius: 6px;
    padding: 0.45rem 0.55rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.route-map-context-menu-item:hover {
    background: #eff6ff;
}

.top-bar-logout {
    margin-left: 0.15rem;
}

.login-shell {
    min-height: calc(100vh - 56px - 2.2rem);
    display: grid;
    place-items: center;
    padding: 1.2rem;
}

.login-card {
    width: 100%;
    max-width: 520px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 253, 248, 0.94));
    border: 1px solid rgba(41, 95, 134, 0.16);
    border-radius: 16px;
    padding: 1.25rem 1.35rem;
    box-shadow: 0 12px 32px rgba(28, 36, 41, 0.09);
}

.login-card h1 {
    font-family: 'Barlow Condensed', 'Bahnschrift SemiCondensed', 'Arial Narrow', sans-serif;
    font-size: 2rem;
    line-height: 1.05;
    letter-spacing: 0.02em;
    margin-bottom: 0.3rem;
}

.login-card-subtitle {
    color: var(--text-muted);
    font-size: 0.93rem;
    margin-bottom: 1.15rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.login-form label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
}

.login-form input {
    width: 100%;
    padding: 0.6rem 0.72rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 0.45rem;
    background: rgba(255, 255, 255, 0.96);
}

.login-form input:focus {
    outline: 2px solid rgba(41, 95, 134, 0.3);
    border-color: rgba(41, 95, 134, 0.44);
}

.login-card .btn {
    justify-content: center;
    margin-top: 0.2rem;
}

.route-focus-tooltip {
    background: #111827;
    border: 1px solid #1f2937;
    color: #f9fafb;
    font-weight: 700;
    padding: 2px 8px;
}

.search-container {
    position: relative;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}

.search-container input:not([type="checkbox"]) {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
}

.search-container .layer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.search-container .layer-toggle-main {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.search-container .layer-toggle input[type="checkbox"] {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

.search-container .layer-toggle span {
    line-height: 1.25;
}

.search-container .layer-toggle-count {
    flex: 0 0 auto;
    min-width: 2ch;
    text-align: right;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.search-container .layer-reload {
    display: inline-flex;
}

.search-container .layer-actions {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}

.search-container .layer-stats {
    margin-top: 0.7rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.search-container .layer-stats-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.1rem;
}

.search-container .layer-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text);
}

.search-container .layer-stat-row strong {
    font-size: 0.82rem;
}

.search-container .layer-stat-row-total {
    margin-top: 0.2rem;
    padding-top: 0.35rem;
    border-top: 1px dashed #cbd5e1;
    font-weight: 600;
}

.inspiration-container {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.inspiration-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.inspiration-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
}

.inspiration-status {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 600;
}

.inspiration-summary {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    padding: 0.45rem 0.55rem;
    font-size: 0.8rem;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.inspiration-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 230px;
    overflow-y: auto;
    padding-right: 0.15rem;
}

.inspiration-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    padding: 0.4rem 0.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.45rem;
    align-items: center;
}

.inspiration-item-main {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.inspiration-item-order {
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 9999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.inspiration-item-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inspiration-item-id {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex: 0 0 auto;
}

.inspiration-item-meta {
    grid-column: 1 / 2;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.inspiration-item-actions {
    display: inline-flex;
    align-items: center;
    justify-self: end;
    gap: 0.3rem;
}

.inspiration-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.2rem 0;
}

.raw-map-stats {
    margin-top: 0.6rem;
}

.raw-map-trip-actions {
    border-top: 1px solid var(--border);
}

.raw-map-load-progress {
    margin-top: 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.raw-map-load-progress-label {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.raw-map-load-progress-track {
    width: 100%;
    height: 0.38rem;
    border-radius: 9999px;
    background: #e2e8f0;
    overflow: hidden;
}

.raw-map-load-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #0ea5e9);
    transition: width 0.2s ease;
}

.raw-trip-list {
    padding: 0.6rem 0.75rem;
}

.raw-trip-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.5rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.45rem;
    background: #ffffff;
}

.raw-trip-item:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.raw-trip-main {
    display: inline-flex;
    gap: 0.45rem;
    align-items: baseline;
}

.raw-trip-meta {
    grid-column: 1 / -1;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.raw-source-inline {
    color: #334155;
}

.raw-trip-empty {
    color: var(--text-muted);
    font-size: 0.86rem;
    padding: 0.4rem 0.2rem;
}

.raw-trip-load-more {
    display: flex;
    justify-content: center;
    padding: 0.35rem 0.2rem 0.15rem;
}

.raw-source-name {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.raw-map-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.25rem;
}

.raw-map-section-toggle {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}

.raw-source-dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 9999px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    display: inline-block;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0.75rem;
    right: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
}

.search-result-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.search-result-item:hover { background: #f1f5f9; }

.stats-bar {
    padding: 0.5rem 1rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 1.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.back-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.back-links .back-link {
    margin-bottom: 0;
}

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

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.fetch-progress-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fetch-progress-panel-bottom {
    margin-top: 0.85rem;
    margin-bottom: 0;
}

.fetch-progress-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.fetch-progress-header span {
    color: #1d4ed8;
    font-size: 0.82rem;
}

.fetch-progress-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.fetch-progress-toggle {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}

.fetch-progress-log {
    border-top: 1px solid rgba(59, 130, 246, 0.18);
    padding-top: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
}

.fetch-progress-line {
    color: #1e3a8a;
    white-space: pre;
    word-break: break-word;
}

.fetch-progress-log-expanded {
    max-height: 8.5rem;
    overflow-y: auto;
}

.fetch-progress-log-collapsed {
    max-height: none;
    overflow: hidden;
}

.fetch-progress-log-collapsed .fetch-progress-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.75rem 1rem;
    background: var(--danger);
    color: white;
    border-radius: 6px;
    z-index: 1000;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}
