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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 600px;
    width: 100%;
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    position: relative;
}

h1 {
    color: #333;
    font-size: 1.8em;
    font-weight: 600;
}

.version {
    position: absolute;
    top: 0;
    right: 0;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 40px;
    font-size: 1em;
}

.upload-section {
    margin-bottom: 30px;
}

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

label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 0.95em;
}

select, input[type="file"], input[type="text"], input[type="password"] {
    width: 100%;
    padding: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s;
    background: white;
}

select:focus, input[type="text"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

/* Better looking inputs for login */
input[type="text"], input[type="password"] {
    background: #f9fafb;
}

input::placeholder {
    color: #9aa3af;
}

.file-input-wrapper {
    position: relative;
}

input[type="file"] {
    cursor: pointer;
}

.file-name {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    font-size: 0.9em;
}

.btn-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.result, .error {
    margin-top: 20px;
    padding: 20px;
    border-radius: 10px;
    animation: slideIn 0.3s ease-out;
}

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

.result {
    background: #d4edda;
    border: 2px solid #c3e6cb;
}

.error {
    background: #f8d7da;
    border: 2px solid #f5c6cb;
}

.result-content {
    text-align: center;
}

.success-icon, .error-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    margin: 0 auto 15px;
}

.success-icon {
    background: #28a745;
    color: white;
}

.error-icon {
    background: #dc3545;
    color: white;
}

.result-message, .error-message {
    margin-bottom: 15px;
    font-weight: 500;
}

.result-message {
    color: #155724;
}

.error-message {
    color: #721c24;
}

.btn-download {
    display: inline-block;
    padding: 12px 30px;
    background: #28a745;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s;
}

}.btn-download:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-secondary {
    display: inline-block;
    padding: 12px 30px;
    background: #6c757d;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-secondary:hover { background: #5a6268; transform: translateY(-2px); }

.btn-small { padding: 8px 16px; }

.admin-header {
    display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; position:relative;
}

.header-actions { display:flex; gap:8px; align-items:center; }

.footer {
    text-align: center;
    padding-top: 20px;
    color: #999;
    font-size: 0.85em;
    border-top: 1px solid #f0f0f0;
}

@media (max-width: 600px) {
    .container {
        padding: 25px;
    }

    h1 {
        font-size: 1.5em;
    }

    .version {
        position: static;
        margin-left: auto;
    }

    .header, .admin-header, .login-header {
        justify-content: space-between;
    }
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    max-width: 420px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 12px;
}

.modal-content p {
    margin: 8px 0;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-button svg {
    flex-shrink: 0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

/* ==================== */
/* Template Wizard      */
/* ==================== */

.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 28px;
    padding: 0 10px;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.4;
    transition: opacity 0.3s;
}
.wizard-step.active,
.wizard-step.completed {
    opacity: 1;
}

.step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ddd;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95em;
    transition: all 0.3s;
}
.wizard-step.active .step-circle {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.wizard-step.completed .step-circle {
    background: #28a745;
    color: #fff;
}

.step-label {
    font-size: 0.75em;
    color: #666;
    white-space: nowrap;
}
.wizard-step.active .step-label {
    color: #333;
    font-weight: 600;
}

.wizard-step-line {
    flex: 1;
    height: 2px;
    background: #ddd;
    margin: 0 8px;
    margin-bottom: 22px;
    min-width: 30px;
}

.wizard-title {
    font-size: 1.15em;
    margin-bottom: 6px;
    color: #333;
}
.wizard-subtitle {
    font-size: 0.95em;
    margin: 18px 0 10px;
    color: #555;
}
.wizard-desc {
    font-size: 0.85em;
    color: #888;
    margin-bottom: 18px;
}
.wizard-hint {
    font-size: 0.78em;
    color: #999;
    margin-top: 4px;
}
.wizard-info {
    font-size: 0.82em;
    color: #667eea;
    margin-bottom: 10px;
    font-weight: 500;
}

.preview-table-wrap {
    overflow-x: auto;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}
.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78em;
    white-space: nowrap;
}
.preview-table th {
    background: #f4f0ff;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #ddd;
}
.preview-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #eee;
    color: #444;
}
.preview-table tr:last-child td {
    border-bottom: none;
}

.column-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: all 0.2s;
    cursor: grab;
    position: relative;
}
.column-card:active { cursor: grabbing; }
.column-card.excluded { opacity: 0.4; background: #f9f9f9; }
.column-card.dragging { opacity: 0.5; border-color: #667eea; box-shadow: 0 4px 12px rgba(102,126,234,0.3); }
.column-card.drag-over { border-color: #667eea; border-style: dashed; }

.column-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.drag-handle { color: #ccc; font-size: 1.2em; cursor: grab; user-select: none; line-height: 1; }
.column-card-name { flex: 1; font-weight: 600; font-size: 0.9em; color: #333; }
.column-card-sample { font-size: 0.75em; color: #999; margin-left: auto; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

.toggle-switch { position: relative; width: 42px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc; border-radius: 22px; transition: 0.3s;
}
.toggle-slider:before {
    content: ""; position: absolute;
    height: 16px; width: 16px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: linear-gradient(135deg, #667eea, #764ba2); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

.column-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.column-rename {
    flex: 1; min-width: 120px; padding: 6px 10px;
    border: 1px solid #ddd; border-radius: 6px; font-size: 0.82em;
    outline: none; transition: border-color 0.2s;
}
.column-rename:focus { border-color: #667eea; }

.type-buttons { display: flex; gap: 0; border-radius: 6px; overflow: hidden; border: 1px solid #ddd; }
.type-btn {
    padding: 5px 10px; font-size: 0.78em; background: #f9f9f9;
    border: none; cursor: pointer; color: #666; transition: all 0.2s;
}
.type-btn.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.type-btn:hover:not(.active) { background: #eee; }

.date-format-select {
    padding: 5px 8px; border: 1px solid #ddd; border-radius: 6px;
    font-size: 0.78em; outline: none; display: none;
}
.date-format-select.visible { display: inline-block; }

.text-input {
    width: 100%; padding: 10px 14px;
    border: 1px solid #ddd; border-radius: 8px;
    font-size: 0.95em; outline: none; transition: border-color 0.2s;
}
.text-input:focus { border-color: #667eea; }

.wizard-nav { display: flex; gap: 10px; margin-top: 20px; }
.wizard-nav .btn-secondary { flex: 0 0 auto; }
.wizard-nav .btn-submit { flex: 1; }

.btn-secondary {
    padding: 10px 20px; border: 1px solid #ddd; border-radius: 8px;
    background: #fff; color: #666; font-size: 0.9em; cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { background: #f5f5f5; border-color: #bbb; }

.template-list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid #eee; font-size: 0.85em;
}
.template-list-item:last-child { border-bottom: none; }
.template-list-name { font-weight: 500; color: #333; }
.template-list-meta { color: #999; font-size: 0.8em; }
.template-delete-btn {
    background: none; border: none; color: #dc3545; cursor: pointer;
    font-size: 0.85em; padding: 4px 8px; border-radius: 4px;
}
.template-delete-btn:hover { background: #fff0f0; }

.reorder-arrows { display: none; flex-direction: column; gap: 2px; }
.reorder-btn {
    background: none; border: 1px solid #ddd; border-radius: 4px;
    padding: 1px 6px; cursor: pointer; font-size: 0.7em; color: #888; line-height: 1;
}
.reorder-btn:hover { background: #f0f0f0; }

@media (max-width: 600px) {
    .reorder-arrows { display: flex; }
    .drag-handle { display: none; }
    .wizard-steps { gap: 0; }
    .step-label { font-size: 0.65em; }
}
