/* CRM Layout - Similar to Dashboard */
/* Variables de color: heredadas de design-tokens.css (única fuente de verdad,
   incluye soporte dark mode vía [data-theme="dark"]) — ver alias legacy ahí. */
.crm-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg-gradient, var(--bg));
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
}

/* Sidebar */
.crm-sidebar {
  width: 280px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  /* 100vh en mobile se calcula sobre el viewport "grande" (con la barra del
     navegador oculta) -- si la barra está visible, el sidebar queda más alto
     que lo realmente visible y el botón de cerrar sesión (último hijo del
     flex column) termina tapado por debajo del borde de la pantalla. 100dvh
     sigue el viewport visible real; 100vh queda de fallback para navegadores
     sin soporte. */
  height: 100vh;
  height: 100dvh;
  left: 0;
  top: 0;
  z-index: 100;
}

.crm-sidebar .sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.crm-sidebar .sidebar-header .theme-toggle-btn,
.crm-sidebar .sidebar-header .sidebar-icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  color: var(--text);
  padding: 0;
  flex-shrink: 0;
}

.crm-sidebar .sidebar-header .theme-toggle-btn:hover,
.crm-sidebar .sidebar-header .sidebar-icon-btn:hover {
  background: rgba(249, 115, 22, 0.12);
  border-color: var(--accent);
  transform: scale(1.05);
}

.crm-sidebar .sidebar-header .theme-toggle-btn:active,
.crm-sidebar .sidebar-header .sidebar-icon-btn:active {
  transform: scale(0.95);
}

.crm-sidebar .sidebar-header .logo {
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
  color: var(--text);
  transition: color 0.3s ease;
  flex: 1;
}

.crm-sidebar .sidebar-header .logo span {
  color: var(--accent);
  transition: color 0.3s ease;
}

.admin-badge {
  background: var(--accent);
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}

.crm-sidebar .sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.crm-sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.crm-sidebar .nav-item:hover {
  background: rgba(249, 115, 22, 0.05);
  color: var(--text);
}

.crm-sidebar .nav-item.active {
  background: rgba(249, 115, 22, 0.1);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.crm-sidebar .nav-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.crm-sidebar .nav-label {
  font-size: 15px;
}

/* Icon system (frontend/components/icons.js) — svg hereda color del texto */
.icon-svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.crm-sidebar .nav-icon .icon-svg,
.sidebar-footer .nav-icon .icon-svg {
  width: 20px;
  height: 20px;
}
.crm-header .btn-icon .icon-svg,
.theme-toggle-btn .icon-svg,
.sidebar-icon-btn .icon-svg {
  width: 19px;
  height: 19px;
}
.section-header .icon-svg {
  width: 22px;
  height: 22px;
}
.stat-icon,
.action-icon,
.dashboard-priority-icon,
.dashboard-feed-icon {
  color: var(--accent);
}
.stat-icon .icon-svg,
.action-icon .icon-svg {
  width: 30px;
  height: 30px;
}
.dashboard-priority-icon .icon-svg,
.dashboard-feed-icon .icon-svg {
  width: 20px;
  height: 20px;
}
.dashboard-shortcut-link span .icon-svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}
/* Icono chico embebido en línea con texto (badges, labels de tabla) */
.icon-inline {
  display: inline-flex;
  vertical-align: -3px;
}
.icon-inline .icon-svg {
  width: 14px;
  height: 14px;
}
.action-btn .icon-svg {
  width: 15px;
  height: 15px;
}
.ui-btn .icon-svg {
  width: 14px;
  height: 14px;
}
.btn-icon .icon-svg {
  width: 16px;
  height: 16px;
}

.crm-sidebar .sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.crm-sidebar .btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.crm-sidebar .btn-logout:hover {
  background: rgba(249, 115, 22, 0.1);
  border-color: var(--accent);
  color: var(--text);
}

/* Main Content */
.crm-main {
  flex: 1;
  margin-left: 280px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.crm-header {
  background: color-mix(in srgb, var(--bg-card) 92%, transparent);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 72px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.crm-header .header-content {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.crm-header .header-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

/* Botón hamburguesa + backdrop para mostrar/ocultar el menú lateral en mobile.
   El botón reusa .mobile-menu-toggle (definida en styles.css para la landing,
   display:none por defecto). */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

.crm-header .header-actions {
  display: flex;
  gap: 12px;
}

.crm-header .btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s ease;
}

.crm-header .btn-icon:hover {
  background: rgba(249, 115, 22, 0.1);
  border-color: var(--accent);
}

/* Content Sections */
.crm-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.deprecated-section,
.deprecated-section.active {
  display: none !important;
}

.projects-section-header {
  align-items: flex-start;
}

.projects-board {
  display: block;
}

.projects-kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.projects-kanban-column {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  min-height: 240px;
}

.projects-kanban-column-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.projects-kanban-column-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.projects-kanban-column-count {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.18);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.projects-kanban-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-card,
.project-list-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-card.is-kanban {
  min-height: 100%;
}

.project-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.project-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.project-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.project-meta-pill.project-type-saas {
  background: rgba(79, 70, 229, 0.14);
  color: #a5b4fc;
}

.project-meta-pill.project-type-enterprise {
  background: rgba(16, 185, 129, 0.14);
  color: #86efac;
}

.project-info,
.project-description {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.project-info p {
  margin: 4px 0;
}

.project-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-primary-400), var(--accent));
}

.progress-text {
  font-size: 12px;
  color: var(--muted);
}

.project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.project-actions .action-btn {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
}

.project-actions .action-btn.danger,
.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.24);
}

.project-actions .action-btn.danger:hover,
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
}

.projects-list-view {
  overflow-x: auto;
}

.projects-list-table {
  width: 100%;
  border-collapse: collapse;
}

.projects-list-table th,
.projects-list-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.projects-list-table th {
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.projects-list-table td {
  font-size: 13px;
  color: var(--text);
}

.projects-list-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.project-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.project-status-planificacion { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
.project-status-desarrollo { background: rgba(59, 130, 246, 0.16); color: #60a5fa; }
.project-status-testing { background: rgba(168, 85, 247, 0.16); color: #c084fc; }
.project-status-desplegado { background: rgba(14, 165, 233, 0.16); color: #38bdf8; }
.project-status-completado { background: rgba(16, 185, 129, 0.16); color: #34d399; }
.project-status-cancelado { background: rgba(239, 68, 68, 0.16); color: #f87171; }

@media (max-width: 768px) {
  .projects-section-header {
    flex-direction: column;
  }

  .projects-list-table {
    min-width: 860px;
  }
}

.section-help-text {
  color: var(--muted);
  margin-bottom: 16px;
  font-size: 0.95em;
}

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

/* Welcome Card */
.welcome-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 32px;
}

.dashboard-welcome-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.welcome-card h2 {
  font-size: 32px;
  margin: 0 0 8px;
  color: var(--text);
}

.welcome-card p {
  color: var(--muted);
  font-size: 16px;
  margin: 0;
}

.dashboard-home-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.dashboard-home-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dashboard-home-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dashboard-home-card-head h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.dashboard-home-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-home-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-priority-item,
.dashboard-feed-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-card) 45%, transparent);
}

.dashboard-priority-icon,
.dashboard-feed-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(249, 115, 22, 0.12);
  font-size: 18px;
  flex-shrink: 0;
}

.dashboard-priority-item strong,
.dashboard-feed-body strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.dashboard-priority-item p,
.dashboard-feed-body p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.dashboard-feed-item.is-unread {
  border-color: rgba(249, 115, 22, 0.4);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.08);
}

.dashboard-feed-body {
  min-width: 0;
  flex: 1;
}

.dashboard-feed-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.dashboard-feed-title-row span,
.dashboard-feed-body small {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashboard-shortcut-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-card) 45%, transparent);
  transition: all 0.2s ease;
}

.dashboard-shortcut-link:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.dashboard-shortcut-link span {
  font-size: 22px;
}

.dashboard-shortcut-link strong {
  display: block;
  font-size: 14px;
}

.dashboard-shortcut-link small {
  color: var(--muted);
  font-size: 12px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat-icon {
  font-size: 32px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(249, 115, 22, 0.1);
  border-radius: 12px;
  flex-shrink: 0;
}

.stat-content h3 {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--text);
}

.stat-content p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* Quick Actions */
.quick-actions {
  margin-top: 32px;
}

.quick-actions h3 {
  font-size: 20px;
  margin: 0 0 16px;
  color: var(--text);
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.action-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  text-align: center;
}

.action-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

.action-icon {
  font-size: 32px;
}

.action-label {
  font-size: 14px;
  font-weight: 600;
}

/* Pipeline CRM (inspirado en Bora) */
.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pipeline-summary {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.pipeline-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.pipeline-kpi-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pipeline-kpi-label {
  font-size: 12px;
  color: var(--muted);
}

.pipeline-kpi-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.pipeline-search {
  min-width: 300px;
}

.pipeline-search-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
}

.pipeline-container {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  min-height: 520px;
}

.pipeline-view {
  margin-top: 6px;
}

.pipeline-column {
  min-width: 290px;
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.pipeline-column-header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  padding-bottom: 10px;
}

.pipeline-column-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pipeline-column-title h3 {
  margin: 0;
  font-size: 15px;
}

.pipeline-count {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}

.pipeline-cards {
  min-height: 120px;
  flex: 1;
  padding: 2px;
}

.pipeline-cards.drag-over {
  outline: 2px dashed var(--accent);
  border-radius: 10px;
}

.pipeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  cursor: move;
}

.pipeline-card.dragging {
  opacity: 0.55;
}

.pipeline-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.pipeline-card-description {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.pipeline-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.pipeline-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pipeline-tag {
  border-radius: 999px;
  border: 1px solid rgba(249, 115, 22, 0.5);
  background: rgba(249, 115, 22, 0.16);
  color: #7c2d12;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.4;
}

.pipeline-card-action {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.bulk-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.bulk-selection-count {
  font-weight: 700;
  color: var(--text);
  min-width: 130px;
}

.selection-cell {
  width: 38px;
  text-align: center;
}

.pipeline-card-select {
  position: absolute;
  top: 8px;
  right: 8px;
}

.pipeline-card {
  position: relative;
}

.pipeline-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.btn.danger {
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fff;
}

/* Chatwoot Config */
#chatwoot-import-results {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}

@media (max-width: 900px) {
  .pipeline-header {
    flex-direction: column;
    align-items: stretch;
  }

  .pipeline-search {
    min-width: 0;
  }

  .bulk-actions-bar {
    align-items: stretch;
  }

  .bulk-actions-bar .btn,
  .bulk-actions-bar .filter-select {
    width: 100%;
  }
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.view-toggle-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.view-toggle-group .btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.section-header h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

/* Filters Bar */
.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-input,
.filter-select {
  flex: 1;
  min-width: 200px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Tables */
.table-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: rgba(249, 115, 22, 0.05);
}

.data-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.data-table tbody tr:hover {
  background: rgba(249, 115, 22, 0.05);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.section-view-controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.view-mode-buttons,
.view-actions-buttons {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

#service-requests-admin-list {
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
}

#service-requests-admin-list.requests-list-mode {
  grid-template-columns: 1fr;
}

#service-requests-admin-list.requests-list-mode,
#quotes-list-view {
  display: block;
}

.list-table-container {
  width: 100%;
  overflow-x: auto;
}

.list-mode-table {
  min-width: 980px;
}

.list-mode-table td {
  vertical-align: top;
}

.cell-expand-link {
  margin-left: 6px;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: underline;
  padding: 0;
}

.cell-expand-link:hover {
  color: var(--primary-light);
}

#cell-detail-modal-content {
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--text-primary);
}

.service-request-card {
  min-width: 0;
}

.service-request-details {
  overflow-x: auto;
}

.service-request-details.is-collapsed,
.quote-list-details.is-collapsed {
  display: none;
}

.service-request-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

#quotes-list-view {
  margin-top: 12px;
  grid-template-columns: 1fr;
}

.quote-list-card .project-info p {
  margin: 4px 0;
}

/* Config Sections */
.config-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.config-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.config-card h3 {
  font-size: 20px;
  margin: 0 0 8px;
  color: var(--text);
}

.config-card p {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 16px;
}

/* Analytics */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.analytics-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.chart-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.analytics-card {
  border-radius: 16px;
  overflow: hidden;
}

.analytics-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.analytics-card-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

#analytics-revenue-chart,
#analytics-payment-method-chart,
#analytics-conversion-chart {
  min-height: 220px;
  max-height: 280px;
}

@media (max-width: 820px) {
  .analytics-content {
    grid-template-columns: 1fr;
  }

  .analytics-card-header {
    align-items: flex-start;
  }
}

/* Configs Grid */
.configs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.payment-config-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
}

.payment-config-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.payment-config-card.status-active {
  border-left: 4px solid #10b981;
}

.payment-config-card.status-inactive {
  border-left: 4px solid #ef4444;
}

.payment-config-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.payment-config-header h3 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--text);
}

.payment-method-name {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.payment-config-details {
  margin-bottom: 16px;
}

.payment-config-details p {
  margin: 8px 0;
  font-size: 14px;
  color: var(--text);
}

.payment-config-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: rgba(249, 115, 22, 0.12);
  border-color: var(--accent);
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.config-section {
  margin-bottom: 40px;
}

.config-section h3 {
  margin: 0;
  font-size: 20px;
  color: var(--text);
}

.config-accordion-shell {
  margin-bottom: 16px;
}

.config-accordion {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.config-accordion + .config-accordion {
  margin-top: 10px;
}

.config-accordion-summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 247, 237, 0.8));
  border-bottom: 1px solid transparent;
}

/* Chevron propio: el marcador nativo de <details> se oculta más abajo. */
.config-accordion-summary::after {
  content: '';
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.config-accordion[open] > .config-accordion-summary::after {
  transform: rotate(-135deg);
}

.config-accordion-summary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.config-accordion-summary::-webkit-details-marker {
  display: none;
}

.config-accordion[open] .config-accordion-summary {
  border-bottom-color: var(--border);
}

.config-accordion-title {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}

.config-accordion-hint {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
}

.config-accordion-body {
  padding: 16px;
}

.config-accordion-source-title {
  display: none;
}

.config-pagination-controls {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.config-pagination-status {
  font-size: 0.83rem;
  color: var(--muted);
  font-weight: 600;
}

.config-pagination-size {
  min-width: 88px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.82rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  z-index: 1;
}

.modal-card.large {
  max-width: 800px;
}

/* Modal de artículo (Base de Conocimiento) en pantalla completa -- el campo
   de contenido (editor Quill) queda muy chico en el modal normal para
   escribir notas largas. Alcance acotado a este modal (id explícito), no
   afecta al resto de los modales del CRM. */
.modal-fullscreen-toggle {
  position: absolute;
  top: 16px;
  right: 56px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  line-height: 1;
}
.modal-fullscreen-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}
#article-modal-card.fullscreen {
  max-width: 96vw;
  width: 96vw;
  max-height: 94vh;
  height: 94vh;
  display: flex;
  flex-direction: column;
}
#article-modal-card.fullscreen form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
#article-modal-card.fullscreen .ql-container {
  min-height: 45vh;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(249, 115, 22, 0.1);
  color: var(--text);
}

/* Subscription Management Modal Styles */
.subscription-management-info {
    padding: 0;
}

.subscription-management-info .info-section {
    margin-bottom: 24px;
}

.subscription-management-info .info-section h4 {
    margin-bottom: 16px;
    color: var(--text);
    font-size: 1.1rem;
}

.subscription-management-info .info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.subscription-management-info .info-grid > div {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.subscription-management-info .info-grid > div:last-child {
    border-bottom: none;
}

.subscription-management-info .info-grid strong {
    color: var(--muted);
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subscription-management-info .actions-section {
    margin-top: 24px;
}

.subscription-management-info .actions-section h4 {
    margin-bottom: 16px;
    color: var(--text);
    font-size: 1.1rem;
}

.subscription-management-info .actions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.subscription-management-info .action-item {
    transition: all 0.2s;
}

.subscription-management-info .action-item:hover {
    border-color: var(--accent);
    transform: translateX(4px);
}

.subscription-management-info .action-item.success {
    border-left: 4px solid #10b981;
}

.subscription-management-info .action-item.warning {
    border-left: 4px solid #f59e0b;
}

.subscription-management-info .action-item.danger {
    border-left: 4px solid #ef4444;
}

.subscription-management-info .action-item.muted {
    border-left: 4px solid var(--muted);
    opacity: 0.7;
}

.alert {
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
}

.alert strong {
    display: block;
    margin-bottom: 8px;
}

.alert p {
    margin: 0;
    font-size: 0.9rem;
}

.modal-card h3 {
  margin: 0 0 24px;
  font-size: 24px;
  color: var(--text);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
}

.status-badge.active {
  background: var(--color-success-bg);
  color: var(--color-success-fg);
}

.status-badge.inactive {
  background: var(--color-danger-bg);
  color: var(--color-danger-fg);
}

.status-badge.pending {
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
}

.status-badge.neutral,
.status-badge.muted {
  background: var(--bg-alt);
  color: var(--text-secondary);
}

/* Alias usados por subscriptions.js (getStatusClass) — mismos tokens que active/pending/inactive */
.status-badge.success {
  background: var(--color-success-bg);
  color: var(--color-success-fg);
}
.status-badge.warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
}
.status-badge.error {
  background: var(--color-danger-bg);
  color: var(--color-danger-fg);
}
.status-badge.info {
  background: var(--color-info-bg);
  color: var(--color-info-fg);
}

/* Tabs simples dentro de una sección (Roles y Permisos, Solicitudes y Cotizaciones) */
.doc-tab {
  padding: 8px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .9rem;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  font-weight: 500;
}
.doc-tab:hover {
  color: var(--accent);
}
.doc-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.action-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.action-btn.edit {
  background: var(--color-accent-subtle);
  color: var(--accent);
}

.action-btn.edit:hover {
  background: var(--color-accent-soft);
}

.action-btn.delete,
.action-btn.danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-fg);
}

.action-btn.delete:hover,
.action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.action-btn.success {
  background: var(--color-success-bg);
  color: var(--color-success-fg);
}

.action-btn.success:hover {
  background: rgba(16, 185, 129, 0.3);
}

.action-btn.warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
}

.action-btn.warning:hover {
  background: rgba(245, 158, 11, 0.3);
}

.action-btn.view {
  background: var(--color-success-bg);
  color: var(--color-success-fg);
}

.action-btn.view:hover {
  background: rgba(16, 185, 129, 0.3);
}

/* Inner Tabs (para sección de suscripciones) */
.inner-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.inner-tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 12px 20px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
}

.inner-tab-btn:hover {
  color: var(--text);
  background: rgba(249, 115, 22, 0.05);
}

.inner-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.inner-tab-content {
  display: none;
}

.inner-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* Product Badge */
.product-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(249, 115, 22, 0.2);
  color: var(--accent);
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  .crm-sidebar {
    width: 240px;
  }
  
  .crm-main {
    margin-left: 240px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-home-panels {
    grid-template-columns: 1fr;
  }

  .dashboard-welcome-head {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .actions-grid {
    grid-template-columns: 1fr;
  }
  
  .analytics-content {
    grid-template-columns: 1fr;
  }
}

/* Usuarios - Estilos específicos */
.role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(249, 115, 22, 0.14);
  color: #9a3412;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
  margin-bottom: 0;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.service-item {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.service-select {
  flex: 1;
  min-width: 200px;
}

.service-item input[type="number"] {
  flex: 1;
  min-width: 150px;
}

.enterprise-saas-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.enterprise-saas-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  min-width: 110px;
  cursor: pointer;
}

.enterprise-saas-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.enterprise-saas-item input[type="url"] {
  flex: 2;
  min-width: 220px;
}

.enterprise-saas-item select[name$="-status"] {
  flex: 1;
  min-width: 150px;
}

.enterprise-saas-item input:disabled,
.enterprise-saas-item select:disabled {
  opacity: 0.5;
}

.enterprise-infra-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-small:hover {
  background: rgba(249, 115, 22, 0.9);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(249, 115, 22, 0.1);
}

.btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.pagination {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.pagination-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pagination-controls button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.pagination-controls button:hover:not(:disabled) {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.pagination-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-controls button.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.pagination-info {
  color: var(--muted);
  font-size: 14px;
}

.required {
  color: #ef4444;
}

@media (max-width: 640px) {
  .crm-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .crm-sidebar.open {
    transform: translateX(0);
  }

  .crm-main {
    margin-left: 0;
  }

  /* Con el botón de tutorial sumado al de tema, 2 botones de 40px + el logo
     (+ badge ADMIN) ya no entran holgados en el sidebar angosto de mobile. */
  .crm-sidebar .sidebar-header {
    padding: 16px;
    gap: 6px;
  }

  .crm-sidebar .sidebar-header .logo {
    font-size: 17px;
  }

  .crm-sidebar .sidebar-header .theme-toggle-btn,
  .crm-sidebar .sidebar-header .sidebar-icon-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .crm-content {
    padding: 16px;
  }
  
  .service-item {
    flex-direction: column;
    align-items: stretch;
  }
  
  .service-select,
  .service-item input[type="number"] {
    width: 100%;
    min-width: auto;
  }

  .enterprise-saas-item input[type="url"],
  .enterprise-saas-item select[name$="-status"] {
    width: 100%;
    min-width: auto;
  }

  .enterprise-infra-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-backdrop.active {
    display: block;
  }
}

/* ===============================================
   DOCUMENTOS SECTION
   =============================================== */

.documents-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.documents-filters {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.filter-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.filter-select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s;
}

.filter-select:hover {
  border-color: var(--accent);
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.documents-folder-summary {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.documents-list-container {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 24px;
}

.documents-list-container h3 {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.documents-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.document-reference-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
  color: #075985;
  font-size: 11px;
  font-weight: 600;
}

.document-upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.03);
  color: var(--muted);
  text-align: center;
  padding: 20px 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.document-upload-dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.12);
  color: var(--text);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 16px;
  padding: 0;
}

.btn-icon:hover {
  background: rgba(249, 115, 22, 0.1);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* Responsive para documentos */
@media (max-width: 768px) {
  .documents-filters {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }
}

/* ===============================================
   KANBAN BOARD - TAREAS
   =============================================== */

.kanban-board-full {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.kanban-column {
  background: transparent;
  border-radius: 12px;
}

.kanban-column-header {
  background: var(--card);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border: 1px solid var(--border);
}

.kanban-column-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.kanban-count {
  background: var(--accent);
  color: #000;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}

.kanban-items {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kanban-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: move;
  transition: all 0.2s;
  position: relative;
}

.kanban-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
  border-color: var(--accent);
}

.kanban-item.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.kanban-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px 0;
}

.kanban-item-body {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.kanban-item-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.kanban-item-priority {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 11px;
}

.kanban-item-priority.baja {
  background: #6b7280;
  color: white;
}

.kanban-item-priority.media {
  background: #f59e0b;
  color: white;
}

.kanban-item-priority.alta {
  background: #ef4444;
  color: white;
}

.kanban-item-priority.urgente {
  background: #dc2626;
  color: white;
}

.kanban-item-due {
  color: var(--muted);
  font-size: 11px;
}

.kanban-item-due.overdue {
  color: #ef4444;
  font-weight: bold;
}

.kanban-item-due.today {
  color: #f59e0b;
  font-weight: bold;
}

.kanban-item-meta {
  color: var(--muted);
  font-size: 11px;
}

.kanban-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}

/* Drag and Drop States */
.kanban-column.drag-over {
  background: rgba(249, 115, 22, 0.05);
  border: 2px dashed var(--accent);
}

.tasks-view {
  margin-top: 20px;
}

/* Responsive Kanban */
@media (max-width: 1200px) {
  .kanban-board-full {
    grid-template-columns: 1fr;
  }
  
  .kanban-column {
    margin-bottom: 24px;
  }
}

@media (max-width: 768px) {
  .kanban-board-full {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .kanban-item {
    padding: 10px;
  }
  
  .kanban-item-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Toggle Switch Styles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent, #ff6a00);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ============================================ */
/* BASE DE CONOCIMIENTO */
/* ============================================ */

.knowledge-base-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 200px);
}

.kb-sidebar {
    width: 300px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
}

.kb-sidebar h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: var(--text);
}

.kb-folder-item {
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.kb-folder-item:hover {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--accent);
}

.kb-folder-item.active {
    background: rgba(249, 115, 22, 0.2);
    border-color: var(--accent);
}

.kb-folder-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kb-folder-icon {
    font-size: 20px;
}

.kb-folder-name {
    flex: 1;
    font-weight: 500;
    color: var(--text);
}

.kb-folder-count {
    font-size: 12px;
    color: var(--muted);
}

.kb-subfolders {
    margin-left: 30px;
    margin-top: 8px;
}

.kb-subfolder {
    font-size: 14px;
}

.kb-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.kb-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.kb-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    overflow-y: auto;
    flex: 1;
}

.kb-article-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.kb-article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kb-article-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.kb-article-content {
    padding: 15px;
}

.kb-article-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.kb-article-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.kb-article-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.kb-article-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.kb-article-summary {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 10px;
}

.kb-article-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.kb-article-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.kb-article-card[data-clickable="true"] {
    cursor: pointer;
}

/* Vista de lista (toggle Tarjetas/Lista) -- misma fuente de datos que la
   grilla de tarjetas, una fila compacta por artículo. */
.kb-articles-grid.kb-view-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kb-article-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.kb-article-row:hover {
    border-color: var(--accent);
}

.kb-article-row-icon {
    flex-shrink: 0;
    font-size: 18px;
    width: 28px;
    text-align: center;
}

.kb-article-row-main {
    flex: 1;
    min-width: 0;
}

.kb-article-row-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kb-article-row-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
    flex-wrap: wrap;
}

.kb-article-row-badges {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.kb-article-row-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Estado activo genérico para los toggles Tarjetas/Lista, Lista/Tabla, etc. --
   ya existían varios (solicitudes, cotizaciones, proyectos) sin feedback
   visual de cuál modo está activo. */
.view-mode-buttons .btn.active {
    background: rgba(249, 115, 22, 0.1);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

/* ============================================ */
/* TICKETS MEJORADOS */
/* ============================================ */

.ticket-view-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ticket-view-section {
    padding: 15px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.ticket-view-section h4 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: var(--text);
}

.ticket-view-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item strong {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
}

.ticket-note-item,
.ticket-message-item {
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.note-header,
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--muted);
}

.note-author,
.message-author {
    font-weight: 600;
    color: var(--text);
}

.note-content,
.message-content {
    color: var(--text);
    line-height: 1.5;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.checkbox-label:hover {
    background: rgba(249, 115, 22, 0.1);
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* -------------------------------------------------------------------------- */
/* 2026 visual refresh: CRM minimalista y dinamico (sin cambios funcionales)   */
/* -------------------------------------------------------------------------- */

.crm-body {
  /* Variables ya heredadas de design-tokens.css. El fondo decorativo usa
     --bg-gradient (token con variante dark) en vez de un gradiente fijo en claro. */
  background: var(--bg-gradient);
}

.crm-sidebar {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  border-right: 1px solid rgba(17, 24, 39, 0.09);
  box-shadow: 8px 0 28px rgba(17, 24, 39, 0.05);
}

.crm-sidebar .sidebar-header {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(255, 247, 237, 0.88));
}

.crm-sidebar .sidebar-header .logo {
  letter-spacing: -0.01em;
}

.crm-sidebar .nav-item {
  margin: 4px 10px;
  border-radius: 12px;
  border-left: 0;
}

.crm-sidebar .nav-item:hover {
  background: rgba(249, 115, 22, 0.12);
  transform: translateX(2px);
}

.crm-sidebar .nav-item.active {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.16), rgba(251, 146, 60, 0.08));
  border: 1px solid rgba(249, 115, 22, 0.26);
}

.crm-header {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
}

.crm-header h1 {
  letter-spacing: -0.02em;
}

.project-card,
.project-list-card,
.stat-card,
.kanban-item {
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.project-card:hover,
.project-list-card:hover,
.stat-card:hover,
.kanban-item:hover {
  transform: translateY(-3px);
  border-color: rgba(249, 115, 22, 0.34);
  box-shadow: 0 20px 44px rgba(249, 115, 22, 0.14);
}

.status-badge,
.kanban-count,
.kanban-item-priority,
.nav-group-badge {
  border-radius: 999px;
}

.btn,
.action-btn,
.filter-select,
.filter-input,
input,
select,
textarea {
  border-radius: 12px;
}

.btn,
.action-btn.primary {
  background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
  border-color: rgba(249, 115, 22, 0.45);
  box-shadow: 0 12px 24px rgba(249, 115, 22, 0.2);
}

.btn:hover,
.action-btn.primary:hover {
  box-shadow: 0 16px 30px rgba(249, 115, 22, 0.28);
}

.content-section.active {
  animation: crmSectionReveal 0.36s ease;
}

@keyframes crmSectionReveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.table-container,
.documents-list-container,
.kanban-column {
  overflow-x: auto;
}

@media (max-width: 1100px) {
  .crm-header {
    padding: 0 20px;
  }

  .content-section {
    padding: 22px;
  }
}

@media (max-width: 768px) {
  .crm-header {
    min-height: 64px;
    height: auto;
    padding: 10px 14px;
  }

  .crm-header h1 {
    font-size: 1.08rem;
    line-height: 1.2;
  }

  .stat-card,
  .welcome-card,
  .project-card,
  .project-list-card {
    border-radius: 14px;
  }

  .crm-sidebar .nav-item {
    margin: 3px 8px;
    padding: 12px 14px;
  }
}

@media (max-width: 520px) {
  .crm-sidebar .nav-label {
    font-size: 14px;
  }

  .btn,
  .action-btn,
  .filter-select,
  .filter-input,
  input,
  select,
  textarea {
    border-radius: 10px;
  }

  .section-view-controls {
    flex-direction: column;
    align-items: stretch;
  }

  #service-requests-admin-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .content-section.active,
  .project-card,
  .project-list-card,
  .stat-card,
  .kanban-item,
  .crm-sidebar .nav-item,
  .btn,
  .action-btn {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}

/* Tema oscuro CRM (sol/luna) */
body.theme-dark.crm-body {
  background:
    radial-gradient(1200px 560px at 95% -12%, rgba(249, 115, 22, 0.16), transparent 62%),
    radial-gradient(980px 440px at -8% 15%, rgba(37, 99, 235, 0.18), transparent 64%),
    linear-gradient(180deg, #0b1220 0%, #111827 52%, #0f172a 100%);
  color: #f8fafc;
}

body.theme-dark .crm-sidebar {
  background: rgba(15, 23, 42, 0.86);
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 10px 0 34px rgba(2, 6, 23, 0.5);
}

body.theme-dark .crm-sidebar .sidebar-header,
body.theme-dark .crm-header {
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(148, 163, 184, 0.22);
}

body.theme-dark .crm-sidebar .nav-item,
body.theme-dark .crm-sidebar .logo,
body.theme-dark .crm-header h1,
body.theme-dark .crm-body .section-header h3,
body.theme-dark .crm-body h2,
body.theme-dark .crm-body h3,
body.theme-dark .crm-body h4,
body.theme-dark .crm-body h5,
body.theme-dark .crm-body label,
body.theme-dark .crm-body p,
body.theme-dark .crm-body small,
body.theme-dark .crm-body span {
  color: #e2e8f0;
}

body.theme-dark .crm-sidebar .nav-item:hover {
  background: rgba(37, 99, 235, 0.18);
}

body.theme-dark .crm-sidebar .nav-item.active {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.22), rgba(37, 99, 235, 0.2));
  border-color: rgba(251, 146, 60, 0.4);
  color: #ffffff;
}

body.theme-dark .filter-input,
body.theme-dark .filter-select,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea,
body.theme-dark .ui-input {
  background: rgba(15, 23, 42, 0.72);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.36);
}

body.theme-dark .btn.btn-secondary,
body.theme-dark .action-btn:not(.primary) {
  background: rgba(30, 41, 59, 0.92);
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.34);
}

body.theme-dark .btn.btn-secondary:hover,
body.theme-dark .action-btn:not(.primary):hover {
  background: rgba(37, 99, 235, 0.24);
  border-color: rgba(96, 165, 250, 0.5);
}

body.theme-dark .config-accordion {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.24);
}

body.theme-dark .config-accordion-summary {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.78));
  border-bottom-color: rgba(148, 163, 184, 0.24);
}

body.theme-dark .config-accordion-title {
  color: #f8fafc;
}

body.theme-dark .config-accordion-hint,
body.theme-dark .config-pagination-status {
  color: #cbd5e1;
}

body.theme-dark .config-pagination-size {
  background: rgba(15, 23, 42, 0.86);
  border-color: rgba(148, 163, 184, 0.38);
  color: #f8fafc;
}

/* ---- Selector de plantillas de portada (Base de Conocimiento / blog) ---- */
.cover-template-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.cover-template-option {
  cursor: pointer;
  border: 2px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--muted, #6b7280);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cover-template-option:hover {
  border-color: var(--accent);
}
.cover-template-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--color-accent-soft, rgba(249, 115, 22, 0.15));
  color: var(--accent);
  font-weight: 600;
}
.cover-template-swatch {
  height: 56px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 6px;
}
.cover-template-swatch.tpl-1 { background: linear-gradient(160deg, var(--accent), #111827); }
.cover-template-swatch.tpl-2 { background: radial-gradient(circle at 75% 20%, #8a3f16, #111827 60%); }
.cover-template-swatch.tpl-3 { background: #f8f9fc; color: #111827; border-bottom: 4px solid var(--accent); }
.cover-template-swatch.tpl-custom { background: #f3f4f6; color: #9ca3af; font-size: 20px; }

body.theme-dark .cover-template-option {
  border-color: rgba(148, 163, 184, 0.38);
  color: #cbd5e1;
}
body.theme-dark .cover-template-swatch.tpl-3 { background: #1f2937; color: #f8fafc; }
body.theme-dark .cover-template-swatch.tpl-custom { background: rgba(148, 163, 184, 0.15); }

