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

html, body {
    width: 100%;
    height: 100%;
    overflow-x: scroll;
    overflow-y: scroll;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding: 0;
    color: #2d3748;
    line-height: 1.6;
    overflow-x: scroll;
    overflow-y: scroll;
}

.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    background: transparent;
    padding: 30px 20px;
    display: block;
    visibility: visible;
    opacity: 1;
    overflow-x: scroll;
    overflow-y: visible;
}

/* Pantalla de Login/Registro */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-screen.hidden {
    display: none;
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 10px;
    color: #2d3748;
    font-size: 1.8rem;
}

.login-subtitle {
    text-align: center;
    color: #718096;
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.auth-tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 25px;
    gap: 0;
}

.auth-tab {
    flex: 1;
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #718096;
    transition: all 0.3s ease;
    font-family: inherit;
}

.auth-tab:hover {
    color: #2d3748;
    background: #f7fafc;
}

.auth-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #f7fafc;
}

.auth-form-container {
    animation: fadeIn 0.3s ease;
}

.auth-form-container.hidden {
    display: none;
}

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

.success-message {
    margin-top: 15px;
    padding: 12px;
    background: #c6f6d5;
    color: #22543d;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #2d3748;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-hint {
    display: block;
    margin-top: 6px;
    color: #718096;
    font-size: 0.85rem;
}

.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
}

.error-message {
    margin-top: 15px;
    padding: 12px;
    background: #fed7d7;
    color: #742a2a;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
}

.main-content {
    width: 100%;
}

.main-content.hidden {
    display: none;
}

/* Header Moderno */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: block;
    visibility: visible;
    width: 100%;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 15px;
}

.header-top h1 {
    margin: 0;
    flex: 1;
}

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

.user-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
    color: #718096;
    font-size: 0.9rem;
}

.user-info span {
    font-weight: 600;
    color: #2d3748;
}

.header-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-badge {
    display: inline-block;
    margin-left: 15px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Panel de Administración */
.admin-panel {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 30px;
    margin-bottom: 30px;
}

.admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.admin-panel-header h2 {
    margin: 0;
    color: #2d3748;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 12px;
    color: white;
}

.stat-card h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.9;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.stat-card .stat-number.income {
    color: #c6f6d5;
}

.stat-card .stat-number.expense {
    color: #fed7d7;
}

.admin-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-filters .form-input {
    flex: 1;
    min-width: 200px;
}

.admin-table-container {
    overflow-x: auto;
    max-height: 600px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.admin-table-container table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.admin-table-container thead {
    background: #2d3748;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-table-container th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
}

.admin-table-container td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

.admin-table-container tbody tr:hover {
    background: #f7fafc;
}

.view-details-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Modal de Detalles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #e2e8f0;
}

.modal-header h3 {
    margin: 0;
    color: #2d3748;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #718096;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close-btn:hover {
    background: #f7fafc;
    color: #2d3748;
}

.modal-body {
    padding: 30px;
}

.modal-body p {
    margin-bottom: 15px;
    color: #2d3748;
}

.modal-body h4 {
    margin-top: 25px;
    margin-bottom: 15px;
    color: #2d3748;
}

.modal-table-container {
    overflow-x: auto;
    max-height: 400px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-top: 15px;
}

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

.modal-table th {
    background: #f7fafc;
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: #2d3748;
    border-bottom: 2px solid #e2e8f0;
}

.modal-table td {
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-table tbody tr:hover {
    background: #f7fafc;
}

header h1 {
    font-size: 2.5rem;
    color: #1a202c;
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: #718096;
    font-size: 1.1rem;
    font-weight: 400;
}

/* Cards Modernos */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 24px;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* API Key Section */
.api-key-section {
    margin-bottom: 24px;
    padding: 24px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: block;
    visibility: visible;
    width: 100%;
    box-sizing: border-box;
}

.api-key-label {
    display: block;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.api-key-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.api-key-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
    background: #f7fafc;
}

.api-key-input:focus {
    outline: none;
    border-color: #4299e1;
    background: white;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.api-key-hint {
    display: block;
    color: #718096;
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
    display: block;
    visibility: visible;
    width: 100%;
}

.upload-box {
    border: 2px dashed #cbd5e0;
    border-radius: 16px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: white;
    display: block;
    visibility: visible;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.upload-box:hover {
    border-color: #4299e1;
    background: #f7fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.upload-box.dragover {
    border-color: #4299e1;
    background: #ebf8ff;
    transform: scale(1.01);
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    cursor: pointer;
}

.upload-label svg {
    color: #4299e1;
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3748;
}

.upload-hint {
    font-size: 0.95rem;
    color: #718096;
}

.file-name {
    margin-top: 16px;
    text-align: center;
    color: #4299e1;
    font-weight: 500;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

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

/* Results */
.results {
    margin-top: 30px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
    padding: 24px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.results-header h2 {
    color: #1a202c;
    font-size: 1.75rem;
    font-weight: 700;
}

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

.category-manager {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.category-manager .form-input {
    min-width: 220px;
}

.stat-badge {
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    background: #edf2f7;
    color: #2d3748;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-badge.income {
    background: #c6f6d5;
    color: #22543d;
}

.stat-badge.expense {
    background: #fed7d7;
    color: #742a2a;
}

.stat-badge.balance {
    background: #bee3f8;
    color: #2a4365;
}

.stat-badge.balance.negative {
    background: #fed7d7;
    color: #742a2a;
}

/* Table */
.table-container {
    max-height: 600px;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
    background: white;
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: #2d3748;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: #f7fafc;
}

td {
    padding: 16px;
    font-size: 0.95rem;
    color: #2d3748;
}

.type-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.type-badge.gasto {
    background: #fed7d7;
    color: #742a2a;
}

.type-badge.ingreso {
    background: #c6f6d5;
    color: #22543d;
}

.amount {
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.amount.negative {
    color: #e53e3e;
}

.amount.positive {
    color: #38a169;
}

/* Charts */
.charts-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 30px;
}

.chart-section {
    padding: 30px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
}

.chart-section:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.chart-section h3 {
    text-align: center;
    color: #1a202c;
    margin-bottom: 30px;
    font-size: 1.4rem;
    font-weight: 600;
}

.chart-container {
    position: relative;
    height: 500px;
    max-width: 100%;
    margin: 0 auto;
}

.chart-container canvas {
    max-width: 100% !important;
    height: auto !important;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.chart-container-sankey {
    position: relative;
    height: 500px;
    max-width: 100%;
    margin: 0 auto;
    z-index: 1;
    pointer-events: auto;
    overflow: hidden;
}

.chart-container-sankey div {
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

.chart-container-sankey .plot-container,
.chart-container-sankey .svg-container {
    width: 100% !important;
    height: 100% !important;
}

/* Category Badges */
.category-badge {
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.category-badge.category-display {
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-badge.category-display:hover {
    opacity: 0.85;
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.category-cell {
    position: relative;
}

.category-select {
    display: none;
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid #4299e1;
    font-size: 0.95rem;
    font-weight: 600;
    background: white;
    color: #2d3748;
    cursor: pointer;
    outline: none;
    min-width: 180px;
    appearance: none;
    height: auto;
    line-height: 1.5;
    z-index: 100;
}

.category-select:focus {
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* Asegurar que las opciones del select también tengan un tamaño adecuado */
.category-select option {
    padding: 10px 14px;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.5;
    min-height: 40px;
}

/* Category Colors */
.category-restauracion { background: #fff5e1; color: #92400e; }
.category-salud { background: #fee2e2; color: #991b1b; }
.category-moda { background: #e0e7ff; color: #3730a3; }
.category-ocio { background: #d1fae5; color: #065f46; }
.category-transporte { background: #dbeafe; color: #1e40af; }
.category-deporte { background: #e0f2fe; color: #0c4a6e; }
.category-supermercado { background: #fef3c7; color: #92400e; }
.category-servicios { background: #e0e7ff; color: #1e1b4b; }
.category-educacion { background: #f3f4f6; color: #374151; }
.category-bancario { background: #f0f9ff; color: #0c4a6e; }
.category-tecnologia { background: #ede9fe; color: #5b21b6; }
.category-hogar { background: #fef3c7; color: #78350f; }
.category-belleza { background: #fce7f3; color: #831843; }
.category-salario { background: #d1fae5; color: #14532d; }
.category-devolucion { background: #ccfbf1; color: #134e4a; }
.category-ingreso { background: #dcfce7; color: #166534; }
.category-otros { background: #f3f4f6; color: #4b5563; }

/* Buttons */
.actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
    padding: 24px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: #4299e1;
    color: white;
}

.btn-primary:hover {
    background: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
}

.btn-secondary {
    background: #718096;
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(113, 128, 150, 0.3);
}

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

/* AI Status */
.ai-status {
    margin-top: 16px;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    text-align: center;
    font-weight: 500;
}

.ai-status.loading {
    background: #bee3f8;
    color: #2c5282;
    border: 1px solid #90cdf4;
}

.ai-status.success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.ai-status.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #fc8181;
}

/* Error */
.error {
    background: #fed7d7;
    color: #742a2a;
    padding: 16px 20px;
    border-radius: 12px;
    margin-top: 24px;
    border-left: 4px solid #e53e3e;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hidden {
    display: none !important;
}

/* Debug */
.debug {
    margin-top: 30px;
    padding: 24px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.debug h3 {
    margin-bottom: 16px;
    color: #2d3748;
    font-weight: 600;
}

.debug-content {
    margin-top: 16px;
}

.debug-content pre {
    background: #f7fafc;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    max-height: 400px;
    overflow-y: scroll;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.debug-content p {
    margin: 12px 0;
    font-size: 0.9rem;
    color: #4a5568;
}

.debug-content span {
    font-weight: 600;
    color: #4299e1;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

/* Scrollbars personalizados */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Para Firefox */
* {
    scrollbar-width: auto;
    scrollbar-color: #888 #f1f1f1;
}

/* Responsive - Tablets */
@media (max-width: 1024px) {
    .container {
        padding: 20px 16px;
    }

    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-container {
        height: 350px;
    }

    .chart-container-sankey {
        height: 350px;
    }
}

/* Responsive - Móviles */
@media (max-width: 768px) {
    .container {
        padding: 12px;
        max-width: 100%;
    }

    /* Header */
    header {
        padding: 16px 12px;
        margin-bottom: 20px;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-top h1 {
        font-size: 1.5rem;
        width: 100%;
    }

    .header-buttons {
        width: 100%;
        justify-content: space-between;
    }

    .header-buttons .btn {
        flex: 1;
        min-width: auto;
    }

    .user-info {
        font-size: 0.85rem;
        margin-top: 10px;
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .admin-badge {
        margin-left: 0;
        margin-top: 8px;
        font-size: 0.75rem;
        padding: 3px 10px;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    /* Login Screen */
    .login-container {
        padding: 10px;
    }

    .login-card {
        padding: 25px 20px;
        border-radius: 16px;
    }

    .login-card h1 {
        font-size: 1.5rem;
    }

    .login-subtitle {
        font-size: 0.85rem;
        margin-bottom: 20px;
    }

    .auth-tab {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

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

    .form-input {
        padding: 12px 14px;
        font-size: 16px; /* Previene zoom en iOS */
    }

    /* API Key Section */
    .api-key-section {
        padding: 16px;
        margin-bottom: 16px;
    }

    .api-key-input-group {
        flex-direction: column;
        gap: 10px;
    }

    .api-key-input-group .btn {
        width: 100%;
    }

    /* Upload Section */
    .upload-box {
        padding: 30px 20px;
    }

    .upload-label svg {
        width: 36px;
        height: 36px;
    }

    .upload-text {
        font-size: 0.95rem;
    }

    .upload-hint {
        font-size: 0.85rem;
    }

    /* Results */
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
        gap: 12px;
    }

    .results-header h2 {
        font-size: 1.3rem;
    }

    .stats {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .stat-badge {
        width: 100%;
        text-align: center;
        padding: 10px;
        min-width: 0;
    }

    /* Table */
    .table-container {
        max-height: 500px;
        margin-bottom: 16px;
    }

    table {
        font-size: 0.75rem;
        min-width: 800px; /* Permite scroll horizontal */
    }

    th, td {
        padding: 10px 6px;
        font-size: 0.75rem;
    }

    th {
        font-size: 0.7rem;
        padding: 8px 6px;
    }

    /* Charts */
    .charts-container {
        gap: 16px;
    }

    .chart-section {
        padding: 16px;
        margin-bottom: 16px;
    }

    .chart-section h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .chart-container {
        height: 300px;
    }

    .chart-container-sankey {
        height: 300px;
    }

    /* Actions */
    .actions {
        padding: 16px;
        gap: 8px;
        flex-direction: column;
    }

    .actions .btn {
        width: 100%;
        padding: 12px;
    }

    /* Buttons */
    .btn {
        font-size: 0.9rem;
        padding: 10px 16px;
    }

    .btn-small {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Admin Panel */
    .admin-panel {
        padding: 16px;
        margin-bottom: 16px;
    }

    .admin-panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .admin-panel-header h2 {
        font-size: 1.3rem;
    }

    .admin-panel-header .btn {
        width: 100%;
    }

    .admin-stats {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card h3 {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .admin-filters {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 16px;
    }

    .admin-filters .form-input,
    .admin-filters select {
        width: 100%;
        min-width: auto;
    }

    .admin-table-container {
        max-height: 500px;
    }

    .admin-table-container table {
        font-size: 0.7rem;
        min-width: 900px; /* Permite scroll horizontal */
    }

    .admin-table-container th,
    .admin-table-container td {
        padding: 8px 6px;
        font-size: 0.7rem;
    }

    .view-details-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Modal */
    .modal-content {
        max-width: 100%;
        margin: 10px;
        max-height: 95vh;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-body p {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    .modal-body h4 {
        font-size: 1rem;
        margin-top: 20px;
        margin-bottom: 12px;
    }

    .modal-table-container {
        max-height: 300px;
    }

    .modal-table {
        font-size: 0.7rem;
        min-width: 700px;
    }

    .modal-table th,
    .modal-table td {
        padding: 8px 6px;
    }

    /* Debug */
    .debug {
        padding: 16px;
    }

    .debug-content {
        font-size: 0.8rem;
    }

    /* Loading */
    .loading {
        padding: 20px;
    }

    .loading p {
        font-size: 0.9rem;
    }
}

/* Responsive - Móviles pequeños */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    header {
        padding: 12px 8px;
    }

    .header-top h1 {
        font-size: 1.3rem;
    }

    .login-card {
        padding: 20px 16px;
    }

    .login-card h1 {
        font-size: 1.3rem;
    }

    .results-header h2 {
        font-size: 1.1rem;
    }

    .chart-section h3 {
        font-size: 1rem;
    }

    .chart-container,
    .chart-container-sankey {
        height: 250px;
    }

    table {
        font-size: 0.7rem;
        min-width: 700px;
    }

    th, td {
        padding: 8px 4px;
        font-size: 0.7rem;
    }

    .admin-stats .stat-number {
        font-size: 1.3rem;
    }

    .admin-table-container table {
        font-size: 0.65rem;
        min-width: 800px;
    }
}
