/* Identidad institucional (Lineamientos Gráficos 2025): Museo Sans en títulos, Inter en el texto. */
@font-face {
    font-family: "Museo Sans";
    src: url("../fuentes/MuseoSans-500.otf") format("opentype");
    font-weight: 500 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Museo Sans";
    src: url("../fuentes/MuseoSans-700.otf") format("opentype");
    font-weight: 700 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Museo Sans";
    src: url("../fuentes/MuseoSans-900.otf") format("opentype");
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --brand-blue: #333376;
    --brand-orange: #f98829;
    --brand-sky: #0071bc;
    --brand-yellow: #f9d53d;
    --brand-ivory: #f7f4f0;
    --brand-charcoal: #2a2a2a;
    --blue: var(--brand-blue);
    --blue-dark: #25265c;
    --blue-secondary: var(--brand-sky);
    --orange: var(--brand-orange);
    --orange-hover: #d96f18;
    --yellow: var(--brand-yellow);
    --white: #ffffff;
    --surface: #ffffff;
    --soft: var(--brand-ivory);
    --surface-alt: #f0eeeb;
    --blue-soft: #e8f2f9;
    --orange-soft: #fff0e4;
    --yellow-soft: #fff8d7;
    --text: var(--brand-charcoal);
    --muted: #5f6268;
    --danger: #b42318;
    --success: #176b45;
    --border: #d6d3cf;
    /* Solido: el azul semitransparente anterior tenia contraste 1,75:1 (minimo WCAG 3:1). */
    --focus: #0057a3;
    --shadow: 0 18px 48px rgba(51, 52, 118, 0.12);
    --font-interface: "Inter", Arial, sans-serif;
    --font-heading: "Museo Sans", "Inter", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: var(--font-interface);
    background: var(--soft);
}

h1,
h2,
h3,
h4,
h5,
h6,
legend,
th {
    font-family: var(--font-heading);
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

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

button,
a,
input,
select,
textarea {
    min-width: 0;
}

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

/* Red de seguridad: con teclado el foco siempre se ve, aunque un estilo use outline:none. */
:focus-visible:not([tabindex="-1"]) {
    outline: 3px solid var(--focus) !important;
    outline-offset: 2px !important;
}

/* Sobre la barra lateral azul oscuro el azul no contrasta: amarillo. */
.icon-rail :focus-visible {
    outline-color: #ffd23f !important;
}

.button {
    display: inline-flex;
    min-height: 44px;
    padding: 0 18px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    text-align: center;
}

.button-primary {
    color: var(--white);
    background: var(--blue);
}

.button-primary:hover {
    background: var(--blue-dark);
}

.button-secondary {
    color: var(--brand-charcoal);
    background: var(--orange);
}

.button-secondary:hover {
    background: var(--yellow);
}

.button-light {
    color: var(--blue-dark);
    border: 1px solid var(--border);
    background: var(--surface);
}

.button-light:hover {
    border-color: var(--blue);
}

.button-danger {
    color: var(--white);
    background: var(--danger);
}

.button-danger:hover {
    background: #8f1d14;
}

.app-page {
    background: var(--soft);
}

.app-shell {
    min-height: 100vh;
}

.brand-mark {
    display: inline-grid;
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    color: var(--brand-charcoal);
    border-radius: 8px;
    place-items: center;
    background: var(--orange);
    font-weight: 900;
}

.app-main {
    width: auto;
    max-width: none;
    margin: 36px 28px 36px 100px;
    padding-left: 0;
}

.eyebrow {
    margin: 0 0 6px;
    /* Naranjo de marca oscurecido para texto: #f98829 sobre blanco da 2,3:1 (WCAG pide 4,5:1). */
    color: var(--orange-text, #a35200);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.brand-isotipo {
    display: block;
    width: 46px;
    height: auto;
    flex: 0 0 auto;
}

.section-heading {
    display: grid;
    margin-bottom: 16px;
    gap: 4px;
}

.section-heading h2,
.page-panel h1 {
    margin: 0;
    color: var(--blue-dark);
}

.section-heading h2 {
    font-size: clamp(1.35rem, 3vw, 1.85rem);
}

.page-panel {
    padding: clamp(24px, 5vw, 42px);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.page-panel h1 {
    margin-bottom: 12px;
    font-size: clamp(1.7rem, 4vw, 2.35rem);
    line-height: 1.1;
}

.page-panel p {
    max-width: 680px;
    margin: 0 0 10px;
    color: var(--muted);
    line-height: 1.7;
}

.button-row {
    display: flex;
    margin-top: 22px;
    flex-wrap: wrap;
    gap: 12px;
}

/* Ayuda bajo los botones de un formulario (p. ej. «Guardar como pendiente»). */
.button-row + .field-help {
    margin-top: 10px;
}

.user-menu {
    position: relative;
}

.avatar-button {
    display: inline-grid;
    width: 46px;
    height: 46px;
    overflow: hidden;
    color: var(--white);
    border-radius: 999px;
    cursor: pointer;
    place-items: center;
    background: var(--blue);
    font-weight: 800;
    list-style: none;
}

.avatar-button::-webkit-details-marker {
    display: none;
}

.avatar-button img,
.profile-avatar-xl img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 40;
    display: grid;
    width: min(270px, calc(100vw - 32px));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.user-dropdown-header {
    display: grid;
    padding: 16px;
    gap: 4px;
    border-bottom: 1px solid var(--border);
}

.user-dropdown-header strong {
    color: var(--blue-dark);
}

.user-dropdown-header span {
    color: var(--muted);
    font-size: 0.88rem;
    word-break: break-word;
}

.user-dropdown a,
.user-dropdown button {
    width: 100%;
    padding: 13px 16px;
    color: var(--text);
    border: 0;
    background: var(--surface);
    text-align: left;
    cursor: pointer;
}

.user-dropdown a:hover,
.user-dropdown button:hover,
.user-dropdown a:focus,
.user-dropdown button:focus {
    outline: none;
    background: var(--soft);
}

.user-dropdown button {
    color: var(--danger);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 22px;
}

.profile-avatar-xl {
    display: inline-grid;
    width: 112px;
    height: 112px;
    overflow: hidden;
    flex: 0 0 auto;
    color: var(--white);
    border-radius: 999px;
    place-items: center;
    background: var(--blue);
    font-size: 2rem;
    font-weight: 800;
}

.form-grid {
    display: grid;
    margin-top: 22px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.field-group {
    display: grid;
    gap: 8px;
}

.field-full {
    grid-column: 1 / -1;
}

.field-group label,
.dynamic-fieldset > legend {
    color: var(--blue-dark);
    font-size: 0.94rem;
    font-weight: 700;
}

/* Grupos de opciones (radios/casillas): fieldset para que NVDA lea la pregunta. */
.dynamic-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.dynamic-fieldset > legend {
    padding: 0;
    margin-bottom: 6px;
}

.field-group input,
.field-group select,
.field-group textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.password-input-wrap {
    position: relative;
}

.field-group .password-input-wrap input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    display: inline-grid;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--muted);
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    place-items: center;
    transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle:focus {
    color: var(--blue-dark);
    background: var(--soft);
}

.password-toggle:focus {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.password-toggle svg {
    width: 22px;
    height: 22px;
}

.field-group textarea {
    resize: vertical;
}

.field-error {
    margin: 0;
    color: var(--danger);
    font-size: 0.88rem;
    font-weight: 600;
}

.status-message,
.error-box,
.info-box {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 8px;
    font-weight: 700;
}

.status-message {
    color: var(--success);
    background: #e9f7ef;
}

.invitation-message {
    display: grid;
    gap: 10px;
    color: var(--blue-dark);
    border: 1px solid #b9d7c6;
}

.invitation-message p {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.invitation-message .button {
    width: fit-content;
}

.invitation-message code {
    display: block;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.error-box {
    color: var(--danger);
    background: #fff0ed;
}

.error-list {
    display: grid;
    margin: 10px 0 0;
    padding-left: 20px;
    gap: 6px;
    color: var(--text);
    font-weight: 600;
}

.error-list li::marker {
    color: var(--danger);
}

.error-box-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
}

.error-list a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.info-box {
    color: var(--blue-dark);
    background: var(--blue-soft);
    border: 1px solid #b9d8ec;
}

.section-divider {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.table-wrap {
    overflow-x: auto;
    margin-top: 22px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--blue-dark);
    font-size: 0.88rem;
    text-transform: uppercase;
}

.permission-grid {
    display: grid;
    margin: 22px 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.permission-item {
    display: flex;
    padding: 12px 14px;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--soft);
    font-weight: 700;
}

@media (max-width: 760px) {
    .app-main {
        width: calc(100% - 82px);
        margin: 0 10px 28px 72px;
        padding-left: 0;
        padding-top: 68px;
    }

    .profile-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-grid,
    .permission-grid {
        grid-template-columns: 1fr;
    }
}

/* Formularios cortos en una columna (contraseña, perfil): el orden visual es el de lectura. */
.form-panel-angosto {
    max-width: 46rem;
}

.form-una-columna {
    display: grid;
    margin-top: 16px;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

.form-paso {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.form-paso h2 {
    margin: 0 0 6px;
    color: var(--blue-dark);
    font-size: 1.2rem;
}

.form-paso > .field-help {
    margin: 0;
}
