/* Estilo general */
body {
  margin: 0;
  font-family: "Open Sans", Arial, sans-serif;
  background: #f5f7fb;
  color: #111827;
}



a {
  color: #e07e14;
  text-decoration: none;
}

a:hover {
  color: #18d36e;
}

.header {
  background: #111827;
  color: #f9fafb;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.header-user {
  font-size: 0.9rem;
}

.header-link {
  color: #e5e7eb;
}

.header-separator {
  margin: 0 8px;
  color: #9ca3af;
}

.container {
  max-width: 1500px;
  margin: 24px auto;
  background: #ffffff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

h1, h2 {
  color: #111827;
  margin-top: 0;
}

form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  margin-bottom: 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 0.95rem;
}

textarea {
  resize: vertical;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: #e07e14;
  color: #ffffff;
}

.btn-primary:hover {
  background: #c66a0e;
}

.btn-secondary {
  background: #111827;
  color: #ffffff;
}

.btn-secondary:hover {
  background: #020617;
}

.btn-light {
  background: #e5e7eb;
  color: #111827;
}

.btn-light:hover {
  background: #d1d5db;
  color: #111827;
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.form-container,
.admin-container {
  max-width: 1100px;
}

.form-section {
  padding: 18px;
  margin-bottom: 18px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
}

.form-section h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}

.form-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 18px;
}

.summary-grid {
  margin: 16px 0 22px;
  gap: 10px;
}

.summary-grid > div {
  padding: 12px;
  border-radius: 6px;
  background: #f3f4f6;
}

.summary-grid strong,
.summary-grid span {
  display: block;
}

.summary-grid span {
  margin-top: 4px;
  font-size: 0.9rem;
}

.business-unit-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 600;
  white-space: nowrap;
}

.alert {
  padding: 10px 12px;
  margin-bottom: 16px;
  border-radius: 4px;
}

.alert-error {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.alert-success {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
}

.field-help,
.result-count {
  color: #6b7280;
  font-size: 0.82rem;
}

.filter-panel {
  padding: 12px;
  border-radius: 6px;
  background: #f3f4f6;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
}

.inline-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.inline-form label {
  flex: 1 1 260px;
  margin: 0;
}

.compact-form {
  margin: 0;
}

.leads-table table {
  min-width: 1600px;
}

/* Contenedor de la tabla */
.table-wrapper {
  width: 100%;
  margin-top: 16px;
  padding: 0;
  overflow-x: auto;                  /* <-- barra horizontal */
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch; /* mejor en trackpad/móvil */
}

/* La tabla debe ocupar SIEMPRE todo el ancho del wrapper */
.table-wrapper table {
  width: 100% !important;   /* <-- la tabla toma el ancho real de sus columnas */
  min-width: 100%;        /* <-- pero nunca menos que el contenedor */
  border-collapse: collapse;
  table-layout: auto;     /* <-- deja que las columnas crezcan naturalmente */
  box-sizing: border-box;
  margin: 0;
}

/* Celdas */
.table-wrapper table th,
.table-wrapper table td {
  border: 1px solid #cbc7c7;
  padding: 6px 8px;
  text-align: left;
  white-space: normal;
  word-wrap: break-word;
  font-size: 0.85rem;
}

/* Un poco más de aire para la última columna (Acciones) */
.table-wrapper table th:last-child,
.table-wrapper table td:last-child {
  padding-right: 18px;
  text-align: center;
}

/* Ancho específico por columnas (con table-layout: fixed) */

/* Columna 1: ID (más pequeña) */
.table-wrapper table th:nth-child(1),
.table-wrapper table td:nth-child(1) {
  width: 15px;          /* ajusta si quieres aún más chica */
}

/* Columna 2: Empresa (más ancha) */
.table-wrapper table th:nth-child(2),
.table-wrapper table td:nth-child(2) {
  width: 200px;         /* puedes subir a 280–300 si lo necesitas */
}

/* Opcional: columna Acciones que no sea tan ancha */
.table-wrapper table th:last-child,
.table-wrapper table td:last-child {
  width: 90px;
}



/* Tabla siempre pegada al margen izquierdo del container */
table {
  width: 100%;
  border-collapse: collapse;
  box-sizing: border-box;   /* <- para que el 100% incluya los bordes */
  margin: 0 auto;           /* centrada dentro del contenedor */
}

/* Celdas: sin desplazamiento horizontal raro */
table th,
table td {
  border: 1px solid #e5e7eb;
  padding: 6px 8px;
  text-align: left;
  white-space: normal;
  word-wrap: break-word;
  font-size: 0.85rem;
}

table th {
  background: #f3f4f6;
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.badge-status {
  background: #e5e7eb;
  color: #111827;
}

.badge-ganado {
  background: #16a34a;
  color: #ffffff;
}

.badge-perdido {
  background: #b91c1c;
  color: #ffffff;
}

.badge-cotizado {
  background: #2563eb;
  color: #ffffff;
}

.filter-bar {
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-bar input,
.filter-bar select {
  width: auto;
}

.filter-bar label {
  margin: 0;
  font-size: 0.85rem;
}

.funnel-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 14px 0 18px;
}

.funnel-stage {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
  background: #ffffff;
}

.funnel-stage strong,
.funnel-stage span {
  display: block;
}

.funnel-stage strong {
  font-size: 1.35rem;
}

.funnel-stage span {
  color: #4b5563;
  font-size: 0.85rem;
}

.legacy-summary {
  display: inline-block;
  margin: 0 0 16px;
  padding: 8px 10px;
  border: 1px solid #fde68a;
  border-radius: 6px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.9rem;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }

/* Campos de fecha más pequeños */
.input-small {
  max-width: 220px;       /* ajusta a gusto: 180, 200, etc. */
}

/* Cuando Flatpickr crea el input visible, mantiene la clase,
   así que lo controlamos también acá */
.flatpickr-input.input-small {
  max-width: 220px;
}

.pagination {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.pagination a,
.pagination span {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  font-size: 0.85rem;
}

.pagination .active {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
}

.pagination .disabled {
  color: #9ca3af;
}

/* Lead vencido (más de 7 días sin contacto) */
.row-vencido {
  background: #fee2e2; /* rojo suave */
}
.row-vencido td {
  border-color: #fecaca;
}

@media (max-width: 700px) {
  .header,
  .page-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .container {
    margin: 12px;
    padding: 14px;
  }
}
.funnel-stage {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.funnel-stage:hover {
    border-color: #f28c00;
    transform: translateY(-1px);
}

.funnel-stage.active {
    border: 2px solid #f28c00;
    background: #fff7ed;
}


/* =========================================================
   ACTUALIZACIÓN VISUAL CRM AQSA
   ---------------------------------------------------------
   Esta sección NO elimina ni renombra clases existentes.
   Solo mejora su presentación y agrega clases específicas
   para el dashboard comercial.
   ========================================================= */

:root {
  --crm-bg: #f4f6f8;
  --crm-surface: #ffffff;
  --crm-surface-soft: #f8fafc;
  --crm-border: #e2e7ee;
  --crm-border-strong: #d5dbe4;
  --crm-text: #142033;
  --crm-muted: #687386;
  --crm-orange: #e07e14;
  --crm-orange-dark: #c56b0f;
  --crm-orange-soft: #fff5e9;
  --crm-red: #c83b3b;
  --crm-red-soft: #fff0f0;
  --crm-amber: #c86c09;
  --crm-amber-soft: #fff6e8;
  --crm-blue: #2d63e8;
  --crm-blue-soft: #eef4ff;
  --crm-green: #17834a;
  --crm-green-soft: #eef9f2;
  --crm-navy: #142033;
  --crm-shadow: 0 1px 2px rgba(15, 23, 42, 0.03), 0 8px 28px rgba(15, 23, 42, 0.055);
}

/* Base más clara */
body {
  background: var(--crm-bg);
  color: var(--crm-text);
}

a {
  color: var(--crm-orange);
}

a:hover {
  color: var(--crm-orange-dark);
}

/* Header más limpio manteniendo las mismas clases */
.header {
  background: #ffffff;
  color: var(--crm-text);
  border-bottom: 1px solid var(--crm-border);
  padding: 14px 28px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.header-title {
  color: var(--crm-navy);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-user {
  color: var(--crm-muted);
}

.header-link {
  color: var(--crm-navy);
  font-weight: 600;
}

.header-link:hover {
  color: var(--crm-orange);
}

.header-separator {
  color: #c0c7d1;
}

/* Contenedor general más parecido a una app, no a una caja cerrada */
.container {
  max-width: 1500px;
  margin: 26px auto;
  background: transparent;
  padding: 0 24px 30px;
  border-radius: 0;
  box-shadow: none;
}

h1,
h2 {
  color: var(--crm-navy);
}

h1 {
  letter-spacing: -0.035em;
}

.page-title-row {
  align-items: center;
  margin-bottom: 20px;
}

/* Formularios */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
  border-color: var(--crm-border-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--crm-text);
  min-height: 40px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

textarea {
  min-height: 92px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="file"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #f0a24d;
  box-shadow: 0 0 0 3px rgba(224, 126, 20, 0.12);
}

/* Botones */
.btn {
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 9px;
  font-weight: 700;
  line-height: 1.1;
  transition: transform .12s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--crm-orange);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(224, 126, 20, 0.16);
}

.btn-primary:hover {
  background: var(--crm-orange-dark);
  color: #ffffff;
}

.btn-secondary {
  background: var(--crm-navy);
  color: #ffffff;
}

.btn-secondary:hover {
  background: #0b1424;
  color: #ffffff;
}

.btn-light {
  background: #ffffff;
  color: var(--crm-navy);
  border: 1px solid var(--crm-border);
}

.btn-light:hover {
  background: var(--crm-surface-soft);
  color: var(--crm-navy);
  border-color: #cfd6df;
}

/* Tarjetas / secciones */
.form-section {
  padding: 20px;
  margin-bottom: 18px;
  border: 1px solid var(--crm-border);
  border-radius: 14px;
  background: var(--crm-surface);
  box-shadow: var(--crm-shadow);
}

.form-section h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.summary-grid > div {
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  background: var(--crm-surface-soft);
}

/* Alertas */
.alert {
  padding: 14px 16px;
  margin-bottom: 18px;
  border-radius: 12px;
  line-height: 1.45;
}

.alert-error {
  color: #991b1b;
  background: #fff1f1;
  border: 1px solid #f4c5c5;
}

.alert-success {
  color: #166534;
  background: #eefaf2;
  border: 1px solid #bfe5ca;
}

.alert-info {
  color: #31506f;
  background: #f4f8fc;
  border: 1px solid #dce7f2;
}

.alert-warning {
  color: #7d470b;
  background: #fff8ef;
  border: 1px solid #f2d0a5;
}

.field-help,
.result-count {
  color: var(--crm-muted);
}

/* Filtros */
.filter-panel {
  padding: 14px;
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  background: var(--crm-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .02);
}

.filter-bar {
  gap: 10px;
}

/* Tablas más suaves y legibles */
.table-wrapper {
  margin-top: 12px;
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  background: #ffffff;
}

.table-wrapper table th,
.table-wrapper table td,
table th,
table td {
  border-color: var(--crm-border);
  padding: 9px 10px;
  color: var(--crm-text);
}

table th,
.table-wrapper table th {
  background: #f7f8fa;
  color: #667085;
  font-weight: 700;
  font-size: 0.75rem;
}

table tbody tr {
  transition: background-color .12s ease;
}

table tbody tr:hover {
  background: #fafbfd;
}

/* Badges */
.business-unit-badge {
  background: var(--crm-orange-soft);
  color: #b45309;
  font-weight: 700;
}

.badge {
  padding: 4px 8px;
  font-weight: 700;
}

.badge-status {
  background: #eef1f5;
  color: #334155;
}

.badge-ganado {
  background: var(--crm-green);
}

.badge-perdido {
  background: var(--crm-red);
}

.badge-cotizado {
  background: var(--crm-blue);
}

/* Embudo / KPIs generales */
.funnel-summary {
  gap: 12px;
  margin: 16px 0 22px;
}

.funnel-stage {
  position: relative;
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  padding: 15px 16px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.035);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.funnel-stage:hover {
  border-color: #efb16c;
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(15, 23, 42, 0.07);
}

.funnel-stage strong {
  font-size: 1.6rem;
  line-height: 1;
  color: var(--crm-navy);
  letter-spacing: -0.03em;
}

.funnel-stage span {
  color: #556174;
  font-weight: 700;
  margin-top: 8px;
}

.funnel-stage.active {
  border: 2px solid var(--crm-orange);
  background: var(--crm-orange-soft);
}

/* Vencidos menos agresivos */
.row-vencido {
  background: #fff5f5;
}

.row-vencido td {
  border-color: #f2d2d2;
}

/* Paginación */
.pagination a,
.pagination span {
  padding: 7px 11px;
  border-radius: 8px;
  border-color: var(--crm-border);
  background: #ffffff;
}

.pagination .active {
  background: var(--crm-navy);
  border-color: var(--crm-navy);
}

/* =========================================================
   DASHBOARD COMERCIAL ADMINISTRADOR
   ========================================================= */

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.dashboard-hero h1 {
  margin: 0 0 5px;
  font-size: 1.75rem;
}

.dashboard-hero p {
  margin: 0;
  color: var(--crm-muted);
}

.dashboard-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-filter {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.dashboard-filter label {
  min-width: 240px;
  margin: 0;
}

.dashboard-filter select {
  width: 100%;
  margin-bottom: 0;
}

.dashboard-attention {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid #f0c99a;
  border-radius: 14px;
  background: linear-gradient(90deg, #fff7ed 0%, #fffdf9 100%);
}

.dashboard-attention-title {
  font-weight: 800;
  color: var(--crm-navy);
}

.dashboard-attention-text {
  color: var(--crm-muted);
  margin-top: 3px;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 20px;
}

.dashboard-kpi {
  min-height: 112px;
  position: relative;
  display: block;
  padding: 18px 17px 16px;
  border: 1px solid var(--crm-border);
  border-radius: 14px;
  background: #ffffff;
  color: inherit;
  box-shadow: var(--crm-shadow);
  overflow: hidden;
}

.dashboard-kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #cbd5e1;
}

.dashboard-kpi:hover {
  color: inherit;
  border-color: #d8dee7;
  transform: translateY(-2px);
}

.dashboard-kpi-value {
  font-size: 1.85rem;
  font-weight: 850;
  line-height: 1;
  color: var(--crm-navy);
  letter-spacing: -0.04em;
}

.dashboard-kpi-label {
  margin-top: 9px;
  color: #566174;
  font-weight: 800;
  font-size: .88rem;
}

.dashboard-kpi-help {
  margin-top: 4px;
  color: #7a8494;
  font-size: .76rem;
  line-height: 1.3;
}

.dashboard-kpi--danger::before { background: var(--crm-red); }
.dashboard-kpi--warning::before { background: var(--crm-amber); }
.dashboard-kpi--blue::before { background: var(--crm-blue); }
.dashboard-kpi--orange::before { background: var(--crm-orange); }
.dashboard-kpi--green::before { background: var(--crm-green); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, .72fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.dashboard-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.dashboard-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.dashboard-section-title {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.dashboard-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 900;
  font-size: .95rem;
}

.dashboard-icon--danger {
  color: var(--crm-red);
  background: var(--crm-red-soft);
}

.dashboard-icon--warning {
  color: var(--crm-amber);
  background: var(--crm-amber-soft);
}

.dashboard-icon--blue {
  color: var(--crm-blue);
  background: var(--crm-blue-soft);
}

.dashboard-icon--orange {
  color: var(--crm-orange);
  background: var(--crm-orange-soft);
}

.dashboard-icon--green {
  color: var(--crm-green);
  background: var(--crm-green-soft);
}

.dashboard-section-head h2 {
  margin: 0;
  font-size: 1rem;
}

.dashboard-section-head p {
  margin: 4px 0 0;
  color: var(--crm-muted);
  font-size: .8rem;
}

.dashboard-link {
  color: var(--crm-orange);
  font-weight: 800;
  white-space: nowrap;
}

.dashboard-link:hover {
  color: var(--crm-orange-dark);
}

.dashboard-days {
  display: inline-block;
  padding: 6px 9px;
  border-radius: 8px;
  font-weight: 800;
  font-size: .78rem;
  white-space: nowrap;
}

.dashboard-days--danger {
  color: #b42318;
  background: #fdeaea;
}

.dashboard-days--warning {
  color: #a95705;
  background: #fff2dc;
}

.dashboard-seller {
  font-weight: 800;
  color: var(--crm-navy);
}

.dashboard-muted {
  color: var(--crm-muted);
  font-size: .78rem;
  line-height: 1.4;
  margin-top: 3px;
}

.dashboard-empty {
  padding: 24px 8px;
  color: var(--crm-muted);
  text-align: center;
}

.dashboard-list {
  margin-top: 2px;
}

.dashboard-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--crm-border);
}

.dashboard-list-item:last-child {
  border-bottom: 0;
}

.dashboard-list-main strong {
  color: var(--crm-navy);
}

.dashboard-list-side {
  text-align: right;
}

.dashboard-list-action {
  display: inline-block;
  margin-top: 5px;
  font-weight: 800;
}

.dashboard-seller-summary th,
.dashboard-seller-summary td {
  vertical-align: middle;
}

.dashboard-seller-summary .metric-link {
  font-weight: 800;
  color: var(--crm-navy);
}

.dashboard-seller-summary .metric-link:hover {
  color: var(--crm-orange);
}

.dashboard-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}

.dashboard-status-grid .funnel-stage {
  margin: 0;
}

.dashboard-no-link {
  cursor: default;
}

.dashboard-no-link:hover {
  transform: none;
  border-color: var(--crm-border);
}

@media (max-width: 1150px) {
  .dashboard-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid,
  .dashboard-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .header {
    padding: 14px 16px;
  }

  .container {
    margin: 18px auto;
    padding: 0 14px 24px;
  }

  .dashboard-hero,
  .dashboard-attention {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-kpi:last-child {
    grid-column: 1 / -1;
  }

  .dashboard-section-head {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .dashboard-kpis {
    grid-template-columns: 1fr;
  }

  .dashboard-kpi:last-child {
    grid-column: auto;
  }
}

/* =========================================================
   SELECTOR DE TEMA
   ========================================================= */

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.theme-form {
  margin: 0;
  padding: 0;
  display: flex;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #142033;
  border-radius: 8px;
  background: #142033;
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color .15s ease,
    color .15s ease,
    border-color .15s ease,
    transform .12s ease;
}

.theme-toggle:hover {
  background: #26364f;
  color: #ffffff;
  border-color: #26364f;
}

.theme-toggle:active {
  transform: translateY(1px);
}

.theme-toggle-icon {
  font-size: 17px;
  line-height: 1;
}

.theme-toggle-text {
  white-space: nowrap;
}


/* =========================================================
   MODO OSCURO GLOBAL CRM AQSA
   ========================================================= */

html,
body {
  min-height: 100%;
}

body[data-theme="dark"] {
  background: #0f172a !important;
  color: #f1f5f9;
  color-scheme: dark;
}


/* ---------------------------------------------------------
   CONTENEDOR GENERAL
   --------------------------------------------------------- */

body[data-theme="dark"] .container {
  background: transparent !important;
  color: #f1f5f9;
  box-shadow: none;
}


/* ---------------------------------------------------------
   HEADER
   --------------------------------------------------------- */

body[data-theme="dark"] .header {
  background: #111827 !important;
  color: #f8fafc !important;
  border-bottom-color: #334155 !important;
  box-shadow: none;
}

body[data-theme="dark"] .header-title {
  color: #ffffff !important;
}

body[data-theme="dark"] .header-user {
  color: #cbd5e1 !important;
}

body[data-theme="dark"] .header-link {
  color: #f1f5f9 !important;
}

body[data-theme="dark"] .header-link:hover {
  color: #f59e0b !important;
}

body[data-theme="dark"] .header-separator {
  color: #64748b !important;
}


/* ---------------------------------------------------------
   BOTÓN CLARO / OSCURO
   --------------------------------------------------------- */

body[data-theme="dark"] .theme-toggle {
  background: #f8fafc !important;
  color: #111827 !important;
  border-color: #cbd5e1 !important;
}

body[data-theme="dark"] .theme-toggle:hover {
  background: #e2e8f0 !important;
  color: #111827 !important;
  border-color: #94a3b8 !important;
}


/* ---------------------------------------------------------
   TÍTULOS Y TEXTO GENERAL
   --------------------------------------------------------- */

body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3,
body[data-theme="dark"] h4,
body[data-theme="dark"] h5,
body[data-theme="dark"] h6 {
  color: #f8fafc !important;
}

body[data-theme="dark"] p {
  color: #cbd5e1;
}

body[data-theme="dark"] .page-title-row {
  color: #f8fafc;
}

body[data-theme="dark"] .field-help,
body[data-theme="dark"] .result-count,
body[data-theme="dark"] .dashboard-muted {
  color: #94a3b8 !important;
}


/* ---------------------------------------------------------
   TARJETAS / SECCIONES
   --------------------------------------------------------- */

body[data-theme="dark"] .form-section,
body[data-theme="dark"] .filter-panel {
  background: #182235 !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
  box-shadow: none;
}

body[data-theme="dark"] .form-section h2 {
  color: #f8fafc !important;
}

body[data-theme="dark"] .summary-grid > div {
  background: #1e293b !important;
  color: #f1f5f9 !important;
  border: 1px solid #334155 !important;
}

body[data-theme="dark"] .summary-grid strong {
  color: #f8fafc !important;
}

body[data-theme="dark"] .summary-grid span {
  color: #cbd5e1 !important;
}


/* ---------------------------------------------------------
   FORMULARIOS
   --------------------------------------------------------- */

body[data-theme="dark"] form label,
body[data-theme="dark"] label {
  color: #f8fafc !important;
}

body[data-theme="dark"] input[type="text"],
body[data-theme="dark"] input[type="email"],
body[data-theme="dark"] input[type="password"],
body[data-theme="dark"] input[type="date"],
body[data-theme="dark"] input[type="file"],
body[data-theme="dark"] input[type="number"],
body[data-theme="dark"] input[type="tel"],
body[data-theme="dark"] input[type="search"],
body[data-theme="dark"] select,
body[data-theme="dark"] textarea {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: #475569 !important;
}

body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder {
  color: #94a3b8 !important;
  opacity: 1;
}

body[data-theme="dark"] select option {
  background: #1e293b;
  color: #f8fafc;
}

body[data-theme="dark"] input[type="date"] {
  color-scheme: dark;
}

body[data-theme="dark"] input:disabled,
body[data-theme="dark"] select:disabled,
body[data-theme="dark"] textarea:disabled,
body[data-theme="dark"] input[readonly] {
  background: #172033 !important;
  color: #cbd5e1 !important;
  border-color: #334155 !important;
  opacity: 1 !important;
}

body[data-theme="dark"] input[type="checkbox"],
body[data-theme="dark"] input[type="radio"] {
  accent-color: #e07e14;
}


/* ---------------------------------------------------------
   BOTONES
   --------------------------------------------------------- */

body[data-theme="dark"] .btn-primary {
  background: #e07e14 !important;
  color: #ffffff !important;
}

body[data-theme="dark"] .btn-primary:hover {
  background: #c56b0f !important;
  color: #ffffff !important;
}

body[data-theme="dark"] .btn-secondary {
  background: #111c30 !important;
  color: #ffffff !important;
  border: 1px solid #334155 !important;
}

body[data-theme="dark"] .btn-secondary:hover {
  background: #243147 !important;
  color: #ffffff !important;
}

body[data-theme="dark"] .btn-light {
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid #475569 !important;
}

body[data-theme="dark"] .btn-light:hover {
  background: #334155 !important;
  color: #ffffff !important;
  border-color: #64748b !important;
}


/* ---------------------------------------------------------
   TABLAS
   --------------------------------------------------------- */

body[data-theme="dark"] .table-wrapper {
  background: #182235 !important;
  border-color: #475569 !important;
}

body[data-theme="dark"] table {
  color: #f1f5f9 !important;
}

body[data-theme="dark"] table th,
body[data-theme="dark"] .table-wrapper table th {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: #475569 !important;
}

body[data-theme="dark"] table td,
body[data-theme="dark"] .table-wrapper table td {
  background: #182235 !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

body[data-theme="dark"] table tbody tr:hover td {
  background: #243147 !important;
}


/* Lead vencido */
body[data-theme="dark"] .row-vencido,
body[data-theme="dark"] .row-vencido td {
  background: #2b1d21 !important;
  border-color: #63343a !important;
}

body[data-theme="dark"] .row-vencido:hover td {
  background: #352127 !important;
}


/* ---------------------------------------------------------
   BADGES
   --------------------------------------------------------- */

/* Se mantienen claros para generar contraste sobre el fondo oscuro. */
body[data-theme="dark"] .business-unit-badge {
  background: #fff7ed !important;
  color: #b45309 !important;
}

body[data-theme="dark"] .badge-status {
  background: #f1f5f9 !important;
  color: #26364f !important;
}

body[data-theme="dark"] .badge-ganado {
  background: #16a34a !important;
  color: #ffffff !important;
}

body[data-theme="dark"] .badge-perdido {
  background: #b91c1c !important;
  color: #ffffff !important;
}

body[data-theme="dark"] .badge-cotizado {
  background: #2563eb !important;
  color: #ffffff !important;
}


/* ---------------------------------------------------------
   EMBUDO / RESUMEN DE ESTADOS
   --------------------------------------------------------- */

body[data-theme="dark"] .funnel-stage {
  background: #182235 !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
  box-shadow: none;
}

body[data-theme="dark"] .funnel-stage strong {
  color: #f8fafc !important;
}

body[data-theme="dark"] .funnel-stage span {
  color: #94a3b8 !important;
}

body[data-theme="dark"] .funnel-stage:hover {
  background: #1e293b !important;
  border-color: #e07e14 !important;
}

body[data-theme="dark"] .funnel-stage.active {
  background: #332515 !important;
  border-color: #e07e14 !important;
}

body[data-theme="dark"] .funnel-stage.active strong {
  color: #ffffff !important;
}

body[data-theme="dark"] .funnel-stage.active span {
  color: #fdba74 !important;
}


/* ---------------------------------------------------------
   RESUMEN LEGACY
   --------------------------------------------------------- */

body[data-theme="dark"] .legacy-summary {
  background: #332515 !important;
  color: #fde68a !important;
  border-color: #785829 !important;
}


/* ---------------------------------------------------------
   ALERTAS GENERALES
   --------------------------------------------------------- */

body[data-theme="dark"] .alert-error {
  color: #fecaca !important;
  background: #3b171b !important;
  border-color: #7f1d1d !important;
}

body[data-theme="dark"] .alert-success {
  color: #bbf7d0 !important;
  background: #123522 !important;
  border-color: #166534 !important;
}

body[data-theme="dark"] .alert-info {
  color: #bfdbfe !important;
  background: #152b45 !important;
  border-color: #31506f !important;
}

body[data-theme="dark"] .alert-warning {
  color: #fde68a !important;
  background: #35250f !important;
  border-color: #80551d !important;
}


/* ---------------------------------------------------------
   PAGINACIÓN
   --------------------------------------------------------- */

body[data-theme="dark"] .pagination a,
body[data-theme="dark"] .pagination span {
  background: #182235 !important;
  color: #cbd5e1 !important;
  border-color: #334155 !important;
}

body[data-theme="dark"] .pagination a:hover {
  background: #243147 !important;
  color: #ffffff !important;
}

body[data-theme="dark"] .pagination .active {
  background: #e07e14 !important;
  color: #ffffff !important;
  border-color: #e07e14 !important;
}

body[data-theme="dark"] .pagination .disabled {
  color: #64748b !important;
}


/* =========================================================
   DASHBOARD COMERCIAL
   ========================================================= */

body[data-theme="dark"] .dashboard-hero {
  background: transparent !important;
  color: #f8fafc !important;
}

body[data-theme="dark"] .dashboard-hero h1 {
  color: #ffffff !important;
}

body[data-theme="dark"] .dashboard-hero p {
  color: #94a3b8 !important;
}


/* Filtro dashboard */
body[data-theme="dark"] .dashboard-filter {
  background: #182235 !important;
  border-color: #334155 !important;
}


/* Aviso de atención */
body[data-theme="dark"] .dashboard-attention {
  background: #35250f !important;
  border-color: #80551d !important;
  color: #fef3c7 !important;
}

body[data-theme="dark"] .dashboard-attention-title {
  color: #fde68a !important;
}

body[data-theme="dark"] .dashboard-attention-text {
  color: #fcd9a3 !important;
}


/* KPIs */
body[data-theme="dark"] .dashboard-kpi {
  background: #182235 !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
  box-shadow: none;
}

body[data-theme="dark"] .dashboard-kpi:hover {
  background: #1d2940 !important;
  border-color: #475569 !important;
}

body[data-theme="dark"] .dashboard-kpi-value {
  color: #ffffff !important;
}

body[data-theme="dark"] .dashboard-kpi-label {
  color: #f1f5f9 !important;
}

body[data-theme="dark"] .dashboard-kpi-help {
  color: #94a3b8 !important;
}


/* Secciones del dashboard */
body[data-theme="dark"] .dashboard-section-title h2,
body[data-theme="dark"] .dashboard-section-head h2 {
  color: #f8fafc !important;
}

body[data-theme="dark"] .dashboard-section-title p,
body[data-theme="dark"] .dashboard-section-head p {
  color: #94a3b8 !important;
}

body[data-theme="dark"] .dashboard-list-item {
  background: transparent !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

body[data-theme="dark"] .dashboard-list-main strong {
  color: #f8fafc !important;
}

body[data-theme="dark"] .dashboard-empty {
  background: #1e293b !important;
  color: #94a3b8 !important;
  border-color: #334155 !important;
}

body[data-theme="dark"] .dashboard-seller {
  color: #93c5fd !important;
}

body[data-theme="dark"] .dashboard-seller-summary .metric-link,
body[data-theme="dark"] .metric-link {
  color: #93c5fd !important;
}

body[data-theme="dark"] .dashboard-link,
body[data-theme="dark"] .dashboard-list-action {
  color: #60a5fa !important;
}

body[data-theme="dark"] .dashboard-link:hover,
body[data-theme="dark"] .dashboard-seller:hover,
body[data-theme="dark"] .dashboard-seller-summary .metric-link:hover,
body[data-theme="dark"] .metric-link:hover,
body[data-theme="dark"] .dashboard-list-action:hover {
  color: #93c5fd !important;
}


/* Iconos dashboard: versiones menos brillantes en oscuro */
body[data-theme="dark"] .dashboard-icon--danger {
  color: #fca5a5 !important;
  background: #3b1f24 !important;
}

body[data-theme="dark"] .dashboard-icon--warning {
  color: #fdba74 !important;
  background: #3b2a16 !important;
}

body[data-theme="dark"] .dashboard-icon--blue {
  color: #93c5fd !important;
  background: #172c4d !important;
}

body[data-theme="dark"] .dashboard-icon--orange {
  color: #fdba74 !important;
  background: #3b2a16 !important;
}

body[data-theme="dark"] .dashboard-icon--green {
  color: #86efac !important;
  background: #143522 !important;
}


/* Días vencidos: se mantienen como badges claros de alerta */
body[data-theme="dark"] .dashboard-days--danger {
  color: #b42318 !important;
  background: #fdeaea !important;
}

body[data-theme="dark"] .dashboard-days--warning {
  color: #a95705 !important;
  background: #fff2dc !important;
}


/* ---------------------------------------------------------
   RESPONSIVE DEL HEADER + BOTÓN DE TEMA
   --------------------------------------------------------- */

@media (max-width: 700px) {
  .header-brand {
    width: 100%;
    justify-content: space-between;
  }

  .theme-toggle {
    min-height: 32px;
    padding: 6px 10px;
  }
}
