/* Rutas Comerciales — UI mobile premium */

#comercialRutasScreen.active { display: flex; }
body.cr-tool-active #appContainerTienda > .bottom-nav { display: none !important; }

.cr-tool {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(120, 81, 169, 0.12), transparent 60%),
    radial-gradient(800px 300px at 100% 0%, rgba(147, 112, 219, 0.08), transparent 50%),
    var(--gray-50, #f9fafb);
  color: var(--gray-900, #111827);
}

.cr-icon { display: block; flex-shrink: 0; }

/* Header / page bar */
.cr-page-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 0.75rem;
}
.cr-page-bar--inicio {
  margin-bottom: 0.85rem;
}
.cr-page-bar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gray-100, #f3f4f6);
  border: none;
  color: var(--primary, #7851A9);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}
.cr-back-btn:active { transform: scale(0.96); background: var(--gray-200, #e5e7eb); }

.cr-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.85rem 0.85rem;
  padding-bottom: calc(5.75rem + env(safe-area-inset-bottom));
}

/* Bottom nav */
.cr-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 1000;
  padding: 0.25rem 0.15rem calc(0.35rem + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(17, 24, 39, 0.06);
}
.cr-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.4rem 0.1rem;
  border: none;
  background: none;
  font-size: 0.58rem;
  font-weight: 500;
  color: #9ca3af;
  cursor: pointer;
  min-height: 3.35rem;
  border-radius: 12px;
  transition: color 0.15s ease, background 0.15s ease;
}
.cr-nav-item .cr-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  transition: background 0.15s ease, color 0.15s ease;
}
.cr-nav-item.active {
  color: var(--primary, #7851A9);
  font-weight: 700;
}
.cr-nav-item.active .cr-nav-icon {
  background: linear-gradient(135deg, rgba(120, 81, 169, 0.16), rgba(147, 112, 219, 0.12));
  color: var(--primary, #7851A9);
}

/* Cards */
.cr-card {
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.04), 0 1px 2px rgba(17, 24, 39, 0.03);
}
.cr-card-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  color: var(--gray-800, #1f2937);
}
.cr-card-title .cr-icon { color: var(--primary, #7851A9); }

/* Fields */
.cr-field { margin-bottom: 0.75rem; }
.cr-field > label,
.cr-field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 0.3rem;
  letter-spacing: 0.01em;
}
.cr-field input:not([type="checkbox"]):not([type="radio"]),
.cr-field select,
.cr-field textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 0.92rem;
  box-sizing: border-box;
  background: #fff;
  color: var(--gray-900, #111827);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cr-field input:not([type="checkbox"]):not([type="radio"]):focus,
.cr-field select:focus,
.cr-field textarea:focus {
  outline: none;
  border-color: var(--primary-light, #9370DB);
  box-shadow: 0 0 0 3px rgba(120, 81, 169, 0.15);
}
.cr-field textarea { min-height: 80px; resize: vertical; }
.cr-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Buttons */
.cr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.cr-btn:active { transform: scale(0.98); }
.cr-btn-primary {
  background: linear-gradient(135deg, var(--primary, #7851A9), var(--primary-light, #9370DB));
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 14px rgba(120, 81, 169, 0.28);
}
.cr-btn-secondary {
  background: var(--gray-100, #f3f4f6);
  color: var(--gray-800, #1f2937);
}
.cr-btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}
.cr-btn-icon-danger {
  background: transparent;
  color: #ef4444;
  border: none;
  box-shadow: none;
}
.cr-btn-icon-danger:active {
  background: #fef2f2;
}
.cr-btn.cr-btn-outline.cr-btn-icon-danger {
  border: 1.5px solid #fecaca;
  color: #ef4444;
  background: #fff;
}
.cr-btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; border-radius: 10px; }
.cr-btn-outline {
  background: transparent;
  border: 1.5px solid rgba(120, 81, 169, 0.35);
  color: var(--primary, #7851A9);
}
.cr-btn-dark {
  background: #111827;
  color: #fff;
  border: 1.5px solid #111827;
}
.cr-btn-dark:active {
  background: #000;
}
.cr-btn-cat {
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--cr-cat, #7851A9) 35%, transparent);
}
.cr-btn-ghost {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(4px);
}
.cr-btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
}

/* Filters & search */
.cr-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.cr-chip-row {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.1rem 0 0.65rem;
  margin-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cr-chip-row::-webkit-scrollbar { display: none; }
.cr-chip {
  flex-shrink: 0;
  border: 1.5px solid #e5e7eb;
  background: #fff;
  color: #4b5563;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.cr-chip.is-active {
  background: var(--primary, #7851A9);
  border-color: var(--primary, #7851A9);
  color: #fff;
}
.cr-filters select,
.cr-filters input {
  flex: 1;
  min-width: 120px;
  padding: 0.55rem 0.7rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 0.85rem;
  background: #fff;
}
.cr-search-wrap {
  position: relative;
  margin-bottom: 0.85rem;
}
.cr-search-wrap .cr-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}
.cr-search {
  width: 100%;
  padding: 0.7rem 0.9rem 0.7rem 2.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  font-size: 0.9rem;
  box-sizing: border-box;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.cr-search:focus {
  outline: none;
  border-color: var(--primary-light, #9370DB);
  box-shadow: 0 0 0 3px rgba(120, 81, 169, 0.12);
}

/* List items */
.cr-list-item {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 14px;
  padding: 0.85rem;
  margin-bottom: 0.55rem;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04);
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.1s ease;
}
.cr-list-item--cat {
  border-width: 1.5px;
  border-style: solid;
  border-left-width: 4px;
}
.cr-cat-panel--soft {
  border: 1.5px solid;
  border-left-width: 4px;
  box-shadow: none;
  color: inherit;
  filter: none;
}
.cr-cat-panel--soft::before,
.cr-cat-panel--soft::after { display: none; }
.cr-card--soft {
  border: 1.5px solid;
  border-left-width: 4px;
  box-shadow: none;
}
.cr-card--soft .cr-card-title {
  color: inherit;
}
.cr-card--soft .cr-card-title .cr-icon {
  color: var(--cr-cat, var(--primary, #7851A9));
}
.cr-btn-soft {
  background: transparent;
  border: 1.5px solid currentColor;
  color: inherit;
}
.cr-btn-soft-fill {
  background: #fff;
  color: inherit;
  border: 1px solid rgba(0,0,0,0.06);
  font-weight: 600;
}
.cr-counter[style] {
  border-width: 1.5px;
  border-style: solid;
}
.cr-list-item:active {
  background: #fafafa;
  transform: scale(0.995);
}
.cr-list-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.cr-list-main {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  color: var(--gray-900, #111827);
}
.cr-list-sub {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.cr-cliente-ciudad {
  margin-top: 0.3rem;
  margin-bottom: 0.05rem;
  font-weight: 600;
}
.cr-cliente-ciudad .cr-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.cr-cliente-rutas {
  margin-top: 0.3rem;
}
.cr-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  margin-top: 0.4rem;
}
.cr-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: #6b7280;
  background: var(--gray-50, #f9fafb);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.cr-meta-chip .cr-icon { width: 12px; height: 12px; }
.cr-ruta-chip {
  font-weight: 700;
  background: color-mix(in srgb, var(--cr-ruta, #9ca3af) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--cr-ruta, #9ca3af) 40%, #e5e7eb);
}
.cr-ruta-chip--empty {
  color: #9ca3af;
  font-weight: 600;
  background: var(--gray-50, #f9fafb);
  border: 1px solid #e5e7eb;
}

.cr-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Category panels */
.cr-cat-panel {
  border-radius: 18px;
  padding: 1.15rem;
  color: #fff;
  margin-bottom: 0.75rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  position: relative;
  overflow: hidden;
  filter: saturate(1.05) brightness(0.88);
}
.cr-cat-panel::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.cr-cat-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.28) 100%);
  pointer-events: none;
  z-index: 0;
}
.cr-cat-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  position: relative;
  z-index: 1;
}
.cr-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  flex-shrink: 0;
  border: 2.5px solid rgba(255, 255, 255, 0.55);
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.cr-cat-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  opacity: 0.95;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cr-cat-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 0.15rem;
}
.cr-cat-empresa {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0.92;
}
.cr-cat-empresa .cr-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.cr-cliente-facts {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  color: #111827;
}
.cr-fact {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  color: #111827;
}
.cr-fact > .cr-icon,
.cr-fact-icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
  opacity: 0.85;
  display: inline-flex;
  color: #111827;
}
.cr-fact > span,
.cr-fact-ruta-body {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.cr-fact-ruta-inline {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem;
}
.cr-fact-ruta-sep {
  opacity: 0.5;
  font-weight: 600;
}

.cr-actions-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  position: relative;
  z-index: 1;
}
.cr-actions-row .cr-btn { flex: 1; }

.cr-sticky-footer {
  position: fixed;
  bottom: calc(3.6rem + env(safe-area-inset-bottom));
  left: 0; right: 0;
  padding: 0.65rem 0.85rem;
  background: linear-gradient(to top, rgba(249, 250, 251, 0.98) 55%, transparent);
  z-index: 999;
  display: flex;
  justify-content: center;
  box-sizing: border-box;
}
.cr-sticky-footer .cr-btn {
  width: 100%;
  max-width: 100%;
}

/* Counters */
.cr-counters {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.75rem 0;
}
.cr-counters-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.cr-counters-row--2 {
  grid-template-columns: repeat(2, 1fr);
}
.cr-counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
  padding: 0.55rem 0.2rem;
  background: #fff;
  border-radius: 14px;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 0.62rem;
  font-weight: 600;
  color: #6b7280;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.cr-counter:active { transform: scale(0.96); }
.cr-counter .cr-counter-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50, #f9fafb);
  color: var(--primary, #7851A9);
}
.cr-counter strong {
  display: block;
  font-size: 1.05rem;
  color: var(--gray-900, #111827);
  font-weight: 800;
}
.cr-counter.incident .cr-counter-icon {
  background: #fee2e2 !important;
  color: #ef4444 !important;
}
.cr-counter.incident,
.cr-counter.incident strong { color: #b91c1c !important; }

/* Pendientes */
.cr-pendiente-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}
.cr-pendiente-form .cr-field { margin-bottom: 0; }
.cr-date-input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 0.92rem;
  box-sizing: border-box;
  background: #fff;
  color: var(--gray-900, #111827);
  min-height: 2.6rem;
}
.cr-date-input:focus {
  outline: none;
  border-color: var(--primary-light, #9370DB);
  box-shadow: 0 0 0 3px rgba(120, 81, 169, 0.15);
}
.cr-pendiente-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cr-pendiente-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.7rem 0.75rem;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
}
.cr-pendiente-item.is-urgente {
  background: #fef2f2;
  border-color: #fecaca;
}
.cr-pendiente-item.done { opacity: 0.55; }
.cr-pendiente-item.done .cr-pendiente-text { text-decoration: line-through; }
.cr-pendiente-text-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem;
}
.cr-prio-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--cr-prio, #7851A9);
  background: color-mix(in srgb, var(--cr-prio, #7851A9) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--cr-prio, #7851A9) 30%, transparent);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
}
.cr-ruta-mes-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  margin: 0.75rem 0 0.25rem;
}
.cr-ruta-mes-stat {
  background: #f9fafb;
  border: 1px solid #eef0f2;
  border-radius: 12px;
  padding: 0.55rem 0.3rem;
  text-align: center;
}
.cr-ruta-mes-icon {
  display: inline-flex;
  color: var(--primary, #7851A9);
  margin-bottom: 0.15rem;
}
.cr-ruta-mes-stat strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.2;
  word-break: break-word;
}
.cr-ruta-mes-stat span {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: #6b7280;
  margin-top: 0.1rem;
}
.cr-pendiente-check {
  width: 20px;
  height: 20px;
  margin-top: 0.1rem;
  accent-color: var(--primary, #7851A9);
  flex-shrink: 0;
}
.cr-pendiente-body { flex: 1; min-width: 0; }
.cr-pendiente-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-900, #111827);
}
.cr-pendiente-date {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
}

.cr-historial-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.cr-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #6b7280;
  margin: 0.85rem 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Quick nav */
.cr-quick-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}
.cr-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 0.35rem;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-700, #374151);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.cr-quick-btn:active { transform: scale(0.97); }
.cr-quick-btn .cr-quick-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(120, 81, 169, 0.14), rgba(147, 112, 219, 0.1));
  color: var(--primary, #7851A9);
}

/* Resumen stats row */
.cr-resumen-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.cr-resumen-item {
  text-align: center;
  padding: 0.7rem 0.4rem;
  background: var(--gray-50, #f9fafb);
  border-radius: 12px;
}
.cr-resumen-item strong {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary, #7851A9);
}
.cr-resumen-item span {
  font-size: 0.68rem;
  color: #6b7280;
  font-weight: 600;
}

/* Rutas */
.cr-ruta-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.4rem;
  vertical-align: middle;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px currentColor;
}
.cr-ruta-today {
  border-left: 4px solid var(--primary, #7851A9);
  background: linear-gradient(90deg, rgba(120, 81, 169, 0.06), #fff 40%);
}
.cr-color-picker { display: flex; gap: 0.55rem; flex-wrap: wrap; }
.cr-color-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease;
}
.cr-color-dot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px #374151, 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: scale(1.08);
}
.cr-itin-hint {
  margin: 0.15rem 0 0.7rem;
  font-size: 0.72rem !important;
}
.cr-itin-hint-desktop {
  display: none;
  margin: 0.15rem 0 0.7rem;
  font-size: 0.72rem !important;
}
.cr-itin-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Wrappers desktop: neutros en mobile (display: contents) */
.cr-desktop-dash,
.cr-desktop-dash-main,
.cr-desktop-dash-side {
  display: contents;
}
.cr-swipe-item {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
}
.cr-swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.cr-swipe-bg span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.cr-swipe-bg--right {
  justify-content: flex-start;
  background: #43a047;
}
.cr-swipe-bg--left {
  justify-content: flex-end;
  background: #e53935;
}
.cr-swipe-item.swiping-right .cr-swipe-bg--right,
.cr-swipe-item.swiping-left .cr-swipe-bg--left {
  opacity: 1;
}
.cr-swipe-content {
  position: relative;
  z-index: 1;
  margin: 0 !important;
  will-change: transform;
  cursor: grab;
}
.cr-swipe-item:not(.is-done):not(.is-missed) .cr-swipe-content {
  background: inherit;
}
.cr-itin-side {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.cr-swipe-item.is-done .cr-swipe-content {
  background: #e8f5e9 !important;
  border-color: #43a047 !important;
  color: #2e7d32 !important;
}
.cr-swipe-item.is-missed .cr-swipe-content {
  background: #ffebee !important;
  border-color: #e53935 !important;
  color: #c62828 !important;
}
.cr-swipe-item.is-done .cr-list-main,
.cr-swipe-item.is-missed .cr-list-main {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}
.cr-swipe-item.is-done .cr-list-main {
  color: #2e7d32;
}
.cr-swipe-item.is-missed .cr-list-main {
  color: #c62828;
}
.cr-swipe-item.is-done .cr-badge,
.cr-swipe-item.is-missed .cr-badge {
  opacity: 0.55;
}
.cr-itin-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  color: transparent;
  background: transparent;
}
.cr-swipe-item.is-done .cr-itin-mark {
  color: #fff;
  background: #43a047;
}
.cr-swipe-item.is-missed .cr-itin-mark {
  color: #fff;
  background: #e53935;
}

/* Choice grid */
.cr-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}
.cr-choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 0.5rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  color: var(--gray-800, #1f2937);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.cr-choice-btn .cr-icon { color: var(--primary, #7851A9); }
.cr-choice-btn:active { transform: scale(0.97); }
.cr-choice-btn.danger {
  border-color: #fecaca;
  color: #dc2626;
}
.cr-choice-btn.danger .cr-icon { color: #ef4444; }
.cr-choice-btn.selected {
  border-color: var(--primary, #7851A9);
  background: rgba(120, 81, 169, 0.08);
}

/* Events */
.cr-event-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  margin: 0;
  border: 1px solid #f0f0f0;
  background: #fff;
  cursor: default;
  font: inherit;
  color: inherit;
  border-radius: 12px;
  box-sizing: border-box;
}
.cr-event-card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.cr-event-row--tap {
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.cr-event-row--tap:active {
  background: rgba(120, 81, 169, 0.05);
  border-color: rgba(120, 81, 169, 0.2);
}
.cr-event-dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.05rem;
}
.cr-event-dot--ok {
  background: #ecfdf5;
  color: #10b981;
}
.cr-event-dot--danger {
  background: #fef2f2;
  color: #ef4444;
}
.cr-event-body { flex: 1; min-width: 0; }
.cr-event-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.cr-event-top strong {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cr-event-date {
  font-size: 0.7rem;
  color: #9ca3af;
  flex-shrink: 0;
}
.cr-event-resumen {
  font-size: 0.72rem;
  color: #6b7280;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-event-price {
  font-size: 0.75rem;
  font-weight: 700;
  color: #059669;
  margin-top: 0.12rem;
}
.cr-event-actions { display: flex; gap: 0.3rem; }
.cr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.cr-modal {
  background: #fff;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 1rem 1rem 1.25rem;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
}
.cr-modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.85rem;
}
.cr-action-sheet { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }

.cr-event-client {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #4b5563;
}
.cr-ruta-labels {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.cr-ruta-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
}
.cr-ruta-item {
  border-left-width: 5px !important;
  border-left-style: solid !important;
  border-left-color: var(--cr-ruta, #999) !important;
}
.cr-orden-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: default;
  user-select: none;
}
.cr-orden-row .cr-orden-label {
  flex: 1;
  min-width: 0;
}
.cr-orden-row .cr-badge {
  flex-shrink: 0;
}
.cr-orden-row .cr-drag-handle {
  cursor: grab;
  color: #9ca3af;
  padding: 0.45rem 0.35rem;
  display: inline-flex;
  align-items: center;
  touch-action: none;
}
.cr-orden-row.cr-orden-pending .cr-drag-handle {
  color: var(--primary, #7851A9);
}
.cr-orden-row.cr-orden-dragging {
  opacity: 0.95;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.18);
  border-color: var(--primary-light, #9370DB);
  transform: scale(1.02);
}
.cr-orden-placeholder {
  border: 2px dashed rgba(120, 81, 169, 0.35);
  border-radius: 14px;
  margin-bottom: 0.55rem;
  background: rgba(120, 81, 169, 0.06);
}
.cr-orden-btns {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}
.cr-orden-btns .cr-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.cr-ruta-assign-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cr-ruta-assign-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 52px;
  padding: 0.7rem 0.8rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.cr-ruta-assign-item .cr-field-label,
.cr-ruta-assign-item.cr-field-label {
  margin: 0;
}
.cr-ruta-assign-bar {
  width: 5px;
  align-self: stretch;
  min-height: 28px;
  border-radius: 999px;
  background: var(--cr-ruta, #9ca3af);
  flex-shrink: 0;
}
.cr-ruta-assign-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.cr-ruta-assign-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--gray-900, #111827);
  line-height: 1.25;
}
.cr-ruta-assign-desc {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cr-ruta-assign-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid #d1d5db;
  background: #fff;
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.cr-ruta-assign-item.is-selected {
  border-color: var(--cr-ruta, #7851A9);
  background: color-mix(in srgb, var(--cr-ruta, #7851A9) 10%, #fff);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--cr-ruta, #7851A9) 25%, transparent);
}
.cr-ruta-assign-item.is-selected .cr-ruta-assign-check {
  background: var(--cr-ruta, #7851A9);
  border-color: var(--cr-ruta, #7851A9);
  color: #fff;
}

.cr-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
  padding: 0.85rem 0.9rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  background: #f9fafb;
}
.cr-switch-row.is-on {
  background: color-mix(in srgb, var(--primary, #7851A9) 8%, #fff);
  border-color: color-mix(in srgb, var(--primary, #7851A9) 35%, #e5e7eb);
}
.cr-switch-copy {
  flex: 1;
  min-width: 0;
}
.cr-switch-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gray-900, #111827);
}
.cr-switch-sub {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.35;
}
.cr-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  margin: 0;
  cursor: pointer;
}
.cr-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.cr-switch-track {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #d1d5db;
  display: block;
  position: relative;
  transition: background 0.15s ease;
}
.cr-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease;
}
.cr-switch input:checked + .cr-switch-track {
  background: var(--primary, #7851A9);
}
.cr-switch input:checked + .cr-switch-track .cr-switch-thumb {
  transform: translateX(20px);
}
.cr-cat-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.cr-cat-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.65rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.cr-cat-option-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--cr-cat, #78909c) 14%, #fff);
  color: var(--cr-cat, #78909c);
}
.cr-cat-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.cr-cat-option-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gray-900, #111827);
  line-height: 1.2;
}
.cr-cat-option-imp {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
}
.cr-cat-option.is-selected {
  border-color: var(--cr-cat, #7851A9);
  background: color-mix(in srgb, var(--cr-cat, #7851A9) 10%, #fff);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--cr-cat, #7851A9) 28%, transparent);
}
.cr-cat-option.is-selected .cr-cat-option-icon {
  background: var(--cr-cat, #7851A9);
  color: #fff;
}
.cr-cat-option.is-selected .cr-cat-option-name {
  color: var(--cr-cat, #111827);
}
.cr-cat-option:active {
  transform: scale(0.98);
}
@media (max-width: 360px) {
  .cr-cat-picker {
    grid-template-columns: 1fr;
  }
}

/* Stats */
.cr-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.cr-stat-box {
  background: linear-gradient(160deg, #fafafa, #f3f4f6);
  border-radius: 14px;
  padding: 0.85rem;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.cr-stat-box--tap {
  cursor: pointer;
  font: inherit;
  color: inherit;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.cr-stat-box--tap:active {
  transform: scale(0.98);
}
.cr-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  margin: 0 auto 0.45rem;
  background: color-mix(in srgb, var(--primary, #7851A9) 12%, #fff);
  color: var(--primary, #7851A9);
}
.cr-stat-box--tap[data-cr-stat="presupuestos"] .cr-stat-icon {
  background: #e3f2fd;
  color: #1e88e5;
}
.cr-stat-box--tap[data-cr-stat="pedidos"] .cr-stat-icon {
  background: #e8f5e9;
  color: #43a047;
}
.cr-stat-box--tap[data-cr-stat="ventas"] .cr-stat-icon {
  background: #fff8e1;
  color: #f9a825;
}
.cr-stat-box strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary, #7851A9);
}
.cr-stat-box span {
  font-size: 0.72rem;
  color: #6b7280;
  font-weight: 600;
}

.cr-empty {
  text-align: center;
  color: #9ca3af;
  padding: 2.25rem 1rem;
  font-size: 0.88rem;
}
.cr-empty .cr-empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.75rem;
  border-radius: 16px;
  background: var(--gray-100, #f3f4f6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}

.cr-erp-banner {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  background: #eef6ff;
  color: #1e3a5f;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid #cfe3f8;
}
.cr-input-readonly,
input.cr-input-readonly {
  background: #f3f4f6 !important;
  color: #6b7280 !important;
  cursor: default;
}

.cr-inline-form {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.cr-inline-form .cr-field {
  flex: 1;
  min-width: 120px;
  margin-bottom: 0;
}

.cr-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0;
}
.cr-toggle-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
}

@media (min-width: 600px) and (max-width: 1023px) {
  .cr-bottom-nav,
  .cr-sticky-footer {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
  .cr-bottom-nav { border-radius: 16px 16px 0 0; }
}

/* Paridad: badges / dossier */
.cr-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0;
}
.cr-prospecto-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #e0f2f1;
  color: #00695c;
}

/* ========================================
   Desktop / PC (≥1024px) — mobile inchangé
   ======================================== */
@media (min-width: 1024px) {
  body.cr-tool-active #appContainerTienda.app-container {
    bottom: 0;
  }

  #comercialRutasScreen.screen.active {
    height: 100%;
  }

  .cr-tool {
    flex-direction: row;
    align-items: stretch;
    background:
      radial-gradient(900px 420px at 18% -8%, rgba(120, 81, 169, 0.1), transparent 55%),
      radial-gradient(700px 360px at 100% 0%, rgba(147, 112, 219, 0.07), transparent 50%),
      linear-gradient(180deg, #f7f5fb 0%, var(--gray-50, #f9fafb) 40%, #f3f4f6 100%);
  }

  /* Sidebar navigation */
  .cr-bottom-nav {
    position: relative;
    inset: auto;
    width: 232px;
    min-width: 232px;
    max-width: none;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.3rem;
    padding: 1.35rem 0.85rem 1.35rem;
    border-top: none;
    border-right: 1px solid rgba(17, 24, 39, 0.07);
    border-radius: 0;
    box-shadow: 4px 0 24px rgba(17, 24, 39, 0.04);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    transform: none;
    left: auto;
    z-index: 2;
  }

  .cr-bottom-nav::before {
    content: 'Rutas';
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
    padding: 0 0.7rem 0.85rem;
  }

  .cr-nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    min-height: 0;
    padding: 0.72rem 0.8rem;
    font-size: 0.86rem;
    border-radius: 12px;
    color: #6b7280;
  }

  .cr-nav-item:hover {
    background: rgba(120, 81, 169, 0.06);
    color: var(--primary, #7851A9);
  }

  .cr-nav-item .cr-nav-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .cr-nav-item.active {
    background: linear-gradient(135deg, rgba(120, 81, 169, 0.14), rgba(147, 112, 219, 0.1));
    color: var(--primary, #7851A9);
  }

  .cr-nav-item.active .cr-nav-icon {
    background: linear-gradient(135deg, var(--primary, #7851A9), var(--primary-light, #9370DB));
    color: #fff;
  }

  /* Contenu principal */
  .cr-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 2rem 2rem;
    padding-bottom: 2rem;
    max-width: none;
  }

  .cr-page-bar {
    margin-bottom: 1rem;
  }

  .cr-page-bar-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
  }

  .cr-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  }

  .cr-back-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08);
  }

  .cr-back-btn:active {
    transform: none;
  }

  .cr-search-wrap {
    max-width: 520px;
    margin-bottom: 1.1rem;
  }

  .cr-search {
    border-radius: 14px;
    padding: 0.78rem 1rem 0.78rem 2.65rem;
    font-size: 0.94rem;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 20px rgba(17, 24, 39, 0.04);
  }

  .cr-quick-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.15rem;
    max-width: 920px;
  }

  .cr-quick-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    font-size: 0.84rem;
    border-radius: 14px;
    transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  }

  .cr-quick-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(120, 81, 169, 0.28);
    box-shadow: 0 8px 20px rgba(120, 81, 169, 0.1);
  }

  .cr-quick-btn:active {
    transform: none;
  }

  .cr-quick-btn .cr-quick-icon {
    width: 38px;
    height: 38px;
  }

  /* Dashboard Inicio */
  .cr-desktop-dash {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 1.15rem;
    align-items: start;
  }

  .cr-desktop-dash-main,
  .cr-desktop-dash-side {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
  }

  .cr-card {
    border-radius: 18px;
    padding: 1.2rem 1.25rem;
    margin-bottom: 0.95rem;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.03), 0 10px 28px rgba(17, 24, 39, 0.045);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
  }

  .cr-card-title {
    font-size: 0.98rem;
    margin-bottom: 0.9rem;
  }

  .cr-resumen-item {
    padding: 1rem 0.5rem;
    border-radius: 14px;
    background: linear-gradient(160deg, #faf8ff, #f3f4f6);
  }

  .cr-resumen-item strong {
    font-size: 1.55rem;
  }

  .cr-resumen-item span {
    font-size: 0.74rem;
  }

  /* Listes & grilles */
  .cr-list-item {
    margin-bottom: 0.65rem;
    border-radius: 14px;
    transition: background 0.12s ease, box-shadow 0.15s ease, transform 0.12s ease, border-color 0.12s ease;
  }

  .cr-list-item:hover {
    background: #fff;
    box-shadow: 0 8px 22px rgba(17, 24, 39, 0.08);
    transform: translateY(-1px);
  }

  .cr-list-item:active {
    transform: none;
  }

  .cr-content[data-cr-panel="rutas"][data-cr-view="list"] {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.85rem;
    align-content: start;
  }

  .cr-content[data-cr-panel="rutas"][data-cr-view="list"] > #crNuevaRuta,
  .cr-content[data-cr-panel="rutas"][data-cr-view="list"] > .cr-empty {
    grid-column: 1 / -1;
  }

  .cr-content[data-cr-panel="rutas"][data-cr-view="list"] > .cr-list-item,
  .cr-content[data-cr-panel="rutas"][data-cr-view="list"] > .cr-ruta-item {
    margin-bottom: 0;
    height: 100%;
  }

  #crClienteListBody {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
  }

  #crClienteListBody > .cr-list-item {
    margin-bottom: 0;
    height: 100%;
  }

  .cr-chip-row {
    padding-bottom: 0.85rem;
    scrollbar-width: thin;
  }

  .cr-chip:hover {
    border-color: rgba(120, 81, 169, 0.45);
    color: var(--primary, #7851A9);
  }

  .cr-filters {
    gap: 0.65rem;
    margin-bottom: 1rem;
    max-width: 640px;
  }

  .cr-filters select,
  .cr-filters input {
    flex: 1 1 180px;
    max-width: 280px;
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
  }

  /* Formulaires centrés */
  .cr-content[data-cr-view="rutaForm"],
  .cr-content[data-cr-view="clienteForm"],
  .cr-content[data-cr-view="eventForm"] {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }

  .cr-content[data-cr-view="clienteForm"] .cr-card,
  .cr-content[data-cr-view="rutaForm"] .cr-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
    align-items: start;
  }

  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-card-title,
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-erp-banner,
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-btn,
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-cat-picker,
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-ruta-assign-list,
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-section-title,
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-list-sub,
  .cr-content[data-cr-view="clienteForm"] .cr-card > p,
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-switch-row,
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-field:has(textarea),
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-field:has(.cr-cat-picker),
  .cr-content[data-cr-view="clienteForm"] .cr-card > .cr-field:has(.cr-ruta-assign-list),
  .cr-content[data-cr-view="rutaForm"] .cr-card > .cr-card-title,
  .cr-content[data-cr-view="rutaForm"] .cr-card > .cr-btn,
  .cr-content[data-cr-view="rutaForm"] .cr-card > .cr-field:has(.cr-color-picker) {
    grid-column: 1 / -1;
  }

  .cr-btn {
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  }

  .cr-btn:hover {
    filter: brightness(1.03);
  }

  .cr-btn-primary {
    box-shadow: 0 6px 18px rgba(120, 81, 169, 0.28);
  }

  .cr-btn-primary:hover {
    box-shadow: 0 8px 22px rgba(120, 81, 169, 0.36);
  }

  .cr-btn:active {
    transform: none;
  }

  .cr-content[data-cr-panel="rutas"][data-cr-view="list"] > #crNuevaRuta,
  .cr-content[data-cr-panel="clientes"][data-cr-view="list"] > #crNuevoCliente {
    max-width: 260px;
    margin-bottom: 0.25rem !important;
  }

  /* Détail ruta: ficha + grille de clientes */
  .cr-content[data-cr-view="rutaDetail"]:not(:has(#crRutaGestionListBody)):not(:has(#crOrdenList)) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    align-content: start;
  }

  .cr-content[data-cr-view="rutaDetail"]:not(:has(#crRutaGestionListBody)):not(:has(#crOrdenList)) > .cr-page-bar,
  .cr-content[data-cr-view="rutaDetail"]:not(:has(#crRutaGestionListBody)):not(:has(#crOrdenList)) > .cr-card,
  .cr-content[data-cr-view="rutaDetail"]:not(:has(#crRutaGestionListBody)):not(:has(#crOrdenList)) > .cr-section-title {
    grid-column: 1 / -1;
  }

  .cr-content[data-cr-view="rutaDetail"]:not(:has(#crRutaGestionListBody)):not(:has(#crOrdenList)) > .cr-card {
    max-width: 720px;
  }

  .cr-content[data-cr-view="rutaDetail"]:not(:has(#crRutaGestionListBody)):not(:has(#crOrdenList)) > .cr-list-item {
    margin-bottom: 0;
    height: 100%;
  }

  .cr-content[data-cr-view="rutaDetail"]:not(:has(#crRutaGestionListBody)):not(:has(#crOrdenList)) > .cr-section-title {
    margin-top: 0.35rem;
    margin-bottom: 0;
  }

  .cr-ruta-mes-stats {
    gap: 0.5rem;
  }

  .cr-ruta-mes-stat {
    padding: 0.7rem 0.4rem;
  }

  .cr-ruta-mes-stat strong {
    font-size: 0.95rem;
  }

  /* Itinerario: panneau + liste */
  .cr-itin-card {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    gap: 0.85rem 1.5rem;
    align-items: start;
    padding: 1.35rem 1.4rem !important;
  }

  .cr-itin-card > .cr-card-title {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .cr-itin-controls {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 1rem;
    border-radius: 16px;
    background: linear-gradient(160deg, #faf8ff, #f3f4f6);
    border: 1px solid rgba(120, 81, 169, 0.1);
  }

  .cr-itin-controls .cr-field {
    margin-bottom: 0.65rem;
  }

  .cr-itin-hint {
    display: none;
  }

  .cr-itin-hint-desktop {
    display: block;
    margin: 0.1rem 0 0;
  }

  .cr-itin-list {
    grid-column: 2;
    grid-row: 2 / 4;
    max-height: calc(100vh - 12rem);
    overflow-y: auto;
    padding-right: 0.25rem;
    align-self: stretch;
  }

  .cr-itin-maps-btn {
    grid-column: 1;
    grid-row: 3;
    margin-top: 0 !important;
    width: 100%;
    max-width: none;
  }

  .cr-swipe-content {
    cursor: grab;
  }

  .cr-swipe-content:active {
    cursor: grabbing;
  }

  /* Sticky footer au-dessus du contenu, à droite de la sidebar */
  .cr-sticky-footer {
    left: 232px;
    right: 0;
    bottom: 0;
    max-width: none;
    transform: none;
    padding: 0.85rem 2rem 1.1rem;
    background: linear-gradient(to top, rgba(249, 250, 251, 0.98) 60%, transparent);
  }

  .cr-sticky-footer .cr-btn {
    max-width: 360px;
  }

  /* Modales centrées type dialog */
  .cr-modal-overlay {
    align-items: center;
    padding: 1.5rem;
  }

  .cr-modal {
    width: min(520px, 100%);
    max-width: 520px;
    border-radius: 18px;
    padding: 1.35rem 1.4rem 1.5rem;
    box-shadow: 0 24px 60px rgba(17, 24, 39, 0.22);
  }

  .cr-action-sheet {
    padding-bottom: 1.25rem;
  }

  .cr-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .cr-choice-btn:hover {
    border-color: rgba(120, 81, 169, 0.4);
    background: rgba(120, 81, 169, 0.04);
  }

  .cr-choice-btn:active {
    transform: none;
  }

  .cr-event-row--tap:hover {
    background: rgba(120, 81, 169, 0.04);
    border-color: rgba(120, 81, 169, 0.18);
  }

  .cr-event-row--tap:active {
    background: rgba(120, 81, 169, 0.05);
  }

  .cr-stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    max-width: 900px;
  }

  .cr-stat-box {
    padding: 1.1rem 0.85rem;
  }

  .cr-stat-box--tap:hover {
    box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
    border-color: rgba(120, 81, 169, 0.2);
  }

  .cr-stat-box--tap:active {
    transform: none;
  }

  .cr-counter:hover {
    box-shadow: 0 6px 16px rgba(17, 24, 39, 0.08);
  }

  .cr-counter:active {
    transform: none;
  }

  .cr-cat-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cr-historial-list {
    max-width: 860px;
  }

  .cr-content[data-cr-panel="historial"][data-cr-view="list"] .cr-filters,
  .cr-content[data-cr-panel="ajustes"] .cr-card {
    max-width: 860px;
  }

  .cr-content[data-cr-view="clienteDetail"] {
    max-width: 1100px;
  }

  .cr-content[data-cr-view="clienteDetail"] .cr-cliente-facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 1.15rem;
  }

  .cr-content[data-cr-view="clienteDetail"] .cr-pendiente-form {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(120px, 0.7fr) minmax(140px, 0.8fr) auto;
    align-items: end;
    gap: 0.55rem 0.65rem;
  }

  .cr-content[data-cr-view="clienteDetail"] .cr-pendiente-form .cr-field {
    margin-bottom: 0;
  }

  .cr-content[data-cr-view="clienteDetail"] .cr-counters-row {
    gap: 0.55rem;
  }

  .cr-empty {
    padding: 2.75rem 1.25rem;
  }
}

@media (min-width: 1400px) {
  .cr-bottom-nav {
    width: 248px;
    min-width: 248px;
  }

  .cr-content {
    padding: 1.75rem 2.5rem 2.25rem;
  }

  .cr-sticky-footer {
    left: 248px;
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }

  .cr-desktop-dash {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 1.35rem;
  }

  .cr-content[data-cr-panel="rutas"][data-cr-view="list"],
  #crClienteListBody {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }
}
