* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 24px;
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f5f7;
    color: #1f2937;
}

.contenedor {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
}

.contenedor-formulario {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.cabecera-formulario {
    margin-bottom: 24px;
}

h1 {
    margin: 0 0 8px;
    font-size: 30px;
}

p {
    line-height: 1.5;
}

.boton {
    display: inline-block;
    padding: 11px 16px;
    border: 0;
    border-radius: 8px;
    background: #2563eb;
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.boton:hover {
    background: #1d4ed8;
}

.boton-secundario {
    background: #64748b;
}

.boton-secundario:hover {
    background: #475569;
}

.boton-editar {
    background: #d97706;
}

.boton-editar:hover {
    background: #b45309;
}

.boton-eliminar {
    background: #dc2626;
}

.boton-eliminar:hover {
    background: #b91c1c;
}

.resumen {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.tarjeta {
    padding: 20px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.tarjeta span {
    display: block;
    margin-bottom: 8px;
    color: #6b7280;
    font-size: 14px;
}

.tarjeta strong {
    font-size: 25px;
}

.tabla-contenedor {
    overflow-x: auto;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    white-space: nowrap;
}

th {
    background: #eaf0f8;
    font-size: 14px;
}

tbody tr:hover {
    background: #f9fafb;
}

.acciones {
    display: flex;
    gap: 8px;
}

.acciones form {
    margin: 0;
}

.acciones .boton {
    padding: 8px 10px;
    font-size: 13px;
}

.mensaje {
    padding: 16px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.mensaje-error {
    margin-bottom: 20px;
    padding: 16px 18px;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
}

.mensaje-error ul {
    margin: 0;
    padding-left: 20px;
}

.mensaje-exito {
    border: 1px solid #86efac;
    background: #dcfce7;
    color: #166534;
}

.sin-datos {
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
}

.observaciones {
    min-width: 220px;
    white-space: normal;
}

.formulario {
    padding: 24px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.grupo {
    margin-bottom: 20px;
}

.grupo-doble {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.grupo-triple {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

label {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
}

input:focus,
textarea:focus {
    outline: 2px solid #93c5fd;
    border-color: #2563eb;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

fieldset {
    margin: 0 0 22px;
    padding: 20px;
    border: 1px solid #dbe3ec;
    border-radius: 10px;
}

legend {
    padding: 0 8px;
    font-weight: 700;
}

.formulario .acciones {
    justify-content: flex-end;
    margin-top: 24px;
}

.ayuda {
    margin-top: 6px;
    color: #64748b;
    font-size: 13px;
}

.resumen-calculo {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 20px;
    padding: 16px;
    border-radius: 10px;
    background: #eff6ff;
}

.resumen-calculo strong {
    display: block;
    margin-top: 4px;
    font-size: 20px;
}

@media (max-width: 900px) {
    .tabla-contenedor {
        overflow: visible;
        background: transparent;
        box-shadow: none;
    }

    .tabla-contenedor table,
    .tabla-contenedor tbody {
        display: block;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .tabla-contenedor thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .tabla-contenedor tbody {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
        gap: 16px;
    }

    .tabla-contenedor tbody tr {
        display: block;
        min-width: 0;
        overflow: hidden;
        border: 1px solid #dbe3ec;
        border-radius: 12px;
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    }

    .tabla-contenedor tbody tr:hover {
        background: #ffffff;
    }

    .tabla-contenedor td {
        display: grid;
        grid-template-columns: minmax(112px, 38%) minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        width: 100%;
        padding: 11px 14px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .tabla-contenedor td::before {
        content: attr(data-label);
        color: #64748b;
        font-size: 13px;
        font-weight: 700;
    }

    .tabla-contenedor td:first-child {
        padding-top: 14px;
        background: #eaf0f8;
        font-weight: 700;
    }

    .tabla-contenedor td:last-child {
        padding-top: 14px;
        padding-bottom: 14px;
        border-bottom: 0;
    }

    .tabla-contenedor .observaciones {
        min-width: 0;
    }

    .tabla-contenedor .acciones {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .tabla-contenedor .acciones form,
    .tabla-contenedor .acciones .boton {
        width: 100%;
    }
}

@media (max-width: 700px) {
    body {
        padding: 14px;
    }

    .contenedor,
    .contenedor-formulario {
        width: calc(100% - 16px);
        max-width: calc(100% - 16px);
    }

    .cabecera {
        align-items: stretch;
        flex-direction: column;
    }

    .cabecera .boton {
        width: 100%;
    }

    .resumen,
    .grupo-doble,
    .grupo-triple,
    .resumen-calculo {
        grid-template-columns: 1fr;
    }

    .formulario .acciones {
        flex-direction: column-reverse;
    }

    .formulario .acciones .boton {
        width: 100%;
    }

    h1 {
        font-size: 24px;
    }
}

@media (max-width: 420px) {
    .tabla-contenedor td {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .tabla-contenedor .acciones {
        grid-template-columns: 1fr;
    }
}
