:root {
    --rur-primary: #0f4c81;
    --rur-primary-hover: #0a3358;
    --rur-primary-light: #f0f6fa;
    --rur-accent: #2563eb;
    --rur-accent-hover: #1d4ed8;
    --rur-emerald: #059669;
    --rur-emerald-hover: #047857;
    --rur-amber: #d97706;
    --rur-amber-hover: #b45309;
    --rur-bg: #f8fafc;
    --rur-card-bg: #ffffff;
    --rur-text: #1e293b;
    --rur-text-muted: #475569;
    --rur-border: #cbd5e1;
    --rur-border-focus: #0f4c81;
    --rur-input-bg: #ffffff;
    --rur-success-bg: #f0fdf4;
    --rur-success-border: #bbf7d0;
    --rur-success-text: #166534;
    --rur-error-bg: #fef2f2;
    --rur-error-border: #fecaca;
    --rur-error-text: #991b1b;
    --rur-radius: 10px;
    --rur-shadow: 0 4px 20px -2px rgba(15, 76, 129, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
}

.rur-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.rur-wrapper {
    width: 100%;
    padding: 1.5rem 0.75rem;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--rur-text);
}

.rur-container {
    width: 100%;
    max-width: 840px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rur-page-title {
    font-size: 1.85rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0.5rem 0 1.5rem 0;
    text-align: center;
    letter-spacing: -0.025em;
}

.rur-card {
    background: var(--rur-card-bg);
    width: 100%;
    border-radius: var(--rur-radius);
    padding: 2.25rem 2.5rem;
    box-shadow: var(--rur-shadow);
    border: 1px solid var(--rur-border);
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

/* ========================================================
   CUADROS SUPERIORES DE PASOS CON LÍNEA DE PROGRESO
   ======================================================== */
.rur-step-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: -2.25rem -2.5rem 2rem -2.5rem;
    border-bottom: 1px solid var(--rur-border);
    background-color: #f8fafc;
    position: relative;
}

.rur-step-progress-track {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: transparent;
    z-index: 2;
}

.rur-step-progress-bar {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, var(--rur-primary) 0%, var(--rur-accent) 100%);
    transition: width 0.35s ease, background-color 0.3s ease;
}

.rur-step-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    color: var(--rur-text-muted);
    background-color: #f8fafc;
    position: relative;
    border: none;
    outline: none;
}

.rur-step-tab:focus-visible {
    box-shadow: inset 0 0 0 2px var(--rur-primary);
}

.rur-step-tab:first-child {
    border-right: 1px solid var(--rur-border);
}

.rur-tab-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: #e2e8f0;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.rur-tab-text {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Estado Activo */
.rur-step-tab.active {
    background-color: #ffffff;
    color: var(--rur-primary);
}

.rur-step-tab.active .rur-tab-num {
    background-color: var(--rur-primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(15, 76, 129, 0.3);
}

/* Estado Completado */
.rur-step-tab.completed {
    background-color: #f0fdf4;
    color: var(--rur-emerald);
}

.rur-step-tab.completed .rur-tab-num {
    background-color: var(--rur-emerald);
    color: #ffffff;
}

/* ========================================================
   ENCABEZADOS DE PASOS
   ======================================================== */
.rur-step-content {
    display: none;
    animation: rurFadeIn 0.25s ease-out;
}

.rur-step-content.active {
    display: block;
}

@keyframes rurFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.rur-step-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.rur-section-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rur-text);
    margin: 0 0 0.35rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

.rur-section-desc {
    font-size: 0.875rem;
    color: var(--rur-text-muted);
    margin: 0;
}


/* ========================================================
   FORMULARIO: INPUTS Y ESTILOS
   ======================================================== */
.rur-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.rur-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.rur-field label {
    font-size: 0.825rem;
    font-weight: 600;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    letter-spacing: 0.01em;
}

.rur-req {
    color: #dc2626;
    font-weight: 700;
}

.rur-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.rur-icon {
    position: absolute;
    left: 0.75rem;
    width: 1rem;
    height: 1rem;
    color: #94a3b8;
    pointer-events: none;
    z-index: 2;
    transition: color 0.15s ease;
}

.rur-card input[type="text"],
.rur-card input[type="number"],
.rur-card select {
    width: 100%;
    padding: 0.5rem 0.85rem 0.5rem 2.35rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--rur-text);
    background-color: var(--rur-input-bg);
    border: 1px solid var(--rur-border);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    box-sizing: border-box;
    height: 38px;
    line-height: normal;
}

.rur-card textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--rur-text);
    background-color: var(--rur-input-bg);
    border: 1px solid var(--rur-border);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    resize: vertical;
    min-height: 75px;
}

.rur-card input:focus,
.rur-card select:focus,
.rur-card textarea:focus {
    background-color: #ffffff;
    border-color: var(--rur-border-focus);
    box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.15);
}

.rur-input-wrap:focus-within .rur-icon {
    color: var(--rur-border-focus);
}

.rur-card select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 0.95em;
    cursor: pointer;
}

.rur-card select:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
    border-color: #e2e8f0;
    opacity: 0.9;
}

/* Grupo de Cédula Unificado (Input-Group) */
.rur-cedula-group {
    display: flex;
    width: 100%;
}

.rur-cedula-group select {
    width: 72px;
    flex-shrink: 0;
    padding-left: 0.75rem;
    padding-right: 1.5rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    background-color: #f8fafc;
    font-weight: 600;
}

.rur-cedula-group .rur-input-wrap {
    flex-grow: 1;
}

.rur-cedula-group .rur-input-wrap input {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ========================================================
   BLOQUE PARA AÑADIR / EDITAR FILAS
   ======================================================== */
.rur-add-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 1.25rem 1.35rem 0.5rem 1.35rem;
    margin-bottom: 1.75rem;
    transition: all 0.25s ease;
}

.rur-add-box.rur-editing-mode {
    border-color: var(--rur-amber);
    background-color: #fffbeb;
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2);
}

.rur-add-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #e2e8f0;
}

.rur-add-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rur-add-btn-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rur-btn-add {
    background-color: var(--rur-emerald);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.2);
}

.rur-btn-add:hover {
    background-color: var(--rur-emerald-hover);
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.rur-editing-mode .rur-btn-add {
    background-color: var(--rur-amber);
}

.rur-editing-mode .rur-btn-add:hover {
    background-color: var(--rur-amber-hover);
}

.rur-btn-cancel {
    background-color: #e2e8f0;
    color: #334155;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.rur-btn-cancel:hover {
    background-color: #cbd5e1;
}

/* ========================================================
   TABLA DINÁMICA FORMAL
   ======================================================== */
.rur-table-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.rur-table-section-title {
    margin: 0;
    font-size: 1rem;
    color: var(--rur-text);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rur-table-container {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--rur-border);
    background: #ffffff;
}

.rur-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.rur-table th {
    background-color: #f8fafc;
    color: #334155;
    font-weight: 700;
    padding: 0.75rem 0.95rem;
    border-bottom: 1.5px solid var(--rur-border);
    white-space: nowrap;
    font-size: 0.825rem;
}

.rur-table td {
    padding: 0.65rem 0.95rem;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
    vertical-align: middle;
}

.rur-table tbody tr:hover {
    background-color: #f8fafc;
}

.rur-col-num {
    width: 45px;
    font-weight: 700;
    color: #64748b;
}

.rur-col-actions {
    width: 140px;
    text-align: center;
}

.rur-table-empty {
    text-align: center;
    padding: 2.25rem 1rem;
    color: var(--rur-text-muted);
}

.rur-empty-icon {
    width: 34px;
    height: 34px;
    stroke: #94a3b8;
    margin-bottom: 0.4rem;
}

.rur-empty-hint {
    color: #64748b;
    display: block;
    margin-top: 0.25rem;
}

.rur-row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.rur-btn-edit {
    background-color: #e0f2fe;
    color: #0369a1;
    border: none;
    border-radius: 5px;
    padding: 0.3rem 0.55rem;
    font-size: 0.775rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s ease;
}

.rur-btn-edit:hover {
    background-color: #bae6fd;
    color: #0284c7;
}

.rur-btn-del {
    background-color: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 5px;
    padding: 0.3rem 0.55rem;
    font-size: 0.775rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s ease;
}

.rur-btn-del:hover {
    background-color: #fecaca;
    color: #b91c1c;
}

/* ========================================================
   BOTONES DE NAVEGACIÓN Y ACCIÓN
   ======================================================== */
.rur-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.rur-btn-nav {
    padding: 0.7rem 1.45rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.2s ease;
    border: none;
}

.rur-btn-prev {
    background-color: #e2e8f0;
    color: #334155;
}

.rur-btn-prev:hover {
    background-color: #cbd5e1;
}

.rur-btn-next,
.rur-btn-submit {
    background: linear-gradient(135deg, var(--rur-primary) 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 76, 129, 0.2);
    margin-left: auto;
}

.rur-btn-next:hover,
.rur-btn-submit:hover {
    background: linear-gradient(135deg, var(--rur-primary-hover) 0%, #1e40af 100%);
    box-shadow: 0 4px 12px rgba(15, 76, 129, 0.3);
}

.rur-btn-submit:disabled,
.rur-btn-next:disabled {
    background: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
}

/* Spinner */
.rur-btn-spinner {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.rur-spin-circle {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: rurSpin 0.75s linear infinite;
}

@keyframes rurSpin {
    to { transform: rotate(360deg); }
}

/* Alertas */
.rur-alert {
    display: none;
    padding: 0.85rem 1.15rem;
    border-radius: 7px;
    font-size: 0.875rem;
    line-height: 1.45;
    margin-top: 1.25rem;
    animation: rurFadeIn 0.25s ease-out;
}

.rur-alert-success {
    background: var(--rur-success-bg);
    border: 1px solid var(--rur-success-border);
    color: var(--rur-success-text);
}

.rur-alert-error {
    background: var(--rur-error-bg);
    border: 1px solid var(--rur-error-border);
    color: var(--rur-error-text);
}

.rur-badge-count {
    background-color: var(--rur-primary-light);
    color: var(--rur-primary);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    margin-left: 0.4rem;
}

/* ========================================================
   RESPONSIVIDAD Y CARD-VIEW PARA MÓVILES (< 768px)
   ======================================================== */
@media (max-width: 768px) {
    .rur-card {
        padding: 1.5rem 1rem;
        border-radius: 8px;
    }
    
    .rur-step-tabs {
        margin: -1.5rem -1rem 1.5rem -1rem;
    }

    .rur-grid-2 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .rur-add-box {
        padding: 1.1rem 0.9rem;
    }

    .rur-add-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .rur-add-btn-group {
        width: 100%;
    }

    .rur-btn-add,
    .rur-btn-cancel {
        flex: 1;
        justify-content: center;
    }

    .rur-actions {
        flex-direction: column-reverse;
    }

    .rur-btn-nav {
        width: 100%;
        justify-content: center;
    }

    /* Card-view móvil para la tabla de períodos */
    .rur-table-container {
        border: none;
        background: transparent;
    }

    .rur-table, 
    .rur-table thead, 
    .rur-table tbody, 
    .rur-table th, 
    .rur-table td, 
    .rur-table tr {
        display: block;
    }

    .rur-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .rur-table tbody tr {
        background: #ffffff;
        border: 1px solid var(--rur-border);
        border-radius: 8px;
        margin-bottom: 0.85rem;
        padding: 0.75rem 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    }

    .rur-table td {
        border: none;
        padding: 0.35rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.825rem;
    }

    .rur-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #475569;
        margin-right: 0.75rem;
    }

    .rur-table td.rur-col-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 0.6rem;
        margin-top: 0.4rem;
        border-top: 1px dashed #e2e8f0;
    }

    .rur-table td.rur-col-actions::before {
        display: none;
    }
}
