  /* ============================================================
     OPTOPUS — Módulo Error en Peso v1
     Extiende styles.css (no redefine variables).
     Solo agrega las clases específicas del módulo.
     ============================================================ */

  /* ===== Chips de navegación en el workspace (Opción A) ===== */
  .ep-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .ep-chip {
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .ep-chip:hover {
    background: #f9fafb;
    border-color: #d1d5db;
  }
  .ep-chip.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
  }
  .ep-chip-badge {
    background: #e5e7eb;
    color: #374151;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
  }
  .ep-chip.active .ep-chip-badge {
    background: rgba(255,255,255,0.25);
    color: #fff;
  }
  .ep-chip-badge.alert {
    background: #fef3c7;
    color: #92400e;
  }

  /* ===== Validación MIO en vivo ===== */
  .ep-field input.mio-valid {
    border-color: #10b981;
    background: #f0fdf4;
  }
  .ep-field input.mio-valid:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px #dcfce7;
  }
  .ep-field input.mio-invalid {
    border-color: #ef4444;
    background: #fef2f2;
  }
  .ep-field input.mio-invalid:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px #fee2e2;
  }
  .ep-mio-error-msg {
    color: #991b1b;
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
    min-height: 16px;
    display: block;
  }

  /* ===== Chip badge variante danger ===== */
  .ep-chip-badge.danger {
    background: #fee2e2;
    color: #991b1b;
  }
  .ep-chip.active .ep-chip-badge.danger {
    background: rgba(255,255,255,0.25);
    color: #fff;
  }

  /* ===== Reportes con error ===== */
  .ep-item.error-report {
    border-left: 4px solid #ef4444;
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
  }
  .ep-item-error-motivo {
    grid-column: 1 / -1;
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
    padding: 6px 10px;
    background: #fef2f2;
    border-radius: 6px;
    line-height: 1.5;
  }
  .btn-volver-reportar {
    grid-column: 1 / -1;
    margin-top: 4px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    background: #1d4ed8;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 0.3px;
    text-align: left;
    width: fit-content;
  }
  .btn-volver-reportar:hover { background: #1e40af; }
  .btn-volver-reportar:active { transform: scale(0.97); }

  /* ===== Hint / explicación arriba del formulario ===== */
  .ep-hint {
    background: #eff6ff;
    border-left: 3px solid #2563eb;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #1e3a8a;
    border-radius: 6px;
  }

  /* ===== Form fields (mismo lenguaje que el cierre) ===== */
  .ep-form-grid {
    display: grid;
    gap: 14px;
  }
  .ep-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .ep-field label {
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .ep-field input[type="text"],
  .ep-field input[type="number"] {
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    background: #f9fafb;
    font-family: inherit;
    color: #111827;
  }
  .ep-field input[type="text"]:focus,
  .ep-field input[type="number"]:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px #dbeafe;
  }
  .ep-field small {
    color: #6b7280;
    font-size: 11px;
    margin-top: 2px;
  }

  /* Fila con dos campos (peso sistema / peso real) */
  .ep-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* ===== Caja de diferencia (auto-calculada como kpi del cierre) ===== */
  .ep-diferencia {
    display: grid;
    grid-template-columns: 1fr 170px;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #f9fafb;
    border: 1.5px dashed #d1d5db;
    margin: 6px 0;
  }
  .ep-diferencia.sobre {
    background: #fee2e2;
    border-color: #ef4444;
    border-style: solid;
  }
  .ep-diferencia.sub {
    background: #fed7aa;
    border-color: #fb923c;
    border-style: solid;
  }
  .ep-diferencia.cero {
    background: #f3f4f6;
    border-color: #9ca3af;
    border-style: solid;
  }
  .ep-dif-l {
    color: #6b7280;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .ep-dif-l small {
    display: block;
    font-size: 10px;
    font-weight: 500;
    margin-top: 2px;
    color: #9ca3af;
    text-transform: none;
    letter-spacing: 0;
  }
  .ep-diferencia.sobre .ep-dif-l { color: #9a3412; }
  .ep-diferencia.sobre .ep-dif-l small { color: #c2410c; }
  .ep-diferencia.sub .ep-dif-l { color: #9a3412; }
  .ep-diferencia.sub .ep-dif-l small { color: #c2410c; }
  .ep-dif-v {
    text-align: right;
    background: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    border: 1px solid #d1d5db;
    font-variant-numeric: tabular-nums;
  }
  .ep-diferencia.sobre .ep-dif-v {
    color: #991b1b;
    border-color: #ef4444;
  }
  .ep-diferencia.sub .ep-dif-v {
    color: #9a3412;
    border-color: #fb923c;
  }

  /* ===== Subida de fotos ===== */
  .ep-fotos-input {
    padding: 10px 12px;
    border: 1.5px dashed #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
  }
  .ep-fotos-input:hover {
    border-color: #2563eb;
    background: #eff6ff;
  }
  .ep-fotos-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    margin-top: 8px;
  }
  .ep-fotos-preview img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
  }

  /* Wrapper con botón remove (Bug 7) */
  .ep-foto-preview {
    position: relative;
    display: inline-block;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
  }
  .ep-foto-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    display: block;
    border-radius: 0;
    border: none;
  }
  .ep-foto-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
  }

  /* ===== Advertencia outlier (>10 lb) ===== */
  .ep-warn {
    background: #fef3c7;
    border-left: 3px solid #fbbf24;
    padding: 10px 14px;
    border-radius: 6px;
    color: #92400e;
    font-size: 13px;
    margin: 4px 0;
  }
  .ep-warn.hidden { display: none; }
  .ep-warn strong { font-weight: 700; }

  /* ===== Mensajes de respuesta del submit ===== */
  .ep-msg {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    display: none;
  }
  .ep-msg.success { display: block; background: #d1fae5; color: #065f46; }
  .ep-msg.error { display: block; background: #fee2e2; color: #991b1b; }
  .ep-msg.warn { display: block; background: #fef3c7; color: #92400e; }
  .ep-msg.show { display: block; background: #e0f2fe; color: #075985; }
  .ep-msg.hidden { display: none; }

  /* ===== Lista de mis reportes / pendientes ===== */
  .ep-lista {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .ep-lista-empty,
  .ep-lista-loading,
  .ep-lista-error {
    text-align: center;
    padding: 30px 20px;
    color: #6b7280;
    background: #fff;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    font-style: italic;
  }
  .ep-lista-error {
    color: #991b1b;
    border-color: #fecaca;
    background: #fef2f2;
    font-style: normal;
  }

  .ep-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: start;
  }
  .ep-item.pendiente {
    border-left: 4px solid #10b981;
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 4px 12px;
    align-items: start;
  }
  .ep-item-main {
    grid-column: 1;
    grid-row: 1;
  }
  .ep-item-pesos-inline {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 13px;
    color: #374151;
    display: flex;
    gap: 6px;
    align-items: center;
  }
  .ep-item-pesos-inline .arrow { color: #9ca3af; }
  .ep-item-pesos-inline .diff {
    font-weight: 700;
    color: #9a3412;
    margin-left: 4px;
  }
  .ep-item-reportado-por {
    grid-column: 1 / -1;
    grid-row: 3;
    font-size: 11px;
    color: #6b7280;
  }
  .ep-item-reportado-por.migrado {
    color: #92400e;
    font-style: italic;
  }
  .ep-item-urgencia {
    grid-column: 2;
    grid-row: 1;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    align-self: start;
  }
  .ep-item-urgencia.normal { background: #f3f4f6; color: #6b7280; }
  .ep-item-urgencia.medio  { background: #fef3c7; color: #92400e; }
  .ep-item-urgencia.alto   { background: #fee2e2; color: #991b1b; }

  .ep-item-mio {
    font-weight: 700;
    font-size: 15px;
    color: #111827;
  }
  .ep-item-casillero {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    margin-top: 2px;
  }
  .ep-item-status {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
  }
  .ep-status-warn { background: #fef3c7; color: #92400e; }
  .ep-status-info { background: #dbeafe; color: #1e40af; }
  .ep-status-success { background: #d1fae5; color: #065f46; }
  .ep-status-error { background: #fee2e2; color: #991b1b; }
  /* Modificado por el robot pero esperando que el paquete se entregue (aún no facturable) */
  .ep-status-espera { background: #ffedd5; color: #9a3412; }

  .ep-item-pesos {
    grid-column: 1 / -1;
    font-size: 13px;
    color: #374151;
    background: #f9fafb;
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .ep-item-pesos .arrow { color: #9ca3af; }
  .ep-item-pesos .diff {
    margin-left: auto;
    font-weight: 700;
    color: #9a3412;
  }
  .ep-item-pesos .diff.sobre { color: #991b1b; }

  .ep-item-fecha {
    grid-column: 1 / -1;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
  }

  /* ===== Responsive (consistente con styles.css) ===== */
  @media (max-width: 768px) {
    .ep-field-row { grid-template-columns: 1fr; }
    .ep-diferencia { grid-template-columns: 1fr; }
    .ep-dif-v { text-align: center; }
  }

/* =====================================================================
   MÓVIL — < 768px
   Optimizaciones para celular compartido en agencia
   ===================================================================== */
@media (max-width: 768px) {

  /* === Padding general más generoso para tap-targets === */
  .ws-header { padding: 12px 14px; }
  .ws-title { font-size: 20px; }
  .ws-subtitle { font-size: 13px; }

  /* === Chips de navegación === */
  .ep-chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ep-chips::-webkit-scrollbar { display: none; }
  .ep-chip {
    flex-shrink: 0;
    padding: 10px 16px;
    font-size: 14px;
    min-height: 44px;
  }

  /* === Hint compacto === */
  .ep-hint {
    font-size: 13px;
    padding: 10px 12px;
  }

  /* === Inputs grandes (tap-target 48px, evita zoom iOS) === */
  .ep-field label {
    font-size: 12px;
    margin-bottom: 4px;
  }
  .ep-field input[type="text"],
  .ep-field input[type="number"] {
    font-size: 16px;
    padding: 14px;
    min-height: 48px;
  }

  /* === Pesos lado a lado en pantalla pequeña === */
  .ep-field-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* === Caja de diferencia centrada === */
  .ep-diferencia {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px;
    text-align: center;
  }
  .ep-dif-v {
    text-align: center;
    font-size: 22px;
    padding: 12px;
  }
  .ep-dif-l { text-align: center; }

  /* === Botón "Tomar foto" prominente === */
  .ep-fotos-input {
    padding: 16px;
    font-size: 15px;
    text-align: center;
    background: #eff6ff;
    border-color: #2563eb;
    color: #1e40af;
    font-weight: 600;
  }
  .ep-fotos-preview img { height: 72px; }

  /* === Botón Enviar STICKY abajo === */
  .actions-row {
    position: sticky;
    bottom: 0;
    background: #fff;
    margin-left: -16px;
    margin-right: -16px;
    margin-bottom: -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #e5e7eb;
    z-index: 10;
  }
  .btn-send {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    min-height: 52px;
  }
  .btn-clear {
    min-height: 52px;
    padding: 16px;
    font-size: 14px;
  }

  /* === Cards de lista táctiles === */
  .ep-item {
    padding: 12px 14px;
    min-height: 80px;
  }
  .ep-item-mio { font-size: 16px; }
  .ep-item-casillero { font-size: 13px; }

  /* === Sidebar oculto, desliza desde la izquierda === */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 100;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  }
  .sidebar.show { transform: translateX(0); }

  /* Overlay semitransparente cuando sidebar abierto */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }
  .sidebar.show ~ .sidebar-overlay { display: block; }

  /* === Workspace full-width === */
  .workspace { padding: 12px; }

  /* === Sin hover en táctil, solo active === */
  .ep-chip:hover { background: #fff; border-color: #e5e7eb; }
  .ep-chip:active { transform: scale(0.97); }
  .ep-item:active { background: #f9fafb; }
}

/* === Safe area para iPhones con notch === */
@supports (padding: max(0px)) {
  .portal-header {
    padding-top: max(12px, env(safe-area-inset-top));
  }
}

/* === Fix overflow horizontal formulario móvil === */
@media (max-width: 768px) {
  #view-error-peso {
    overflow-x: hidden;
    max-width: 100vw;
  }

  #view-error-peso *,
  #view-error-peso *::before,
  #view-error-peso *::after {
    box-sizing: border-box;
  }

  #view-error-peso .ep-form-grid,
  #view-error-peso .card,
  #view-error-peso .card-b,
  #view-error-peso .ep-field,
  #view-error-peso .actions-row {
    max-width: 100%;
  }

  #view-error-peso input,
  #view-error-peso textarea,
  #view-error-peso button {
    max-width: 100%;
    min-width: 0; /* Bug 6: evita overflow en grid de 2 cols */
  }

  #view-error-peso .ep-field-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); /* Bug 6 */
    gap: 8px;
  }

  #view-error-peso .actions-row {
    width: 100%;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  #view-error-peso .btn-send {
    width: 100%;
    padding: 14px 12px;
    font-size: 15px;
  }
}
