:root {
    --verde-900: #075b36;
    --verde-800: #08783f;
    --verde-700: #198a4c;
    --verde-100: #ebf7e5;
    --verde-50: #f5fbf2;
    --tinta: #183129;
    --gris: #64756f;
    --gris-claro: #8b9994;
    --linea: #dbe7e0;
    --fondo-input: #fbfdfc;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    color: var(--tinta);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    background: radial-gradient(circle at 8% 12%, rgba(120, 185, 91, .25), transparent 28%),
                radial-gradient(circle at 92% 88%, rgba(7, 91, 54, .13), transparent 30%),
                linear-gradient(135deg, #f5fbf2, #e7f4df);
}

.page-shell {
    width: min(1140px, 100%);
}

.credencial-card {
    display: grid;
    grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
    min-height: 670px;
    overflow: hidden;
    border: 1px solid rgba(7, 91, 54, .09);
    border-radius: 28px;
    background: white;
    box-shadow: 0 26px 70px rgba(20, 66, 45, .16);
}

/* ==================== PANEL IZQUIERDO: IDENTIDAD INSTITUCIONAL ==================== */
.brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: 48px;
    color: white;
    background: linear-gradient(145deg, var(--verde-900), var(--verde-700) 65%, #53a35a);
}

.brand-panel::before,
.brand-panel::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 50%;
    pointer-events: none;
}

.brand-panel::before {
    width: 380px;
    height: 380px;
    right: -210px;
    top: -110px;
    box-shadow: 0 0 0 55px rgba(255, 255, 255, .035),
                0 0 0 110px rgba(255, 255, 255, .025);
}

.brand-panel::after {
    width: 310px;
    height: 310px;
    left: -170px;
    bottom: -150px;
}

.brand-logo,
.brand-copy,
.brand-footer {
    position: relative;
    z-index: 1;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-mark {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    color: var(--verde-900);
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.logo-mark svg {
    width: 32px;
    height: 32px;
}

.logo-type strong {
    display: block;
    font-size: 24px;
    letter-spacing: .12em;
    font-weight: 800;
}

.logo-type small {
    display: block;
    margin-top: 5px;
    opacity: .82;
    font-size: 11.5px;
    line-height: 1.45;
}

.brand-copy {
    margin: 40px 0;
}

.brand-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 22px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    background: rgba(255, 255, 255, .09);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.brand-eyebrow i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bdea9e;
    box-shadow: 0 0 10px #bdea9e;
}

.brand-copy h1 {
    margin: 0;
    font-size: clamp(34px, 3.8vw, 50px);
    letter-spacing: -.045em;
    line-height: 1.05;
    font-weight: 800;
}

.brand-copy p {
    margin: 18px 0 24px;
    opacity: .85;
    font-size: 15px;
    line-height: 1.65;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feature-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    opacity: .92;
}

.feature-pill svg {
    width: 18px;
    height: 18px;
    color: #bdea9e;
    flex-shrink: 0;
}

.brand-footer {
    opacity: .75;
    font-size: 12.5px;
    line-height: 1.6;
}

/* ==================== PANEL DERECHO: FORMULARIO Y CONSULTA ==================== */
.form-panel {
    display: flex;
    align-items: center;
    padding: 56px clamp(32px, 5vw, 68px);
    background: white;
}

.form-wrap {
    width: 100%;
    max-width: 520px;
    margin: auto;
}

.mobile-logo {
    display: none;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    color: var(--verde-800);
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    transition: color .15s ease, transform .15s ease;
}

.back-link:hover {
    color: var(--verde-900);
    transform: translateX(-3px);
}

.back-link svg {
    width: 18px;
    height: 18px;
}

.badge-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 22px;
    border-radius: 16px;
    color: var(--verde-800);
    background: var(--verde-100);
}

.badge-icon svg {
    width: 27px;
    height: 27px;
}

h2 {
    margin: 0;
    font-size: clamp(28px, 2.8vw, 36px);
    letter-spacing: -.035em;
    line-height: 1.15;
    color: var(--tinta);
    font-weight: 800;
}

.intro {
    margin: 12px 0 28px;
    color: var(--gris);
    font-size: 14.5px;
    line-height: 1.6;
}

.field-group {
    margin-bottom: 20px;
}

.field-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.field-head label {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--tinta);
}

.field-hint {
    font-size: 12px;
    color: var(--gris-claro);
}

.input-wrap {
    position: relative;
}

.input-icon {
    position: absolute;
    top: 50%;
    left: 16px;
    width: 20px;
    height: 20px;
    color: var(--gris-claro);
    transform: translateY(-50%);
    pointer-events: none;
    transition: color .18s ease;
}

.txtMatricula,
.form-input {
    width: 100%;
    height: 54px;
    padding: 0 18px 0 48px;
    border: 1.5px solid var(--linea);
    border-radius: 14px;
    color: var(--tinta);
    background: var(--fondo-input);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .04em;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.txtMatricula::placeholder,
.form-input::placeholder {
    color: #9aa7a2;
    font-weight: 400;
    letter-spacing: 0;
}

.txtMatricula:focus,
.form-input:focus {
    outline: 0;
    border-color: var(--verde-700);
    background: white;
    box-shadow: 0 0 0 4px rgba(25, 138, 76, .12);
}

.input-wrap:focus-within .input-icon {
    color: var(--verde-700);
}

.btnPrincipal,
.primary-button {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 54px;
    margin-top: 22px;
    padding: 12px 20px;
    border: 0;
    border-radius: 14px;
    color: white;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--verde-800), var(--verde-700));
    box-shadow: 0 12px 24px rgba(7, 120, 63, .22);
    transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

.btnPrincipal:hover,
.primary-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 16px 28px rgba(7, 120, 63, .28);
}

.btnPrincipal:active,
.primary-button:active {
    transform: translateY(0);
}

/* ==================== MENSAJES DE ESTADO ==================== */
.mensaje {
    display: block;
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
}

.mensaje-error {
    background: #fef3f2;
    border: 1px solid #fecdca;
    color: #b42318;
    font-weight: 600;
}

.mensaje-ok {
    background: #edfcf2;
    border: 1px solid #aaf0c4;
    color: #0f763e;
    font-weight: 600;
}

/* ==================== RESULTADO Y CREDENCIAL ==================== */
.resultado {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--linea);
}

.resultado-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.resultado-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--verde-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

.resultado-title svg {
    width: 18px;
    height: 18px;
    color: var(--verde-700);
}

.credencial-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 22px;
}

.credencial {
    width: 100%;
    max-width: 380px;
    border-radius: 20px;
    box-shadow: 0 16px 45px rgba(7, 91, 54, .18), 0 2px 10px rgba(0, 0, 0, .06);
    overflow: hidden;
    position: relative;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
}

.plantilla-credencial {
    display: block;
    width: 100%;
    height: auto;
}

.credencial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.avatar {
    position: absolute;
    top: 25.9%;
    left: 50%;
    transform: translateX(-50%);
    width: 112px;
    height: 112px;
    border-radius: 50%;
    border: 7px solid #fff;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .45), 0 8px 18px rgba(0, 0, 0, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 50px;
    font-weight: bold;
}

.avatar-inicial,
.avatar-neutral {
    background: linear-gradient(145deg, #bc4b89, #8b174e);
}

.datos {
    position: absolute;
    color: #fff;
    left: 8%;
    right: 8%;
    text-align: center;
}

.label {
    display: block;
    font-size: 8px;
    font-weight: bold;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .82);
}

.valor {
    display: block;
    font-size: 12px;
    font-weight: bold;
    line-height: 1.08;
    min-height: 14px;
    padding: 0 0 3px;
    border-bottom: 1px solid rgba(255, 255, 255, .45);
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, .2);
}

.valor-nombre {
    border-bottom: 0;
    font-size: 15.5px;
    line-height: 1.15;
    min-height: 0;
    padding: 0;
    text-transform: uppercase;
}

.datos-nombre {
    left: 10%;
    right: 10%;
    top: 49.0%;
}

.datos-matricula {
    left: 28%;
    right: 28%;
    top: 72.6%;
}

.datos-carrera {
    left: 8%;
    right: 8%;
    top: 78.1%;
}

.datos-grupo {
    left: 18%;
    right: 60%;
    top: 83.2%;
}

.datos-periodo {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    left: 4%;
    right: 4%;
    top: 93.2%;
    color: #3b2519;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
}

.acciones {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 18px;
}

.btnSecundario,
.btn-print {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    max-width: 380px;
    min-height: 48px;
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid var(--linea);
    background: white;
    color: var(--verde-900);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
    transition: background .18s ease, transform .18s ease, border-color .18s ease;
}

.btnSecundario:hover,
.btn-print:hover {
    background: var(--verde-50);
    border-color: var(--verde-700);
    transform: translateY(-1px);
}

.btnSecundario svg,
.btn-print svg {
    width: 19px;
    height: 19px;
    stroke-width: 2;
}

/* ==================== NOTAS DE PIE ==================== */
.security-note {
    margin: 32px 0 0;
    padding-top: 22px;
    border-top: 1px solid #edf2ef;
    color: #74837d;
    font-size: 12.5px;
    line-height: 1.55;
}

.support {
    margin-top: 12px;
    color: var(--gris);
    font-size: 12px;
    line-height: 1.5;
}

.address-note {
    margin-top: 18px;
    color: var(--gris-claro);
    font-size: 11px;
    line-height: 1.5;
}

/* ==================== RESPONSIVO ==================== */
@media (max-width: 920px) {
    body {
        padding: 20px;
    }

    .credencial-card {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .brand-panel {
        display: none;
    }

    .form-panel {
        padding: 40px clamp(24px, 6vw, 56px);
    }

    .mobile-logo {
        display: block;
        margin-bottom: 28px;
        color: var(--verde-900);
        font-size: 22px;
        font-weight: 800;
        letter-spacing: .1em;
    }

    .mobile-logo small {
        display: block;
        margin-top: 4px;
        color: var(--gris);
        font-size: 11.5px;
        letter-spacing: 0;
        font-weight: 500;
    }
}

@media (max-width: 480px) {
    body {
        display: block;
        padding: 0;
        background: white;
    }

    .credencial-card {
        min-height: 100vh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .form-panel {
        min-height: 100vh;
        padding: 30px 20px 36px;
    }

    .back-link {
        margin-bottom: 24px;
    }
}

/* ==================== ESTILOS DE IMPRESIÓN ==================== */
@media print {
    body {
        background: white !important;
        padding: 0 !important;
        display: block !important;
    }

    .page-shell {
        width: 100% !important;
    }

    .credencial-card {
        border: 0 !important;
        box-shadow: none !important;
        display: block !important;
    }

    .no-print,
    .brand-panel,
    .back-link,
    .mobile-logo,
    .badge-icon,
    h2,
    .intro,
    .field-group,
    .btnPrincipal,
    .primary-button,
    .mensaje,
    .security-note,
    .support,
    .address-note,
    .acciones,
    .resultado-header {
        display: none !important;
    }

    .form-panel {
        padding: 0 !important;
    }

    .form-wrap {
        max-width: none !important;
        margin: 0 !important;
    }

    .resultado {
        margin: 0 auto !important;
        padding: 20mm 0 0 !important;
        border: 0 !important;
        max-width: 90mm !important;
    }

    .credencial {
        box-shadow: none !important;
        border: 0 !important;
    }

    .plantilla-credencial {
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    .avatar,
    .valor,
    .label,
    .datos-periodo {
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
}
