/* ── Variables ── */
:root {
    --morado: #754280;
    --morado-oscuro: #5e2f6c;
    --morado-claro: #f3eaf5;
    --turquesa: #37cfb6;
    --turquesa-claro: #e6faf7;
    --naranja: #ef5e08;
    --amarillo: #feaf01;
    --fondo: #f7f5f9;
    --texto: #1a1a18;
    --texto-suave: #666;
    --borde: #e0d8e5;
}

/* ── Reset ── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Header de inicio (home/admin/index) ── */
.site-header {
    width: 100%;
    background: var(--morado);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 14px 40px rgba(117, 66, 128, 0.12);
}

.site-header img {
    height: 58px;
    width: auto;
}

.site-header-text {
    color: #fff;
}

.site-header-text h2 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.site-header-text span {
    font-size: 0.82rem;
    opacity: 0.9;
}

/* ── Contenedor principal ── */
.container {
    width: 100%;
    max-width: 1240px;
    min-height: calc(100vh - 2rem);
    margin: 0 auto;
    padding: 1.25rem 1.25rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Encabezado de página ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 0;
}

.page-brand img,
.site-logo {
    height: 80px;
    width: auto;
    border-radius: 16px;
    background: #fff;
    padding: 0.75rem;
    box-shadow: 0 18px 40px rgba(117, 66, 128, 0.08);
}

.btn-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.4rem;
    background: var(--morado);
    color: #fff;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.2s;
}

.btn-home:hover {
    background: var(--morado-oscuro);
    transform: translateY(-1px);
}

/* ── Tipografía ── */
h1 {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--morado-oscuro);
    margin-bottom: 0.35rem;
}

.subtitulo {
    font-size: 0.95rem;
    color: var(--texto-suave);
    line-height: 1.5;
    margin-bottom: 1rem;
}

section h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--morado-oscuro);
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--turquesa);
    display: inline-block;
}

/* ── Tarjetas ── */
.card {
    background: #fff;
    border: 0.5px solid var(--borde);
    border-top: 4px solid var(--morado);
    border-radius: 16px;
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 22px 60px rgba(117, 66, 128, 0.08);
}

/* ── Campos de formulario ── */
.campo {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.78rem;
    color: var(--morado);
    margin-bottom: 0.4rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

select,
input[type="text"],
input[type="date"],
input[type="radio"] {
    font-family: inherit;
}

select,
input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 0.75rem 0.95rem;
    font-size: 0.95rem;
    border: 1.5px solid var(--borde);
    border-radius: 12px;
    background: #fafaf8;
    color: var(--texto);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus,
input[type="text"]:focus,
input[type="date"]:focus {
    border-color: var(--turquesa);
    background: #fff;
    box-shadow: 0 10px 30px rgba(55, 207, 182, 0.12);
}

textarea {
    width: 100%;
    padding: 0.75rem 0.95rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1.5px solid var(--borde);
    border-radius: 12px;
    background: #fafaf8;
    color: var(--texto);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    resize: vertical;
    min-height: 80px;
}

textarea:focus {
    border-color: var(--turquesa);
    background: #fff;
    box-shadow: 0 10px 30px rgba(55, 207, 182, 0.12);
}

/* ── Botones ── */
.btn-submit {
    display: block;
    width: 100%;
    padding: 0.95rem;
    background: linear-gradient(135deg, var(--turquesa) 0%, var(--morado) 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    margin-top: 1.5rem;
    text-align: center;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.btn-submit:hover {
    background: linear-gradient(135deg, #2fd5c6 0%, var(--morado-oscuro) 100%);
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(55, 207, 182, 0.18);
}

.btn-secondary {
    background: var(--naranja);
    color: #fff;
    box-shadow: 0 8px 18px rgba(239, 94, 8, 0.18);
}

.btn-secondary:hover {
    background: #d24c06;
}

/* ── Layout de filtros ── */
.filtros-form,
.wizard-buttons {
    width: 100%;
}

.filtro-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

/* ── Formulario por pasos (wizard) ── */
.wizard-buttons {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.wizard-buttons .btn-submit {
    flex: 1;
    min-width: 170px;
    margin-top: 0;
}

.fieldset-step { display: none; }
.fieldset-step.active { display: block; }

.form-pager {
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--morado-oscuro);
}

.num-categoria {
    display: inline-block;
    background: var(--morado-claro);
    color: var(--morado-oscuro);
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 6px;
    padding: 3px 9px;
    margin-right: 6px;
    vertical-align: middle;
}

/* ── Fieldset / criterios ── */
fieldset {
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: 14px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    width: 100%;
}

legend {
    font-weight: 700;
    font-size: 1rem;
    padding: 0 0.5rem;
    color: var(--morado-oscuro);
}

.criterio {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--borde);
}

.criterio:first-of-type {
    margin-top: 0.75rem;
    border-top: none;
}

.criterio-label {
    font-size: 0.92rem;
    color: var(--morado-oscuro);
    margin-bottom: 0.5rem;
    display: block;
}

.criterio-descripcion {
    margin-top: 0.5rem;
    font-size: 0.88rem;
    color: var(--texto-suave);
    line-height: 1.5;
}

.opciones {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.opciones label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.92rem;
    cursor: pointer;
    color: var(--texto);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.opciones input[type="radio"] {
    accent-color: var(--turquesa);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.detalles-criterio {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--turquesa-claro);
    border: 1px solid var(--borde);
    border-radius: 12px;
    font-size: 0.88rem;
}

.detalles-criterio h5 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--morado-oscuro);
    font-size: 0.95rem;
    font-weight: 700;
}

.detalles-criterio p {
    margin: 0.3rem 0;
    line-height: 1.5;
}

/* ── Info grid (datos del evaluado) ── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    background: #fff;
    border: 0.5px solid var(--borde);
    border-radius: 14px;
    padding: 1.25rem;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--morado);
    margin-bottom: 2px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.info-item span {
    font-weight: 600;
    color: var(--texto);
}

/* ── Métricas ── */
.metric-boxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
}

.metric-card {
    background: var(--morado-claro);
    border: 0.5px solid var(--borde);
    border-left: 5px solid var(--morado);
    border-radius: 14px;
    padding: 1rem 1.25rem;
}

.metric-card span {
    display: block;
    font-size: 0.82rem;
    color: var(--morado);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.4rem;
}

.metric-card strong {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--morado-oscuro);
}

/* ── Tablas ── */
.ranking-table {
    overflow-x: auto;
}

.ranking-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ranking-table th {
    background: var(--morado);
    color: #fff;
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 700;
}

.ranking-table td {
    padding: 0.85rem 1rem;
    border-bottom: 0.5px solid var(--borde);
}

.ranking-table tbody tr:first-child td {
    background: var(--turquesa-claro);
    font-weight: 700;
    color: var(--morado-oscuro);
}

.ranking-table tbody tr:hover td {
    background: var(--morado-claro);
}

/* ── Utilidades ── */
.divisor {
    border: none;
    border-top: 0.5px solid var(--borde);
    margin: 1.25rem 0;
}

canvas {
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
}

.nota {
    font-size: 0.78rem;
    color: var(--texto-suave);
    text-align: center;
    margin-top: 1rem;
}

.confirmacion {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1b6e3e;
    margin-bottom: 1rem;
}

/* ── Dashboard layout ── */
.dash-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    flex-wrap: wrap;
}

.dash-header .site-logo {
    height: 48px;
    padding: 0.4rem;
    border-radius: 10px;
}

.dash-header h1 {
    font-size: 1.1rem;
    margin-bottom: 0;
}

.dash-header .subtitulo {
    font-size: 0.78rem;
    margin-bottom: 0;
    display: none;
}

.dash-header .btn-home {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 10px;
}

.dash-header .dash-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.dash-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(243,234,245,0.95) 100%);
    border: 1px solid rgba(117, 66, 128, 0.16);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(117, 66, 128, 0.07);
}

.filters-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.filters-bar .campo {
    flex: 1;
    min-width: 130px;
    margin-bottom: 0;
}

.filters-bar label {
    font-size: 0.72rem;
    margin-bottom: 0.25rem;
}

.filters-bar select,
.filters-bar input[type="text"] {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    border-radius: 10px;
}

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-family: inherit;
    background: linear-gradient(135deg, var(--turquesa) 0%, var(--morado) 100%);
    color: #fff;
    white-space: nowrap;
    align-self: flex-end;
    transition: background 0.2s;
}

.btn-sm:hover {
    background: linear-gradient(135deg, #2bb7a7 0%, var(--morado-oscuro) 100%);
}

.metric-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.metric-chip {
    background: var(--morado-claro);
    border-left: 4px solid var(--morado);
    border-radius: 10px;
    padding: 0.4rem 0.85rem;
    flex: 1;
    min-width: 120px;
}

.metric-chip span {
    display: block;
    font-size: 0.7rem;
    color: var(--morado);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.metric-chip strong {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--morado-oscuro);
}

.dash-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.dash-grid-eq {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.chart-box {
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: 12px;
    padding: 0.75rem;
}

.chart-box h3 {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--morado-oscuro);
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid var(--turquesa);
    display: inline-block;
}

.chart-wrap {
    position: relative;
    height: 210px;
}

.chart-wrap-lg {
    position: relative;
    height: 260px;
}

.table-sm {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.table-sm th {
    background: var(--morado);
    color: #fff;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 700;
    position: sticky;
    top: 0;
}

.table-sm td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid #f0edf2;
}

.table-sm tbody tr:hover td { background: var(--morado-claro); }

.table-scroll {
    max-height: 200px;
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid var(--borde);
}

.dim-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.71rem;
    font-weight: 600;
    margin: 1px 2px;
    white-space: nowrap;
}

.badge-green {
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #a5d6a7;
}

.badge-orange {
    background: #fff3e0;
    color: #bf360c;
    border: 1px solid #ffcc80;
}

.dash-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.dash-nav a,
.dash-nav button {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: none;
    color: #fff;
    background: var(--morado);
    transition: background 0.2s;
}

.dash-nav a:hover,
.dash-nav button:hover { background: var(--morado-oscuro); }

.dash-nav .btn-accent { background: var(--turquesa); }
.dash-nav .btn-accent:hover { background: #2bb7a7; }
.dash-nav .btn-warn { background: var(--naranja); }
.dash-nav .btn-warn:hover { background: #d24c06; }

.report-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--morado);
    margin: 1rem 0 0.35rem 0;
    padding-left: 0.25rem;
    border-left: 3px solid var(--turquesa);
}

/* ── Responsive ── */
@media (max-width: 700px) {
    .dash-grid, .dash-grid-eq { grid-template-columns: 1fr; }
    h1 { font-size: 1.45rem; }
}

/* ── Impresión ── */
@media print {
    body {
        background: #fff;
        color: #000;
        padding: 0;
    }

    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .no-print { display: none !important; }

    #historial-observaciones { display: block !important; }

    .page-header,
    .page-brand,
    .site-logo,
    h1,
    .subtitulo {
        color: #000;
    }

    .page-header {
        background: transparent;
        box-shadow: none;
        padding: 0;
        margin-bottom: 1rem;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
        background: #fff;
        padding: 1rem;
    }

    .filtros-form,
    .wizard-buttons,
    .btn-home,
    .btn-submit,
    .btn-secondary,
    a[role="button"] {
        display: none !important;
    }

    .ranking-table th { background: #f5f5f5; color: #000; }
    .ranking-table th,
    .ranking-table td { border-color: #ccc; }

    .nota, .confirmacion, label, .campo { break-inside: avoid; }
    section { page-break-inside: avoid; }
    canvas { page-break-inside: avoid; }

    .dash-header {
        border-bottom: 2px solid #ccc;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
    }

    .dash-card {
        background: #fff;
        box-shadow: none;
        padding: 0;
    }

    .metric-row {
        display: flex;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .metric-chip {
        border: 1px solid #ccc;
        background: #fff;
        box-shadow: none;
    }

    .chart-box {
        border: 1px solid #ddd;
        box-shadow: none;
        background: #fff;
        break-inside: avoid;
        margin-bottom: 1rem;
    }

    .chart-wrap-lg { height: 280px; }

    .table-scroll {
        max-height: none;
        overflow: visible;
    }
}
