/* ==========================================================
   Herramienta: Madurez digital de instituciones financieras
   Requiere core-bancario-base.css (tokens, topbar, botones, formulario, contenido)
   ========================================================== */

:root {
    --mdf-step-off: #e3e8f0;
    --mdf-step-past: #9db8e8;
}

/* ---------- Hero ---------- */
.mdf-hero {
    padding-block: 48px 56px;
    color: var(--dcb-blanco);
    background: linear-gradient(180deg, var(--dcb-azul-900) 0%, var(--dcb-azul-800) 100%);
}

.mdf-hero__context { color: var(--dcb-azul-100); font-size: 15px; font-weight: 600; }

.mdf-hero h1 {
    max-width: 18ch;
    margin-top: 10px;
    font-size: clamp(2rem, 4.2vw, 3.3rem);
    font-weight: 800;
    line-height: 1.07;
    letter-spacing: -0.02em;
}

.mdf-hero__lead { max-width: 64ch; margin-top: 16px; color: #d5deeb; font-size: 17px; }

.mdf-profile {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 28px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--dcb-radio-md);
    background: rgba(255, 255, 255, 0.06);
}

.mdf-profile .dcb-field > span { color: var(--dcb-blanco); }

.mdf-hero__tip { margin-top: 12px; color: var(--dcb-azul-100); font-size: 14px; }

/* ---------- Layout ---------- */
.mdf-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 28px;
    align-items: start;
    padding-block: 36px 24px;
}

/* ---------- Dimensiones y preguntas ---------- */
.mdf-dim { margin-bottom: 12px; border-radius: var(--dcb-radio-lg); background: var(--dcb-blanco); scroll-margin-top: 16px; }

.mdf-dim > .mdf-dim__header {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 20px 22px;
    border-bottom: 1px solid var(--dcb-linea);
}

.mdf-dim__num {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--dcb-azul-800);
    background: var(--dcb-gris);
    font-weight: 800;
}

.mdf-dim .mdf-dim__num { color: var(--dcb-blanco); background: var(--dcb-azul-800); }

.mdf-dim__head h2 { color: var(--dcb-azul-900); font-size: 17px; font-weight: 800; line-height: 1.3; }

.mdf-dim__head span { display: block; color: var(--dcb-texto-suave); font-size: 14px; line-height: 1.4; }

.mdf-dim__score { display: grid; justify-items: end; gap: 2px; }

.mdf-dim__score strong { color: var(--dcb-azul-300); font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

.mdf-dim__score span { color: var(--dcb-texto-suave); font-size: 13px; white-space: nowrap; }

.mdf-questions { border-top: 1px solid var(--dcb-gris); }

.mdf-q { padding: 18px 22px 20px; border-bottom: 1px solid var(--dcb-gris); scroll-margin-top: 20px; }

.mdf-q:last-child { border-bottom: 0; }

.mdf-q.is-flash { animation: mdf-flash 1.2s ease; }

@keyframes mdf-flash { 0% { background: var(--dcb-azul-50); } 100% { background: transparent; } }

.mdf-q__text { color: var(--dcb-gris-oscuro); font-size: 15.5px; font-weight: 600; line-height: 1.45; }

.mdf-q__code { margin-right: 8px; color: var(--dcb-azul-300); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }

.mdf-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }

.mdf-opt { position: relative; display: block; cursor: pointer; }

.mdf-opt input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }

.mdf-opt__face {
    display: grid;
    gap: 7px;
    height: 100%;
    padding: 10px 10px 12px;
    border: 1.5px solid var(--dcb-linea);
    border-radius: var(--dcb-radio-sm);
    background: var(--dcb-blanco);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mdf-opt__meter { display: flex; gap: 3px; }

.mdf-opt__meter i { flex: 1; height: 5px; border-radius: 3px; background: var(--dcb-gris); }

.mdf-opt__meter i.is-on { background: var(--dcb-azul-100); }

.mdf-opt__text { color: var(--dcb-gris-oscuro); font-size: 13px; font-weight: 600; line-height: 1.3; }

.mdf-opt:hover .mdf-opt__face { border-color: var(--dcb-azul-100); }

.mdf-opt input:checked + .mdf-opt__face { border-color: var(--dcb-azul-300); background: var(--dcb-azul-50); }

.mdf-opt input:checked + .mdf-opt__face .mdf-opt__meter i.is-on { background: var(--dcb-azul-300); }

.mdf-opt input:checked + .mdf-opt__face .mdf-opt__text { color: var(--dcb-azul-800); }

.mdf-opt input:focus-visible + .mdf-opt__face { outline: 3px solid var(--dcb-naranja); outline-offset: 2px; }

/* ---------- Tablero: escalera de madurez ---------- */
.mdf-board { position: sticky; top: 16px; }

.mdf-board__card { padding: 22px; border-radius: var(--dcb-radio-lg); background: var(--dcb-blanco); }

.mdf-board__title { color: var(--dcb-azul-900); font-size: 17px; font-weight: 800; }

.mdf-stairs {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 132px;
    margin-top: 30px;
}

.mdf-stair {
    position: relative;
    flex: 1;
    height: var(--h);
    border-radius: 6px 6px 2px 2px;
    background: var(--mdf-step-off);
    transition: background-color 0.35s ease;
}

.mdf-stair.is-past { background: var(--mdf-step-past); }

.mdf-stair.is-current { background: var(--dcb-azul-300); }

.mdf-stair__you {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--dcb-blanco);
    background: var(--dcb-naranja);
    font-size: 11.5px;
    font-weight: 800;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, 6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.mdf-stair__you::after {
    position: absolute;
    top: 100%;
    left: 50%;
    border: 4px solid transparent;
    border-top-color: var(--dcb-naranja);
    transform: translateX(-50%);
    content: "";
}

.mdf-stair.is-current .mdf-stair__you { opacity: 1; transform: translate(-50%, 0); }

.mdf-verdict { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 18px; }

.mdf-verdict__score { color: var(--dcb-texto-suave); font-weight: 700; }

.mdf-verdict__score strong {
    color: var(--dcb-azul-900);
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.mdf-verdict__level { color: var(--dcb-azul-300); font-size: 17px; font-weight: 800; }

.mdf-verdict__note { margin-top: 4px; color: var(--dcb-texto-suave); font-size: 13.5px; line-height: 1.45; }

.mdf-progress { display: grid; gap: 6px; margin-top: 16px; color: var(--dcb-texto-suave); font-size: 13px; font-weight: 600; }

.mdf-progress__track { display: block; height: 6px; border-radius: 3px; background: var(--dcb-gris); overflow: hidden; }

.mdf-progress__track span { display: block; width: 0; height: 100%; background: var(--dcb-azul-800); transition: width 0.25s ease; }

.mdf-board__sub { margin-top: 20px; color: var(--dcb-azul-900); font-size: 14px; font-weight: 800; }

.mdf-dimrows { display: grid; gap: 4px; margin-top: 8px; }

.mdf-dimrow {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) 30px;
    gap: 10px;
    align-items: center;
    padding: 5px 0;
    color: inherit;
    text-decoration: none;
}

.mdf-dimrow__name { overflow: hidden; color: var(--dcb-gris-oscuro); font-size: 12.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }

/* La franja muestra los cinco niveles; el punto, la puntuación de la dimensión */
.mdf-dimrow__track {
    position: relative;
    height: 10px;
    border-radius: 5px;
    background: repeating-linear-gradient(90deg, var(--dcb-gris) 0 calc(20% - 2px), var(--dcb-blanco) calc(20% - 2px) 20%);
}

.mdf-dimrow__track i {
    position: absolute;
    top: 50%;
    left: 0;
    width: 14px;
    height: 14px;
    border: 2px solid var(--dcb-blanco);
    border-radius: 50%;
    background: var(--dcb-azul-300);
    box-shadow: 0 1px 3px rgba(5, 13, 36, 0.3);
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: left 0.35s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.mdf-dimrow__track i.is-set { opacity: 1; }

.mdf-dimrow__track i.is-weak { background: var(--dcb-naranja); }

.mdf-dimrow__value { text-align: right; color: var(--dcb-azul-900); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }

.mdf-dimrow:hover .mdf-dimrow__name { color: var(--dcb-azul-300); }

.mdf-board__actions { display: grid; gap: 8px; margin-top: 18px; }

.mdf-board__actions .dcb-btn { width: 100%; }

.mdf-reset {
    justify-self: center;
    padding: 6px 10px;
    border: 0;
    color: var(--dcb-texto-suave);
    background: none;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.mdf-reset:hover { color: var(--dcb-rojo); }

/* ---------- Resultados ---------- */
.mdf-results { padding-block: 12px 72px; }

.mdf-results__card { padding: clamp(20px, 4vw, 44px); border-radius: var(--dcb-radio-lg); background: var(--dcb-blanco); }

.mdf-results__card > h2 { color: var(--dcb-azul-900); font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 800; line-height: 1.15; }

.mdf-results__intro, .mdf-results__empty { margin-top: 6px; color: var(--dcb-texto-suave); }

.mdf-insight {
    max-width: 80ch;
    margin-top: 18px;
    padding: 14px 18px;
    border-left: 4px solid var(--dcb-naranja);
    border-radius: var(--dcb-radio-sm);
    color: var(--dcb-gris-oscuro);
    background: #fff3e6;
    font-weight: 600;
}

.mdf-insight.is-match { border-left-color: var(--dcb-azul-300); background: var(--dcb-azul-50); }

.mdf-priorities {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
    padding: 0;
    list-style: none;
    counter-reset: mdf-priority;
}

.mdf-priorities li {
    padding: 18px 20px;
    border-radius: var(--dcb-radio-md);
    background: var(--dcb-gris);
    counter-increment: mdf-priority;
}

.mdf-priorities li::before {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-bottom: 10px;
    border-radius: 50%;
    color: var(--dcb-blanco);
    background: var(--dcb-azul-800);
    font-weight: 800;
    content: counter(mdf-priority);
}

.mdf-priorities li:first-child::before { background: var(--dcb-naranja); }

.mdf-priorities strong { display: block; color: var(--dcb-azul-900); font-weight: 800; line-height: 1.3; }

.mdf-priorities__score { display: block; margin-top: 2px; color: var(--dcb-azul-300); font-size: 13px; font-weight: 700; }

.mdf-priorities p { margin-top: 8px; color: var(--dcb-texto-suave); font-size: 14.5px; }

/* ---------- Contenido: los cinco niveles ---------- */
.mdf-levels {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    margin-top: 28px;
    padding: 0;
    list-style: none;
}

.mdf-levels li {
    display: grid;
    align-content: start;
    gap: 6px;
    min-height: calc(140px + var(--step) * 28px);
    padding: 16px;
    border-top: 4px solid var(--dcb-azul-300);
    border-radius: var(--dcb-radio-sm);
    background: var(--dcb-gris);
}

.mdf-levels__range { color: var(--dcb-azul-300); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }

.mdf-levels strong { color: var(--dcb-azul-900); font-weight: 800; line-height: 1.25; }

.mdf-levels span:last-child { color: var(--dcb-texto-suave); font-size: 14px; }

.dcb-related a + a { margin-left: 4px; }

/* ---------- Barra móvil y aviso ---------- */
.mdf-mobilebar { display: none; }

.mdf-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 50;
    padding: 12px 16px;
    border-radius: var(--dcb-radio-sm);
    color: var(--dcb-blanco);
    background: var(--dcb-azul-900);
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mdf-toast.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .mdf-scale { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    .mdf-layout { grid-template-columns: minmax(0, 1fr); }
    .mdf-board { position: static; order: -1; }
    .mdf-scale { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .mdf-priorities { grid-template-columns: minmax(0, 1fr); }
    .mdf-levels { grid-template-columns: minmax(0, 1fr); }
    .mdf-levels li { min-height: 0; margin-left: calc(var(--step) * 14px); }
    .mdf-mobilebar {
        position: fixed;
        right: 12px;
        bottom: 12px;
        left: 12px;
        z-index: 40;
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 16px;
        border-radius: var(--dcb-radio-md);
        color: var(--dcb-blanco);
        background: var(--dcb-azul-900);
        box-shadow: 0 10px 30px rgba(5, 13, 36, 0.35);
        font-size: 14px;
        font-weight: 600;
        text-decoration: none;
        transition: opacity 0.2s ease, transform 0.2s ease;
    }
    .mdf-mobilebar strong { font-size: 16px; font-variant-numeric: tabular-nums; }
    .mdf-mobilebar.is-hidden { opacity: 0; transform: translateY(16px); pointer-events: none; }
    .dcb-footer { padding-bottom: 84px; }
}

@media (max-width: 720px) {
    .mdf-hero { padding-block: 32px 40px; }
    .mdf-profile { grid-template-columns: minmax(0, 1fr); padding: 16px; }
    .mdf-dim > .mdf-dim__header { grid-template-columns: 32px minmax(0, 1fr); padding: 16px; }
    .mdf-dim__num { width: 32px; height: 32px; }
    .mdf-dim__score { grid-column: 2; justify-content: start; justify-items: start; grid-auto-flow: column; gap: 10px; align-items: baseline; }
    .mdf-q { padding: 14px 16px 16px; }
    .mdf-scale { grid-template-columns: minmax(0, 1fr); }
    .mdf-opt__face { grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 12px; padding: 10px 12px; }
}

/* ---------- Reporte para imprimir / PDF ----------
   En pantalla no se ve; al imprimir es lo único que sale, en hoja carta con márgenes. */
.mdf-report { display: none; }

.rep { color: #1f2937; font-size: 10.5pt; line-height: 1.5; }

.rep h1, .rep h2, .rep h3, .rep h4 { margin: 0; color: var(--dcb-azul-900); line-height: 1.2; }

.rep-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6mm;
    align-items: end;
    padding-bottom: 5mm;
    border-bottom: 2.5pt solid var(--dcb-azul-800);
}

.rep-brand { margin: 0 0 1.5mm; color: var(--dcb-azul-300); font-size: 9.5pt; font-weight: 700; }

.rep-head h1 { font-size: 20pt; font-weight: 800; letter-spacing: -0.01em; }

.rep-date { margin: 0; color: var(--dcb-texto-suave); font-size: 9pt; text-align: right; }

.rep-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4mm;
    margin: 5mm 0 0;
}

.rep-meta dt { color: var(--dcb-texto-suave); font-size: 8.5pt; font-weight: 600; }

.rep-meta dd { margin: 0.5mm 0 0; color: var(--dcb-azul-900); font-weight: 700; }

.rep-section { margin-top: 8mm; }

.rep-section > h3 {
    margin-bottom: 3mm;
    padding-bottom: 1.5mm;
    border-bottom: 0.75pt solid var(--dcb-linea);
    font-size: 12.5pt;
    font-weight: 800;
    break-after: avoid;
}

.rep-intro { margin: 0 0 3mm; color: var(--dcb-texto-suave); }

/* Resultado general: número grande + nivel */
.rep-overall {
    display: grid;
    grid-template-columns: 42mm minmax(0, 1fr);
    gap: 7mm;
    align-items: center;
    margin-top: 7mm;
    padding: 6mm;
    border-radius: 3mm;
    background: #f1f4f9;
    break-inside: avoid;
}

.rep-score { text-align: center; }

.rep-score strong { display: block; color: var(--dcb-azul-800); font-size: 40pt; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }

.rep-score span { color: var(--dcb-texto-suave); font-size: 9pt; }

.rep-overall__label { margin: 0; color: var(--dcb-texto-suave); font-size: 9pt; font-weight: 600; }

.rep-overall h2 { margin-top: 1mm; font-size: 17pt; font-weight: 800; }

.rep-overall p { margin: 1.5mm 0 0; }

.rep-warn { color: #b45309; font-size: 9.5pt; font-weight: 600; }

/* Escala de 5 niveles */
.rep-scale {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2mm;
    margin: 0;
    padding: 0;
    list-style: none;
    break-inside: avoid;
}

.rep-scale li {
    position: relative;
    padding: 3mm 3mm 3.5mm;
    border-top: 2.5mm solid #d6dce8;
    background: #f7f9fc;
}

.rep-scale li:nth-child(2) { border-top-color: #b8c7e6; }
.rep-scale li:nth-child(3) { border-top-color: #7d9bd9; }
.rep-scale li:nth-child(4) { border-top-color: #3d6fd6; }
.rep-scale li:nth-child(5) { border-top-color: var(--dcb-azul-800); }

.rep-scale strong { display: block; color: var(--dcb-azul-900); font-size: 9.5pt; line-height: 1.25; }

.rep-scale span { display: block; margin-top: 1mm; color: var(--dcb-texto-suave); font-size: 8pt; }

.rep-scale li.is-current { outline: 1.5pt solid var(--dcb-azul-800); background: #fff; }

.rep-scale li.is-current::after {
    content: attr(data-you);
    position: absolute;
    top: -7.5mm;
    left: 3mm;
    padding: 0.6mm 2mm;
    border-radius: 1mm;
    color: #fff;
    background: var(--dcb-azul-800);
    font-size: 7.5pt;
    font-weight: 700;
}

.rep-scale-wrap { padding-top: 6mm; }

/* Tablas */
.rep-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }

.rep-table th {
    padding: 2mm 2.5mm;
    color: #fff;
    background: var(--dcb-azul-800);
    font-size: 8.5pt;
    font-weight: 700;
    text-align: left;
}

.rep-table td { padding: 2.2mm 2.5mm; border-bottom: 0.75pt solid var(--dcb-linea); vertical-align: top; }

.rep-table tr { break-inside: avoid; }

.rep-table thead { display: table-header-group; }

.rep-num { width: 11mm; color: var(--dcb-texto-suave); font-variant-numeric: tabular-nums; }

.rep-tag {
    display: inline-block;
    margin-left: 1.5mm;
    padding: 0.2mm 1.6mm;
    border-radius: 1mm;
    color: #b42318;
    background: #fde8e8;
    font-size: 7.5pt;
    font-weight: 700;
    white-space: nowrap;
}

.rep-bar { display: grid; grid-template-columns: minmax(0, 1fr) 9mm; gap: 2mm; align-items: center; }

.rep-bar__track { height: 2.6mm; border-radius: 2mm; background: #e3e8f0; overflow: hidden; }

.rep-bar__fill { display: block; height: 100%; border-radius: 2mm; background: var(--dcb-azul-300); }

.rep-bar strong { color: var(--dcb-azul-900); text-align: right; font-variant-numeric: tabular-nums; }

/* Prioridades */
.rep-priorities { margin: 0; padding: 0; list-style: none; counter-reset: rep; }

.rep-priorities li {
    display: grid;
    grid-template-columns: 8mm minmax(0, 1fr) auto;
    gap: 1mm 3mm;
    padding: 3mm 0;
    border-bottom: 0.75pt solid var(--dcb-linea);
    counter-increment: rep;
    break-inside: avoid;
}

.rep-priorities li::before {
    content: counter(rep);
    display: grid;
    grid-row: 1 / span 2;
    place-items: center;
    width: 6.5mm;
    height: 6.5mm;
    border-radius: 50%;
    color: #fff;
    background: var(--dcb-azul-800);
    font-size: 9pt;
    font-weight: 800;
}

.rep-priorities strong { color: var(--dcb-azul-900); font-size: 10.5pt; }

.rep-priorities em { color: var(--dcb-azul-300); font-style: normal; font-weight: 800; font-variant-numeric: tabular-nums; }

.rep-priorities p { grid-column: 2 / -1; margin: 0; color: #374151; }

.rep-insight { margin: 3mm 0 0; padding: 3mm 4mm; border-left: 1mm solid var(--dcb-azul-300); background: #f1f4f9; }

/* Detalle de respuestas */
.rep-answers { break-before: page; }

.rep-dim { margin-top: 5mm; }

.rep-dim h4 {
    display: flex;
    justify-content: space-between;
    gap: 4mm;
    margin-bottom: 1.5mm;
    font-size: 10.5pt;
    font-weight: 800;
    break-after: avoid;
}

.rep-dim h4 span { color: var(--dcb-azul-300); font-variant-numeric: tabular-nums; }

.rep-answer { display: flex; gap: 2mm; align-items: center; white-space: nowrap; }

.rep-meter { display: inline-flex; gap: 0.6mm; }

.rep-meter i { display: block; width: 2.2mm; height: 2.2mm; border-radius: 0.5mm; background: #e3e8f0; }

.rep-meter i.is-on { background: var(--dcb-azul-300); }

.rep-pending { color: #9aa3b2; font-style: italic; }

.rep-empty { margin-top: 8mm; padding: 6mm; border: 1pt dashed var(--dcb-linea); color: var(--dcb-texto-suave); text-align: center; }

.rep-foot {
    margin-top: 9mm;
    padding-top: 3mm;
    border-top: 0.75pt solid var(--dcb-linea);
    color: var(--dcb-texto-suave);
    font-size: 8.5pt;
    break-inside: avoid;
}

.rep-foot p { margin: 0 0 1.5mm; }

@media print {
    @page { size: letter; margin: 15mm 15mm 17mm; }
    html, body { background: #fff !important; }
    body > *:not(.mdf-report) { display: none !important; }
    .mdf-report { display: block !important; }
    * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
