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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Upload screen */
.upload-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.upload-content {
    text-align: center;
    color: white;
    max-width: 500px;
    padding: 40px;
}

.upload-content h1 {
    font-size: 3rem;
    font-weight: 300;
    margin-bottom: 60px;
    color: #ff6b6b;
}

.file-upload-area {
    margin-top: 60px;
    margin-bottom: 40px;
}

.file-upload-button {
    display: block;
    padding: 40px 60px;
    border: 2px dashed rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 1rem;
}

.file-upload-button:hover,
.file-upload-area.drag-over .file-upload-button {
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.file-upload-button .file-types {
    display: block;
    font-size: 0.9rem;
    margin-top: 10px;
    opacity: 0.7;
}

/* Results screen */
.results-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 900;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.main-container {
    display: flex;
    height: 100vh;
}

.left-panel {
    flex: 1;
    padding: 20px 10px 20px 20px;
}

#map {
    height: 100%;
    width: 100%;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
}

/* Right sidebar */
.right-sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    padding: 20px 20px 20px 10px;
}

.sidebar-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
}

.track-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
    word-wrap: break-word;
    line-height: 1.3;
}

/* Legend with toggleable items */
.legend {
    background: rgba(236, 240, 241, 0.8);
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #2c3e50;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-item.toggleable {
    cursor: pointer;
    user-select: none;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.legend-item.toggleable:hover {
    background: rgba(0, 0, 0, 0.05);
}

.legend-line {
    display: inline-block;
    width: 24px;
    height: 3px;
    margin-right: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-line.original {
    background: #3498db;
}

.legend-line.processed {
    background: #e74c3c;
}

.legend-eye {
    margin-left: auto;
    font-size: 0.8rem;
    transition: opacity 0.2s;
}

/* Stats panel */
.stats-panel {
    background: rgba(236, 240, 241, 0.8);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    color: #2c3e50;
}

.stats-table th {
    font-weight: 600;
    text-align: right;
    padding: 2px 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.stats-table th:first-child {
    text-align: left;
}

.stats-table td {
    padding: 3px 6px;
    text-align: right;
    white-space: nowrap;
}

.stats-table td:first-child {
    text-align: left;
    font-weight: 500;
}

/* Buttons */
.process-button {
    padding: 12px 24px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    width: 100%;
}

.process-button:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.process-button.disabled {
    background: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.process-button.disabled:hover {
    background: #bdc3c7;
    transform: none;
}

/* Primary action button */
.primary-button {
    background: #27ae60;
}

.primary-button:hover {
    background: #219a52;
}

/* Options button - subtle outline style */
.options-button {
    background: transparent;
    color: #7f8c8d;
    border: 1px solid #bdc3c7;
    box-shadow: none;
}

.options-button:hover {
    background: #f0f0f0;
    color: #5a6c6e;
    border-color: #95a5a6;
    transform: none;
    box-shadow: none;
}

.options-button.active {
    background: #ecf0f1;
    color: #2c3e50;
    border-color: #95a5a6;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.reset-button {
    background: #95a5a6;
    margin-top: auto;
}

.reset-button:hover {
    background: #7f8c8d;
}

/* Options panel */
.options-panel {
    height: 100%;
    width: 100%;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    overflow-y: auto;
    padding: 20px;
}

.options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.options-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

/* Option groups - collapsible sections */
.option-group {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 5px;
    margin-bottom: 4px;
}

.option-group-header {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    background: rgba(236, 240, 241, 0.5);
    border-radius: 5px;
    transition: background 0.15s;
}

.option-group-header:hover {
    background: rgba(236, 240, 241, 0.9);
}

.option-group-arrow {
    font-size: 0.6rem;
    margin-right: 8px;
    transition: transform 0.15s;
    color: #7f8c8d;
}

.option-group.expanded .option-group-arrow {
    transform: rotate(90deg);
}

.option-group-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2c3e50;
}

.option-group-count {
    font-size: 0.75rem;
    color: #8e44ad;
    margin-left: 8px;
    font-weight: 500;
}

.option-group-body {
    display: none;
    padding: 6px 10px 8px;
    column-width: 280px;
    column-gap: 20px;
}

.option-group.expanded .option-group-body {
    display: block;
}

.option-item {
    break-inside: avoid;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    font-size: 0.78rem;
    line-height: 1.3;
}

.option-checkbox {
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.option-label {
    cursor: pointer;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.option-negated .option-label {
    text-decoration: line-through;
    color: #95a5a6;
}

.option-value {
    width: 80px;
    min-width: 50px;
    flex-shrink: 1;
    padding: 1px 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.72rem;
    color: #333;
    background: #fff;
}

.option-value:focus {
    border-color: #8e44ad;
    outline: none;
}

.option-value::placeholder {
    color: #bbb;
    font-size: 0.68rem;
}

/* Version footer */
.version-footer {
    position: fixed;
    bottom: 2px;
    right: 10px;
    width: 300px;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    z-index: 1001;
    pointer-events: none;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-content {
    text-align: center;
    padding: 40px;
}

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

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

.loading-content p {
    font-size: 1.1rem;
    font-weight: 300;
    color: #ff6b6b;
}

/* Error overlay */
.error-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.error-content {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    margin: 20px;
}

.error-content h3 {
    color: #e74c3c;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.error-content p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;

}

#errorBackBtn {
    padding: 12px 24px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

#errorBackBtn:hover {
    background: #2980b9;
}

/* Mobile: sidebar becomes bottom drawer */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    .left-panel {
        padding: 10px 10px 5px 10px;
        flex: 1;
        min-height: 0;
    }

    .right-sidebar {
        width: 100%;
        padding: 5px 10px 10px 10px;
        max-height: 40vh;
        overflow-y: auto;
    }

    .sidebar-content {
        padding: 12px 15px;
    }

    .track-name {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    .legend {
        margin-bottom: 10px;
        padding: 8px 12px;
    }

    .stats-panel {
        margin-bottom: 10px;
    }

    .process-button {
        padding: 10px 20px;
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .reset-button {
        margin-top: 5px;
    }


    .upload-content {
        padding: 20px;
    }

    .upload-content h1 {
        font-size: 2rem;
        margin-bottom: 40px;
    }

    .file-upload-button {
        padding: 30px 40px;
    }
}

@media (max-width: 480px) {
    .upload-content h1 {
        font-size: 1.5rem;
    }

    .file-upload-button {
        padding: 20px 30px;
        font-size: 0.9rem;
    }

    .stats-table {
        font-size: 0.75rem;
    }

}
