:root {
  --primary: #FC4C02;
  --primary-dark: #E34402;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --text: #1C1E21;
  --muted: #6B7280;
  --border: #E5E7EB;
  --danger: #EF4444;
  --warning: #F59E0B;
  --success: #10B981;
  --radius: 10px;
  --strava: #FC4C02;
}

[data-theme="light"] {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --text: #1C1E21;
  --muted: #6B7280;
  --border: #E5E7EB;
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1E1E1E;
  --text: #E5E7EB;
  --muted: #9CA3AF;
  --border: #2A2A2A;
}

[data-theme="mid"] {
  --bg: #2D3A2E;
  --surface: #3A4A3C;
  --text: #E8F0E8;
  --muted: #A8C0A8;
  --border: #4A5D4E;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; margin: 0; max-width: 100%; overflow-x: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  max-width: 100%;
  flex-wrap: wrap;
  gap: 8px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.header-title { min-width: 0; }
.logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #121212;
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  overflow: hidden;
  border: 1px solid var(--primary);
}
.header-title h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
}
.header-title p {
  font-size: 11px;
  color: var(--muted);
}
.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.badge-health {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-weight: 600;
}
[data-theme="dark"] .badge-health,
[data-theme="mid"] .badge-health {
  color: #34D399;
}
.badge-health.down {
  background: rgba(239, 68, 68, 0.14);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
}

/* Misión Banner */
.mision-banner {
  padding: 8px 14px;
  background: #1E293B;
  color: #F8FAFC;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #334155;
}
.cercania-chip {
  font-size: 11px;
  color: #38BDF8;
  font-weight: 600;
}
.cercania-chip[hidden] { display: none !important; }

/* Layout */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  min-height: calc(100vh - 61px - 56px);
  min-height: calc(100dvh - 104px - 56px);
  max-width: 100%;
  overflow-x: hidden;
  padding-bottom: 56px;
  box-sizing: border-box;
}
.sidebar {
  width: 360px;
  min-width: 320px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 104px);
  overflow: hidden;
}
.sidebar-controls {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.search-row {
  display: flex;
  gap: 8px;
  max-width: 360px;
  width: 100%;
}
.search-row > * { min-width: 0; }
.input, .select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(252,76,2,0.18); }
.select { min-width: 120px; }
.search-row .select { flex: 0 0 128px; max-width: 42%; }

.btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: 4px 8px; font-size: 11px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 360px; width: 100%; }
.actions-grid .btn { width: 100%; }
.hint {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
}

/* Lista clientes */
.lista-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.lista-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.lista-header h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.count { font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 999px; }
.cliente-card {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.cliente-card:hover { border-color: var(--primary); }
.cliente-card.no-gps { border-left: 3px solid var(--warning); background: #FFFBEB; }
[data-theme="dark"] .cliente-card.no-gps { background: #262012; }
[data-theme="mid"] .cliente-card.no-gps { background: #3D4532; }

.cliente-card.entregado-local { border-left: 3px solid #0E7A3B; background: #F0FDF9; }
[data-theme="dark"] .cliente-card.entregado-local { background: #102820; }
[data-theme="mid"] .cliente-card.entregado-local { background: #2A4638; }

.cliente-card input[type="checkbox"] { margin-top: 4px; accent-color: var(--primary); }
.cliente-info { flex: 1; min-width: 0; }
.cliente-nombre { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cliente-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 999px; font-weight: 600; }
.badge-zona { background: rgba(252, 76, 2, 0.12); color: var(--primary); }
.badge-warn { background: rgba(245, 158, 11, 0.18); color: #D97706; }
[data-theme="dark"] .badge-warn, [data-theme="mid"] .badge-warn { color: #FBBF24; }
.badge-flag { background: rgba(239, 68, 68, 0.16); color: var(--danger); }
.badge-rif { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-entregado-local { background: rgba(16, 185, 129, 0.18); color: #10B981; border: 1px solid rgba(16, 185, 129, 0.35); }
.list-sentinel { height: 1px; min-height: 1px; background: transparent; }

/* Ruta optimizada / Misión activa */
.ruta-panel {
  padding: 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  max-height: 290px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ruta-panel h4 { font-size: 13px; margin-bottom: 6px; }
.ruta-panel ol { padding-left: 18px; font-size: 13px; }
.ruta-panel li { margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.ruta-panel li:last-child { border-bottom: none; }
.ruta-stats { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Map */
.map-wrap { flex: 1; min-width: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 0; position: relative; }
#map {
  height: calc(100vh - 61px - 56px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  height: calc(100dvh - 104px - 56px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  min-height: 420px;
  width: 100%;
  flex: 1;
}
.leaflet-container { font-family: inherit; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  max-height: 92dvh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 10px; font-size: 16px; }
.form-grid { display: grid; gap: 10px; }
.form-row { display: grid; gap: 4px; }
.form-row label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-row .input { font-size: 14px; }
.coords { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

.toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  display: none;
  z-index: 3000;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.toast.show { display: block; }

/* Strava pins + estados de parada en Misión + clusters */
.pin-wrap { background: transparent; border: none; }
.pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--strava);
  color: #fff;
  border: 2px solid #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.pin.pin-visitado { background: #10B981; }
.pin.pin-online { background: #2563EB; }
.pin.pin-cerrado { background: #F59E0B; }
.pin.pin-novisitado { background: #6B7280; }
.pin.pin-geocerca { background: #0D9488; box-shadow: 0 0 0 4px rgba(13,148,136,.35), 0 2px 6px rgba(0,0,0,.35); }
.pin.pin-mora-critica { background: #DC2626; box-shadow: 0 0 0 3px rgba(220,38,38,.35), 0 2px 6px rgba(0,0,0,.35); }
.pin.pin-mora-vencido { background: #EA580C; }
.pin.pin-mora-proximo { background: #D97706; }
.pin.pin-mora-aldia { background: #059669; }
.pin span { display: block; transform: translateY(0.5px); }

.cluster-wrap { background: transparent; border: none; }
.cluster-chip {
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: 999px;
  background: #1E1E1E;
  color: var(--strava);
  border: 2px solid var(--strava);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.dot-wrap { background: transparent; border: none; }
.dot-pin { width: 14px; height: 14px; border-radius: 50%; background: #FC4C02; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); display: block; }
.dot-pin.selected { background: #D4A017; border: 3px solid #FFD700; box-shadow: 0 0 0 3px rgba(255,215,0,.45), 0 2px 8px rgba(0,0,0,.4); font-size: 12px; line-height: 1; display: flex; align-items: center; justify-content: center; color: #fff; }
.dot-pin.selected.nogps { background: #3B3B3B; border: 3px solid #FFD700; }
.dot-wrap.sel .dot-pin.selected { transform: scale(1.15); }

html[data-theme] body, html[data-theme] .header, html[data-theme] .sidebar, html[data-theme] .cliente-card {
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.my-location-dot { position: relative; z-index: 2; width: 16px; height: 16px; border-radius: 50%; background: #2A93D5; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(42,147,213,.2), 0 2px 6px rgba(0,0,0,.3); }
.my-location-wrap { background: transparent; border: none; overflow: visible !important; }
.my-location-cone {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transform: translate(-50%, -50%) rotate(var(--user-heading, 0deg));
  transition: opacity .2s ease;
  background: conic-gradient(from -32deg at 50% 50%, rgba(252,76,2,0) 0deg, rgba(42,147,213,.42) 14deg, rgba(252,76,2,.55) 32deg, rgba(42,147,213,.42) 50deg, rgba(252,76,2,0) 64deg, transparent 64deg 360deg);
  -webkit-mask-image: radial-gradient(circle, rgba(0,0,0,.95) 18%, rgba(0,0,0,.45) 58%, transparent 72%);
  mask-image: radial-gradient(circle, rgba(0,0,0,.95) 18%, rgba(0,0,0,.45) 58%, transparent 72%);
}
.my-location-cone::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid #FC4C02;
}
html.has-heading .my-location-cone { opacity: 1; }

.compass-chip {
  position: absolute;
  top: 12px;
  right: max(12px, env(safe-area-inset-right, 12px));
  z-index: 450;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(18, 18, 18, 0.88);
  color: #F8FAFC;
  border: 1.5px solid #FC4C02;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,.28);
  cursor: pointer;
}
.compass-chip[hidden] { display: none !important; }
.compass-arrow {
  display: inline-block;
  color: #FC4C02;
  font-size: 12px;
  line-height: 1;
  transform: rotate(var(--user-heading, 0deg));
}
.offline-data-chip {
  position: absolute;
  top: 12px;
  left: 52px;
  z-index: 440;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(0,0,0,.22);
  pointer-events: none;
}
.offline-data-chip[hidden] { display: none !important; }
.fab-my-location { position: absolute; bottom: 24px; right: max(24px, env(safe-area-inset-right, 24px)); width: 44px; height: 44px; border-radius: 50%; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 4px 12px rgba(0,0,0,.15); font-size: 18px; cursor: pointer; z-index: 400; display: grid; place-items: center; }
.fab-my-location:hover { border-color: var(--primary); }

.selection-badge { font-size: 12px; font-weight: 700; color: var(--primary); background: #FFF0EB; border: 1px solid #FFD5C2; padding: 2px 8px; border-radius: 999px; }
[data-theme="dark"] .selection-badge { background: #3A2015; border-color: #5A2D1A; }

.panel-toggles { display: flex; gap: 8px; margin-bottom: 8px; }
.panel-toggles .btn { flex: 1; justify-content: flex-start; border: 1px solid var(--border); background: var(--surface); }
#actionsMenu[hidden] { display: none !important; }
#clientesMenu[hidden] { display: none !important; }

.mini-menu {
  position: fixed;
  bottom: 0;
  left: 360px;
  right: 0;
  background: var(--surface);
  border-top: 2px solid var(--strava);
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 900;
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  max-width: calc(100vw - 360px);
  flex-wrap: nowrap;
}
.mini-menu::-webkit-scrollbar { display: none; }
.mini-menu-actions { display: flex; gap: 6px; align-items: center; overflow-x: auto; overflow-y: visible; scrollbar-width: none; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; flex: 1; min-width: 0; }
.mini-menu-actions::-webkit-scrollbar { display: none; }
#miniMenuCount { font-size: 13px; font-weight: 700; color: var(--text); flex-shrink: 0; white-space: nowrap; }
.mini-menu .btn { flex: 0 0 auto; min-width: 0; white-space: nowrap; padding: 7px 10px; font-size: 12px; overflow: visible; }

.dropdown-wrap { position: relative; display: inline-block; width: 100%; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); list-style: none; padding: 4px; margin: 0; z-index: 1200; }
[role="menuitem"] { padding: 8px 12px; font-size: 13px; cursor: pointer; border-radius: 6px; }
[role="menuitem"]:hover, [role="menuitem"]:focus { background: var(--bg); outline: none; color: var(--primary); }
.dropdown-menu[hidden] { display: none !important; }

.offline-banner { background: #1E1E1E; color: #FC4C02; padding: 8px 12px; text-align: center; font-size: 13px; font-weight: 700; border-bottom: 2px solid #FC4C02; position: sticky; top: 0; z-index: 1500; }
.offline-banner[hidden] { display: none !important; }

/* Ocultar badge externo inyectado por preview de Netlify */
iframe[title*="Netlify"], .netlify-badge { display: none !important; }

#clientesMenu { display: flex; flex-direction: column; max-height: 62vh; overflow: hidden; }
#clientesMenu .lista-wrap { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
#listaClientes { flex: 1; overflow-y: auto; max-height: 48vh; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#listaClientes .cliente-card:last-child { margin-bottom: 12px; }

.pending-dropup-container {
  position: fixed;
  bottom: 64px;
  left: 370px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  z-index: 9999;
  max-width: calc(100vw - 24px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  pointer-events: auto;
}
.pending-dropup-container[hidden] { display: none !important; }

.pending-dropup {
  width: 220px;
  max-height: 160px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 4px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.pending-dropup-row {
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.2;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pending-dropup-row:hover { background: var(--bg); }
.pending-dropup-row.selected { background: var(--success); color: #fff; font-weight: 600; }
.pending-dropup-confirm { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; flex-shrink: 0; }
.pending-dropup-empty { font-size: 12px; color: var(--muted); padding: 10px; text-align: center; }

/* Responsive Portrait Mobile */
@media (max-width: 900px) {
  .layout { flex-direction: column; padding-bottom: 72px; }
  .sidebar { width: 100%; min-width: 0; max-height: none; }
  #map { min-height: 360px; height: calc(100dvh - 104px - 72px); }
  .mini-menu { left: 0; right: 0; width: 100%; max-width: 100vw; margin: 0; bottom: env(safe-area-inset-bottom, 0px); }
  #clientesMenu { max-height: 58vh; }
  #listaClientes { max-height: 42vh; }
  .pending-dropup { width: 185px; }
  .pending-dropup-container { left: 8px; bottom: 76px; }
}

/* Responsive Landscape Mobile (rotación física horizontal sin tapar el mapa) */
@media (orientation: landscape) and (max-height: 540px) {
  body { height: 100dvh; overflow: hidden; }
  .header {
    padding: 4px max(12px, env(safe-area-inset-right, 0px)) 4px max(12px, env(safe-area-inset-left, 0px));
    gap: 4px;
  }
  #headerSub { display: none; }
  .logo { width: 26px; height: 26px; }
  .header-title h1 { font-size: 13px; }
  .header-actions .btn { padding: 4px 8px; font-size: 11px; min-height: 28px; }
  .mision-banner {
    padding: 4px max(12px, env(safe-area-inset-right, 0px)) 4px max(12px, env(safe-area-inset-left, 0px));
    font-size: 11px;
  }
  .layout {
    flex-direction: row !important;
    flex: 1;
    min-height: 0;
    padding-bottom: 0 !important;
    overflow: hidden;
  }
  .sidebar {
    width: clamp(248px, 34vw, 310px);
    min-width: 240px;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    padding-left: env(safe-area-inset-left, 0px);
    border-right: 1px solid var(--border);
  }
  #clientesMenu { max-height: none; overflow: visible; }
  #listaClientes { max-height: none; overflow-y: visible; }
  .map-wrap { flex: 1; height: 100%; min-height: 0; }
  #map { height: 100% !important; min-height: 0 !important; }
  .mini-menu {
    left: clamp(248px, 34vw, 310px);
    right: 0;
    width: auto;
    max-width: none;
    padding: 4px 10px;
  }
  .fab-my-location { bottom: 52px; right: max(14px, env(safe-area-inset-right, 14px)); }
}

/* =========================================================================
 * Guías de Despacho (GD-*) y Guías de Cobranzas (GC-*) — Controles Táctiles
 * ========================================================================= */
.btn-touch {
  min-height: 44px;
  padding: 10px 14px;
  font-size: 13px;
}
.btn-icon {
  flex: 0 0 40px;
  min-height: 40px;
  padding: 0;
}
.seg-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.seg-btn {
  min-height: 40px;
  padding: 6px 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s ease;
  text-align: center;
  line-height: 1.2;
}
.seg-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(252,76,2,.3);
}
.guide-builder {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.guide-builder[hidden], .panel-toggles[hidden] {
  display: none !important;
}
.guide-preview-box {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}
.guide-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.guide-candidates-list {
  max-height: 42vh;
  overflow-y: auto;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}
.guide-empty {
  font-size: 12.5px;
  color: var(--muted);
  padding: 14px 10px;
  text-align: center;
  background: var(--bg);
  border-radius: 8px;
  border: 1px dashed var(--border);
}
.guide-subped-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}
.guide-subped {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
}
.guide-subped input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
}
.bcv-chip {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16,185,129,.15);
  color: #059669;
  border: 1px solid rgba(16,185,129,.35);
}
[data-theme="dark"] .bcv-chip, [data-theme="mid"] .bcv-chip {
  color: #34D399;
}
.mora-chips {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.mora-chips::-webkit-scrollbar { display: none; }
.mora-chip {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.mora-chip.active {
  border-color: var(--primary);
  background: rgba(252,76,2,.14);
  color: var(--primary);
}
.mora-critica { background: rgba(220,38,38,.16); color: #EF4444; }
.mora-vencido { background: rgba(234,88,12,.16); color: #F97316; }
.mora-proximo { background: rgba(217,119,6,.16); color: #F59E0B; }
.mora-aldia { background: rgba(16,185,129,.16); color: #10B981; }
.badge-bs { background: rgba(37,99,235,.15); color: #3B82F6; }
.badge-divisas { background: rgba(16,185,129,.15); color: #10B981; }

.stop-mini-ped-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.stop-mini-ped {
  font-size: 11.5px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.guide-stop-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.carga-sku-row, .radio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  cursor: pointer;
}
.carga-sku-row input[type="checkbox"], .radio-card input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.ped-diff-card {
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  margin-bottom: 8px;
}
.stepper-item {
  padding: 8px 0;
  border-top: 1px dashed var(--border);
}
.stepper-item:first-of-type { border-top: none; }
.stepper-controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.stepper-group > span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}
.stepper-box {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.btn-step {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.btn-step:active { background: var(--primary); color: #fff; }
.step-input {
  flex: 1;
  width: 40px;
  height: 44px;
  border: none;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--surface);
  color: var(--text);
}
.capture-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 9px;
  border: 1px dashed var(--border);
  background: var(--bg);
}
.capture-status {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}
.capture-thumb {
  max-height: 150px;
  width: 100%;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
}
