* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f8f9fc;
    color: #2c3e50;
    line-height: 1.6;
}

.container {
    max-width: 1360px;
    margin: 20px auto;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.13);
    overflow: hidden;
}

/* ==================== HEADER ==================== */
header {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    padding: 45px 20px;
    text-align: center;
}
h1 {
    font-size: 36px;
    font-weight: 900;
    margin: 0;
}

/* ==================== UPLOAD ==================== */
.upload-section {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 30px;
}
.upload-section button {
    padding: 15px 38px;
    border: none;
    border-radius: 50px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}
#loadData { background: #e74c3c; }
#loadData:hover { background: #c0392b; transform: translateY(-4px); }
.reset-btn { background: #636e72; }
.reset-btn:hover { background: #4d565b; transform: translateY(-4px); }

/* ==================== LOADING ==================== */
.loading {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.97);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.spinner {
    width: 90px;
    height: 90px;
    border: 8px solid #f0f0f0;
    border-top: 8px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== WARNING ==================== */
.performance-warning {
    background: #fff8e1;
    color: #d35400;
    padding: 20px;
    margin: 30px;
    border-radius: 16px;
    text-align: center;
    font-weight: 600;
    border-left: 6px solid #f39c12;
}

/* ==================== KPI CARDS ==================== */
.kpi-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    justify-content: center;
    padding: 50px 20px;
    background: #f0f4f8;
}
.card {
    background: white;
    padding: 32px 25px;
    border-radius: 22px;
    width: 310px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    transition: all 0.4s ease;
}
.card:hover {
    transform: translateY(-12px);
    box-shadow: 0 20px 45px rgba(0,0,0,0.15);
}
.value {
    font-size: 44px;
    font-weight: 900;
    margin: 12px 0 6px 0;
}
.currency {
    font-size: 18px;
    color: #7f8c8d;
    font-weight: 600;
}

/* Colores especiales */
.usd7   { background: linear-gradient(135deg, #10b981, #34d399) !important; color: white; }
.usd105 { background: linear-gradient(135deg, #f97316, #fb923c) !important; color: white; }
.usd-card { background: linear-gradient(135deg, #2980b9, #3498db) !important; color: white; }

.usd-card small {
    display: block;
    margin-top: 8px;
    opacity: 0.95;
    font-size: 14.5px;
}

/* ==================== CEDIS SECTION ==================== */
.comparison-section {
    padding: 70px 20px;
    background: linear-gradient(135deg, #f8f9fc, #e8f0fe);
    text-align: center;
}
.comparison-section h2 {
    font-size: 29px;
    margin-bottom: 45px;
    color: #2c3e50;
}

.pie-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 70px;
    flex-wrap: wrap;
    margin-bottom: 60px;
}
#cedisPieChart {
    max-width: 380px;
    max-height: 380px;
}

.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-width: 260px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 20px;
}
.color-box {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}
.cedi-color { background: #27ae60; }
.others-color { background: #e67e22; }
.percent-value {
    font-size: 28px;
    font-weight: 800;
    margin-left: auto;
    color: #2c3e50;
}

.comparison-cards {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}
.comp-card {
    background: white;
    padding: 35px 45px;
    border-radius: 24px;
    width: 360px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.12);
    transition: all 0.4s;
}
.comp-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 30px 70px rgba(0,0,0,0.18);
}
.comp-card.cedi { border-top: 8px solid #27ae60; }
.comp-card.others { border-top: 8px solid #e67e22; }

/* ==================== GRÁFICOS - CORRECCIÓN DE DESBORDE ==================== */
.charts-container {
    padding: 40px 20px;
}
.chart-container {
    max-width: 1100px;
    margin: 0 auto 70px;
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}
.chart-container h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
    font-weight: 800;
    color: #2c3e50;
}
.chart-container canvas {
    width: 100% !important;
    height: 420px !important;
    max-height: 420px !important;
    display: block;
    margin: 0 auto;
}

/* ==================== TABLAS ==================== */
.table-container {
    padding: 0 40px 80px;
}
.table-container h2 {
    text-align: center;
    margin: 60px 0 35px;
    font-size: 28px;
    font-weight: 800;
    color: #2c3e50;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 70px rgba(0,0,0,0.15);
}
th {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 22px;
    font-weight: 700;
    font-size: 16px;
    text-align: center;
}
td {
    padding: 18px;
    text-align: center;
    border-bottom: 1px solid #eee;
    font-size: 15px;
}
tr:hover { background: #f8fbff; }
.summary {
    background: linear-gradient(135deg, #2c3e50, #1a2530) !important;
    color: white;
    font-weight: 900;
    font-size: 18px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .card, .comp-card {
        width: 100%;
        max-width: 340px;
    }
    .chart-container canvas {
        height: 320px !important;
    }
    .container { margin: 10px; }
    h1 { font-size: 28px; }
}