/* ════════════════════════════════════════════════════════════════
   bee-partner · app.css
   Piel del boceto (BeePartner_standalone_estable.html) sobre el andamiaje de
   comportamiento del base (public/js/admin.js).
   Tokens en :root · componentes en clases · sin build step.
   Las clases/estados acoplados a admin.js (sortable-header.active/.desc,
   .is-open, .tab-content--active, .tab-nav__item--active, [data-toast])
   se definen aquí para que cada hook tenga su CSS.
════════════════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens (del boceto) ── */
:root {
  /* Acento dorado Conectabee */
  --bee: #D4A032;
  --bee-dark: #B8891C;
  --bee-light: #FEF9EC;
  --bee-border: rgba(212, 160, 50, .25);

  /* Fondos */
  --dark: #F0F2F5;   /* fondo de página */
  --dark2: #FFFFFF;  /* fondo de cards */
  --dark3: #F5F7FA;  /* secciones sutiles */

  /* Bordes */
  --border: #DDE1E8;

  /* Texto */
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;

  /* Alertas */
  --red: #DC2626;
  --red-bg: rgba(220, 38, 38, .06);
  --red-border: rgba(220, 38, 38, .22);

  /* Estados */
  --amber: #D97706;
  --green: #059669;
  --blue: #1565C0;

  /* Forma y elevación */
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Escala tipográfica: única perilla de la UI. 1rem = base; todos los
     font-size del stack se expresan en rem relativos a 14 (diseño del boceto),
     así subir la base aquí escala toda la UI de forma consistente. */
  --font-base: 16px;
}

/* ── Base ── */
html { font-size: var(--font-base); }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--dark);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--bee); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Utilidades ── */
.hidden { display: none !important; }
.muted { color: var(--text-secondary); }
.text-right { text-align: right; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.or-line { display: flex; align-items: center; gap: 10px; margin: 16px 0; font-size: calc(11rem / 14); color: var(--text-tertiary); }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-grow { flex: 1; }
.link-center { display: block; text-align: center; }
.mt-2 { margin-top: 8px; }

/* ── Logo (hexágonos del boceto) ── */
.hex-icon {
  width: 26px; height: 26px; background: var(--bee);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.hex-icon i { font-size: calc(12rem / 14); color: #fff; }
.hex-lg {
  width: 38px; height: 38px; background: var(--bee);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.hex-lg i { font-size: calc(17rem / 14); color: #fff; }
.hex-lg span { font-size: calc(14rem / 14); font-weight: 800; color: #fff; letter-spacing: -.5px; }
.brand-lines { display: flex; flex-direction: column; }
.logo-text { font-size: calc(13rem / 14); font-weight: 400; color: var(--text-primary); line-height: 1.2; }
.logo-text b { color: var(--bee); font-weight: 600; }
/* Subtítulo bajo BeePartner: "PORTAL VENDEDOR · by Conectabee" (boceto) */
.logo-sub { font-size: calc(8.5rem / 14); color: var(--text-tertiary); letter-spacing: .08em; line-height: 1.2; }
.logo-sub-by { color: var(--bee-dark); }

/* ════════ APP SHELL · barra superior (boceto) ════════ */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: var(--dark2); position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06); gap: 12px;
}
.top-bar-brand { display: flex; align-items: center; gap: 10px; }
.top-bar-right { display: flex; align-items: center; gap: 8px; font-size: calc(12rem / 14); color: var(--text-secondary); flex-wrap: wrap; }
.top-sep { color: var(--border); font-size: calc(14rem / 14); }
.uavatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bee-light); border: 1.5px solid var(--bee);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(11rem / 14); font-weight: 600; color: var(--bee); flex-shrink: 0;
}
.role-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: calc(9rem / 14); background: var(--bee-light); color: var(--bee-dark);
  border: 1px solid var(--bee-border); border-radius: 10px; padding: 2px 8px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.role-badge i { font-size: calc(10rem / 14); }
/* Rol + distribuidor apilados y centrados en el header (la línea de distribuidor se omite para admins sin distribuidor) */
.user-meta { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.user-distributor { font-size: calc(10rem / 15); color: var(--text-secondary); line-height: 1.2; text-align: center; }

/* ── Contenedor principal ── */
/* El portal (vendedor/gerente) usa el ancho completo del viewport como el
   boceto; el gutter lateral lo da el padding de .main. Las pantallas de auth
   (login/registro) viven en .screen-auth y siguen centradas. */
.main { padding: 20px; }
.container { width: 100%; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inp-upper { text-transform: uppercase; }
.page-title { font-size: calc(20rem / 14); font-weight: 700; color: var(--text-primary); }
.page-sub { font-size: calc(12rem / 14); color: var(--text-secondary); margin-top: 2px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ════════ CARDS ════════ */
.card {
  background: var(--dark2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: calc(14rem / 14); font-weight: 600; color: var(--text-primary); }
.card-body { font-size: calc(13rem / 14); color: var(--text-secondary); line-height: 1.6; }

/* ════════ MÉTRICAS (cards KPI · boceto) ════════ */
.metrics-bar { margin-bottom: 10px; } /* fila del selector de mes, sobre las cards */
/* El selector de mes va pegado a la izquierda: abre su dropdown hacia la derecha (no se sale del viewport) */
.month-filter .dropdown-menu { left: 0; right: auto; }
.kpi-grid { display: grid; gap: 8px; margin-bottom: 14px; }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-5 { grid-template-columns: repeat(5, 1fr); } /* métricas nacionales admin (M7b): + Efectividad */
.kpi-grid-7 { grid-template-columns: repeat(7, 1fr); } /* Vista Macro (M12): + Agencias + Vendedores */
@media (max-width: 1100px) { .kpi-grid-7 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 720px) { .kpi-grid-4, .kpi-grid-5, .kpi-grid-7 { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--dark2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.kpi-label { font-size: calc(9rem / 14); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.kpi-val { font-size: calc(20rem / 14); font-weight: 600; color: var(--text-primary); line-height: 1.1; }
.kpi-sub { font-size: calc(9rem / 14); color: var(--text-tertiary); margin-top: 2px; }
/* Valor coloreado por umbral (M12): Efectividad en Vista Macro, mismos colores que <x-effectiveness-bar>. */
.kpi-val--good { color: var(--green); }
.kpi-val--mid { color: var(--amber); }
.kpi-val--low { color: var(--red); }
/* "Instalados" resaltado (acento dorado, boceto) */
.kpi.hl { border: 1.5px solid var(--bee); background: var(--bee-light); }
.kpi.hl .kpi-label, .kpi.hl .kpi-sub { color: var(--bee-dark); }
.kpi.hl .kpi-val { color: var(--bee); }

/* ════════ PANEL ADMIN (M7 · filtros + ranking de dealers) ════════ */
/* Tabla de datos (ranking · boceto): cabeceras sutiles, números tabulares a la derecha. */
.data-table-wrap { background: var(--dark2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.data-table { width: 100%; border-collapse: collapse; font-size: calc(12rem / 14); }
.data-table th { padding: 9px 12px; text-align: left; font-size: calc(9rem / 14); text-transform: uppercase; letter-spacing: .06em; color: var(--text-tertiary); font-weight: 700; border-bottom: 1px solid var(--border); background: var(--dark3); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--dark3); color: var(--text-secondary); vertical-align: middle; }
.data-table td:first-child { color: var(--text-primary); } /* 1ª columna (nombre Vendedor/Dealer): negro, no gris (M12) */
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .muted { color: var(--text-tertiary); } /* "Nunca" (sin actividad), más apagado */
/* Renombrado inline en tabla (M16, catálogo de marcas): input + botón Guardar en la misma celda. */
.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-edit .inp { max-width: 280px; }
/* Actividad coloreada por antigüedad del último acceso (M12): verde hoy/ayer (≤1d), ámbar 2-4d, rojo ≥5d·Nunca.
   Vendedores/Agencias colorean SOLO el dot (texto normal); Vista Macro colorea el valor (sin dot). */
.activity { display: inline-flex; align-items: center; gap: 5px; }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.activity-dot--good { background: var(--green); }
.activity-dot--mid { background: var(--amber); }
.activity-dot--bad { background: var(--red); }
.activity-val--good { color: var(--green); }
.activity-val--mid { color: var(--amber); }
.activity-val--bad { color: var(--red); }
.data-table tbody tr:hover td { background: var(--dark3); }

/* Ranking de dealers en tarjetas (Vista Macro · boceto). Solo datos reales: posición, nombre, marca·ciudad,
   Instalaciones, Vendedores, Actividad (+ panel de detalle del #1). Sin NPS/Conv/Rev/score/grupo/estatus. */
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-card { display: flex; align-items: flex-start; gap: 14px; background: var(--dark2); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.rank-card.is-first { flex-direction: column; align-items: stretch; border-color: var(--bee); background: var(--bee-light); }
.rank-top { display: flex; align-items: flex-start; gap: 14px; }
.rank-pos { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: calc(14rem / 14); font-weight: 700; flex-shrink: 0; background: var(--dark3); color: var(--text-secondary); }
.rank-card.is-first .rank-pos { background: rgba(212, 160, 50, .14); color: var(--bee); }
.rank-main { flex: 1; min-width: 0; }
.rank-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 3px; }
.rank-name { font-size: calc(13rem / 14); font-weight: 700; color: var(--text-primary); }
.rank-badge { font-size: calc(9rem / 14); padding: 2px 8px; border-radius: 4px; background: var(--bee-light); color: var(--bee-dark); font-weight: 700; border: 1px solid var(--bee); }
.rank-sub { font-size: calc(10rem / 14); color: var(--text-tertiary); margin-bottom: 6px; }
.rank-kpis { display: flex; gap: 5px; flex-wrap: wrap; }
.rank-kpi { background: var(--dark3); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: calc(10rem / 14); color: var(--text-tertiary); display: inline-flex; align-items: center; gap: 4px; }
.rank-kpi b { color: var(--text-primary); }
.rank-detail { margin-top: 10px; padding: 10px 12px; background: var(--dark2); border: 1px solid var(--bee); border-radius: 10px; }
.rank-detail-title { font-size: calc(9rem / 14); font-weight: 700; color: var(--bee-dark); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.rank-detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rank-stat { text-align: center; }
.rank-stat-val { font-size: calc(20rem / 14); font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.rank-stat.hl .rank-stat-val { color: var(--bee); }
.rank-stat-lbl { font-size: calc(9rem / 14); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.rank-detail-meta { margin-top: 8px; font-size: calc(10rem / 14); color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.rank-detail-meta i { font-size: calc(9rem / 14); color: var(--text-tertiary); }

/* Desglose por ciudad de Vista Macro (boceto: "Instalaciones por ciudad" + "Agencias por ciudad"). Solo
   agregados (ciudad + conteos). NO se replica la fila/variante de "dealer en alerta" del boceto. */
.section-title { font-size: calc(11rem / 14); font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.section-title i { font-size: calc(12rem / 14); color: var(--bee); }
.section-title-note { font-size: calc(9rem / 14); color: var(--text-tertiary); font-weight: 400; text-transform: none; letter-spacing: 0; flex-shrink: 0; }
.section-title--spaced { margin-top: 24px; }

/* Instalaciones por ciudad: barras verticales agrupadas en CSS (instalados sólido al frente + leads de fondo, un
   color por ciudad vía --bar-color), réplica del canvas del boceto sin JS. La altura va por --bar-h (patrón
   .eff-bar). El boceto envuelve la gráfica en una card; el eje Y son líneas punteadas con su valor (tope = máx). */
.city-chart-card { background: var(--dark2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.city-chart { position: relative; display: flex; align-items: flex-end; gap: 18px; overflow-x: auto; overflow-y: hidden; padding: 20px 6px 0 26px; margin-bottom: 10px; }
/* Eje Y: la banda (120px) coincide con .city-chart-bars y arranca 34px arriba (alto de .city-chart-foot). */
.city-chart-axis { position: absolute; left: 26px; right: 6px; bottom: 34px; height: 120px; pointer-events: none; }
.city-axis-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); }
.city-axis-val { position: absolute; left: -22px; top: -6px; font-size: calc(8rem / 14); color: var(--text-tertiary); }
.city-chart-col { position: relative; display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; min-width: 48px; } /* alineadas a la izquierda; nuevas ciudades se agregan a la derecha (scroll-x si rebasan) */
.city-chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; }
.city-chart-bar { position: relative; width: 16px; height: var(--bar-h, 0%); min-height: 2px; border-radius: 3px 3px 0 0; }
.city-chart-bar.is-installed { background: var(--bar-color, var(--bee)); }
.city-chart-bar.is-leads { background: var(--bar-color, var(--bee)); opacity: .26; }
.city-chart-val { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: calc(11rem / 14); font-weight: 700; color: var(--bar-color, var(--bee)); white-space: nowrap; }
.city-chart-foot { height: 34px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding-top: 6px; }
.city-chart-city { font-size: calc(9rem / 14); font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.city-chart-dealers { font-size: calc(9rem / 14); color: var(--text-tertiary); }
.city-chart-legend { font-size: calc(9rem / 14); color: var(--text-tertiary); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; } /* dentro de .city-chart-card: el margen inferior lo da la card */
.lg-swatch { display: inline-block; width: 10px; height: 8px; border-radius: 2px; background: var(--text-secondary); }
.lg-swatch.is-leads { opacity: .3; }

/* Agencias por ciudad: grid de tarjetas (boceto "Dealers por ciudad", sin la fila de alerta). */
.city-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.city-card { background: var(--dark2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.city-name { font-size: calc(13rem / 14); font-weight: 600; color: var(--text-primary); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.city-name i { font-size: calc(13rem / 14); color: var(--bee); }
.city-dealers { margin-left: auto; font-size: calc(10rem / 14); color: var(--text-tertiary); font-weight: 400; }
.city-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.city-stat { background: var(--dark3); border-radius: 6px; padding: 6px 8px; }
.city-stat-val { font-size: calc(14rem / 14); font-weight: 600; color: var(--text-primary); }
.city-stat.hl .city-stat-val { color: var(--bee); } /* Instalados destacado (mismo patrón que .kpi.hl / .rank-stat.hl) */
.city-stat-lbl { font-size: calc(9rem / 14); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .03em; margin-top: 1px; }
@media (max-width: 1100px) { .city-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .city-grid { grid-template-columns: 1fr; } }

/* Filter-bar estilo boceto, compartido por las 3 pestañas del panel admin (componente <x-admin-filter-bar>:
   Vista Macro · Vendedores · Agencias). Clase propia .admin-filter-bar para NO pisar el .filter-bar de los
   portales vendedor/gerente (mismo nombre, distinto diseño). */
.admin-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; padding: 12px 14px; background: var(--dark2); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.filter-bar-title { font-size: calc(10rem / 14); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.filter-select, .filter-search { background: var(--dark2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; font-size: calc(11rem / 14); color: var(--text-primary); font-family: var(--font); outline: none; transition: border-color .15s; }
.filter-select { padding-right: 24px; cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239CA3AF'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.filter-select:focus, .filter-search:focus { border-color: var(--bee); }
.filter-reset { margin-left: auto; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--text-tertiary); font-size: calc(11rem / 14); cursor: pointer; font-family: var(--font); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; transition: all .15s; }
.filter-reset:hover { color: var(--text-primary); border-color: var(--text-tertiary); text-decoration: none; }
/* Avatar de iniciales del vendedor en la tabla (boceto). */
.vendor-cell { display: flex; align-items: center; gap: 8px; }
.tbl-avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: calc(10rem / 14); font-weight: 600; flex-shrink: 0; background: var(--bee-light); color: var(--bee-dark); }
/* Barra de efectividad (boceto): ancho = --eff por fila; color por umbral (<25 rojo, <40 ámbar, si no verde). */
.eff-cell { display: inline-flex; align-items: center; gap: 6px; }
.eff-bar-wrap { width: 70px; height: 6px; background: var(--dark3); border-radius: 3px; overflow: hidden; }
.eff-bar { display: block; height: 100%; width: var(--eff, 0%); border-radius: 3px; background: var(--green); transition: width .4s; }
.eff-pct { font-size: calc(11rem / 14); font-weight: 600; color: var(--green); font-variant-numeric: tabular-nums; }
.eff-cell.is-mid .eff-bar { background: var(--amber); }
.eff-cell.is-mid .eff-pct { color: var(--amber); }
.eff-cell.is-low .eff-bar { background: var(--red); }
.eff-cell.is-low .eff-pct { color: var(--red); }

/* ════════ BOTONES ════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--dark3); color: var(--text-primary);
  font-family: var(--font); font-size: calc(13rem / 14); font-weight: 600; line-height: 1;
  cursor: pointer; transition: all .15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: calc(11rem / 14); }
.btn-primary { background: var(--bee); color: #fff; border-color: var(--bee); }
.btn-primary:hover { opacity: .9; }
.btn-secondary { background: var(--dark3); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { border-color: #9CA3AF; }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { border-color: #9CA3AF; color: var(--text-primary); }
.btn-whatsapp { background: #25D366; color: #fff; border-color: #25D366; }
.btn-whatsapp:hover { background: #1EBE5A; border-color: #1EBE5A; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { opacity: .9; }
.btn-link { background: none; border: none; color: var(--bee); font-size: calc(12rem / 14); padding: 0; cursor: pointer; font-family: var(--font); }
.btn-link:hover { text-decoration: underline; }

/* ════════ FORMULARIOS ════════ */
.field { margin-bottom: 14px; }
/* Campo de búsqueda acotado a la izquierda (el input es width:100% del campo) */
.field-search { flex: 0 1 300px; max-width: 300px; }
.field-label { font-size: calc(11rem / 14); color: var(--text-secondary); margin-bottom: 5px; display: block; font-weight: 500; letter-spacing: .02em; }
.field-label .req { color: var(--red); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Barra de filtros (índices): q + vendedor reparten el espacio; el filtro de etapa va ajustado a su contenido */
/* align-items: stretch ⇒ el filtro de etapa toma la MISMA altura que los inputs (vendedor/búsqueda) */
.filter-bar { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar .field { margin-bottom: 0; }
.field-grow { flex: 1 1 0; min-width: 180px; }
.filter-bar .stage-filter { flex: 0 0 auto; }
/* Botón de filtro estilo boceto (.ftab); dispara el dropdown de etapa. Altura = la del input vía height:100% */
.ftab { display: inline-flex; align-items: center; gap: 5px; height: 100%; font-size: calc(11rem / 14); padding: 6px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--dark2); color: var(--text-secondary); font-family: var(--font); font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap; transition: all .15s; }
.ftab:hover { border-color: #9CA3AF; color: var(--text-primary); }
/* Activo (etapa seleccionada): mismo verde "completado" del badge de la última etapa, no negro */
.ftab.is-active { background: rgba(5, 150, 105, .08); color: var(--green); border-color: rgba(5, 150, 105, .2); }
.ftab.is-active:hover { border-color: rgba(5, 150, 105, .45); color: var(--green); }
.ftab .ti-chevron-down { font-size: calc(10rem / 14); }
/* Opciones desplegadas del filtro de etapa: fuente más chica */
#stage-filter-menu a { font-size: calc(12rem / 17); }
.inp-wrap { position: relative; display: flex; align-items: center; }
.inp-icon { position: absolute; left: 11px; color: var(--text-tertiary); font-size: calc(14rem / 14); pointer-events: none; z-index: 1; }
.inp {
  width: 100%; background: var(--dark2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; font-size: calc(13rem / 14); color: var(--text-primary);
  font-family: var(--font); outline: none; transition: border-color .15s; -webkit-appearance: none;
}
.inp.icon-pad { padding-left: 34px; }
.inp.eye-pad { padding-right: 38px; } /* deja lugar al botón .inp-eye (mostrar/ocultar contraseña) */
.inp:focus { border-color: var(--bee); }
.inp.is-invalid { border-color: var(--red); } /* combobox: texto que no resuelve a una opción válida */
.inp::placeholder { color: var(--text-tertiary); }

/* Combobox con buscador predictivo (data-combo): input + lista filtrable; se elige una opción (mapea a un hidden). */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 240px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--dark2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.combo-option { padding: 8px 10px; border-radius: 6px; font-size: calc(13rem / 14); color: var(--text-primary); cursor: pointer; white-space: nowrap; }
.combo-option:hover, .combo-option.is-active { background: var(--bee-light); color: var(--bee-dark); }
.combo-option[hidden] { display: none; }
.inp-eye { position: absolute; right: 10px; background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 4px; font-size: calc(14rem / 14); }
.inp-eye:hover { color: var(--text-secondary); }
select.inp { cursor: pointer; background: #fff; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: calc(13rem / 14); color: var(--text-primary); padding: 4px 0; }
.check-row input[type="checkbox"], .check-row input[type="radio"] { width: 15px; height: 15px; accent-color: var(--bee); cursor: pointer; }

/* ════════ TABLAS (+ sortable, acoplado a admin.js) ════════ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--dark2); }
.table { width: 100%; border-collapse: collapse; font-size: calc(13rem / 14); }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table thead th { font-size: calc(11rem / 14); font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; background: var(--dark3); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--dark3); }
/* Sortable: admin.js conmuta .active y .desc en th.sortable-header */
.sortable-table th.sortable-header { cursor: pointer; user-select: none; position: relative; padding-right: 26px; }
.sortable-table th.sortable-header::after { content: '↕'; position: absolute; right: 10px; color: var(--text-tertiary); font-size: calc(11rem / 14); opacity: .6; }
.sortable-table th.sortable-header.active { color: var(--bee); }
.sortable-table th.sortable-header.active::after { content: '↑'; color: var(--bee); opacity: 1; }
.sortable-table th.sortable-header.active.desc::after { content: '↓'; }

/* ════════ BADGES / CHIPS (estados del boceto) ════════ */
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 4px; font-size: calc(10rem / 14); font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-success { background: rgba(5, 150, 105, .08); color: var(--green); border-color: rgba(5, 150, 105, .2); }
.badge-warning { background: rgba(217, 119, 6, .08); color: var(--amber); border-color: rgba(217, 119, 6, .2); }
.badge-danger  { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.badge-neutral { background: var(--dark3); color: var(--text-tertiary); border-color: var(--border); }

/* ════════ ALERTAS (banner de flash; admin.js lo oculta tras el toast) ════════ */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: calc(12rem / 14); border: 1px solid transparent; margin-bottom: 12px; }
.alert-success { background: rgba(5, 150, 105, .08); color: var(--green); border-color: rgba(5, 150, 105, .25); }
.alert-error   { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.alert-warning { background: rgba(217, 119, 6, .08); color: var(--amber); border-color: rgba(217, 119, 6, .25); }
.alert-info    { background: rgba(21, 101, 192, .08); color: var(--blue); border-color: rgba(21, 101, 192, .25); }

/* ════════ DROPDOWN genérico (data-toggle → .is-open) ════════ */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; min-width: 190px;
  background: var(--dark2); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 6px; z-index: 60;
}
.dropdown-menu.is-open { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: none; background: none;
  color: var(--text-secondary); font-size: calc(12rem / 14); font-family: var(--font); border-radius: 6px; cursor: pointer; text-decoration: none;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--dark3); color: var(--text-primary); text-decoration: none; }
.dropdown-menu a.is-active { color: var(--bee-dark); font-weight: 600; background: var(--bee-light); }

/* ════════ TABS (data-tab-group; admin.js conmuta .active/.tab-nav__item--active y .tab-content--active) ════════ */
.tab-nav { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-nav::-webkit-scrollbar { height: 0; }
.tab-nav__item {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border: none; background: transparent;
  color: var(--text-tertiary); font-size: calc(12rem / 14); font-weight: 500; cursor: pointer; font-family: var(--font);
  border-bottom: 2px solid transparent; white-space: nowrap; transition: all .15s;
}
.tab-nav__item:hover { color: var(--text-secondary); }
.tab-nav__item.active, .tab-nav__item--active { color: var(--bee); border-bottom-color: var(--bee); }
.tab-nav__action { margin-left: auto; align-self: center; padding-left: 12px; } /* acción a la derecha en la fila de tabs (p.ej. Nueva agencia) */
[data-tab-panel] { display: none; padding: 16px 2px; }
[data-tab-panel].tab-content--active { display: block; }

/* ════════ COLAPSABLE (data-collapse-toggle → .is-open) ════════ */
.collapsible { display: none; padding: 12px 0 2px; }
.collapsible.is-open { display: block; }

/* ════════ WIZARD de pasos (registro) ════════ */
.wizard-step { display: none; }
.wizard-step.is-active { display: block; }
.wizard-dots { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 20px; }
.wizard-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); background: var(--dark2); color: var(--text-tertiary); display: flex; align-items: center; justify-content: center; font-size: calc(11rem / 14); font-weight: 600; }
.wizard-dot.is-active { border-color: var(--bee); color: var(--bee); }
.wizard-dot.is-done { border-color: var(--bee); background: var(--bee); color: #fff; }
.wizard-actions { display: flex; gap: 8px; margin-top: 18px; }
.field-error { color: var(--red); font-size: calc(11rem / 14); margin-top: 4px; }
.check-inline { display: flex; align-items: flex-start; gap: 8px; font-size: calc(12rem / 14); color: var(--text-secondary); line-height: 1.5; }
.check-inline input { margin-top: 2px; accent-color: var(--bee); }

/* ── Cajas del código de verificación (6 dígitos) ── */
.code-row { display: flex; gap: 8px; justify-content: center; margin: 8px 0 4px; }
.code-box { width: 44px; height: 52px; text-align: center; font-size: calc(22rem / 14); font-weight: 700; border: 1.5px solid var(--border); border-radius: 8px; background: var(--dark2); color: var(--text-primary); font-family: var(--font); outline: none; }
.code-box:focus { border-color: var(--bee); }

/* ════════ PORTAL DEL VENDEDOR (tarjetas + progreso de 9 pasos · boceto) ════════ */
.cards-area { display: flex; flex-direction: column; gap: 10px; }
.service-card { background: var(--dark2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; transition: all .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.service-card:hover { border-color: #9CA3AF; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
/* Área clickeable de la tarjeta (link al estatus); el botón vive fuera del <a> para HTML válido */
.service-card-body { display: block; text-decoration: none; color: inherit; }
.service-card-body:hover { text-decoration: none; }
.card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
/* Avatar con las iniciales del cliente (azul ligero, boceto) */
.card-avatar { width: 32px; height: 32px; border-radius: 50%; background: #EFF6FF; color: #3B82F6; display: flex; align-items: center; justify-content: center; font-size: calc(11rem / 14); font-weight: 600; flex-shrink: 0; }
.card-info { flex: 1; min-width: 0; }
.card-name { font-size: calc(13rem / 14); font-weight: 600; color: var(--text-primary); }
.card-meta { font-size: calc(11rem / 14); color: var(--text-tertiary); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.card-meta span { display: flex; align-items: center; gap: 4px; }
.card-srv-badge { font-size: calc(10rem / 14); font-weight: 700; color: var(--bee); background: var(--bee-light); border: 1px solid var(--bee-border); border-radius: 4px; padding: 2px 7px; letter-spacing: .03em; white-space: nowrap; }
.status-badge { font-size: calc(10rem / 14); border-radius: 5px; padding: 3px 8px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; background: var(--bee-light); color: var(--bee-dark); border: 1px solid var(--bee-border); }
.status-badge.is-complete { background: rgba(5, 150, 105, .08); color: var(--green); border-color: rgba(5, 150, 105, .2); }
/* Hex-stepper: nodo (hexágono) por paso + etiqueta, unidos por la línea de progreso (boceto) */
.hex-stepper { display: flex; align-items: flex-start; margin-top: 8px; }
.hex-step-node { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; min-width: 0; }
.hex-step-hex {
  width: 22px; height: 22px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(9rem / 14); font-weight: 700; flex-shrink: 0;
  background: var(--dark3); color: var(--text-tertiary); transition: background .15s;
}
.hex-step-hex i { font-size: calc(9rem / 14); }
.hex-step-hex.hx-done, .hex-step-hex.hx-current { background: var(--bee); color: #fff; }
/* Línea de progreso entre etapas; el tramo "done" va atenuado (≥50% más tenue que --bee) */
.hex-step-conn { flex: 1; height: 2px; margin-top: 10px; min-width: 4px; background: var(--border); }
.hex-step-conn.hx-done { background: rgba(212, 160, 50, .5); }
.hex-step-lbl {
  font-size: calc(8rem / 14); color: var(--text-tertiary); text-align: center;
  line-height: 1.2; max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hex-step-lbl.hx-active { color: var(--bee-dark); font-weight: 600; }
/* Botones bajo la tarjeta, separados de la barra de progreso por una línea (boceto) */
.card-btns { display: flex; align-items: center; gap: 5px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
/* Chip del vendedor en la esquina inferior derecha de la tarjeta del gerente (lado opuesto al botón) */
.card-vendor { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: calc(10rem / 14); color: var(--text-secondary); background: var(--dark3); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; white-space: nowrap; cursor: pointer; text-decoration: none; transition: all .15s; }
.card-vendor:hover { border-color: var(--bee); background: var(--bee-light); text-decoration: none; }
.card-vendor i { font-size: calc(11rem / 14); color: var(--bee); }
.card-vendor b { color: var(--text-primary); font-weight: 600; }
.card-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 9px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary); font-size: calc(10rem / 14);
  font-family: var(--font); font-weight: 500; white-space: nowrap; cursor: pointer; transition: all .15s;
}
.card-btn i { font-size: calc(11rem / 14); }
.card-btn:hover { border-color: #9CA3AF; color: var(--text-primary); background: var(--dark3); }
.card-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }
.btn-new-service { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius); border: 1.5px solid var(--bee-border); background: var(--bee-light); color: var(--bee-dark); font-size: calc(12rem / 14); font-weight: 600; cursor: pointer; font-family: var(--font); text-decoration: none; transition: all .15s; }
.btn-new-service:hover { background: #FEF3C7; border-color: var(--bee); text-decoration: none; }
.empty-state { text-align: center; padding: 36px 20px; color: var(--text-tertiary); border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--dark2); }
.empty-state i { font-size: calc(30rem / 14); display: block; margin-bottom: 8px; color: var(--border); }
.empty-state p { font-size: calc(13rem / 14); }

/* ════════ PORTAL DEL GERENTE (invitar vendedor · liga copiable) ════════ */
.invite-link-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-link { flex: 1; min-width: 240px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: calc(12rem / 14); color: var(--text-secondary); background: var(--dark2); }

/* ════════ AUTH (login / recuperación · diseño del boceto) ════════ */
.screen-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: #FFFFFF; }
.screen-auth::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(212, 160, 50, .06) 0%, transparent 50%),
    radial-gradient(circle at 85% 80%, rgba(212, 160, 50, .04) 0%, transparent 50%);
}
.screen-auth > * { position: relative; z-index: 1; }
.auth-card {
  background: #FFFFFF; border: 1px solid rgba(212, 160, 50, .15);
  border-radius: 20px; padding: 36px; width: 100%; max-width: 440px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .08), 0 2px 8px rgba(212, 160, 50, .08);
}
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 28px; }
.hex-cluster { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.hex-main {
  width: 56px; height: 56px; background: var(--bee);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: calc(22rem / 14); font-weight: 800; color: #fff; letter-spacing: -.5px;
}
.hex-side { display: flex; flex-direction: column; gap: 5px; }
.hex-sm { width: 20px; height: 20px; background: var(--bee); clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%); }
.hex-sm:last-child { opacity: .4; background: var(--bee-dark); }
.brand-name { font-size: calc(22rem / 14); font-weight: 400; color: var(--text-primary); }
.brand-name b { color: var(--bee); font-weight: 700; }
.brand-sub { font-size: calc(9rem / 14); color: var(--text-tertiary); letter-spacing: .1em; text-transform: uppercase; }
.auth-title { font-size: calc(16rem / 14); font-weight: 600; color: var(--text-primary); text-align: center; margin-bottom: 4px; }
.auth-sub { font-size: calc(12rem / 14); color: var(--text-secondary); text-align: center; margin-bottom: 24px; line-height: 1.6; }

/* ════════ PAGINACIÓN (listados de servicios · partials/pagination) ════════ */
.pagination-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; margin-top: 16px; }
.pagination-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px;
  padding: 6px 10px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--dark2); color: var(--text-secondary);
  font-family: var(--font); font-size: calc(12rem / 14); font-weight: 600; line-height: 1;
  text-decoration: none; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.pagination-btn:hover { border-color: #9CA3AF; color: var(--text-primary); text-decoration: none; }
.pagination-btn--active { background: var(--bee); color: #fff; border-color: var(--bee); }
.pagination-btn--active:hover { color: #fff; }
.pagination-btn--disabled { opacity: .45; cursor: default; pointer-events: none; }
.pagination-info { text-align: center; color: var(--text-tertiary); font-size: calc(11rem / 14); margin-top: 8px; }
