/* Para que todo respete el ancho correctamente */
*,
*::before,
*::after {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ---------- BASE ---------- */

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #e5e7eb;              /* gris claro, mucho menos oscuro */
    margin: 0;
    padding: 16px;
    color: #111827;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

/* ---------- HEADER / BRANDING ---------- */

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    color: #111827;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-desktop {
    max-width: 260px;  /* tope de ancho en escritorio */
    width: 100%;       /* ocupa el ancho disponible dentro del header */
    height: auto;      /* la altura se calcula sola */
}

.logo-mobile {
    display: none; /* de momento no usamos otro logo distinto en móvil */
}

.header-text h1 {
    margin: 0 0 4px;
    font-size: 24px;
    color: #020617;
}

.header-text p {
    margin: 0;
    font-size: 13px;
    color: #4b5563;
}

/* ---------- CARDS / FORM ---------- */

.card {
    background: #f9fafb;
    border-radius: 14px;
    padding: 18px 18px 20px;
    margin-bottom: 16px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
    border: 1px solid #e5e7eb;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
    color: #020617;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-bottom: 12px;
    align-items: center;
}

.form-row label {
    font-size: 14px;
    color: #111827;
}

.form-row input[type="text"],
.form-row input[type="number"] {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5f5;
    min-width: 220px;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
}

.form-row input::placeholder {
    color: #9ca3af;
}

.form-row input:focus {
    outline: 1px solid #1d4ed8;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.hint {
    font-size: 12px;
    color: #6b7280;
}

.buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    padding: 9px 18px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.02em;
}

#calculateBtn {
    background: #1d4ed8;   /* azul LARES aprox */
    color: white;
}

#calculateBtn:hover {
    background: #2563eb;
}

#saveBtn {
    background: #10b981;
    color: white;
}

#saveBtn:hover:enabled {
    background: #059669;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- TABLAS ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
    text-align-last: center;
    background: #ffffff;
}

th, td {
    border: 1px solid #e5e7eb;
    padding: 6px 8px;
    text-align: right;
    color: #111827;
}

th:first-child, td:first-child {
    text-align: left;
}

th {
    background: #f3f4f6;
    color: #111827;
    font-weight: 600;
}

/* Colores de grupo de columnas */
th.group-fijo,
td.group-fijo {
    background: #fef9c3; /* Amarillo pastel */
}

th.group-oferta,
td.group-oferta {
    background: #dbeafe; /* Azul pastel */
}

th.group-hibrida,
td.group-hibrida {
    background: #dcfce7; /* Verde claro */
}

/* Banner IVA */

.banner {
    background: #1d4ed8;
    border: 1px solid #1d4ed8;
    padding: 5px 11px;
    border-radius: 999px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #ffffff;
    text-align: center;
}

/* ---------- VISTA ESCRITORIO / MÓVIL RESULTADOS ---------- */

.table-desktop {
    margin-top: 10px;
}

.mobile-cards {
    display: none;  /* por defecto, sólo escritorio */
}

/* Tarjetas móviles */
.mobile-card {
    border-radius: 12px;
    padding: 12px 14px;
    margin-top: 10px;
    box-shadow: 0 1px 4px rgba(15,23,42,0.16);
    color: #111827;
    background: #ffffff;
}

.mobile-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
    color: #020617;
}

/* Colores coherentes con la tabla grande */
.mobile-card.fijo {
    background: #fef9c3;
}

.mobile-card.oferta {
    background: #dbeafe;
}

.mobile-card.hibrida {
    background: #dcfce7;
}

.mobile-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.mobile-card th,
.mobile-card td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(15,23,42,0.15);
    text-align: right;
}

.mobile-card th:first-child,
.mobile-card td:first-child {
    text-align: left;
}

.mobile-card tr:last-child td {
    border-bottom: none;
}

.mobile-commission {
    font-size: 12px;
    margin-top: 6px;
    color: #111827;
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .container {
        max-width: 100%;
    }

    /* Header más centrado en móvil */
    .main-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .brand {
        justify-content: center;
    }

    .header-text h1 {
        font-size: 20px;
    }

    .header-text p {
        font-size: 12px;
    }

    .form-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row input[type="text"],
    .form-row input[type="number"] {
        min-width: 0;
        width: 100%;          /* ocupa todo el ancho de la card */
        max-width: 100%;
    }

    .buttons {
        flex-direction: column;
        width: 100%;
    }

    .buttons button {
        width: 100%;
    }

    .table-desktop {
        display: none;    /* ocultar tabla grande en móvil */
    }

    .mobile-cards {
        display: block;   /* mostrar tarjetas en móvil */
    }

    table {
        font-size: 12px;
    }

    .brand {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .logo-desktop {
        max-width: 80vw;      /* como mucho el 80% del ancho de pantalla */
        width: auto;
        height: auto;
        margin: 0 auto;
    }
}
