:root {
    --bg-color: #0c1222;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --input-bg: rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* Background gradient blobs */
.blob {
    position: absolute;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.5;
    animation: float 10s ease-in-out infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(0, 0, 0, 0) 70%);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.3) 0%, rgba(0, 0, 0, 0) 70%);
    animation-delay: -5s;
}

@keyframes float {
    0% {
        transform: translateY(0px) scale(1);
    }

    100% {
        transform: translateY(30px) scale(1.05);
    }
}

.app-container {
    width: 100%;
    max-width: 650px;
    padding: 2rem;
    z-index: 10;
}

.app-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.gradient-text {
    background: linear-gradient(135deg, #60a5fa, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* File Upload Area */
.file-upload-wrapper {
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.1);
    position: relative;
}

.file-upload-wrapper:hover,
.file-upload-wrapper.drag-over {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.file-upload-wrapper:hover .upload-icon {
    transform: translateY(-5px);
}

.upload-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upload-text strong {
    font-size: 1.1rem;
    font-weight: 500;
}

.upload-text span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-name-display {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    color: #60a5fa;
    font-weight: 500;
    word-break: break-all;
}

.hidden {
    display: none !important;
}

/* Form Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 500px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

select {
    width: 100%;
    padding: 0.875rem 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    appearance: none;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

select:hover,
select:focus {
    border-color: rgba(96, 165, 250, 0.5);
    background-color: rgba(255, 255, 255, 0.05);
}

select option {
    background-color: #1e293b;
    color: white;
}

/* Primary Button */
.primary-btn {
    margin-top: 1rem;
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    color: white;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 20px -10px rgba(59, 130, 246, 0.5);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px -10px rgba(59, 130, 246, 0.6);
}

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

.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

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

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

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

/* Base Input styling for text and passwords */
input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 0.875rem 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
    border-color: rgba(96, 165, 250, 0.5);
    background-color: rgba(255, 255, 255, 0.05);
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    margin-top: auto;
    margin-bottom: auto;
}

.checkbox-group input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Loader */
.loader {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Status Message */
.status-message {
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
    font-size: 0.95rem;
    animation: slideUp 0.3s ease-out;
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

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

/* ---- Progress Panel ---- */
.progress-panel {
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.18);
    animation: slideUp 0.35s ease-out;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem 0.5rem;
}

.progress-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.progress-timer {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* Bar track */
.progress-bar-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 0 4px 4px 0;
    transform-origin: left center;
}

.progress-bar-fill.running {
    animation: barBounce 1.6s ease-in-out infinite;
}

@keyframes barBounce {
    0%   { width: 15%; margin-left: 0%; }
    50%  { width: 40%; margin-left: 45%; }
    100% { width: 15%; margin-left: 85%; }
}

.progress-bar-fill.done {
    width: 100%;
    margin-left: 0;
    background: linear-gradient(90deg, var(--success-color), #059669);
    animation: none;
    transition: width 0.4s ease;
}

.progress-bar-fill.error {
    width: 100%;
    margin-left: 0;
    background: var(--danger-color);
    animation: none;
}

/* Log stream */
.log-stream {
    max-height: 200px;
    overflow-y: auto;
    padding: 0.6rem 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.log-entry {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding: 0.1rem 0;
    animation: logFadeIn 0.2s ease-out both;
    word-break: break-word;
}

.log-entry.log-success { color: #34d399; }
.log-entry.log-warn    { color: #fbbf24; }

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

/* Download button */
.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin: 0.25rem 1.25rem 1.25rem;
    padding: 0.9rem;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 8px 20px -8px rgba(16, 185, 129, 0.55);
    animation: pulseGreen 2s ease-in-out infinite;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -6px rgba(16, 185, 129, 0.65);
    animation: none;
}

@keyframes pulseGreen {
    0%, 100% { box-shadow: 0 8px 20px -8px rgba(16, 185, 129, 0.55); }
    50%       { box-shadow: 0 8px 30px -4px rgba(16, 185, 129, 0.80); }
}

/* CSV map download button — secondary/muted variant */
.download-map-btn {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 8px 20px -8px rgba(124, 58, 237, 0.5);
    animation: pulsePurple 2s ease-in-out infinite;
    margin-top: 0;
}

.download-map-btn:hover {
    box-shadow: 0 14px 28px -6px rgba(124, 58, 237, 0.7);
}

@keyframes pulsePurple {
    0%, 100% { box-shadow: 0 8px 20px -8px rgba(124, 58, 237, 0.50); }
    50%       { box-shadow: 0 8px 30px -4px rgba(124, 58, 237, 0.75); }
}