:root {
  --bg-dark: #0B0F19;
  --card-bg: rgba(17, 24, 39, 0.82);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-inner: rgba(30, 41, 59, 0.65);
  
  /* Glassmorphism específico de bultos solicitado en canon OLLIN */
  --bulto-glass-bg: rgba(255, 255, 255, 0.05);
  --bulto-glass-border: rgba(255, 255, 255, 0.10);
  --bulto-glass-blur: 12px;
  
  --gold-primary: #F59E0B;
  --gold-glow: rgba(245, 158, 11, 0.35);
  --emerald: #10B981;
  --emerald-glow: rgba(16, 185, 129, 0.35);
  
  --amber: #F97316;
  --red: #EF4444;
  --blue: #3B82F6;
  
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-stack);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 12px 90px 12px;
  overflow-x: hidden;
  position: relative;
}

/* Marca de Agua Obsidiana Náhuatl (Glifo OLLIN al 4% de opacidad) */
body::before {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 460px;
  height: 460px;
  transform: translate(-50%, -50%);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" fill="none" stroke="%23F59E0B" stroke-width="1.8"><circle cx="50" cy="50" r="46" stroke-opacity="0.3"/><path d="M50 15 C35 35, 65 65, 50 85 C65 65, 35 35, 50 15 Z" stroke-opacity="0.4"/><path d="M15 50 C35 35, 65 65, 85 50 C65 35, 35 65, 15 50 Z" stroke-opacity="0.4"/><circle cx="50" cy="50" r="11" stroke-opacity="0.5"/><circle cx="50" cy="50" r="3.5" fill="%2310B981" fill-opacity="0.6"/></svg>');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}

.container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
}

/* Header Ejecutivo con Glassmorphism */
.header-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--gold-glow);
  box-shadow: 0 0 12px var(--gold-glow);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  transition: all 0.3s ease;
}

.badge-status.offline {
  background: rgba(249, 115, 22, 0.15);
  color: var(--amber);
  border-color: rgba(249, 115, 22, 0.3);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Tarjetas Principales Glassmorphism */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-counter {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--gold-primary);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
}

/* Área de Escaneo Rápido (Láser y Cámara) */
.scanner-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-laser-container {
  position: relative;
  width: 100%;
}

.input-laser {
  width: 100%;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  color: #FFFFFF;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px 14px 12px 42px;
  outline: none;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  user-select: text;
}

.input-laser:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 14px var(--gold-glow);
}

.laser-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--gold-primary);
  pointer-events: none;
}

.btn-toggle-cam {
  background: var(--card-inner);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle-cam:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.98);
}

#camera-reader {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: none;
}

/* Lista Dinámica de Bultos Escaneados con Glassmorphism */
.bultos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.bultos-list::-webkit-scrollbar {
  width: 4px;
}

.bultos-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Tarjeta individual de bulto con Glassmorphism estricto */
.bulto-item {
  background: var(--bulto-glass-bg);
  border: 1px solid var(--bulto-glass-border);
  backdrop-filter: blur(var(--bulto-glass-blur));
  -webkit-backdrop-filter: blur(var(--bulto-glass-blur));
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slideDown 0.2s ease-out;
  transition: all 0.2s ease;
}

.bulto-item:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.bulto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bulto-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bulto-pid {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: text;
}

.bulto-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-remove-bulto {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #EF4444;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-remove-bulto:active {
  transform: scale(0.92);
}

/* ====================================================================
   SELECTOR ERGONÓMICO DE CHECKPOINTS (TARJETAS TÁCTILES >= 54px)
   ==================================================================== */
.checkpoint-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
}

.btn-checkpoint-card {
  min-height: 54px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 10px;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 3px;
  gap: 2px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  touch-action: manipulation;
}

.btn-checkpoint-card:active {
  transform: scale(0.96);
}

.btn-checkpoint-card .cp-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.btn-checkpoint-card .cp-code {
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.5px;
}

.btn-checkpoint-card .cp-sub {
  font-size: 0.58rem;
  font-weight: 600;
  opacity: 0.85;
  white-space: nowrap;
  line-height: 1;
}

/* Estado Activo: OK (Verde Esmeralda #10B981 con resplandor neón) */
.btn-checkpoint-card.active-ok {
  background: var(--emerald) !important;
  border-color: var(--emerald) !important;
  color: #000000 !important;
  font-weight: 800 !important;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.65) !important;
}

.btn-checkpoint-card.active-ok .cp-sub {
  color: #064E3B !important;
  opacity: 1 !important;
  font-weight: 700;
}

/* Estado Activo: Incidencias BA / NH / CA / RD (Ámbar Neón #F97316 con resplandor) */
.btn-checkpoint-card.active-incidencia {
  background: #F97316 !important;
  border-color: #F97316 !important;
  color: #000000 !important;
  font-weight: 800 !important;
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.65) !important;
}

.btn-checkpoint-card.active-incidencia .cp-sub {
  color: #431407 !important;
  opacity: 1 !important;
  font-weight: 700;
}

/* ====================================================================
   EVIDENCIA DE VOZ TEOYOLOTL MIC (3 A 5 SEGUNDOS)
   ==================================================================== */
.voice-card {
  border-color: rgba(245, 158, 11, 0.25);
}

.voice-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold-primary);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 3px 8px;
  border-radius: 8px;
}

.voice-recorder-ui {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-voice-record {
  min-height: 52px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px dashed rgba(245, 158, 11, 0.4);
  border-radius: 12px;
  color: #FFFFFF;
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-voice-record:active {
  transform: scale(0.98);
}

.btn-voice-record.recording {
  background: rgba(239, 68, 68, 0.2) !important;
  border: 1.5px solid #EF4444 !important;
  color: #EF4444 !important;
  animation: pulseVoice 1s infinite alternate;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.5);
}

@keyframes pulseVoice {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.98); opacity: 0.85; }
}

.voice-timer {
  background: #EF4444;
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
}

.voice-audio-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.voice-player {
  flex: 1;
  height: 38px;
  outline: none;
}

.btn-voice-delete {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #EF4444;
  font-size: 1rem;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.voice-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Sección Condicional: Poka-Yoke de Receptor */
.receptor-card {
  transition: all 0.3s ease;
}

.receptor-card.hidden {
  display: none !important;
}

.receptor-notice {
  font-size: 0.74rem;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 6px 10px;
  border-radius: 8px;
}

.input-receptor {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #FFFFFF;
  font-size: 0.92rem;
  padding: 10px 12px;
  outline: none;
  user-select: text;
}

.input-receptor:focus {
  border-color: var(--emerald);
}

/* Canvas de Firma Digital */
.signature-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.signature-pad {
  width: 100%;
  height: 130px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  touch-action: none;
}

.signature-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-clear-sig {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

/* Captura de Evidencia Fotográfica */
.photo-section {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-photo-capture {
  flex: 1;
  background: var(--card-inner);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.photo-preview {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: none;
}

/* Botones Fijos de Acción Inferior */
.footer-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--card-border);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  z-index: 100;
  max-width: 500px;
  margin: 0 auto;
}

.btn-primary {
  flex: 2;
  background: linear-gradient(135deg, var(--gold-primary), #D97706);
  border: none;
  color: #000000;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 14px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 18px var(--gold-glow);
  transition: all 0.2s ease;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 14px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.1);
}

/* Modal / Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--gold-primary);
  color: #FFFFFF;
  padding: 12px 20px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 200;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
