*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f5f7fa;
    color: #1e293b;
    line-height: 1.5;
    margin: 0;
    padding: 24px;
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
}

h1 {
    margin-top: 0;
    margin-bottom: 8px;
    color: #0f172a;
    font-size: 1.85rem;
}

h2 {
    margin-top: 0;
    margin-bottom: 14px;
    color: #1e293b;
    font-size: 1.25rem;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 8px;
}

h3 {
    color: #334155;
    font-size: 1.05rem;
    margin-top: 20px;
    margin-bottom: 10px;
}

.contenido-principal > p {
    color: #475569;
    margin-top: 0;
    margin-bottom: 20px;
}

.contenido-principal > p a {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 600;
}

.contenido-principal > p a:hover {
    text-decoration: underline;
}

.card {
    background: #fff;
    padding: 20px 24px;
    margin: 16px 0;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
}

.q {
    display: grid;
    grid-template-columns: 1fr 84px;
    gap: 16px;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid #f1f5f9;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

.q:last-child {
    border-bottom: none;
}

.q:hover {
    background-color: #f8fafc;
}

.q label {
    cursor: pointer;
    font-size: 0.95rem;
    color: #334155;
}

.q select {
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.95rem;
    font-weight: 600;
    background-color: #fff;
    color: #1e293b;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    outline: none;
}

.q select:focus-visible {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

.q select.estado-0 {
    border-color: #dc3545;
    background-color: #fff5f5;
    color: #b02a37;
}

.q select.estado-1 {
    border-color: #fd7e14;
    background-color: #fff9f2;
    color: #ca6510;
}

.q select.estado-2 {
    border-color: #ffc107;
    background-color: #fffdf0;
    color: #997404;
}

.q select.estado-3 {
    border-color: #0d6efd;
    background-color: #f0f6ff;
    color: #0a58ca;
}

.q select.estado-4 {
    border-color: #198754;
    background-color: #f2fbf6;
    color: #146c43;
}

textarea {
    width: 100%;
}

button {
    padding: 10px;
    margin: 5px;
}

.acciones {
    margin-top: 24px;
    text-align: center;
    padding: 18px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.acciones button {
    padding: 12px 22px;
    margin: 2px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.acciones button:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.acciones button:active {
    transform: translateY(0);
}

button#btnRespuestasAleatorias {
    background: #6f42c1;
    color: white;
}

button#btnCalcular {
    background: #0066cc;
    color: white;
}

button#btnExportarExcel {
    background: #28a745;
    color: white;
}

button#btnExportarPDF {
    background: #dc3545;
    color: white;
}

#irFinal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 20px;
    cursor: pointer;
}

.layout {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.contenido-principal {
    flex: 1.45;
    min-width: 0;
}

.panel-ayuda {
    flex: 1;
    min-width: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    background: white;
    border-radius: 10px;
    padding: 22px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.tabla-leyenda {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.tabla-leyenda th,
.tabla-leyenda td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

.tabla-leyenda thead th {
    background-color: #f8fafc;
    color: #334155;
    font-weight: 700;
    border-bottom: 2px solid #cbd5e1;
    white-space: nowrap;
}

.tabla-leyenda tbody tr:hover {
    background-color: #f8fafc;
}

.panel-ayuda p {
    margin-top: 16px;
    margin-bottom: 0;
    font-size: 0.88rem;
    color: #64748b;
    text-align: right;
}

.panel-ayuda a {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 600;
}

.panel-ayuda a:hover {
    text-decoration: underline;
}

#btnGuia {
    position: fixed;
    right: 24px;
    bottom: 20px;
    z-index: 9999;
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px 22px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: 0.3s;
}

#btnGuia:hover {
    background: #0b5ed7;
    transform: scale(1.05);
}

.oculto {
    display: none;
}

#res {
    font-size: 1.5rem;
    padding: 14px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    background: #f8fafc;
    border-left: 6px solid #0d6efd;
    color: #0f172a;
    display: inline-block;
}

#res.nivel-traditional {
    border-left-color: #dc3545;
    background: #fff5f5;
}

#res.nivel-initial {
    border-left-color: #fd7e14;
    background: #fff9f2;
}

#res.nivel-advanced {
    border-left-color: #0d6efd;
    background: #f0f6ff;
}

#res.nivel-optimal {
    border-left-color: #198754;
    background: #f2fbf6;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    align-items: center;
    margin-top: 10px;
}

.chart-wrapper {
    position: relative;
    height: 340px;
    width: 100%;
    padding: 12px;
    background: #fcfdfe;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
}

#dashboard.pdf-export {
    width: 760px;
    max-width: 760px;
}

#dashboard.pdf-export .charts-container {
    grid-template-columns: 1fr;
    gap: 24px;
}

#dashboard.pdf-export .chart-wrapper {
    height: 380px;
}

#dashboard.pdf-export .chart-wrapper:last-child {
    height: 430px;
}

#roadmapContent {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.roadmap-item {
    margin-bottom: 0;
    padding: 16px 18px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    border-left: 6px solid #ccc;
    background: #fafafa;
}

.roadmap-item.prioridad-critica {
    border-left-color: #dc3545;
    background: #fffafa;
}

.roadmap-item.prioridad-alta {
    border-left-color: #fd7e14;
    background: #fffcf8;
}

.roadmap-item.prioridad-media {
    border-left-color: #ffc107;
    background: #fffef7;
}

.roadmap-item.prioridad-optima {
    border-left-color: #198754;
    background: #f8fdf9;
}

.roadmap-item h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.05rem;
}

.roadmap-item ul {
    margin: 0;
    padding-left: 20px;
    color: #334155;
}

.roadmap-item li {
    margin-bottom: 6px;
}

.roadmap-item li:last-child {
    margin-bottom: 0;
}

section#resultados {
    display: none;
    margin-top: 24px;
}

@media (max-width: 1200px) {
    .layout {
        flex-direction: column;
    }

    .panel-ayuda {
        position: relative;
        top: 0;
        width: 100%;
        max-height: none;
        overflow-x: auto;
    }
}

@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .card {
        padding: 16px;
    }

    .q {
        grid-template-columns: 1fr 70px;
        gap: 10px;
    }

    .acciones button {
        width: 100%;
    }
}
