:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--radius-lg);
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

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

.app-header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.step-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
}

.step-section:hover {
    box-shadow: var(--shadow-lg);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: linear-gradient(to right, var(--primary-color), #3b82f6);
    color: white;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.1rem;
}

.step-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

.step-content {
    padding: 24px;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #fafafa;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 16px;
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.upload-progress {
    text-align: center;
    padding: 20px;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar.large {
    height: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #3b82f6);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.column-selector {
    margin-bottom: 24px;
}

.column-selector label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-select,
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.data-preview {
    margin-bottom: 24px;
}

.data-preview h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

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

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: #f1f5f9;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

tr:hover {
    background: #f8fafc;
}

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

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: #475569;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

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

.geocode-progress {
    text-align: center;
    padding: 20px;
}

.progress-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 16px;
}

.progress-stats span {
    font-size: 1rem;
    color: var(--text-secondary);
}

.progress-stats strong {
    color: var(--primary-color);
}

.failed-addresses {
    margin-top: 24px;
    padding: 16px;
    background: #fef2f2;
    border-radius: var(--radius-md);
    border: 1px solid #fecaca;
}

.failed-addresses h3 {
    color: var(--error-color);
    font-size: 1rem;
    margin-bottom: 12px;
}

.failed-list {
    max-height: 200px;
    overflow-y: auto;
}

.failed-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: white;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

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

.failed-item .address {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.failed-item .error {
    font-size: 0.8rem;
    color: var(--error-color);
    margin-right: 12px;
}

.failed-item .retry-btn {
    padding: 4px 12px;
    font-size: 0.8rem;
    background: var(--warning-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.map-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

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

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

.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.marker-info-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    max-width: 300px;
    z-index: 100;
}

.marker-info-panel h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.info-content p {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.info-content strong {
    color: var(--text-primary);
}

.info-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.modal {
    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: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    animation: slideUp 0.3s ease;
}

.modal-content.large {
    max-width: 900px;
}

.modal-content.small {
    max-width: 400px;
}

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

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

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

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

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

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.preview-controls .form-select {
    width: auto;
}

.preview-container {
    text-align: center;
    background: #f1f5f9;
    border-radius: var(--radius-md);
    padding: 20px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#preview-image {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 250px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

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

.toast.info {
    background: var(--primary-color);
}

.app-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: auto;
}

@media (max-width: 768px) {
    .app-header {
        padding: 30px 16px;
    }
    
    .app-header h1 {
        font-size: 1.8rem;
    }
    
    .step-content {
        padding: 16px;
    }
    
    .upload-area {
        padding: 40px 16px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .map-toolbar {
        flex-direction: column;
    }
    
    #map {
        height: 350px;
    }
    
    .progress-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 10px;
    }
    
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .step-header h2 {
        font-size: 1.1rem;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 8px;
    }
}

@media print {
    .app-header,
    .step-section,
    .modal,
    .toast-container,
    .app-footer {
        display: none !important;
    }
    
    .app-container {
        max-width: 100%;
        padding: 0;
    }
    
    #map {
        width: 100%;
        height: 500px;
        border: 1px solid #ccc;
    }
    
    #print-area {
        page-break-inside: avoid;
    }
}
