body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #1f2933;
}

.topbar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 14px 24px;
    background: #1f3a5f;
    color: white;
    font-size: 14px;
}

.topbar-left {
    text-align: left;
    font-weight: 600;
}

.topbar-logo {
    height: 28px;
    width: auto;
    display: block;
}

.topbar-center {
    text-align: center;
    font-weight: 700;
    font-size: 16px;
}

.topbar-right {
    text-align: right;
    font-weight: 600;
}

.page-container {
    min-height: calc(100vh - 50px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    background: white;
    width: 360px;
    padding: 32px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.login-card h1 {
    margin-top: 0;
    margin-bottom: 24px;
    text-align: center;
    font-size: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #c9d1d9;
    border-radius: 6px;
    font-size: 15px;
}

.btn-primary {
    width: 100%;
    padding: 11px;
    background: #1f3a5f;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary:hover {
    background: #16304f;
}

/* ===== CONTENEDORES ===== */

.content-container {
    padding: 30px;
}

.page-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ===== BOTONES ===== */

.btn-primary-small {
    padding: 10px 18px;
    background: #1f3a5f;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary-small:hover {
    background: #16304f;
}

/* ===== TABLAS ===== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.data-table thead {
    background: #1f3a5f;
    color: white;
}

.data-table th {
    padding: 12px;
    text-align: left;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
}

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

/* ===== ESTADOS ===== */

.estado-activo {
    color: #15803d;
    font-weight: 700;
}

.estado-inactivo {
    color: #b91c1c;
    font-weight: 700;
}

/* ===== ACCIONES DE PÁGINA ===== */

.page-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.page-actions a {
    text-decoration: none;
}

/* ===== MENÚ PRINCIPAL ===== */

.user-info {
    margin-top: 4px;
    margin-bottom: 0;
    font-size: 14px;
    color: #4b5563;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 235px));
    gap: 30px;
    align-items: stretch;
}

.menu-card {
    display: block;
    box-sizing: border-box;
    background: white;
    border: 1px solid #d9dee5;
    border-radius: 10px;
    padding: 16px 18px;
    min-height: 120px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
    text-decoration: none;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.menu-card h2 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #12263f;
}

.menu-card p {
    margin: 0;
    font-size: 14px;
    line-height: 1.22;
    color: #374151;
}

.menu-card-link {
    cursor: pointer;
    border-left: 5px solid #1f3a5f;
}

.menu-card-link:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.14);
    transform: translateY(-2px);
    border-color: #1f3a5f;
}

.menu-card-disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ===== FORMULARIOS ===== */

.form-card {
    background: white;
    border: 1px solid #d9dee5;
    border-radius: 10px;
    padding: 24px;
    max-width: 720px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}

.btn-secondary-small {
    display: inline-block;
    padding: 7px 11px;
    background: #e5e7eb;
    color: #374151;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    margin-right: 5px;
    transition: all 0.15s ease;
}

.btn-secondary-small:hover {
    background: #dbe3ea;
    border-color: #94a3b8;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.form-row-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

.form-row-3 .form-group,
.form-row-4 .form-group,
.form-row-5 .form-group {
    margin-bottom: 4px;
}

.form-group select {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #c9d1d9;
    border-radius: 6px;
    font-size: 15px;
    background: white;
}

.form-actions {
    margin-top: 20px;
}

.clave-temporal {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #12263f;
}

.warning-text {
    color: #92400e;
    font-weight: 600;
}

.error-text {
    color: #b91c1c;
    font-weight: 700;
}

/* ===== RESUMEN Y ESTADOS DE PARAMETRIZACIÓN ===== */

.summary-card {
    background: white;
    border: 1px solid #d9dee5;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 20px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 18px;
    margin-bottom: 14px;
}

.summary-label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.summary-value {
    display: block;
    font-size: 22px;
    color: #12263f;
}

.estado-pendiente {
    color: #b45309;
    font-weight: 700;
}

.progress-track {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #1f3a5f;
    border-radius: 999px;
    transition: width 0.2s ease;
}

.status-badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status-complete {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* ===== BADGES DE ESTADO DE FORMULARIO (Panel de Formularios) ===== */

.badge-estado {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-abierto {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.badge-tomado {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #a5b4fc;
}

.badge-en-admin {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.badge-cerrado {
    background: #e5e7eb;
    color: #374151;
    border: 1px solid #cbd5e1;
}

/* ===== PANEL DE FORMULARIOS: ENCABEZADO FIJO + CONTENIDO CON SCROLL ===== */

.panel-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.panel-fixed-top {
    flex-shrink: 0;
    padding: 14px 30px 8px 30px;
    background: #f4f6f8;
    border-bottom: 1px solid #d9dee5;
}

.panel-fixed-top .page-header {
    margin-bottom: 6px;
}

.panel-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 30px 30px 30px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-top: 12px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-field label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.filter-field input,
.filter-field select {
    padding: 6px 8px;
    border: 1px solid #c9d1d9;
    border-radius: 6px;
    font-size: 13px;
    width: auto;
}

.data-table-compact th,
.data-table-compact td {
    padding: 6px 10px;
    font-size: 13px;
}

.data-table-compact thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* ===== DESVIACIONES (valores fuera de rango) ===== */

.data-table tbody tr.fila-desviacion,
.data-table-compact tbody tr.fila-desviacion {
    background: #fef2f2;
}

.data-table tbody tr.fila-desviacion:hover,
.data-table-compact tbody tr.fila-desviacion:hover {
    background: #fee2e2;
}

.badge-desviacion {
    display: inline-block;
    margin-left: 6px;
    color: #b91c1c;
    font-weight: 700;
    font-size: 12px;
    white-space: nowrap;
}

.summary-card-compact {
    padding: 6px 14px;
    margin-bottom: 6px;
}

.summary-card-compact .summary-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 6px 16px;
    margin-bottom: 6px;
}

.summary-card-compact .summary-label {
    font-size: 11px;
    margin-bottom: 2px;
}

.summary-card-compact .summary-value {
    font-size: 14px;
}

.summary-card-compact p {
    margin: 3px 0;
    font-size: 13px;
}

.summary-card-compact h3,
.summary-card-compact h4 {
    margin: 6px 0 4px 0;
    font-size: 14px;
}

/* ===== LINEA DE INFO COMPACTA (encabezados de detalle, una sola fila) ===== */

.info-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 26px;
}

.info-line .info-item {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
}

.info-line .info-item .info-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
}

.info-line .info-item .info-value {
    font-size: 13px;
    color: #12263f;
}

/* ===== FORMULARIO DE EDICIÓN ADMIN: FILAS DE TABLA EDITABLES ===== */

.data-table-compact input[type="text"],
.data-table-compact input[type="number"],
.data-table-compact input[type="datetime-local"],
.data-table-compact select {
    width: 100%;
    box-sizing: border-box;
    padding: 3px 5px;
    border: 1px solid #c9d1d9;
    border-radius: 4px;
    font-size: 12px;
}

.batch-block {
    border: 1px solid #d9dee5;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: #f8fafc;
}

.batch-block h4 {
    margin: 0 0 8px 0;
}

@media (max-width: 900px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }
}

/* ===== NAVEGACIÓN Y STEPPER DE PARAMETRIZACIÓN ===== */

.breadcrumb-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    font-size: 13px;
    color: #64748b;
}

.breadcrumb-nav a {
    color: #1f3a5f;
    font-weight: 600;
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    text-decoration: underline;
}

.breadcrumb-nav strong {
    color: #12263f;
}

.flow-panel {
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border: 1px solid #d9dee5;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}

.flow-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 20px;
}

.flow-heading h2 {
    margin: 3px 0 0;
    font-size: 18px;
    color: #12263f;
}

.flow-heading p {
    max-width: 520px;
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: #475569;
}

.flow-eyebrow {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.stepper {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.stepper-item {
    position: relative;
}

.stepper-item:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 20px;
    left: calc(50% + 24px);
    right: calc(-50% + 24px);
    height: 3px;
    background: #cbd5e1;
    z-index: 0;
}

.stepper-item.is-complete:not(:last-child)::after {
    background: #16a34a;
}

.stepper-item a,
.step-disabled {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 0 8px;
    color: inherit;
    text-decoration: none;
}

.step-number {
    display: flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 3px solid #cbd5e1;
    border-radius: 50%;
    box-sizing: border-box;
    background: white;
    color: #64748b;
    font-weight: 800;
}

.stepper-item.is-current .step-number {
    border-color: #1f3a5f;
    background: #1f3a5f;
    color: white;
}

.stepper-item.is-complete .step-number {
    border-color: #16a34a;
    background: #16a34a;
    color: white;
}

.step-text {
    display: flex;
    flex-direction: column;
    padding-top: 2px;
}

.step-text strong {
    font-size: 14px;
    color: #334155;
}

.step-text small {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.2;
    color: #64748b;
}

.stepper-item.is-current .step-text strong {
    color: #1f3a5f;
}

.stepper-item.is-pending .step-disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.flow-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid #d9dee5;
}

.flow-next-disabled {
    display: inline-block;
    padding: 10px 18px;
    background: #e5e7eb;
    color: #94a3b8;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-weight: 700;
    cursor: not-allowed;
}

.context-notice {
    margin-bottom: 10px;
    padding: 6px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1e3a8a;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    overflow-x: auto;
}

.content-compacto {
    padding-top: 10px;
}

.page-header-compacto {
    margin-bottom: 8px;
}

.inline-form {
    display: inline;
}

@media (max-width: 900px) {
    .flow-heading {
        flex-direction: column;
    }

    .stepper {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .stepper-item:not(:last-child)::after {
        display: none;
    }

    .flow-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .flow-actions a,
    .flow-next-disabled {
        box-sizing: border-box;
        width: 100%;
        text-align: center;
    }
}

.tabla-cajas {
    border-collapse: collapse;
    width: 100%;
    table-layout: auto;
}

.tabla-cajas th,
.tabla-cajas td {
    padding: 6px 8px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    width: 1%;
}

.tabla-cajas td {
    border: 1px solid #d0d7e2;
}

.tabla-cajas thead th {
    border: 2px solid #ffffff;
}

.tabla-cajas .col-texto {
    text-align: left;
    white-space: normal;
    width: auto;
}

.tabla-cajas .col-lote {
    text-align: left;
    white-space: normal;
    width: 260px;
    max-width: 260px;
    overflow-wrap: break-word;
}

.galeria-fotos {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.galeria-foto-thumb {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #d0d0d0;
}

.foto-preview-item {
    position: relative;
    width: 120px;
    height: 120px;
}

.foto-preview-thumb {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #d0d0d0;
    display: block;
}

.foto-preview-quitar {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: #c0392b;
    color: white;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
