/* ==========================================================================
   SD LAB — CRM & OPERACIONES
   Design System: Obsidian Zinc, Precision Typography & High-Density Ergonomics
   ========================================================================== */

:root {
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions */
  --transition-fast: 0.12s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.2s cubic-bezier(0.16, 1, 0.3, 1);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
}

/* ==========================================================================
   DARK THEME (DEFAULT — OBSIDIAN ZINC & SD LAB ORANGE)
   ========================================================================== */
html[data-theme="dark"] {
  --bg-app: #09090b;
  --bg-surface: #111114;
  --bg-surface-elevated: #18181c;
  --bg-surface-hover: #222228;
  --bg-surface-active: #2b2b32;
  
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);

  --text-main: #fafafa;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;
  --text-inverse: #09090b;

  --accent-primary: #f97316;
  --accent-primary-hover: #ea580c;
  --accent-primary-subtle: rgba(249, 115, 22, 0.12);

  --status-activo: #38bdf8;
  --status-activo-bg: rgba(56, 189, 248, 0.1);
  --status-gestion: #f59e0b;
  --status-gestion-bg: rgba(245, 158, 11, 0.1);
  --status-despacho: #818cf8;
  --status-despacho-bg: rgba(129, 140, 248, 0.1);
  --status-completado: #10b981;
  --status-completado-bg: rgba(16, 185, 129, 0.1);

  --kanban-col-bg: #121216;
  --card-bg: #18181d;
  --card-hover: #1f1f26;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);
}

/* ==========================================================================
   LIGHT THEME (CLEAN INDUSTRIAL SLATE)
   ========================================================================== */
html[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-surface-active: #cbd5e1;
  
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-strong: #94a3b8;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;

  --accent-primary: #ea580c;
  --accent-primary-hover: #c2410c;
  --accent-primary-subtle: rgba(234, 88, 12, 0.1);

  --status-activo: #0284c7;
  --status-activo-bg: #e0f2fe;
  --status-gestion: #d97706;
  --status-gestion-bg: #fef3c7;
  --status-despacho: #6366f1;
  --status-despacho-bg: #e0e7ff;
  --status-completado: #059669;
  --status-completado-bg: #d1fae5;

  --kanban-col-bg: #f1f5f9;
  --card-bg: #ffffff;
  --card-hover: #f8fafc;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   BASE RESET & LAYOUT
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   TOP APP BAR & NAVIGATION
   ========================================================================== */
.top-nav {
  min-height: 56px;
  height: auto;
  flex-wrap: wrap;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.nav-brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* BRAND LOGO */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-mark {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-main);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
}

.brand-dot {
  color: var(--accent-primary);
  font-size: 1.35rem;
  line-height: 0;
  margin-left: 1px;
}

.top-nav > div:first-child {
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-main);
  line-height: 1.1;
}

.brand-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* SPOTLIGHT TRIGGER (CTRL + K) */
.spotlight-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 260px;
}

.spotlight-trigger:hover {
  border-color: var(--border-medium);
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.spotlight-placeholder {
  font-size: 0.8rem;
  flex: 1;
  text-align: left;
}

.spotlight-kbd {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* WORKSPACE TABS IN TOP BAR */
.workspace-nav {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.workspace-tabs-container {
  display: flex;
  gap: 4px;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.ws-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.ws-tab:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.ws-tab.active {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.ws-tab.active svg {
  color: var(--accent-primary);
}

.ws-tab-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent-primary);
}

/* TOP ACTIONS */
.nav-right {
  flex-wrap: wrap;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-medium);
}

.btn-danger {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.btn-icon:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-medium);
  color: var(--text-main);
}

/* DROPDOWN */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 190px;
  display: none;
  z-index: 110;
  animation: popIn 0.15s ease-out;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-main);
  border: none;
  background: transparent;
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-surface-hover);
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   WORKSPACE VIEWS & SUBNAV BAR
   ========================================================================== */
.workspace-view {
  display: none;
}

.workspace-view.active {
  display: block;
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.view-toggle-pills {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 3px;
}

.view-pill {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-pill:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.view-pill.active {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.quick-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.select-wrapper {
  position: relative;
}

.filter-select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  outline: none;
  cursor: pointer;
  transition: border var(--transition-fast);
}

.filter-select:focus {
  border-color: var(--accent-primary);
}

.pill-filter-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 5px 11px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pill-filter-btn:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
}

.pill-filter-btn.active {
  background: rgba(249, 115, 22, 0.12);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 700;
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 8px;
  text-decoration: underline;
}

.btn-text-link:hover {
  color: var(--text-main);
}

.count-badge-wrapper {
  display: flex;
  align-items: center;
}

.records-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.ws-help-pill {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.ws-help-pill:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
}

.subview-panel {
  display: none;
}

.subview-panel.active {
  display: block;
}

/* ==========================================================================
   WORKSPACE 1: KANBAN BOARD
   ========================================================================== */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 18px 20px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1200px) {
  .kanban-board {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .kanban-board {
    grid-template-columns: 1fr;
  }
}

.kanban-col {
  background: var(--kanban-col-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 170px);
  overflow: hidden;
}

.col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
}

.col-activo { border-top: 3px solid var(--status-activo); }
.col-gestion { border-top: 3px solid var(--status-gestion); }
.col-despacho { border-top: 3px solid var(--status-despacho); }
.col-completado { border-top: 3px solid var(--status-completado); }

.col-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-activo { background: var(--status-activo); }
.status-gestion { background: var(--status-gestion); }
.status-despacho { background: var(--status-despacho); }
.status-completado { background: var(--status-completado); }

.col-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.col-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.btn-col-add {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
}

.btn-col-add:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.col-body {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
}

.col-body.drag-over {
  background: rgba(249, 115, 22, 0.05);
  border: 1px dashed var(--accent-primary);
}

/* KANBAN CARD */
.kanban-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.kanban-card:hover {
  border-color: var(--border-medium);
  background: var(--card-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.kanban-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-id {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

.tag-zona {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.tag-delivery {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.tag-reparto { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.tag-flete { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.tag-retira { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }

.card-company {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  line-height: 1.25;
}

.card-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.badge-role {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

.card-address {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.3;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  gap: 6px;
}

.card-actions-quick {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-card-action {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
}

.btn-card-action:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-medium);
  color: var(--text-main);
}

.btn-card-status-toggle {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-card-status-toggle:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-medium);
  color: var(--text-main);
}

/* ==========================================================================
   WORKSPACE 1: SPREADSHEET TABLE
   ========================================================================== */
.table-container {
  padding: 16px 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

/* Barra Flotante de Acciones en Lote (Floating Island) */
.table-batch-actions {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--accent-primary);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(249, 115, 22, 0.3);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-main);
  animation: floatUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.table-batch-actions.hidden {
  display: none !important;
}

@keyframes floatUp {
  from { opacity: 0; transform: translate(-50%, 15px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Botón WhatsApp Directo de Alta Conversión */
.btn-wsp-direct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-wsp-direct:hover {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}

.badge-empty-soft {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-subtle);
  display: inline-block;
}

.table-pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.table-scroll-wrap {
  max-width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.canvas-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.canvas-table th, .canvas-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.canvas-table th {
  background: var(--bg-surface-elevated);
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.canvas-table th.th-sort {
  cursor: pointer;
}

.canvas-table th.th-sort:hover {
  color: var(--text-main);
}

.canvas-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

.canvas-table tbody tr.row-selected {
  background: rgba(249, 115, 22, 0.08);
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  display: inline-block;
}

.badge-Activo { background: var(--status-activo-bg); color: var(--status-activo); }
.badge-En_Gestión { background: var(--status-gestion-bg); color: var(--status-gestion); }
.badge-Para_Despacho { background: var(--status-despacho-bg); color: var(--status-despacho); }
.badge-Completado { background: var(--status-completado-bg); color: var(--status-completado); }

/* ==========================================================================
   WORKSPACE 2: ESTIMATOR & PIPELINE
   ========================================================================== */
.estimator-container {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1300px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .estimator-container {
    grid-template-columns: 1fr;
  }
}

.estimator-form-card, .estimator-ticket-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.section-title-wrap h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.section-title-wrap p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--accent-primary);
}

.form-row {
  display: flex;
  gap: 12px;
}

.col-4 { flex: 4; }
.col-6 { flex: 6; }

.estimator-ticket-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  display: flex;
  flex-direction: column;
}

.ticket-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.ticket-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 8px;
}

.ticket-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.badge-emerald { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.badge-blue { background: rgba(56, 189, 248, 0.12); color: #38bdf8; }
.badge-amber { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.badge-purple { background: rgba(168, 85, 247, 0.12); color: #a855f7; }

.ticket-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.ticket-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.ticket-line strong {
  font-family: var(--font-mono);
  color: var(--text-main);
}

.ticket-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--border-medium);
  font-weight: 800;
}

.ticket-total-val {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--accent-primary);
}

.ticket-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* SALES PIPELINE */
.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  flex-wrap: wrap;
}

.pipeline-meta h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.pipeline-meta p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pipeline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 18px 20px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1200px) {
  .pipeline-board {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .pipeline-board {
    grid-template-columns: 1fr;
  }
}

.pipeline-col {
  background: var(--kanban-col-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
  overflow: hidden;
}

.pipeline-col-header {
  padding: 12px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.pipeline-col-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.pipeline-col-title-wrap h4 {
  font-size: 0.85rem;
  font-weight: 700;
}

.pipeline-col-sum {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.pipeline-col-body {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pipeline-col-body.drag-over {
  background: rgba(249, 115, 22, 0.05);
  border: 1px dashed var(--accent-primary);
}

.pipeline-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.pipeline-card:hover {
  background: var(--card-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.pipeline-card-client {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.pipeline-card-concept {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pipeline-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.pipeline-card-amount {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.pipeline-card-seller {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   WORKSPACE 3: LOGÍSTICA & DESPACHOS
   ========================================================================== */
.zones-cluster-container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.zones-header-intro h3 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.zones-header-intro p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.macro-regions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

@media (max-width: 900px) {
  .macro-regions-grid {
    grid-template-columns: 1fr;
  }
}

.region-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.region-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.region-card-header h4 {
  font-size: 1.05rem;
  font-weight: 800;
}

.region-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: var(--bg-surface-elevated);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.region-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.zone-pills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.zone-cluster-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.zone-cluster-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.zone-cluster-btn .zone-chip-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* PLANNER */
.planner-layout {
  padding: 20px;
  max-width: 1500px;
  margin: 0 auto;
}

.planner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.planner-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
}

.planner-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.planner-legend {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-morning { background: #38bdf8; }
.dot-afternoon { background: #f59e0b; }
.dot-express { background: #a855f7; }

.planner-grid-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

@media (max-width: 1024px) {
  .planner-grid-container {
    grid-template-columns: 1fr;
  }
}

.planner-week-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

@media (max-width: 900px) {
  .planner-week-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.day-column {
  background: var(--kanban-col-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.day-header {
  padding: 10px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.day-count-badge {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.day-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.shift-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 0.75rem;
}

.shift-time {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.shift-driver {
  color: var(--text-muted);
  margin-bottom: 2px;
}

.shift-client {
  color: var(--text-subtle);
  font-size: 0.7rem;
}

.planner-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.sidebar-header h4 {
  font-size: 0.95rem;
  font-weight: 800;
}

.driver-capacity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.driver-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
}

.driver-card.overcapacity {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.driver-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.capacity-bar-wrap {
  height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.capacity-bar-fill {
  height: 100%;
  background: #10b981;
  border-radius: var(--radius-full);
}

.capacity-bar-fill.fill-red {
  background: #ef4444;
}

.badge-overcapacity {
  margin-top: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #ef4444;
}

/* QR GENERATOR */
.qr-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1000px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .qr-layout {
    grid-template-columns: 1fr;
  }
}

.qr-form-card, .qr-preview-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.qr-mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.qr-mode-btn {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.qr-mode-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.qr-preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.qr-canvas-wrapper {
  background: #ffffff;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-medium);
  margin-bottom: 14px;
  box-shadow: var(--shadow-md);
}

.qr-info-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.qr-actions {
  width: 100%;
}

/* ==========================================================================
   WORKSPACE 4: MÉTRICAS, ACTIVIDAD & MANUAL
   ========================================================================== */
.analytics-dashboard {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.analytics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .analytics-row {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.bar-chart-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
}

.chart-bar-label {
  width: 70px;
  font-weight: 600;
  color: var(--text-muted);
}

.chart-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
}

.chart-bar-val {
  font-family: var(--font-mono);
  width: 40px;
  text-align: right;
  font-weight: 700;
  color: var(--text-main);
}

/* ACTIVITY TIMELINE */
.activity-container {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.activity-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.activity-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  padding-left: 28px;
}

.activity-timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 9px;
  width: 2px;
  background: var(--border-medium);
}

.activity-item {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.activity-dot {
  position: absolute;
  left: -28px;
  top: 16px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.activity-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* GUIDE */
.guide-container {
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.guide-hero-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-hero-text h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.guide-hero-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

@media (max-width: 768px) {
  .guide-grid {
    grid-template-columns: 1fr;
  }
}

.guide-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.guide-card-header {
  margin-bottom: 10px;
}

.guide-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-bottom: 6px;
}

.guide-card-header h4 {
  font-size: 1rem;
  font-weight: 800;
}

.guide-card-body p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==========================================================================
   INTERACTIVE USER MANUAL / INSTRUCTIVO OPERATIVO
   ========================================================================== */
.manual-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 10px;
}

.guide-accordion-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.manual-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.manual-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.manual-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
}

.manual-step-num {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-primary);
  background: rgba(249, 115, 22, 0.12);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  line-height: 1;
}

.manual-card-header h4 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 3px 0;
}

.manual-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.manual-card-body {
  padding: 20px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.manual-card-body ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manual-card-body li {
  position: relative;
  padding-left: 18px;
}

.manual-card-body li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent-primary);
  font-weight: 900;
  font-size: 1.1rem;
  line-height: 1.4;
}

.manual-card-body strong {
  color: var(--text-main);
}

.manual-card-body code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  color: #38bdf8;
}

.zones-reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.zone-ref-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.zone-ref-code {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--accent-primary);
  background: rgba(249, 115, 22, 0.1);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.zone-ref-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.zone-ref-name {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zone-ref-loc {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.zone-ref-fleet {
  font-size: 0.72rem;
  color: #38bdf8;
  font-family: var(--font-mono);
}

/* ==========================================================================
   MODALS, SPOTLIGHT & DRAWERS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.15s ease-out;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-lg {
  max-width: 820px;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-form {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-surface-elevated);
}

/* SPOTLIGHT (CTRL + K) */
.spotlight-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 640px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin: 10vh auto;
}

.spotlight-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.spotlight-input-wrap svg {
  color: var(--text-muted);
}

.spotlight-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1.05rem;
  color: var(--text-main);
  font-family: var(--font-sans);
}

.spotlight-input-wrap input::placeholder {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.spotlight-esc {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.spotlight-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px 12px;
}

.spotlight-category-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 10px 4px 10px;
}

.spotlight-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-main);
}

.spotlight-item:hover, .spotlight-item.active {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-primary);
}

.spotlight-item-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

.spotlight-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spotlight-item-title {
  font-size: 0.88rem;
  font-weight: 600;
}

.spotlight-item-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.spotlight-item-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

/* WHATSAPP TEMPLATES */
.wsp-template-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.wsp-tpl-btn {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.wsp-tpl-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.wsp-tpl-btn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.5);
  color: #10b981;
  font-weight: 700;
}

/* DETAIL DRAWER */
.detail-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-medium);
  z-index: 150;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.detail-drawer.open {
  right: 0;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 140;
  display: none;
}

.drawer-overlay.open {
  display: block;
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: rgba(249, 115, 22, 0.12);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  display: inline-block;
  margin-bottom: 4px;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.btn-close-drawer {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.drawer-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-section {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.drawer-section h4 {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.drawer-field {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 4px 0;
}

.drawer-field label {
  color: var(--text-muted);
}

.drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 8px;
  background: var(--bg-surface-elevated);
}

/* ==========================================================================
   PRINTABLE REMITO OFICIAL R
   ========================================================================== */
.remito-doc {
  border: 1px solid #cbd5e1;
  padding: 24px;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-family: var(--font-sans);
}

.remito-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.remito-divider {
  height: 2px;
  background: #e2e8f0;
  margin: 12px 0 16px 0;
}

.remito-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: #f8fafc;
  padding: 14px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  margin-bottom: 18px;
}

.remito-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.remito-val {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.remito-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.remito-table th, .remito-table td {
  border: 1px solid #cbd5e1;
  padding: 10px 12px;
  font-size: 0.82rem;
}

.remito-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: #1e293b;
  text-align: left;
}

.remito-footer-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 24px;
  align-items: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed #cbd5e1;
}

.remito-qr-box {
  width: 110px;
  height: 110px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.remito-signature-box {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 90px;
}

.sig-line {
  border-bottom: 1px solid #0f172a;
  margin-bottom: 8px;
  width: 80%;
  margin-left: auto;
  margin-right: auto;
}

@media print {
  body * {
    visibility: hidden;
  }
  #remitoModal, #remitoModal *, #officialQuoteModal, #officialQuoteModal * {
    visibility: visible;
  }
  #remitoModal, #officialQuoteModal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto;
    background: #ffffff !important;
    display: block !important;
    padding: 0 !important;
  }
  .modal-dialog {
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
  }
  .modal-header, .modal-footer {
    display: none !important;
  }
  .remito-doc {
    border: none !important;
    padding: 0 !important;
  }
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success { border-left: 4px solid #10b981; }
.toast-info { border-left: 4px solid var(--accent-primary); }
.toast-warning { border-left: 4px solid #f59e0b; }
.toast-error { border-left: 4px solid #ef4444; }

.toast.fade-out {
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.2s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   COMMERCIAL SALES FEATURES: FOLLOW-UP, TASKS, QUOTE TAGS & BATCH QUEUE
   ========================================================================== */

/* Follow-up tags */
.tag-followup {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.02em;
}

.followup-fresh {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.followup-warning {
  background: rgba(245, 158, 11, 0.14);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.followup-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  animation: pulseAlert 2.5s infinite;
}

.followup-neutral {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

@keyframes pulseAlert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Commercial Task / Next Action Banner on Card */
.card-next-action {
  background: rgba(249, 115, 22, 0.08);
  border: 1px dashed rgba(249, 115, 22, 0.35);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  margin: 7px 0 4px 0;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.action-bullet {
  font-size: 0.8rem;
  flex-shrink: 0;
}

.action-text {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-due {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-primary);
  background: rgba(249, 115, 22, 0.12);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Quote Monetary Tag on Card */
.card-quote-val {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-top: 4px;
}

/* Column Monetary Sum */
.col-money-sum {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-left: 6px;
}

/* Alert Pill Filter */
.pill-filter-alert.active {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

/* Batch Modal Customizations */
.modal-md {
  max-width: 540px;
  width: 90%;
}

.batch-tpl-btn {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.batch-tpl-btn.active {
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  font-weight: 700;
}


/* ============================================================================
   PORTAL DE LOGIN TRADICIONAL & PERSONALIZACIÓN DE VISTA
   ============================================================================ */

.login-overlay {
  position: fixed;
  inset: 0;
  background: #070a11;
  background-image: 
    radial-gradient(circle at 50% 15%, rgba(249, 115, 22, 0.12) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(15, 23, 42, 0.9) 0%, transparent 50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.login-overlay.hidden {
  display: none !important;
}

.login-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 440px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.8);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #f97316, transparent);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #ffffff;
  display: inline-flex;
  align-items: baseline;
  margin-bottom: 8px;
}

.login-logo .dot {
  color: #f97316;
  font-size: 2.4rem;
  line-height: 0;
}

.login-meta h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 4px;
}

.login-meta p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.login-remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.login-footer-hint {
  margin-top: 24px;
  padding: 12px;
  background: var(--bg-surface-elevated);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.login-footer-hint code {
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-weight: 700;
}

/* User pill in top nav */
.user-pill-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  padding: 3px 10px 3px 6px;
  font-size: 0.8rem;
}

.user-avatar-small {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dropzone de carga de archivos */
.upload-dropzone {
  border: 2px dashed rgba(249, 115, 22, 0.4);
  background: rgba(249, 115, 22, 0.03);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.08);
}

.upload-dropzone-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
  display: block;
}

/* Inline cell editor */
.cell-editable {
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s ease;
}

.cell-editable:hover {
  background-color: rgba(249, 115, 22, 0.08) !important;
  outline: 1px dashed rgba(249, 115, 22, 0.4);
}

.inline-cell-input {
  width: 100%;
  background: #090e17;
  border: 1px solid #f97316;
  border-radius: var(--radius-sm);
  color: #f8fafc;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.35);
}


/* ==========================================================================
   ENHANCEMENTS: DRAWER MOBILE, COLUMN MAPPER & ERGONOMICS
   ========================================================================== */
.data-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .data-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.drawer-notes-area {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  font-size: 0.82rem;
  line-height: 1.4;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  resize: vertical;
  font-family: var(--font-sans);
  margin-top: 6px;
}

.drawer-notes-area:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.btn-map-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent-primary);
  text-decoration: none;
  padding: 2px 6px;
  background: rgba(249, 115, 22, 0.1);
  border-radius: var(--radius-xs);
  transition: background 0.15s ease;
  margin-left: 6px;
}

.btn-map-link:hover {
  background: rgba(249, 115, 22, 0.2);
  text-decoration: underline;
}

.mapper-field select {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
}

@media (max-width: 640px) {
  .detail-drawer {
    width: 100vw !important;
    right: -100vw !important;
  }
  .detail-drawer.open {
    right: 0 !important;
  }
}

/* AUDIT LIST IN DRAWER */
.drawer-audit-item {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding: 4px 0;
}
.drawer-audit-item:last-child {
  border-bottom: none;
}
.drawer-audit-time {
  color: var(--accent-primary);
  font-weight: 700;
  margin-right: 4px;
}
