:root {
    --color-fondo: #f6f7f9;
    --color-superficie: #ffffff;
    --color-texto: #1f2933;
    --color-borde: #d7dce2;

    --radio: 6px;
    --espacio: 1rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--color-fondo);
    color: var(--color-texto);
}

header {
    padding: 1.5rem 2rem;
    background: var(--color-primario);
    color: white;
}

header h1 {
    margin: 0;
}

nav {
    padding: 1rem 2rem;
    background: var(--color-superficie);
    border-bottom: 1px solid var(--color-borde);
}

nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

nav > ul {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

nav li ul {
    margin-top: 0.5rem;
    padding-left: 1rem;
}

nav a {
    color: var(--color-primario);
    font-weight: 600;
    text-decoration: none;
}

nav a:hover {
    text-decoration: underline;
}

main {
    width: min(1100px, calc(100% - 2rem));
    margin: 2rem auto;
    padding: 2rem;

    background: var(--color-superficie);

    border-radius: var(--radio);
}

form {
    display: grid;
    gap: var(--espacio);
    margin-bottom: 2rem;
}

.campo-formulario {
    display: grid;
    gap: 0.4rem;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.7rem;

    border: 1px solid var(--color-borde);
    border-radius: var(--radio);
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--color-acento);
    outline-offset: 2px;
}

button {
    width: fit-content;

    padding: 0.7rem 1rem;

    border: 0;
    border-radius: var(--radio);

    background: var(--color-primario);
    color: white;

    cursor: pointer;
}

button:hover {
    background: var(--color-acento);
}

table {
    width: 100%;
    margin-top: 1rem;

    border-collapse: collapse;
}

th,
td {
    padding: 0.8rem;

    border-bottom: 1px solid var(--color-borde);

    text-align: left;
}

th {
    background: var(--color-primario);
    color: white;
}

.error,
.error-campo {
    font-weight: bold;
}

.mensaje {
    margin-bottom: 1rem;
    padding: 1rem;

    border: 1px solid var(--color-borde);
    border-radius: var(--radio);
}

footer {
    width: min(1100px, calc(100% - 2rem));
    margin: 2rem auto;

    text-align: center;
}

@media (max-width: 700px) {
    nav > ul {
        flex-direction: column;
    }

    main {
        padding: 1rem;
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }
}

.cabecera-principal {
    display: flex;
    align-items: center;
}

.logo {
    display: block;
    width: auto;
    max-width: 220px;
    height: 50px;
}

.paginacion {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1.5rem;
}

.paginacion a,
.paginacion strong {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-borde);
    border-radius: var(--radio);
}

.paginacion strong {
    background: var(--color-primario);
    color: white;
}

#final-listado {
    scroll-margin-bottom: 2rem;
}

/* =========================================
   SELECT BUSCABLE PARA RELACIONES
   ========================================= */

.select-buscable {
    position: relative;
    width: 100%;
}

/* Botón principal */
.select-buscable .select-buscable-boton {
    width: 100%;
    min-height: 48px;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 10px 18px;

    background: #ffffff;
    color: #222222;

    border: 1px solid #cccccc;
    border-radius: 6px;

    font: inherit;
    text-align: left;

    cursor: pointer;
}

/* Hover del botón principal */
.select-buscable .select-buscable-boton:hover {
    background: #f7f7f7;
    color: #222222;
}

/* Panel desplegable */
.select-buscable .select-buscable-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;

    z-index: 1000;

    width: 100%;
    max-height: 300px;

    overflow-y: auto;

    background: #ffffff;

    border: 1px solid #cccccc;
    border-radius: 6px;

    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Buscador */
.select-buscable .select-buscable-busqueda {
    box-sizing: border-box;

    width: calc(100% - 16px);
    margin: 8px;
    padding: 10px 12px;

    background: #ffffff;
    color: #222222;

    border: 1px solid #aaaaaa;
    border-radius: 5px;

    font: inherit;
}

/* Focus del buscador */
.select-buscable .select-buscable-busqueda:focus {
    outline: 2px solid #2f80c9;
    outline-offset: 1px;
}

/* Contenedor de opciones */
.select-buscable .select-buscable-opciones {
    display: flex;
    flex-direction: column;

    background: #ffffff;
}

/* Cada cliente */
.select-buscable .select-buscable-opcion {
    display: block;

    width: 100%;
    min-height: 42px;

    padding: 10px 14px;

    background: #ffffff;
    color: #222222;

    border: 0;
    border-radius: 0;

    font: inherit;
    font-weight: normal;
    text-align: left;

    cursor: pointer;
}

/* Hover */
.select-buscable .select-buscable-opcion:hover,
.select-buscable .select-buscable-opcion:focus {
    background: #eeeeee;
    color: #111111;

    outline: none;
}

/* Cliente seleccionado */
.select-buscable
.select-buscable-opcion[aria-selected="true"] {
    background: #e8f1fb;
    color: #111111;
    font-weight: 600;
}

/* Sin resultados */
.select-buscable .select-buscable-vacio {
    margin: 0;
    padding: 14px;

    background: #ffffff;
    color: #666666;
}

/* Muy importante para el atributo hidden */
.select-buscable [hidden] {
    display: none !important;
}