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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 30px 0 20px;
}

header h1 {
    font-size: 2rem;
    color: #1a1a2e;
}

.subtitle {
    color: #666;
    font-size: 1.1rem;
}

.section {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.section h2 {
    font-size: 1.1rem;
    color: #1a1a2e;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}

.empresa-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

select, input[type="text"] {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
}

select {
    min-width: 250px;
}

.nueva-empresa {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nueva-empresa input {
    width: 220px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

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

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

.nueva-empresa button {
    background: #16213e;
    color: #fff;
}

#uploadBtn {
    background: #0f3460;
    color: #fff;
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    font-size: 1rem;
}

#uploadBtn:hover:not(:disabled) {
    background: #16213e;
}

.btn-secondary {
    background: #e8e8e8;
    color: #333;
}

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

.catalogo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.catalogo-card {
    padding: 14px;
    border: 2px solid #eee;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
}

.catalogo-card:hover {
    border-color: #0f3460;
    background: #f0f4ff;
}

.catalogo-card.active {
    border-color: #0f3460;
    background: #0f3460;
    color: #fff;
}

.upload-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

.upload-info p {
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.hint {
    color: #888;
    font-size: 0.85rem !important;
}

.upload-area {
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.upload-area:hover {
    border-color: #0f3460;
    background: #fafbff;
}

.upload-area input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-area p {
    color: #888;
    margin-bottom: 4px;
}

.file-types {
    font-size: 0.8rem;
    color: #aaa;
}

.file-name {
    padding: 8px 0;
    font-size: 0.9rem;
    color: #0f3460;
    font-weight: 500;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.stat-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}

.stat-card .count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f3460;
}

.stat-card .label {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

.loading {
    color: #888;
    text-align: center;
    padding: 20px;
}

.table-container {
    overflow-x: auto;
    margin-top: 12px;
}

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

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    position: sticky;
    top: 0;
}

tr:hover {
    background: #fafbff;
}

.result-success {
    background: #d4edda;
    color: #155724;
    padding: 16px;
    border-radius: 8px;
}

.result-error {
    background: #f8d7da;
    color: #721c24;
    padding: 16px;
    border-radius: 8px;
}

.result-warning {
    background: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 8px;
    font-size: 0.85rem;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

.toast.show {
    opacity: 1;
}

.migrations-section button {
    margin-bottom: 12px;
}

#migrationResult {
    font-size: 0.85rem;
}

.col-required {
    font-weight: 700;
}

@media (max-width: 640px) {
    .empresa-row {
        flex-direction: column;
        align-items: stretch;
    }

    select {
        min-width: auto;
        width: 100%;
    }

    .nueva-empresa {
        flex-direction: column;
    }

    .nueva-empresa input {
        width: 100%;
    }

    .catalogo-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}
