:root {
    --azul-marca: #001388;
    --rojo-marca: #A50932;
    --azul-oscuro: #0a0f3a;
    --fondo-claro: #f4f6ff;
    --texto: #1a1a2e;
    --ok: #0d7a4d;
    --radio: 12px;
    /* Mismo ancho visual para select de provincia y localidad */
    --select-compact-max: 19rem;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body.public-body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--texto);
    background: linear-gradient(145deg, var(--azul-marca), var(--rojo-marca));
    background-attachment: fixed;
}

.shell {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem 0.75rem 2.5rem;
}

/*
 * Formularios públicos: ancho amplio (~el doble del .shell por defecto o más).
 * Se usa .shell.shell-wide para ganar a cualquier .shell suelto (p. ej. fallback inline).
 */
.shell.shell-wide {
    width: min(98%, 100% - 1.25rem);
    max-width: min(1600px, 94vw);
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 640px) {
    .shell.shell-wide {
        width: 100%;
        max-width: none;
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }
}

.card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radio);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}

.card-banner img {
    display: block;
    width: 100%;
    height: auto;
}

.card-header {
    padding: 1.25rem 1.25rem 0.5rem;
    text-align: center;
}

.card-header h1 {
    margin: 0 0 0.35rem;
    font-size: clamp(1.15rem, 4vw, 1.45rem);
    color: var(--azul-marca);
}

.card-header .sub {
    margin: 0;
    font-size: 0.95rem;
    color: #444;
}

.card-body {
    padding: 0 1.25rem 1.35rem;
}

.form-grid {
    display: grid;
    gap: 0.6rem 1rem;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

/* Más campos por fila en escritorio; 1 col en móvil */
@media (min-width: 640px) {
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    .form-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.form-grid > fieldset,
.form-grid > .btn-row {
    grid-column: 1 / -1;
}

.field-span-full {
    grid-column: 1 / -1;
}

/* Grupo de campos que comparten filas (evita huecos con 2 columnas en el formulario principal) */
.form-cluster {
    display: grid;
    gap: 0.6rem 1rem;
    grid-template-columns: minmax(0, 1fr);
    grid-column: 1 / -1;
}

@media (min-width: 640px) {
    .form-cluster {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    .form-cluster {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Primera fila escolar: nombre + email + teléfono siempre 3 columnas desde tablet */
.form-cluster.form-cluster-inst {
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
    .form-cluster.form-cluster-inst {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Solo dos campos (p. ej. provincia + sede): como mucho 2 columnas */
.form-cluster-pair {
    display: grid;
    gap: 0.6rem 1rem;
    grid-template-columns: minmax(0, 1fr);
    grid-column: 1 / -1;
}

@media (min-width: 560px) {
    .form-cluster-pair {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.form-cluster-pair .field {
    min-width: 0;
}

/* Provincia + localidad: sin columnas 50/50 a todo el ancho (evita separación enorme entre ambos) */
.form-cluster-pair.form-cluster-loc {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.65rem 1rem;
}

@media (min-width: 560px) {
    .form-cluster-pair.form-cluster-loc {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

.field label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #c9d2ea;
    border-radius: 8px;
    font-size: 1rem;
}

.field textarea {
    min-height: 4rem;
    resize: vertical;
}

.field small {
    display: block;
    margin-top: 0.25rem;
    color: #555;
    font-size: 0.8rem;
}

.check-grid {
    display: grid;
    gap: 0.5rem;
}

.check-line {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
    background: #eef2ff;
}

.check-line input {
    margin-top: 0.2rem;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem;
    border: none;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(90deg, var(--azul-marca), var(--rojo-marca));
    box-shadow: 0 6px 18px rgba(0, 19, 136, 0.35);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-secondary {
    background: #e8ecfb;
    color: var(--azul-marca);
}

.btn-ghost {
    background: transparent;
    color: var(--azul-marca);
    border: 1px dashed var(--azul-marca);
}

.asesor-block {
    display: grid;
    gap: 0.5rem 0.65rem;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
    .asesor-block {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.asesor-block,
.team-block {
    border: 1px solid #dbe3fb;
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.55rem;
    background: #fafbff;
}

.team-block h4 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: var(--rojo-marca);
}

.alumno-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: 1fr;
}

@media (min-width: 560px) {
    .alumno-grid.cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    .alumno-grid.cols-2 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.footer-mini {
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.footer-mini a {
    color: #fff;
    font-weight: 600;
}

.overlay-submit {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 58, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.overlay-submit.active {
    display: flex;
}

.overlay-inner {
    background: #fff;
    padding: 1.5rem 1.75rem;
    border-radius: 14px;
    width: min(360px, 92vw);
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.progress {
    height: 8px;
    border-radius: 999px;
    background: #e3e8fb;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar {
    height: 100%;
    width: 40%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--azul-marca), var(--rojo-marca));
    animation: indet 1.1s ease-in-out infinite;
}

@keyframes indet {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(220%);
    }
}

.logos-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem 1.25rem;
    padding: 1rem 0 0.5rem;
}

.logos-row img {
    max-height: 56px;
    width: auto;
    object-fit: contain;
}

.public-footer-strip {
    margin-top: 0.35rem;
}

.public-footer-strip .logos-row--partners {
    padding-top: 0.75rem;
    padding-bottom: 0.25rem;
}

.logos-row--partners img {
    max-height: 52px;
}

.logos-row--partners-gradient img {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.public-footer-strip .footer-mini {
    padding-top: 0.15rem;
}

.partner-badge {
    min-width: 120px;
    text-align: center;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--azul-marca), var(--rojo-marca));
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

/* Admin */
body.admin-body {
    margin: 0;
    background: var(--fondo-claro);
    font-family: "Segoe UI", system-ui, sans-serif;
    color: var(--texto);
}

.admin-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 0.75rem 1rem;
    border-radius: var(--radio);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    margin-bottom: 1rem;
}

.admin-nav a {
    color: var(--azul-marca);
    font-weight: 600;
    text-decoration: none;
    margin-right: 0.75rem;
}

.admin-card {
    background: #fff;
    border-radius: var(--radio);
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    margin-bottom: 1rem;
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.data th,
table.data td {
    border: 1px solid #dde3f5;
    padding: 0.45rem 0.5rem;
    vertical-align: top;
}

table.data th {
    background: #eef2ff;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-admin {
    background: #ffe0e6;
    color: var(--rojo-marca);
}

.badge-coord {
    background: #e0f4ff;
    color: var(--azul-marca);
}

.admin-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.5rem;
    max-width: 520px;
}

.admin-menu a {
    display: block;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    background: #fff;
    color: var(--azul-marca);
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* —— Formulario: localidad + categorías —— */
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.label-row label {
    margin: 0;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-plus {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 10px;
    border: 2px dashed var(--azul-marca);
    background: linear-gradient(145deg, rgba(0, 19, 136, 0.08), rgba(165, 9, 50, 0.08));
    color: var(--azul-marca);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-plus:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 14px rgba(0, 19, 136, 0.25);
}

/* Select/input de localidad más compacto; “+” alineado en la misma fila que el control */
.localidad-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: nowrap;
}

/* Mismo ancho efectivo que el select de localidad (los <select> con width:auto se encogen al texto) */
.field.field-select-compact select {
    display: block;
    width: min(100%, var(--select-compact-max));
    max-width: min(100%, var(--select-compact-max));
}

.field .localidad-controls select,
.field .localidad-controls input[type="text"] {
    flex: 0 0 auto;
    width: min(var(--select-compact-max), calc(100% - 2.75rem));
    max-width: min(var(--select-compact-max), calc(100% - 2.75rem));
    min-width: 0;
}

.localidad-controls .btn-plus {
    align-self: center;
}

.field-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: #5a6588;
}

.field-hint.warn {
    color: #a50;
}

.fieldset-plain {
    border: none;
    margin: 0;
    padding: 0;
}

.fieldset-plain > legend {
    font-weight: 700;
    font-size: 1rem;
    color: var(--azul-marca);
    margin-bottom: 0.25rem;
    padding: 0;
}

.cat-section-intro {
    margin: 0 0 0.55rem;
    font-size: 0.88rem;
    color: #4a5568;
    line-height: 1.4;
}

.cat-help-line {
    display: block;
    margin-top: 0.65rem;
    font-size: 0.82rem;
    color: #5a6588;
}

.cat-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr;
}

@media (min-width: 520px) {
    .cat-grid-multi {
        grid-template-columns: repeat(2, 1fr);
    }
    .cat-grid-single {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 860px) {
    .cat-grid-multi {
        grid-template-columns: repeat(3, 1fr);
    }
    .cat-grid-single {
        grid-template-columns: repeat(3, 1fr);
    }
}

.cat-card {
    position: relative;
    display: block;
    margin: 0;
    cursor: pointer;
    border-radius: 14px;
    min-height: 4.5rem;
}

.cat-card-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    z-index: 2;
    cursor: pointer;
    width: 100%;
    height: 100%;
    margin: 0;
}

.cat-card-face {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.85rem 2.25rem 0.85rem 2.75rem;
    min-height: 100%;
    border-radius: 14px;
    border: 2px solid #d4dcf0;
    background: linear-gradient(160deg, #fbfcff 0%, #eef2ff 100%);
    box-shadow: 0 2px 10px rgba(0, 19, 136, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    pointer-events: none;
}

.cat-card:hover .cat-card-face {
    border-color: #9eb0e8;
    box-shadow: 0 6px 20px rgba(0, 19, 136, 0.12);
}

.cat-card-input:focus-visible + .cat-card-face {
    outline: 2px solid var(--azul-marca);
    outline-offset: 2px;
}

.cat-card-input:checked + .cat-card-face {
    border-color: var(--azul-marca);
    background: linear-gradient(145deg, rgba(0, 19, 136, 0.09), rgba(165, 9, 50, 0.08));
    box-shadow: 0 8px 24px rgba(0, 19, 136, 0.18);
}

.cat-card-input:checked + .cat-card-face .cat-card-check {
    opacity: 1;
    transform: scale(1);
    color: var(--rojo-marca);
}

.cat-card-badge {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--azul-marca), var(--rojo-marca));
    color: #fff;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 19, 136, 0.35);
}

.cat-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1e2952;
    line-height: 1.35;
}

.cat-card-check {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%) scale(0.85);
    font-size: 1.1rem;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: var(--rojo-marca);
}

.cat-card-radio .cat-card-face {
    padding-right: 2.25rem;
}
