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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.header-logo {
    height: 2rem;
    width: auto;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-container {
    position: relative;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 0.25rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #e9ecef;
}

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

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item strong {
    color: #2c3e50;
}

.search-result-item small {
    color: #6c757d;
    display: block;
    margin-top: 0.25rem;
}

input[type="text"] {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    width: 200px;
}

.input-wide {
    width: 270px;
}

button {
    padding: 0.5rem 1rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

button:hover {
    background: #2980b9;
}

button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.btn-purple {
    background: #9b59b6;
    margin-left: 0.5rem;
}

.btn-red {
    background: #e74c3c;
    margin-left: 0.5rem;
}

.hidden {
    display: none !important;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 400px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem;
    background: #e9ecef;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid #dee2e6;
}

.tab {
    flex: 1;
    padding: 0.75rem;
    background: #f8f9fa;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
    color: #2c3e50;
}

.tab.active {
    background: white;
    border-bottom: 2px solid #3498db;
    font-weight: 600;
    color: #2c3e50;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.route-info {
    margin-bottom: 1.5rem;
}

.route-info h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.download-button {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
}

.download-button:hover {
    background: #218838;
}

.download-button:active {
    background: #1e7e34;
}

.download-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.download-button .icon {
    font-size: 1.1rem;
}

.error-banner {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    border-left: 4px solid #ffc107;
}

.error-banner-content {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.error-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.error-text {
    color: #856404;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Progress modal for Excel download */
.download-progress-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.download-progress-modal.active {
    display: flex;
}

.download-progress-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 400px;
    max-width: 500px;
}

.download-progress-content h3 {
    margin: 0 0 1.5rem 0;
    color: #2c3e50;
    font-size: 1.25rem;
}

.progress-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
}

.progress-step {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    color: #6c757d;
    transition: color 0.3s;
}

.progress-step.active {
    color: #2c3e50;
    font-weight: 600;
}

.progress-step.completed {
    color: #28a745;
}

.progress-step-icon {
    margin-right: 0.75rem;
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.progress-step.active .progress-step-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: #28a745;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-bar.animated {
    animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e9ecef;
}

.info-label {
    font-weight: 600;
    color: #6c757d;
}

.property-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.property-table th {
    background: #e9ecef;
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.property-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.property-table tr:hover {
    background: #f8f9fa;
    cursor: pointer;
}

.property-table tr.highlighted {
    background: #fff3cd;
}

.property-row {
    background-color: #f8f9fa;
}

.property-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
    border: 2px solid #333;
}

.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
}

.loading.active {
    display: block;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.report-section {
    margin-bottom: 1.5rem;
}

.report-section h4 {
    margin-bottom: 0.75rem;
    color: #2c3e50;
    font-size: 1.1rem;
}

.component-item {
    margin-bottom: 0.75rem;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem;
}

/* Route tooltip styling */
.route-tooltip {
    background: rgba(44, 62, 80, 0.95) !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 6px 10px !important;
    font-size: 0.9rem !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    white-space: nowrap !important;
    z-index: 10000 !important;
    pointer-events: none !important;
}

.route-tooltip::before {
    border-top-color: rgba(44, 62, 80, 0.95) !important;
}

/* Link tooltip styling */
.link-tooltip {
    background: white !important;
    color: #333 !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    padding: 8px 12px !important;
    font-size: 0.75rem !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    white-space: normal !important;
    max-width: 400px !important;
    min-width: 350px !important;
    z-index: 10000 !important;
    pointer-events: none !important;
}

.link-tooltip::before {
    border-top-color: #ccc !important;
}

.muted-text {
    font-weight: normal;
    color: #6c757d;
}

/* Ensure Leaflet tooltip container has proper z-index */
.leaflet-tooltip {
    z-index: 10000 !important;
}

/* Ensure Leaflet interactive layers have pointer events enabled */
.leaflet-interactive {
    pointer-events: auto !important;
}

.leaflet-overlay-pane svg {
    pointer-events: none;
}

.leaflet-overlay-pane svg path.leaflet-interactive {
    pointer-events: auto !important;
}

/* Route selector popup styling */
.route-selector-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.route-selector-popup .leaflet-popup-content {
    margin: 0;
    padding: 0;
}

/* Custom draw line control styling */
.leaflet-control-draw-line {
    transition: background-color 0.2s, color 0.2s;
}

.leaflet-control-draw-line:hover {
    background-color: #f4f4f4 !important;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.modal-close:hover {
    background-color: #e9ecef;
    color: #2c3e50;
}

.modal-body {
    padding: 1.5rem;
    color: #2c3e50;
}

.modal-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #2c3e50;
    font-size: 1.2rem;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body ul {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.modal-body li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.modal-body p {
    line-height: 1.6;
    margin: 0.75rem 0;
}

.filename-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 1rem;
    margin: 1rem 0;
    font-family: monospace;
}

.filename-input:focus {
    outline: none;
    border-color: #366092;
    box-shadow: 0 0 0 3px rgba(54, 96, 146, 0.1);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-weight: 500;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #366092;
    color: white;
}

.btn-primary:hover {
    background-color: #2d4f75;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

