*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --navy: #1a2f4b;
    --navy-dark: #0f1f33;
    --burgundy: #8b1a2b;
    --burgundy-hover: #6d1422;
    --bg-page: #e8eaed;
    --bg-card: #f3f2f1;
    --bg-input: #ffffff;
    --border: #d1d5db;
    --text: #1e293b;
    --text-muted: #64748b;
    --row-alt: #f0f4f8;
    --required: #c42b1c;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-page);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header estilo Taylor */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
}

.site-logo {
    height: 42px;
    width: auto;
    display: block;
}

.page-content {
    padding: 2rem 1.5rem 3rem;
}

.form-wrapper {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Tarjeta del formulario estilo Microsoft Forms */
.form-card {
    background: var(--bg-card);
    border-radius: 2px;
    padding: 2rem 3rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.form-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.required-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.required {
    color: var(--required);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 1.25rem;
}

.instructions {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 1.75rem;
    line-height: 1.6;
    padding: 1rem;
    background: #fff;
    border-left: 3px solid var(--navy);
}

/* Campos de texto */
.field-group {
    margin-bottom: 1.25rem;
}

.field-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.field-group input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--bg-input);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.field-group input:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 1px var(--navy);
}

.field-group input::placeholder {
    color: #9ca3af;
}

/* Preguntas con escala */
.question-block {
    border: none;
    margin-bottom: 0;
    padding: 1rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.question-block.alt {
    background: var(--row-alt);
}

.question-block.has-error {
    outline: 2px solid var(--required);
    outline-offset: -2px;
}

.question-block legend {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
    padding: 0;
    float: left;
    width: 100%;
}

.question-number {
    font-weight: 700;
}

.scale-options {
    clear: both;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.scale-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0.3rem 0;
    font-size: 0.875rem;
    color: var(--text);
}

.scale-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--navy);
    cursor: pointer;
    flex-shrink: 0;
}

.scale-value {
    line-height: 1.4;
}

/* Navegación */
.form-nav {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-start;
}

.form-nav-split {
    justify-content: space-between;
    align-items: center;
}

.btn {
    padding: 0.55rem 1.75rem;
    border: none;
    border-radius: 2px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-next {
    background: #1a1a1a;
    color: #fff;
}

.btn-next:hover {
    background: #333;
}

.btn-back {
    background: transparent;
    color: var(--navy);
    border: 1px solid var(--navy);
}

.btn-back:hover {
    background: rgba(26, 47, 75, 0.06);
}

.btn-submit {
    background: var(--burgundy);
    color: #fff;
}

.btn-submit:hover {
    background: var(--burgundy-hover);
}

/* Pasos */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
}

/* Alertas */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 2px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

@media (max-width: 600px) {
    .form-card {
        padding: 1.25rem 1rem;
    }

    .form-title {
        font-size: 1.25rem;
    }

    .form-nav-split {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

    .form-nav-split .btn {
        width: 100%;
        text-align: center;
    }
}

/* ===== Panel admin ===== */
.admin-login-wrap {
    max-width: 420px;
    margin: 2rem auto 0;
}

.admin-login-card .btn {
    width: 100%;
    margin-top: 0.5rem;
}

.section-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-user {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.btn-outline {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--navy);
    text-decoration: none;
    border-radius: 2px;
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-outline:hover {
    background: var(--row-alt);
}

.admin-wrap {
    max-width: 1200px;
    margin: 0 auto;
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.admin-toolbar-inline {
    margin-bottom: 1.25rem;
}

.admin-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.admin-tab {
    display: inline-block;
    padding: 0.7rem 1.15rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.admin-tab:hover {
    color: var(--navy);
}

.admin-tab.active {
    color: var(--navy);
    border-bottom-color: var(--burgundy);
}

.persona-filter label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.persona-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.persona-filter-row select {
    flex: 1;
    min-width: 260px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: #fff;
}

.persona-filter-row .btn {
    white-space: nowrap;
}

.persona-resumen {
    margin-bottom: 1.25rem;
}

.persona-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.persona-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.75rem;
    font-size: 0.95rem;
}

.link-ver {
    color: var(--burgundy);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.link-ver:hover {
    text-decoration: underline;
}

.acciones-celda {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    white-space: nowrap;
}

.form-eliminar {
    display: inline;
    margin: 0;
}

.btn-eliminar {
    background: #fff;
    color: #991b1b;
    border: 1px solid #dc2626;
    border-radius: 2px;
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-eliminar:hover {
    background: #dc2626;
    color: #fff;
}

.fila-duplicada {
    background: #fffbeb !important;
}

.badge-duplicado {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #92400e;
    background: #fde68a;
    border-radius: 2px;
}

.persona-acciones {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.admin-filter label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.admin-filter select {
    min-width: 220px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: #fff;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 2px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-card h2 {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.1;
}

.severity-section,
.table-section {
    margin-bottom: 1.5rem;
}

.severity-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.severity-block h3 {
    font-size: 1rem;
    color: var(--navy);
    margin-bottom: 0.85rem;
}

.sev-row {
    margin-bottom: 0.65rem;
}

.sev-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.sev-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.sev-bar-fill {
    height: 100%;
    border-radius: 4px;
    min-width: 0;
}

.sev-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 2px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.sev-normal { background: #dcfce7; color: #166534; }
.sev-leve { background: #e0f2fe; color: #075985; }
.sev-moderado { background: #fef9c3; color: #854d0e; }
.sev-severo { background: #ffedd5; color: #9a3412; }
.sev-extremo { background: #fee2e2; color: #991b1b; }

.sev-bar-fill.sev-normal { background: #22c55e; }
.sev-bar-fill.sev-leve { background: #0ea5e9; }
.sev-bar-fill.sev-moderado { background: #eab308; }
.sev-bar-fill.sev-severo { background: #f97316; }
.sev-bar-fill.sev-extremo { background: #ef4444; }

.table-scroll {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    background: var(--navy);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

.admin-table tbody tr:nth-child(even) {
    background: var(--row-alt);
}

.admin-table td .sev-badge {
    margin-left: 0.35rem;
}

@media (max-width: 900px) {
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .severity-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
