/* =====================================================================
   CRM CarinnGroup · estilos propios
   - Sin estilos inline (la CSP los bloquea): todo vive aquí.
   - Independiente de Bootstrap: la interfaz se ve igual aunque no cargue.
   - Paleta compartida con el acceso: tinta azul de la marca y el ámbar de la "ruta".
   ===================================================================== */
:root {
  --ui-ink: #10283f;
  --ui-ink-2: #173a5a;
  --ui-route: #f2a541;
  --ui-bg: #f3f5f8;
  --ui-surface: #ffffff;
  --ui-surface-2: #f8fafc;
  --ui-line: #e1e6ed;
  --ui-line-strong: #cfd8e2;
  --ui-text: #16212c;
  --ui-muted: #5d6b79;
  --ui-focus: #2f6fb0;
  --ui-ok: #1e7a4c;
  --ui-ok-bg: #e6f4ec;
  --ui-warn: #8a5300;
  --ui-warn-bg: #fff3df;
  --ui-error: #b42318;
  --ui-error-bg: #fdf0ee;
  --ui-radius: 12px;
  --ui-font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ui-font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Display", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 256px;
}

/* ---------- Páginas de error (layout de invitado) ---------- */
.guest-body { margin: 0; min-height: 100vh; font-family: var(--ui-font); color: var(--ui-text); background: var(--ui-bg); }
.guest-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; box-sizing: border-box; }
.login-card {
  box-sizing: border-box; width: 100%; max-width: 440px; background: var(--ui-surface);
  border: 1px solid var(--ui-line); border-radius: 16px; padding: 2.5rem 2rem; text-align: center;
}
.login-card .btn { display: inline-block; margin-top: .5rem; padding: .7rem 1.25rem; border-radius: 10px;
  background: var(--ui-ink); color: #fff; font-weight: 600; text-decoration: none; }
.error-code { font-family: var(--ui-font-display); font-size: 3.5rem; font-weight: 700; color: var(--ui-ink); line-height: 1; margin-bottom: .75rem; }
.error-detail { max-height: 320px; overflow: auto; white-space: pre-wrap; background: var(--ui-surface-2); padding: 1rem; border-radius: 8px; }

/* Indicador de estado (ERP, sincronización) */
.status-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #a9b4c0; display: inline-block; }
[data-state="ok"] .status-dot { background: var(--ui-ok); box-shadow: 0 0 0 4px rgba(30, 122, 76, .14); }
[data-state="down"] .status-dot { background: var(--ui-error); box-shadow: 0 0 0 4px rgba(180, 35, 24, .14); }
[data-state="loading"] .status-dot { animation: ui-pulse 1s infinite alternate; }
@keyframes ui-pulse { from { opacity: .3; } to { opacity: 1; } }

/* =====================================================================
   Pantalla de acceso (auth)
   Independiente de Bootstrap: se ve igual aunque no cargue la librería.
   Concepto: a la izquierda, el "territorio" del comercial (clientes y
   la ruta del día); a la derecha, un formulario sobrio y sin adornos.
   ===================================================================== */
:root {
  --auth-ink: #10283f;          /* panel de marca */
  --auth-ink-2: #173a5a;
  --auth-route: #f2a541;        /* ruta / acento */
  --auth-paper: #ffffff;
  --auth-text: #16212c;
  --auth-muted: #5d6b79;
  --auth-line: #cfd8e2;
  --auth-focus: #2f6fb0;
  --auth-error: #b42318;
  --auth-error-bg: #fdf0ee;
  --auth-font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --auth-font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Display", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body[data-page="login"] { margin: 0; background: var(--auth-paper); }
.auth *, .auth *::before, .auth *::after { box-sizing: border-box; }
body[data-page="login"] .guest-shell { display: block; place-items: normal; padding: 0; }

.auth {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--auth-font);
  color: var(--auth-text);
}
.auth .d-none { display: none !important; }

/* ---------- Panel de marca ---------- */
.auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem 3.5rem;
  background: linear-gradient(160deg, var(--auth-ink-2) 0%, var(--auth-ink) 70%);
  color: #fff;
}
.auth-brand-name,
.auth-mobile-name {
  font-family: var(--auth-font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.auth-brand-name { position: relative; z-index: 1; }

.auth-map {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(92%, 640px);
  transform: translate(-50%, -54%);
}
.auth-map-contours path { fill: none; stroke: rgba(255, 255, 255, .09); stroke-width: 1.5; }
.auth-map-clients circle { fill: rgba(255, 255, 255, .38); }
.auth-map-route {
  fill: none;
  stroke: var(--auth-route);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 760;
  stroke-dashoffset: 0;
  animation: auth-route-draw 1.6s cubic-bezier(.45, 0, .2, 1) .25s both;
}
.auth-map-stops circle { fill: var(--auth-ink); stroke: var(--auth-route); stroke-width: 3; }
.auth-map-origin { fill: #fff; }
.auth-map-origin-halo { fill: rgba(255, 255, 255, .16); }

@keyframes auth-route-draw {
  from { stroke-dashoffset: 760; }
  to   { stroke-dashoffset: 0; }
}

.auth-brand-copy { position: relative; z-index: 1; max-width: 30rem; }
.auth-brand-title {
  font-family: var(--auth-font-display);
  font-size: clamp(1.75rem, 2.6vw, 2.5rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: #fff;
}
.auth-brand-text { margin: 0; font-size: 1.0625rem; line-height: 1.55; color: rgba(255, 255, 255, .74); }

/* ---------- Formulario ---------- */
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  background: var(--auth-paper);
}
.auth-form-wrap { width: 100%; max-width: 380px; }
/* Crédito del producto, al pie del panel de acceso */
.auth-panel { flex-direction: column; }
.auth-credit { align-self: stretch; margin: 2.5rem 0 0; font-size: .8125rem; color: var(--ui-muted); text-align: center; letter-spacing: .01em; }
.auth-credit strong { font-weight: 600; color: var(--ui-ink-2); }
.auth-mobile-name { display: none; color: var(--auth-ink); margin-bottom: 2.5rem; }

.auth-title {
  font-family: var(--auth-font-display);
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 .5rem;
}
.auth-subtitle { margin: 0 0 2rem; color: var(--auth-muted); line-height: 1.5; }

.auth-notice,
.auth-error {
  border-radius: 10px;
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .9375rem;
  line-height: 1.45;
}
.auth-notice { background: #eef4fa; color: #1d4466; border-left: 3px solid var(--auth-focus); }
.auth-error  { background: var(--auth-error-bg); color: var(--auth-error); border-left: 3px solid var(--auth-error); }

.auth-form { display: grid; gap: 1.25rem; }
.auth-field { display: grid; gap: .5rem; }
.auth-label { font-size: .9375rem; font-weight: 600; }

.auth-input {
  width: 100%;
  min-height: 3rem;
  padding: .7rem .9rem;
  font: inherit;
  font-size: 1rem;              /* 16px: evita el zoom automático en iOS */
  color: var(--auth-text);
  background: #fff;
  border: 1px solid var(--auth-line);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.auth-input:hover { border-color: #aebccb; }
.auth-input:focus {
  outline: none;
  border-color: var(--auth-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-focus) 22%, transparent);
}
.auth-input-group { position: relative; }
.auth-input-group .auth-input { padding-right: 4.5rem; }
.auth-reveal {
  position: absolute;
  top: 50%;
  right: .4rem;
  transform: translateY(-50%);
  min-width: 3.5rem;
  padding: .45rem .6rem;
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  color: var(--auth-focus);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.auth-reveal:hover { background: #eef4fa; }
.auth-reveal:focus-visible { outline: 2px solid var(--auth-focus); outline-offset: 1px; }
.auth-hint { margin: 0; font-size: .875rem; color: #9a5b00; }

.auth-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  width: 100%;
  min-height: 3.1rem;
  margin-top: .5rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--auth-ink);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color .15s;
}
.auth-submit:hover { background: var(--auth-ink-2); }
.auth-submit:focus-visible { outline: 3px solid var(--auth-route); outline-offset: 2px; }
.auth-submit:disabled { cursor: progress; opacity: .85; }

.auth-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin .7s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-legal { margin: 2rem 0 0; font-size: .8125rem; line-height: 1.5; color: var(--auth-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 899.98px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-name { display: block; }
  .auth-panel {
    align-items: stretch;
    justify-content: flex-start;
    padding: 3rem 1.25rem 2rem;
    /* franja superior que recuerda a la ruta del panel de escritorio */
    background:
      linear-gradient(90deg, var(--auth-ink) 0 60%, var(--auth-route) 60% 100%) top / 100% 6px no-repeat,
      var(--auth-paper);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-map-route { animation: none; }
  .auth-spinner { animation-duration: 1.6s; }
}

/* ---------- Cambio de contraseña (layout de invitado) ---------- */
.auth-card {
  box-sizing: border-box; width: 100%; max-width: 420px;
  padding: 2.25rem 2rem; border: 1px solid var(--auth-line); border-radius: 16px;
  background: var(--auth-paper); font-family: var(--auth-font); color: var(--auth-text);
}
.auth-card *, .auth-card *::before, .auth-card *::after { box-sizing: border-box; }
.auth-card .d-none { display: none !important; }
.auth-card .auth-card-brand { display: block; margin-bottom: 1.75rem; }
.auth-hint--muted { color: var(--auth-muted); line-height: 1.45; }
.auth-card .auth-legal a { color: var(--auth-focus); font-weight: 600; text-decoration: none; }

/* ---------- Página sin conexión (PWA) ---------- */
.offline-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  font-family: var(--auth-font);
  color: var(--auth-text);
  background: var(--auth-paper);
}
.offline { width: 100%; max-width: 380px; }
.offline-icon { display: block; border-radius: 14px; margin-bottom: 2rem; }
.offline-retry { text-decoration: none; box-sizing: border-box; }


/* =====================================================================
   Aplicación: estructura (menú lateral + barra superior + contenido)
   ===================================================================== */
.app {
  margin: 0;
  font-family: var(--ui-font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ui-text);
  background: var(--ui-bg);
  -webkit-font-smoothing: antialiased;
}
.app *, .app *::before, .app *::after { box-sizing: border-box; }
.app.no-scroll { overflow: hidden; }
.app h1, .app h2, .app h3, .app p { margin-top: 0; }
.app a { color: var(--ui-focus); }
.app button { font: inherit; }

.ui-icon { flex: none; width: 20px; height: 20px; }
.ui-icon--sm { width: 14px; height: 14px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  padding: .6rem 1rem; border-radius: 8px; background: var(--ui-ink); color: #fff; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

/* ---------- Menú lateral ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ui-ink);
  color: #fff;
  z-index: 50;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.25rem 1.5rem; }
.sidebar-brand {
  display: inline-flex; align-items: center; gap: .7rem;
  color: #fff !important; text-decoration: none;
  font-family: var(--ui-font-display); font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em;
}
.sidebar-brand img { border-radius: 8px; }
.sidebar .sidebar-close { display: none; color: #fff; }
.sidebar .sidebar-close:hover { background: rgba(255, 255, 255, .08); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 .75rem; }
.sidebar-section { margin: 1.25rem .75rem .5rem; font-size: .8125rem; color: rgba(255, 255, 255, .55); }
.sidebar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar-link {
  position: relative;
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .85rem;
  border-radius: 8px;
  color: rgba(255, 255, 255, .74) !important;
  text-decoration: none;
  font-weight: 500;
}
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff !important; }
.sidebar-link:focus-visible { outline: 2px solid var(--ui-route); outline-offset: -2px; }
/* Página actual: el trazo ámbar de la "ruta" del acceso */
.sidebar-link[aria-current="page"] { background: rgba(255, 255, 255, .1); color: #fff !important; font-weight: 600; }
.sidebar-link[aria-current="page"]::before {
  content: ""; position: absolute; left: -.75rem; top: .55rem; bottom: .55rem;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--ui-route);
}

.sidebar-foot {
  display: flex; align-items: center; gap: .75rem;
  margin: .75rem; padding: .75rem;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-foot > a.icon-btn { margin-left: auto; }
.sidebar-foot form { margin: 0; }
.sidebar-foot .icon-btn { flex: none; color: rgba(255, 255, 255, .74); }
.sidebar-foot .icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ui-route); color: var(--ui-ink);
  font-size: .8125rem; font-weight: 700;
}
.sidebar-user { min-width: 0; display: grid; line-height: 1.3; }
.sidebar-user-name { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .8125rem; color: rgba(255, 255, 255, .6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(16, 40, 63, .5); }
.sidebar-backdrop[hidden] { display: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 8px;
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(16, 40, 63, .06); }
.icon-btn:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }

/* ---------- Barra superior y contenido ---------- */
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  min-height: 64px; padding: .75rem 2rem;
  background: rgba(243, 245, 248, .92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--ui-line);
}
.topbar .topbar-menu { display: none; }
.topbar-title {
  margin: 0; font-family: var(--ui-font-display);
  font-size: 1.375rem; font-weight: 650; letter-spacing: -0.015em; line-height: 1.2;
}
.content { flex: 1; width: 100%; max-width: 1320px; padding: 1.75rem 2rem 2.5rem; outline: none; }
.app-foot { padding: 1rem 2rem 1.5rem; font-size: .8125rem; color: var(--ui-muted); }

.page-lead { margin-bottom: 1.5rem; color: var(--ui-muted); font-size: 1.0625rem; }

/* ---------- Avisos ---------- */
.ui-alert {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.25rem; padding: .8rem 1rem;
  border-radius: 10px; border-left: 3px solid currentColor;
  font-size: .9375rem;
}
.ui-alert--info, .ui-alert--success { background: #eaf2fa; color: #1d4466; }
.ui-alert--success { background: var(--ui-ok-bg); color: var(--ui-ok); }
.ui-alert--warning { background: var(--ui-warn-bg); color: var(--ui-warn); }
.ui-alert--danger { background: var(--ui-error-bg); color: var(--ui-error); }
.ui-alert-close { flex: none; display: grid; place-items: center; padding: 0; width: 24px; height: 24px; border: 0; background: none; color: inherit; cursor: pointer; }
.ui-alert-close .ui-icon { width: 16px; height: 16px; }

.toast-area { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: grid; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast-msg { padding: .8rem 1rem; border-radius: 10px; background: var(--ui-ink); color: #fff; font-size: .9375rem; box-shadow: 0 8px 24px rgba(16, 40, 63, .25); }
.toast-msg--danger { background: var(--ui-error); }
.toast-msg--warning { background: #6b4300; }

/* =====================================================================
   Panel (dashboard)
   Indicadores agrupados en una sola pieza dividida, no tarjetas sueltas:
   se leen como una fila de cifras comparables.
   ===================================================================== */
.kpi-groups { display: grid; gap: 2rem; }
.kpi-group-title { margin-bottom: .75rem; font-size: 1rem; font-weight: 600; color: var(--ui-text); }
.kpi-group-error { margin: 0; padding: 1rem 1.25rem; border-radius: var(--ui-radius); background: var(--ui-surface); border: 1px dashed var(--ui-line-strong); color: var(--ui-muted); }
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--ui-line);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  overflow: hidden;
}
.kpi {
  display: flex; flex-direction: column; gap: .25rem;
  min-height: 132px; padding: 1.25rem 1.5rem;
  background: var(--ui-surface);
  color: var(--ui-text) !important;
  text-decoration: none;
}
.kpi--link:hover { background: var(--ui-surface-2); }
.kpi--link:hover .kpi-label { color: var(--ui-focus); }
.kpi--link:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: -2px; }
.kpi-label { font-size: .9375rem; font-weight: 600; color: var(--ui-muted); }
.kpi-value {
  font-family: var(--ui-font-display);
  font-size: 2.5rem; font-weight: 650; line-height: 1.1; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-hint { margin-top: auto; font-size: .875rem; color: var(--ui-muted); }
.kpi--loading { background: linear-gradient(90deg, var(--ui-surface) 0%, var(--ui-surface-2) 50%, var(--ui-surface) 100%) 0 0 / 200% 100%; animation: ui-shimmer 1.2s linear infinite; }
@keyframes ui-shimmer { to { background-position: -200% 0; } }

.status-strip {
  display: flex; flex-wrap: wrap; gap: .75rem 2rem;
  margin-top: 2rem; padding-top: 1.25rem;
  border-top: 1px solid var(--ui-line);
  font-size: .9375rem; color: var(--ui-muted);
}
.status-item { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.status-label { font-weight: 600; color: var(--ui-text); }

/* =====================================================================
   Listados (clientes)
   ===================================================================== */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: 1rem; }
.search { position: relative; flex: 1 1 320px; max-width: 520px; margin: 0; }
.search-icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--ui-muted); pointer-events: none; }
.search-input {
  width: 100%; min-height: 44px; padding: .6rem .9rem .6rem 2.6rem;
  font: inherit; color: var(--ui-text);
  background: var(--ui-surface); border: 1px solid var(--ui-line-strong); border-radius: 10px;
}
.search-input:focus { outline: none; border-color: var(--ui-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-focus) 20%, transparent); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: #e6ebf1; }
.segmented-btn {
  min-height: 38px; padding: .4rem .9rem;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--ui-muted);
  font-size: .9375rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.segmented-btn:hover { color: var(--ui-text); }
.segmented-btn[aria-pressed="true"] { background: var(--ui-surface); color: var(--ui-ink); box-shadow: 0 1px 2px rgba(16, 40, 63, .12); }
.segmented-btn:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }

.table-wrap { background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.data-table th {
  position: sticky; top: 0;
  padding: .7rem 1rem; text-align: left; white-space: nowrap;
  font-size: .8125rem; font-weight: 600; color: var(--ui-muted);
  background: var(--ui-surface-2); border-bottom: 1px solid var(--ui-line);
}
.data-table td { padding: .8rem 1rem; border-top: 1px solid var(--ui-line); vertical-align: top; }
.data-table tbody tr:first-child td { border-top: 0; }
.data-table tbody tr:hover td { background: var(--ui-surface-2); }
.data-table[aria-busy="true"] tbody { opacity: .55; transition: opacity .15s; }
.col-code { width: 6rem; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.row-link {
  padding: 0; border: 0; background: none; cursor: pointer;
  font-weight: 600; color: var(--ui-text); text-align: left;
}
.row-link:hover { color: var(--ui-focus); text-decoration: underline; }
.row-link:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; border-radius: 2px; }
.cell-sub { display: block; margin-top: .15rem; font-size: .8125rem; color: var(--ui-muted); }
.row-message td { padding: 2rem 1rem; text-align: center; color: var(--ui-muted); }
.row-message--error td { color: var(--ui-error); }

.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; white-space: nowrap; }
.badge--ok { background: var(--ui-ok-bg); color: var(--ui-ok); }
.badge--warn { background: var(--ui-warn-bg); color: var(--ui-warn); }
.badge--muted { background: #eceff3; color: var(--ui-muted); }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1rem; }
.pager-info { font-size: .9375rem; color: var(--ui-muted); }
.pager-buttons { display: flex; gap: .5rem; }
.pager[hidden] { display: none; }
.pager-controls { display: flex; align-items: center; gap: .25rem; }
.pager-pages { display: flex; align-items: center; gap: .25rem; }
.pager-btn {
  min-width: 38px; height: 38px; padding: 0 .55rem; display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: .9375rem; font-variant-numeric: tabular-nums; color: var(--ui-text);
  background: var(--ui-surface); border: 1px solid var(--ui-line-strong); border-radius: 8px; cursor: pointer;
}
.pager-btn:hover:not(:disabled):not(.is-current) { border-color: #aebccb; background: var(--ui-surface-2); }
.pager-btn:disabled { opacity: .4; cursor: default; }
.pager-btn:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.pager-btn.is-current { background: var(--ui-ink); border-color: var(--ui-ink); color: #fff; font-weight: 600; cursor: default; }
.pager-btn .ui-icon { width: 18px; height: 18px; }
.pager-gap { min-width: 1.25rem; text-align: center; color: var(--ui-muted); }
.pager-jump { display: flex; align-items: center; gap: .4rem; }
.pager-jump-label { display: flex; align-items: center; gap: .4rem; font-size: .9375rem; color: var(--ui-muted); }
.pager-input {
  width: 4.75rem; height: 38px; padding: 0 .5rem; font: inherit; text-align: center; color: var(--ui-text);
  background: var(--ui-surface); border: 1px solid var(--ui-line-strong); border-radius: 8px;
}
.pager-input:focus { outline: none; border-color: var(--ui-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-focus) 20%, transparent); }
.pager-go { min-height: 38px; padding-top: 0; padding-bottom: 0; }

/* Encabezados ordenables (en móvil, selector «Ordenar por») */
.sort-mobile { display: none; }
.data-table th[data-sort] { padding: 0; }
.sort-btn {
  display: inline-flex; align-items: center; gap: .3rem; width: 100%; padding: .7rem 1rem; border: 0; background: none;
  font: inherit; font-size: inherit; font-weight: inherit; color: inherit; text-align: left; cursor: pointer; white-space: nowrap;
}
.sort-btn:hover { color: var(--ui-text); }
.sort-btn:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: -2px; border-radius: 4px; }
.sort-ind .ui-icon { width: 14px; height: 14px; }
.sort-ind .sort-up, .sort-ind .sort-down { opacity: .35; }
th.is-sorted { color: var(--ui-ink); }
th.is-sorted:not(.is-desc) .sort-up, th.is-sorted.is-desc .sort-down { opacity: 1; stroke-width: 2.4; }
th.is-sorted:not(.is-desc) .sort-down, th.is-sorted.is-desc .sort-up { opacity: .15; }
.btn-secondary {
  display: inline-flex; align-items: center; gap: .35rem;
  min-height: 40px; padding: .45rem .9rem;
  border: 1px solid var(--ui-line-strong); border-radius: 10px;
  background: var(--ui-surface); color: var(--ui-text);
  font-weight: 600; font-size: .9375rem; cursor: pointer;
}
.btn-secondary:hover:not(:disabled) { border-color: #aebccb; }
.btn-secondary:disabled { opacity: .45; cursor: default; }
.btn-secondary:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.btn-secondary .ui-icon { width: 18px; height: 18px; }

/* ---------- Ficha en panel lateral (<dialog>) ---------- */
.drawer {
  position: fixed; inset: 0 0 0 auto;
  width: min(480px, 100vw); height: 100vh; height: 100dvh; max-width: 100vw; max-height: none;
  margin: 0 0 0 auto; padding: 0;
  border: 0; background: var(--ui-surface); color: var(--ui-text);
  box-shadow: -12px 0 40px rgba(16, 40, 63, .18);
  font-family: var(--ui-font);
}
.drawer[open] { display: flex; flex-direction: column; animation: ui-drawer-in .22s cubic-bezier(.2, .7, .2, 1); }
.drawer::backdrop { background: rgba(16, 40, 63, .45); }
@keyframes ui-drawer-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer *, .drawer *::before, .drawer *::after { box-sizing: border-box; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.25rem 1.25rem 1rem 1.5rem; border-bottom: 1px solid var(--ui-line);
}
.drawer-title { margin: 0 0 .4rem; font-family: var(--ui-font-display); font-size: 1.375rem; font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; }
.drawer-sub { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; font-size: .875rem; color: var(--ui-muted); }
.drawer-sub:empty { display: none; }
.drawer-body { flex: 1; overflow-y: auto; padding: .5rem 1.5rem 2rem; }
.drawer-section { padding: 1.25rem 0; border-top: 1px solid var(--ui-line); }
.drawer-section:first-child { border-top: 0; }
.drawer-section-title { margin: 0 0 .75rem; font-size: 1rem; font-weight: 600; }
.field-list { display: grid; gap: .85rem; margin: 0; }
.field dt { font-size: .8125rem; font-weight: 600; color: var(--ui-muted); }
.field dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
.stack { display: grid; gap: .35rem; }
.contact-link { display: inline-flex; align-items: center; gap: .45rem; color: var(--ui-focus); text-decoration: none; font-weight: 500; }
.contact-link:hover { text-decoration: underline; }
.contact-link .ui-icon { width: 17px; height: 17px; }
.muted { color: var(--ui-muted); }
.text-error { color: var(--ui-error); }

/* =====================================================================
   Botones y formularios comunes
   ===================================================================== */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 42px; padding: .5rem 1.05rem;
  border: 0; border-radius: 10px;
  background: var(--ui-ink); color: #fff;
  font-weight: 600; font-size: .9375rem; cursor: pointer; white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { background: var(--ui-ink-2); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-primary:focus-visible { outline: 3px solid var(--ui-route); outline-offset: 2px; }
.btn-primary .ui-icon { width: 18px; height: 18px; }
.link-btn { padding: .4rem .25rem; border: 0; background: none; color: var(--ui-focus); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.page-head--actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.page-head--actions .page-lead { margin: 0; }

.ui-form { display: grid; gap: .25rem; }
.form-section { margin: 0; padding: 1rem 0 1.25rem; border: 0; border-top: 1px solid var(--ui-line); min-width: 0; }
.ui-form > .form-section:first-of-type { border-top: 0; padding-top: .5rem; }
.form-section-title { float: left; width: 100%; padding: 0; margin-bottom: .75rem; font-size: 1rem; font-weight: 600; color: var(--ui-text); }
.form-section-title ~ * { clear: both; }
.form-note, .form-intro { margin: -.25rem 0 .9rem; font-size: .875rem; color: var(--ui-muted); }
.form-intro { margin: .75rem 0 .25rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-field { display: grid; gap: .35rem; align-content: start; min-width: 0; }
.form-field--full { grid-column: 1 / -1; }
.form-field[hidden], .segmented-btn[hidden] { display: none; }
.ui-label { font-size: .875rem; font-weight: 600; color: var(--ui-text); }
.req { color: var(--ui-error); }
.ui-input, .ui-select {
  width: 100%; min-height: 42px; padding: .55rem .75rem;
  font: inherit; font-size: 1rem; color: var(--ui-text);
  background: var(--ui-surface); border: 1px solid var(--ui-line-strong); border-radius: 9px;
}
textarea.ui-input { min-height: 84px; resize: vertical; line-height: 1.45; }
.ui-select { padding-right: 2rem; }
.ui-input:focus, .ui-select:focus { outline: none; border-color: var(--ui-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-focus) 20%, transparent); }
.field-hint { margin: 0; font-size: .8125rem; color: var(--ui-muted); }
.field-error { margin: 0; font-size: .8125rem; font-weight: 600; color: var(--ui-error); }
.has-error .ui-input, .has-error .ui-select { border-color: var(--ui-error); }
.form-error { margin: .75rem 0 0; padding: .75rem 1rem; border-radius: 10px; background: var(--ui-error-bg); color: var(--ui-error); border-left: 3px solid var(--ui-error); }
.form-error[hidden] { display: none; }
.form-actions {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem;
  margin: .5rem -1.5rem -2rem; padding: .9rem 1.5rem;
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--ui-line);
}
.dup-box .form-actions { position: static; margin: .75rem 0 0; padding: 0; background: none; border: 0; justify-content: flex-start; }

/* Escala BANT 0–3 */
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding: 3px; border-radius: 10px; background: #e6ebf1; }
.scale-option { position: relative; display: block; cursor: pointer; }
.scale-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale-option span {
  display: block; padding: .45rem .25rem; border-radius: 8px; text-align: center;
  font-size: .8125rem; font-weight: 600; color: var(--ui-muted);
}
.scale-input:checked + span { background: var(--ui-surface); color: var(--ui-ink); box-shadow: 0 1px 2px rgba(16, 40, 63, .12); }
.scale-input:focus-visible + span { outline: 2px solid var(--ui-focus); outline-offset: 1px; }

.dup-box { margin: .75rem 0 .5rem; padding: 1rem; border-radius: 10px; background: var(--ui-warn-bg); color: var(--ui-warn); }
.dup-title { margin: 0 0 .5rem; font-weight: 600; }
.dup-box ul { margin: 0; padding-left: 1.2rem; color: var(--ui-text); }

.toast-msg--success { background: var(--ui-ok); }

/* =====================================================================
   Clientes potenciales
   ===================================================================== */

/* Embudo: las etapas abiertas se encadenan como flechas; las cerradas van aparte */
.funnel { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.funnel-steps { flex: 1 1 520px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 0; list-style: none; }
.funnel-closed { flex: 0 1 260px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.funnel-step {
  display: flex; flex-direction: column; justify-content: center; gap: .1rem;
  width: 100%; min-height: 76px; padding: .6rem 1.4rem .6rem 1.6rem;
  border: 0; text-align: left; cursor: pointer;
  background: #e4eaf1; color: var(--ui-text);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%, 16px 50%);
}
.funnel-steps li:first-child .funnel-step { clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%); border-radius: 10px 0 0 10px; padding-left: 1.1rem; }
.funnel-steps li:nth-child(2) .funnel-step { background: #d8e1eb; }
.funnel-steps li:nth-child(3) .funnel-step { background: #ccd8e5; }
.funnel-steps li:nth-child(4) .funnel-step { background: #bfcedf; }
.funnel-closed .funnel-step { clip-path: none; border-radius: 10px; padding: .6rem 1rem; }
.funnel-step--won { background: var(--ui-ok-bg) !important; }
.funnel-step--lost { background: #f1eeee !important; }
.funnel-count { font-family: var(--ui-font-display); font-size: 1.625rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.funnel-name { font-size: .875rem; font-weight: 600; color: var(--ui-muted); }
.funnel-step:hover { filter: brightness(.97); }
.funnel-step:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: -3px; }
.funnel-step[aria-pressed="true"] { background: var(--ui-ink) !important; color: #fff; }
.funnel-step[aria-pressed="true"] .funnel-name { color: rgba(255, 255, 255, .8); }
.funnel-step[aria-pressed="true"] .funnel-count { color: var(--ui-route); }

.toggle-chip {
  display: inline-flex; align-items: center; gap: .45rem;
  min-height: 44px; padding: .45rem .9rem;
  border: 1px solid var(--ui-line-strong); border-radius: 999px;
  background: var(--ui-surface); color: var(--ui-text);
  font-weight: 600; font-size: .9375rem; cursor: pointer;
}
.toggle-chip .ui-icon { width: 18px; height: 18px; color: var(--ui-warn); }
.toggle-chip-count:not(:empty) { padding: .05rem .5rem; border-radius: 999px; background: var(--ui-warn-bg); color: var(--ui-warn); font-size: .8125rem; }
.toggle-chip[aria-pressed="true"] { background: var(--ui-warn-bg); border-color: #e9c27a; color: var(--ui-warn); }
.toggle-chip:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.select-inline .ui-select { min-height: 44px; min-width: 200px; }

/* Etapas, grado y avisos */
.stage--frio { background: #eceff3; color: #4a5866; }
.stage--mql { background: #e5eefa; color: #245a96; }
.stage--sql { background: #efe9fb; color: #5b3fa3; }
.stage--oportunidad { background: var(--ui-warn-bg); color: var(--ui-warn); }
.stage--ganado { background: var(--ui-ok-bg); color: var(--ui-ok); }
.stage--perdido { background: #f6eceb; color: #8f2a20; }
.grade {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 6px;
  font-weight: 700; font-size: .8125rem; background: #eceff3; color: var(--ui-muted);
}
.grade--a { background: var(--ui-ok); color: #fff; }
.grade--b { background: #6aa47f; color: #fff; }
.grade--c { background: #e9c27a; color: #5a3a00; }
.grade--d { background: #d9dde3; color: #4a5866; }
.qual { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.flags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.flags:empty { display: none; }
.flag { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.flag--danger { background: var(--ui-error-bg); color: var(--ui-error); }
.flag--warn { background: var(--ui-warn-bg); color: var(--ui-warn); }
.next-cell { display: grid; gap: .1rem; }
.next-action { font-weight: 500; }
.next-date { font-size: .8125rem; color: var(--ui-muted); }
.next-date.is-late { color: var(--ui-error); font-weight: 600; }

/* Ficha */
.drawer--wide { width: min(620px, 100vw); }
.drawer-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding: 1rem 0 .25rem; }
.next-card { margin: 1rem 0 .5rem; padding: .9rem 1rem; border-radius: 10px; background: #fff7ea; border-left: 4px solid var(--ui-route); }
.next-card.is-late { background: var(--ui-error-bg); border-left-color: var(--ui-error); }
.next-card--closed { background: var(--ui-surface-2); border-left-color: var(--ui-line-strong); }
.next-card-label { font-size: .8125rem; font-weight: 600; color: var(--ui-muted); }
.next-card.is-late .next-card-label { color: var(--ui-error); }
.next-card-action { margin: .15rem 0 0; font-size: 1.0625rem; font-weight: 600; }
.next-card-date { margin: .1rem 0 0; font-size: .9375rem; color: var(--ui-muted); }
.qual-summary { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; }
.qual-summary > div { display: grid; }
.qual-big { font-family: var(--ui-font-display); font-size: 1.75rem; font-weight: 650; line-height: 1.15; }
.bant { display: grid; gap: .45rem; }
.bant-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 320px; }
.bant-label { font-size: .9375rem; }
.bant-dots { display: inline-flex; gap: 4px; }
.bant-dot { width: 22px; height: 8px; border-radius: 4px; background: #e1e6ed; }
.bant-dot.is-on { background: var(--ui-ink); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--ui-line); display: grid; gap: 1rem; }
.timeline-item { position: relative; }
.timeline-item::before {
  content: ""; position: absolute; left: calc(-1rem - 6px); top: .35rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--ui-surface); border: 2px solid var(--ui-line-strong);
}
.timeline-item--llamada::before, .timeline-item--email::before, .timeline-item--reunion::before,
.timeline-item--visita::before, .timeline-item--whatsapp::before { border-color: var(--ui-ink); background: var(--ui-ink); }
.timeline-item--etapa::before { border-color: var(--ui-route); background: var(--ui-route); }
.timeline-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; }
.timeline-type { font-size: .8125rem; font-weight: 600; color: var(--ui-muted); }
.timeline-when { font-size: .8125rem; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.timeline-summary { margin: .1rem 0 0; font-weight: 500; }
.timeline-detail { margin: .25rem 0 0; font-size: .9375rem; color: var(--ui-text); white-space: pre-line; }
.timeline-meta { margin: .2rem 0 0; font-size: .8125rem; color: var(--ui-muted); }
.timeline-meta:empty { display: none; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 991.98px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .22s cubic-bezier(.2, .7, .2, 1), visibility 0s linear .22s;
    box-shadow: 12px 0 40px rgba(16, 40, 63, .25);
  }
  .sidebar[data-open="true"] { transform: none; visibility: visible; transition: transform .22s cubic-bezier(.2, .7, .2, 1); }
  .sidebar .sidebar-close { display: inline-grid; }
  .topbar { padding: .5rem 1rem; padding-top: max(.5rem, env(safe-area-inset-top)); }
  .topbar .topbar-menu { display: inline-grid; margin-left: -.5rem; }
  .content { padding: 1.25rem 1rem 2rem; }
  .kpi { min-height: 0; padding: 1rem 1.25rem; }
  .kpi-value { font-size: 2.125rem; }
  .app-foot { padding: 1rem; }
}

/* Listado en tarjetas en pantallas estrechas */
@media (max-width: 767.98px) {
  .segmented { width: 100%; overflow-x: auto; }
  .segmented-btn { flex: 1; padding: .4rem .5rem; font-size: .875rem; }
  .search { max-width: none; }
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .data-table, .data-table tbody { display: block; }
  .data-table tbody { display: grid; gap: .6rem; }
  .data-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .75rem;
    padding: .9rem 1rem;
    background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius);
  }
  .data-table td { display: block; padding: 0; border: 0 !important; background: none !important; font-size: .875rem; color: var(--ui-muted); }
  .data-table td.col-name { grid-column: 1; grid-row: 1; font-size: 1rem; color: var(--ui-text); }
  .data-table td.col-status { grid-column: 2; grid-row: 1; }
  .data-table td:not(.col-name):not(.col-status) { grid-column: 1 / -1; }
  .data-table td:not(.col-name):not(.col-status)::before { content: attr(data-label) ": "; font-weight: 600; }
  .data-table td:not(.col-name):not(.col-status):not([data-label])::before,
  .data-table td:not(.col-name):not(.col-status)[data-label=""]::before { content: none; }
  .data-table .col-code { width: auto; }
  .row-message td { grid-column: 1 / -1; text-align: center; }
  .drawer, .drawer--wide { width: 100vw; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .funnel-steps { flex-basis: 100%; overflow-x: auto; grid-template-columns: repeat(4, minmax(120px, 1fr)); }
  .funnel-closed { flex-basis: 100%; }
  .funnel-step { min-height: 64px; }
  .funnel-count { font-size: 1.375rem; }
  .select-inline, .select-inline .ui-select { width: 100%; }
  .pager { justify-content: center; }
  .pager-info { width: 100%; text-align: center; }
  .pager-controls { width: 100%; justify-content: center; }
  /* En móvil solo la página actual entre las flechas; para saltar, el campo "Ir a" */
  .pager-pages .pager-btn:not(.is-current), .pager-gap { display: none; }
  .pager-jump { width: 100%; justify-content: center; }
  .sort-mobile { display: flex; align-items: center; gap: .5rem; margin: 0 0 .75rem; font-size: .875rem; font-weight: 600; color: var(--ui-muted); }
  .sort-mobile .ui-select { flex: 1; }
}

/* ===================================================================== Administración */
.tabs { display: flex; gap: .25rem; margin: 0 0 1rem; border-bottom: 1px solid var(--ui-line); overflow-x: auto; scrollbar-width: thin; }
.tab {
  flex: none; padding: .7rem 1rem; margin-bottom: -1px; border-bottom: 3px solid transparent;
  color: var(--ui-muted) !important; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.tab:hover { color: var(--ui-text) !important; }
.tab[aria-current="page"] { color: var(--ui-ink) !important; border-bottom-color: var(--ui-route); }
.tab:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: -2px; border-radius: 6px 6px 0 0; }

.admin-block, .catalog-card {
  margin-top: 1.25rem; padding: 1.25rem; background: var(--ui-surface);
  border: 1px solid var(--ui-line); border-radius: var(--ui-radius);
}
.admin-block-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem 1rem; margin-bottom: .75rem; }
.admin-block-title { margin: 0 0 .25rem; font-family: var(--ui-font-display); font-size: 1.125rem; font-weight: 700; color: var(--ui-ink); }
.admin-block > .muted, .catalog-card > .muted, .admin-block-head .muted { margin: 0 0 1rem; font-size: .9375rem; }
.admin-block .ui-form { max-width: 720px; }
.admin-block .form-section { border: 0; padding: 0; margin: 0; }
/* En la página los formularios no van en panel: botonera normal, no fija */
.admin-block .form-actions { position: static; margin: 1rem 0 0; padding: 0; border: 0; background: none; justify-content: flex-start; }
.data-table--middle td { vertical-align: middle; }
.data-table--middle td .ui-select { max-width: 360px; }

.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { padding: .15rem .55rem; border-radius: 6px; background: #edf1f6; color: var(--ui-ink-2); font-size: .8125rem; font-weight: 600; white-space: nowrap; }

.drawer-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.btn-danger { color: var(--ui-error) !important; }
.btn-danger:hover:not(:disabled) { border-color: var(--ui-error) !important; background: var(--ui-error-bg); }
.form-actions--static { position: static; margin: 1.25rem 0 0; padding: 0; border: 0; background: none; }
.link-btn--danger { color: var(--ui-error); }

/* Grupo de casillas (roles) */
.checks { display: grid; gap: .5rem; }
.check {
  display: flex; align-items: flex-start; gap: .7rem; padding: .7rem .85rem; cursor: pointer;
  border: 1px solid var(--ui-line-strong); border-radius: 10px; background: var(--ui-surface);
}
.check:hover { border-color: #aebccb; }
.check:has(.check-input:checked) { border-color: var(--ui-focus); background: #f0f6fc; }
.check:has(.check-input:focus-visible) { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.check-input { flex: none; width: 18px; height: 18px; margin: .1rem 0 0; accent-color: var(--ui-focus); }
.check-text { display: grid; gap: .1rem; }
.check-label { font-weight: 600; color: var(--ui-text); }
.check-hint { font-size: .8125rem; color: var(--ui-muted); }

/* Contraseña temporal (se muestra una vez) */
.temp-box { padding: 1.1rem; border: 1px solid #f0d6a8; border-radius: var(--ui-radius); background: var(--ui-warn-bg); }
.temp-title { margin: 0 0 .6rem; font-weight: 600; color: var(--ui-text); }
.temp-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.temp-pwd {
  padding: .5rem .8rem; border-radius: 8px; background: var(--ui-surface); border: 1px solid #e7c78f;
  font: 600 1.25rem/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .06em; color: var(--ui-ink);
  user-select: all;
}
.temp-note { margin: .75rem 0 0; font-size: .875rem; color: var(--ui-warn); }

/* Matriz rol × permiso */
.matrix-wrap { max-height: 70vh; overflow: auto; }
.matrix tbody th { position: static; white-space: normal; }
.matrix th[scope="row"] { min-width: 220px; padding: .6rem 1rem; font-size: .9375rem; font-weight: 400; color: var(--ui-text); background: var(--ui-surface); border-bottom: 0; border-top: 1px solid var(--ui-line); }
.matrix tbody tr:hover th[scope="row"], .matrix tbody tr:hover td { background: #f6f9fc; }
.matrix-perm { display: block; }
.matrix thead th { position: sticky; top: 0; z-index: 1; background: var(--ui-surface-2); }
.matrix-cell { text-align: center; width: 1%; white-space: nowrap; }
.matrix-cell input { width: 18px; height: 18px; accent-color: var(--ui-focus); cursor: pointer; }
.matrix-cell input:disabled { cursor: not-allowed; opacity: .6; }
.matrix-group th {
  padding: .5rem .75rem; background: #eef2f7; color: var(--ui-ink-2);
  font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: left;
}

/* Zonas, festivos y formularios en línea */
.note-box { margin-bottom: 1rem; padding: .9rem 1.1rem; border-radius: var(--ui-radius); background: #eef4fb; border: 1px solid #d5e3f2; }
.note-box p { margin: 0; }
.note-box p + p { margin-top: .35rem; font-size: .875rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.inline-form .ui-select, .inline-form .ui-input { width: auto; min-width: 200px; flex: 1 1 200px; max-width: 320px; }
.col-actions { width: 1%; text-align: right; white-space: nowrap; }
.data-table td .ui-select { min-width: 220px; }
.holiday-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ui-line); }
.holiday-list li { display: flex; align-items: center; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--ui-line); }
.holiday-date { min-width: 15rem; font-weight: 600; }
.holiday-list .link-btn { margin-left: auto; }

/* Catálogos */
.catalog-intro { margin: 0; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; align-items: start; }
.catalog-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .35rem; max-height: 420px; overflow-y: auto; }
.catalog-item { display: flex; align-items: center; gap: .5rem; }
.catalog-item.is-off .ui-input { color: var(--ui-muted); text-decoration: line-through; }
.ui-input--inline { border-color: transparent !important; background: transparent; padding-left: .5rem; }
.ui-input--inline:hover { border-color: var(--ui-line-strong) !important; }
.ui-input--inline:focus { border-color: var(--ui-focus) !important; background: var(--ui-surface); }
.catalog-add { display: flex; gap: .5rem; }
.catalog-add .ui-input { flex: 1; }

.switch {
  flex: none; position: relative; width: 40px; height: 24px; padding: 0; border: 0; border-radius: 999px;
  background: #c3ccd6; cursor: pointer; transition: background .15s;
}
.switch-knob {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch.is-on { background: var(--ui-ok); }
.switch.is-on .switch-knob { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }

/* Auditoría */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin-bottom: 1rem; }
.filter { display: grid; gap: .25rem; font-size: .8125rem; font-weight: 600; color: var(--ui-muted); }
.filter .ui-input, .filter .ui-select { min-width: 160px; }
.sev--info { background: #edf1f6; color: var(--ui-ink-2); }
.sev--notice { background: #e8f0fa; color: #1f5a94; }
.sev--warning { background: var(--ui-warn-bg); color: var(--ui-warn); }
.sev--critical { background: var(--ui-error-bg); color: var(--ui-error); }
.sev-text--warning { color: var(--ui-warn); }
.sev-text--critical { color: var(--ui-error); font-weight: 600; }
.code-block {
  margin: 0; max-height: 420px; overflow: auto; padding: .85rem 1rem; border-radius: 8px;
  background: #0f2236; color: #e6edf5; font: .8125rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.text-error { color: var(--ui-error); }

@media (max-width: 767.98px) {
  .admin-block, .catalog-card { padding: 1rem; }
  .inline-form .ui-select, .inline-form .ui-input, .filter, .filter .ui-input, .filter .ui-select { max-width: none; width: 100%; }
  .inline-form > *, .filters > * { flex: 1 1 100%; }
  .data-table td[data-label=""]::before { content: none !important; }
  .data-table td .ui-select { width: 100%; min-width: 0; }
  .holiday-list li { flex-wrap: wrap; gap: .25rem .75rem; }
  .holiday-date { min-width: 0; }
  /* La matriz de permisos se mantiene como tabla con scroll horizontal */
  .matrix-wrap { background: var(--ui-surface); border: 1px solid var(--ui-line); overflow: auto; }
  .matrix, .matrix tbody { display: table; width: 100%; }
  .matrix thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: table-header-group; }
  .matrix tbody { display: table-row-group; }
  .matrix tr { display: table-row; padding: 0; border: 0; border-radius: 0; background: none; }
  .matrix td, .matrix th { display: table-cell; padding: .5rem .6rem; }
  .matrix td::before { content: none !important; }
  .matrix th[scope="row"] { min-width: 180px; }
}

/* Usuarios ↔ empleados del ERP */
.note-box--warn { background: var(--ui-warn-bg); border-color: #f0d6a8; color: var(--ui-text); }
.emp-cell { display: grid; gap: .15rem; justify-items: start; }
.chip--soft { background: var(--ui-surface-2); color: var(--ui-muted); font-weight: 500; }
.emp-filters { display: grid; gap: .75rem; margin-bottom: .5rem; }
.emp-filters .search { max-width: none; }
.emp-checks { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.inline-check { display: inline-flex; align-items: center; gap: .45rem; font-size: .9375rem; cursor: pointer; }
.emp-info { margin: .25rem 0 .75rem; font-size: .875rem; }
.emp-list { display: grid; gap: .5rem; }
.emp-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem;
  padding: .75rem .9rem; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-surface);
}
.emp-main { display: grid; gap: .2rem; min-width: 0; }
.emp-name { font-weight: 600; color: var(--ui-text); }
.emp-main .cell-sub { overflow-wrap: anywhere; }
.emp-row > button { flex: none; }
.emp-warn { margin-top: .35rem; font-size: .875rem; color: var(--ui-warn); }
.emp-summary { display: grid; gap: .15rem; padding: .8rem 1rem; margin-bottom: 1rem; border-radius: 10px; background: #eef4fb; border: 1px solid #d5e3f2; }
@media (max-width: 767.98px) {
  .emp-row { flex-wrap: wrap; }
  .emp-row > button { width: 100%; }
}

/* ===================================================================== Mapa (Fase 3) */
.content--map { max-width: none; padding-bottom: 1rem; display: flex; flex-direction: column; }
.map-page { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: .6rem; }
.map-layers { display: inline-flex; gap: .4rem; }
.layer-btn {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; padding: .4rem .85rem;
  font: inherit; font-size: .9375rem; font-weight: 600; color: var(--ui-muted);
  background: var(--ui-surface); border: 1px solid var(--ui-line-strong); border-radius: 999px; cursor: pointer;
}
.layer-btn[aria-pressed="true"] { color: var(--ui-ink); border-color: var(--ui-ink); }
.layer-btn[aria-pressed="false"] .layer-dot { opacity: .35; }
.layer-btn:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.layer-dot { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; }
.layer-dot--cliente { background: #2f6fb0; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(16, 40, 63, .15); }
.layer-dot--potencial { background: #fff; border: 3.5px solid #e0762b; width: 13px; height: 13px; }
.layer-dot--otro { background: #9db4cc; width: 10px; height: 10px; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(16, 40, 63, .12); }
.map-filters { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1; }
.map-filter .ui-select { width: auto; min-width: 150px; max-width: 205px; }
.map-near-btn { margin-left: auto; }
.map-near-btn .ui-icon { width: 18px; height: 18px; }
.map-status { min-height: 1.25rem; margin: 0 0 .6rem; font-size: .875rem; color: var(--ui-muted); }

.map-body { position: relative; display: flex; flex: none; min-height: 420px; height: calc(100dvh - 260px); }
.map-stage { position: relative; display: flex; flex: 1; min-width: 0; min-height: 0; }
.map-canvas {
  flex: 1; min-width: 0; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); overflow: hidden;
  background: #e9edf1; z-index: 0;
}
.map-panel {
  display: flex; flex-direction: column; width: 360px; flex: none; margin-left: .75rem; min-height: 0; max-height: 100%;
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); overflow: hidden;
}
.map-panel[hidden] { display: none; }
.map-panel-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem .75rem .5rem 1rem; border-bottom: 1px solid var(--ui-line); }
.map-panel-title { margin: 0; font-family: var(--ui-font-display); font-size: 1.0625rem; font-weight: 700; color: var(--ui-ink); }
.map-panel-body { flex: 1; overflow-y: auto; padding: .75rem 1rem 1rem; }
.near-head .ui-select { width: 100%; }
.near-note { margin: .6rem 0 .75rem; font-size: .8125rem; }
.near-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.near-item { border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-surface); }
.near-main {
  display: flex; align-items: flex-start; gap: .6rem; width: 100%; padding: .65rem .75rem .35rem;
  font: inherit; text-align: left; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 10px 10px 0 0;
}
.near-main:hover { background: var(--ui-surface-2); }
.near-main:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: -2px; }
.near-main .layer-dot { margin-top: .3rem; }
.near-text { display: grid; gap: .1rem; flex: 1; min-width: 0; }
.near-name { font-weight: 600; color: var(--ui-text); overflow-wrap: anywhere; }
.near-dist { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ui-ink); white-space: nowrap; }
.near-actions .link-btn { text-decoration: none; font-size: .875rem; }
.near-actions { display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: 0 .75rem .5rem 2.15rem; }

/* Ventana emergente de Leaflet con el estilo del CRM */
.leaflet-container { font-family: var(--ui-font); }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: 0 8px 24px rgba(16, 40, 63, .18); }
.leaflet-popup-content { margin: .85rem 1rem; }
.map-popup { display: grid; gap: .3rem; min-width: 200px; }
.map-popup-title { font-size: 1rem; color: var(--ui-ink); }
.map-popup-sub { font-size: .8125rem; color: var(--ui-muted); }
.map-popup-warn { font-size: .8125rem; color: var(--ui-warn); }
.map-popup-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.btn-sm { min-height: 32px !important; padding: .25rem .65rem !important; font-size: .8125rem !important; border-radius: 8px !important; text-decoration: none; }
a.btn-secondary, a.btn-primary { text-decoration: none; }
.app a.btn-primary, .app a.btn-primary:hover, .app a.btn-primary:visited { color: #fff; }

/* Ubicación de visitas (potenciales) */
.geo-consent { margin: .25rem 0 1rem; }
.geo-consent[hidden] { display: none; }
.timeline-place { display: flex; align-items: center; gap: .35rem; margin: .35rem 0 0; font-size: .8125rem; color: var(--ui-ok); }
.timeline-place .ui-icon { width: 15px; height: 15px; flex: none; }
.timeline-place--far { color: var(--ui-warn); }

/* Barra para corregir una ubicación */
.map-edit {
  position: absolute; left: 50%; bottom: 1rem; z-index: 500; transform: translateX(-50%);
  width: min(640px, calc(100% - 2rem)); padding: .85rem 1rem;
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius);
  box-shadow: 0 10px 30px rgba(16, 40, 63, .22);
}
.map-edit[hidden] { display: none; }
.map-edit-text { margin: 0 0 .6rem; font-size: .9375rem; }
.map-edit-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.map-edit-actions .ui-icon { width: 18px; height: 18px; }

@media (max-width: 991.98px) {
  .map-body { height: calc(100dvh - 230px); }
}
@media (max-width: 767.98px) {
  .content--map { padding: .75rem .75rem .5rem; }
  .map-toolbar { gap: .5rem; }
  .map-filters { flex-basis: 100%; }
  .map-filter { flex: 1 1 140px; }
  .map-filter .ui-select { width: 100%; min-width: 0; }
  .map-near-btn { flex: 1 1 100%; margin-left: 0; }
  .map-layers { flex: 1 1 100%; }
  .layer-btn { flex: 1; justify-content: center; }
  .map-body { height: calc(100dvh - 300px); min-height: 360px; }
  /* Lista de cercanos como hoja inferior sobre el mapa */
  .map-panel {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 600; width: auto; margin: 0;
    max-height: 62%; border-radius: 16px 16px var(--ui-radius) var(--ui-radius); box-shadow: 0 -8px 24px rgba(16, 40, 63, .18);
  }
  .map-edit { bottom: .5rem; }
  .map-edit-actions > * { flex: 1 1 auto; }
}

/* ===================================================================== Panel · análisis comercial */
.analysis { margin-top: 2rem; }
.analysis-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1rem; }
.analysis-title { margin: 0; font-family: var(--ui-font-display); font-size: 1.25rem; font-weight: 700; color: var(--ui-ink); }
.analysis-sub { margin: .15rem 0 0; font-size: .9375rem; color: var(--ui-muted); }
.analysis-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.analysis-filter .ui-select { min-width: 200px; }
.analysis-body { transition: opacity .15s; }
.analysis-body.is-loading { opacity: .55; pointer-events: none; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; margin-bottom: 1rem;
  background: var(--ui-line); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); overflow: hidden; }
.stat { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.15rem; background: var(--ui-surface); }
.stat-label { font-size: .875rem; font-weight: 600; color: var(--ui-muted); }
.stat-value { font-family: var(--ui-font-display); font-size: 1.75rem; font-weight: 700; line-height: 1.15; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.stat-delta { font-size: .8125rem; font-weight: 600; color: var(--ui-text); }
.stat-delta--up span { color: var(--ui-ok); }
.stat-delta--down span { color: var(--ui-error); }
.stat-delta--flat span { color: var(--ui-muted); }
.stat-hint { font-size: .8125rem; color: var(--ui-muted); }

.card-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; }
.card { min-width: 0; padding: 1.15rem 1.25rem; margin-bottom: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.card-grid > .card { margin-bottom: 0; }
.card-head { margin-bottom: .85rem; }
.card-title { margin: 0; font-size: 1rem; font-weight: 700; color: var(--ui-ink); }
.card-sub { margin: .15rem 0 0; font-size: .875rem; color: var(--ui-muted); }

/* Gráficos */
.chart { margin: 0; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: .5rem; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: 0; padding: 0; list-style: none; font-size: .8125rem; color: var(--ui-text); }
.chart-legend li { display: inline-flex; align-items: center; gap: .4rem; }
.chart-key { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.chart-toggle { font-size: .8125rem; }
.chart-plot { position: relative; width: 100%; min-height: 240px; }
.chart-plot[hidden] { display: none; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: #edf0f4; stroke-width: 1; }
.chart-base { stroke: #cfd6de; stroke-width: 1; }
.chart-tick { font-size: 11px; fill: var(--ui-muted); font-variant-numeric: tabular-nums; }
.chart-value { font-size: 11px; font-weight: 600; fill: var(--ui-text); font-variant-numeric: tabular-nums; }
.chart-hit { fill: transparent; }
.chart-col { outline: none; cursor: default; }
.chart-col.is-active .chart-hit, .chart-col:focus-visible .chart-hit { fill: rgba(16, 40, 63, .05); }
.chart-col:focus-visible .chart-hit { stroke: var(--ui-focus); stroke-width: 1.5; }
.chart-tip {
  position: absolute; z-index: 5; min-width: 160px; padding: .6rem .75rem; pointer-events: none;
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: 10px; box-shadow: 0 8px 22px rgba(16, 40, 63, .16);
}
.chart-tip[hidden] { display: none; }
.chart-tip-title { display: block; font-size: .8125rem; color: var(--ui-muted); font-weight: 600; }
.chart-tip-total { display: block; margin-bottom: .35rem; font-size: 1.0625rem; font-weight: 700; color: var(--ui-ink); }
.chart-tip ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.chart-tip li { display: grid; grid-template-columns: 12px auto 1fr; align-items: center; gap: .4rem; font-size: .8125rem; }
.chart-tip-key { width: 12px; height: 2px; border-radius: 1px; }
.chart-tip-val { font-weight: 700; color: var(--ui-text); font-variant-numeric: tabular-nums; text-align: right; }
.chart-tip-name { color: var(--ui-muted); }
.chart-table { margin-top: .25rem; }
.chart-table[hidden], .data-table[hidden] { display: none !important; }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.hbar { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); align-items: center; gap: .75rem; }
.hbar-label { font-size: .9375rem; color: var(--ui-text); text-decoration: none; }
a.hbar-label:hover { text-decoration: underline; }
.hbar-track { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.hbar-fill { display: block; height: 22px; border-radius: 0 4px 4px 0; flex: none; max-width: calc(100% - 3rem); }
.hbar-value { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ui-text); }

/* Tablas del análisis */
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table--compact th, .data-table--compact td { padding: .6rem .8rem; }
.meter-cell { display: inline-flex; align-items: center; gap: .5rem; }
.meter { position: relative; display: inline-block; width: 56px; height: 6px; border-radius: 3px; background: #e6ebf1; overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: #2a78d6; border-radius: 3px; }
.meter-text { min-width: 3.5rem; text-align: right; }
.inline-bar { display: inline-flex; align-items: center; gap: .5rem; justify-content: flex-end; }
.inline-bar-track { position: relative; display: inline-block; width: 70px; height: 6px; }
.inline-bar-fill { position: absolute; right: 0; top: 0; bottom: 0; background: #86b6ef; border-radius: 3px; }

@media (max-width: 991.98px) {
  .card-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
  .analysis-filters, .analysis-filters .segmented { width: 100%; }
  .analysis-filter, .analysis-filter .ui-select { width: 100%; min-width: 0; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 1.4rem; }
  .card { padding: 1rem; }
  .hbar { grid-template-columns: 6rem minmax(0, 1fr); }
  /* Tablas de análisis: se mantienen como tabla (comparar filas es su función) con desplazamiento lateral */
  .card .table-wrap { background: var(--ui-surface); border: 1px solid var(--ui-line); overflow-x: auto; }
  .data-table--compact, .data-table--compact tbody, .chart-table, .chart-table tbody { display: table; width: 100%; }
  .data-table--compact thead, .chart-table thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: table-header-group; }
  .data-table--compact tbody, .chart-table tbody { display: table-row-group; }
  .data-table--compact tr, .chart-table tr { display: table-row; padding: 0; border: 0; border-radius: 0; background: none; }
  .data-table--compact td, .data-table--compact th, .chart-table td, .chart-table th { display: table-cell; padding: .5rem .6rem; font-size: .8125rem; border-top: 1px solid var(--ui-line) !important; }
  .data-table--compact td::before, .chart-table td::before { content: none !important; }
  .data-table--compact .col-name { position: sticky; left: 0; background: var(--ui-surface) !important; z-index: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar[data-open="true"] { transition: none; }
  .drawer[open] { animation: none; }
  .kpi--loading { animation: none; }
  [data-state="loading"] .status-dot { animation: none; }
  .switch, .switch-knob { transition: none; }
  .analysis-body { transition: none; }
}

/* =====================================================================
   Cartera de clientes
   ===================================================================== */
.timeline-type-wrap { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.timeline-type-wrap .chip { font-size: .75rem; padding: .05rem .45rem; }
.cell-sub--mine { color: var(--ui-ok); font-weight: 600; }
.follow-meta { margin: .35rem 0 0; font-size: .875rem; color: var(--ui-muted); }
.drawer .note-box { font-size: .9375rem; }

/* Ventas en la ficha */
.sales .stat-row--compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.sales .stat { padding: .8rem .9rem; }
.sales .stat-value { font-size: 1.35rem; }
.sales-title { margin: 1.1rem 0 .5rem; font-size: .9375rem; font-weight: 700; color: var(--ui-ink); }
.sales-chart .chart { margin: 0; }
.sales-table td, .sales-table th { padding: .5rem .6rem; }
.doc-history { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.doc-history li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .5rem .7rem;
  border: 1px solid var(--ui-line); border-radius: 8px; }
.doc-history-main { display: grid; min-width: 0; font-size: .875rem; }
.doc-history-type { font-weight: 600; font-size: .9375rem; }
.doc-history-side { display: flex; align-items: center; gap: .5rem; flex: none; }

/* Potencial de origen */
.origin-card { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .75rem .9rem;
  border: 1px solid var(--ui-line); border-radius: 10px; }
.origin-card + .origin-card { margin-top: .5rem; }
.origin-card p { margin: 0; }
.origin-name { font-weight: 600; }
.origin-reason { margin-top: .25rem !important; font-size: .875rem; }
.origin-card .muted { font-size: .875rem; }

/* Potencial ganado → cliente del ERP */
.client-link-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  margin: .5rem 0; padding: .8rem 1rem; border-radius: 10px; background: var(--ui-ok-bg); border-left: 4px solid var(--ui-ok); }
.client-link-card.is-pending { background: #eef4fb; border-left-color: var(--ui-focus); }
.client-link-text { min-width: 0; flex: 1 1 260px; }
.client-link-name { margin: .15rem 0 0; font-weight: 600; }
.client-link-card.is-pending .client-link-name { font-weight: 400; font-size: .9375rem; }
.client-link-actions { display: flex; align-items: center; gap: .5rem; }
.client-link-actions a { text-decoration: none; }
.link-search { max-width: none; margin: .75rem 0; }
.link-candidates { display: grid; gap: .4rem; min-height: 3rem; }
.candidate { display: flex; align-items: flex-start; gap: .65rem; padding: .65rem .8rem; border: 1px solid var(--ui-line-strong); border-radius: 10px; cursor: pointer; }
.candidate:has(input:checked) { border-color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-ink); background: #f3f7fc; }
.candidate input { margin-top: .2rem; flex: none; width: 18px; height: 18px; accent-color: var(--ui-ink); }
.candidate-text { display: grid; gap: .15rem; min-width: 0; }
.candidate-name { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-weight: 600; }
.candidate-meta { font-size: .8125rem; color: var(--ui-muted); }

/* =====================================================================
   Presupuestos y ofertas
   ===================================================================== */
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Estado: siempre con texto; el color solo refuerza */
.doc-state { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700;
  letter-spacing: .01em; vertical-align: middle; white-space: nowrap; background: #eceff3; color: #4a5866; }
.doc-state--emitido { background: #e5eefa; color: #245a96; }
.doc-state--enviado { background: #dbe8f8; color: #1c4f86; }
.doc-state--aceptado { background: var(--ui-ok-bg); color: var(--ui-ok); }
.doc-state--rechazado { background: var(--ui-error-bg); color: var(--ui-error); }
.doc-state--caducado { background: var(--ui-warn-bg); color: var(--ui-warn); }
.doc-state--anulado { text-decoration: line-through; }

/* Lista en la ficha del potencial */
.drawer-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: .75rem; }
.drawer-section-head .drawer-section-title { margin: 0; }
.drawer-section-tools { display: flex; flex-wrap: wrap; gap: .4rem; }
.doc-list { display: grid; gap: .5rem; }
.doc-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem .8rem;
  border: 1px solid var(--ui-line); border-radius: 10px; color: inherit; text-decoration: none; }
.doc-row:hover { border-color: var(--ui-line-strong); background: var(--ui-surface-2); }
.doc-row:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.doc-row-main { display: grid; min-width: 0; }
.doc-code { font-size: .8125rem; font-weight: 700; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.doc-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9375rem; }
.doc-row-side { display: grid; justify-items: end; gap: .2rem; flex: none; }
.doc-amount { font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Página del documento */
.doc-page { max-width: 1100px; }
.doc-back { display: inline-flex; align-items: center; gap: .25rem; margin-bottom: .75rem; color: var(--ui-muted); font-weight: 600; text-decoration: none; }
.doc-back:hover { color: var(--ui-ink); }
.doc-head-main { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.doc-kind { margin: 0; font-size: .8125rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-muted); }
.doc-code-title { margin: .1rem 0 .25rem; font-family: var(--ui-font-display); font-size: 1.75rem; font-weight: 650; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.doc-subject { margin: 0; font-size: 1.0625rem; color: var(--ui-text); }
.doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.doc-actions a { text-decoration: none; }
.doc-form .card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; }
.doc-save { display: flex; justify-content: flex-end; }
.doc-empty { margin: 1rem 0 0; padding: 1.25rem; border: 1px dashed var(--ui-line-strong); border-radius: 10px; text-align: center; color: var(--ui-muted); }
.doc-info { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.doc-text + .doc-text { margin-top: 1rem; }
.doc-text p { margin: .35rem 0 0; white-space: pre-line; }

/* Buscador de artículos */
.art-search { position: relative; max-width: 640px; margin-bottom: 1rem; }
.art-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 340px; overflow-y: auto;
  margin: 0; padding: .3rem; list-style: none; background: var(--ui-surface); border: 1px solid var(--ui-line-strong);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(16, 40, 63, .16); }
.art-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 1rem; padding: .55rem .7rem; border-radius: 8px; cursor: pointer; }
.art-option[aria-selected="true"], .art-option:hover { background: #e9f1fb; }
.art-option.is-disabled { cursor: not-allowed; opacity: .6; }
.art-name { font-weight: 600; }
.art-meta { grid-column: 1; font-size: .8125rem; color: var(--ui-muted); }
.art-price { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.art-empty, .art-more { padding: .6rem .7rem; font-size: .875rem; color: var(--ui-muted); }

/* Líneas */
.doc-lines-table th.num, .doc-lines-table td.num { text-align: right; }
.doc-lines-table .col-actions { width: 3rem; text-align: right; }
.doc-lines-table .ui-input { min-height: 38px; padding: .4rem .6rem; font-size: .9375rem; }
.doc-lines-table .col-code { white-space: nowrap; }
.line-desc { min-width: 14rem; min-height: 38px !important; resize: vertical; line-height: 1.35; }
.line-num { width: 6.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.line-num--sm { width: 5rem; }
.ui-input.is-invalid, .ui-input.is-invalid:focus { border-color: var(--ui-error); box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); }
.line-amount { font-weight: 600; }

/* Totales */
.doc-totals { display: flex; justify-content: flex-end; margin-top: 1rem; }
.totals { display: grid; gap: .35rem; min-width: min(360px, 100%); margin: 0; font-variant-numeric: tabular-nums; }
.totals > div { display: flex; justify-content: space-between; gap: 2rem; }
.totals dt { font-weight: 400; color: var(--ui-muted); }
.totals dd { margin: 0; }
.totals-grand { margin-top: .25rem; padding: .6rem .8rem; border-radius: 8px; background: var(--ui-ink); color: #fff; font-weight: 700; font-size: 1.0625rem; }
.totals-grand dt { color: #fff; font-weight: 700; }
.totals--single { min-width: 0; max-width: 360px; }

/* Ventana modal */
.modal { width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 0; border-radius: 14px;
  background: var(--ui-surface); color: var(--ui-text); font-family: var(--ui-font); box-shadow: 0 24px 64px rgba(16, 40, 63, .28); }
.modal[open] { display: flex; flex-direction: column; overflow: hidden; }
.modal::backdrop { background: rgba(16, 40, 63, .45); }
.modal *, .modal *::before, .modal *::after { box-sizing: border-box; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem .25rem; }
.modal-title { margin: 0; font-family: var(--ui-font-display); font-size: 1.25rem; font-weight: 650; }
.modal-body { flex: 1 1 auto; min-height: 0; padding: 0 1.25rem 1.25rem; overflow-y: auto; }
.modal .form-actions { position: static; display: flex; justify-content: flex-end; gap: .5rem; margin: 1rem 0 0; padding: 0; border: 0; background: none; box-shadow: none; }

/* Página pública para el cliente (/p/{token}) */
.pub { box-sizing: border-box; width: 100%; max-width: 760px; margin: 0 auto; padding: 2rem 1rem 3rem; font-family: var(--ui-font); color: var(--ui-text); }
.pub *, .pub *::before, .pub *::after { box-sizing: border-box; }
.pub-brand { margin: 0 0 1.25rem; font-family: var(--ui-font-display); font-size: 1.25rem; font-weight: 700; color: var(--ui-ink); }
.pub-card { padding: 1.5rem; margin-bottom: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: 14px; }
.pub-kind { margin: 0; font-size: .8125rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-muted); }
.pub-title { margin: .2rem 0 .35rem; font-family: var(--ui-font-display); font-size: 1.5rem; font-weight: 650; line-height: 1.25; }
.pub-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; margin: .5rem 0 0; padding: 0; list-style: none; color: var(--ui-muted); font-size: .9375rem; }
.pub-meta strong { color: var(--ui-text); font-weight: 600; }
.pub-amount { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin-top: 1.25rem;
  padding: 1rem 1.1rem; border-radius: 10px; background: var(--ui-surface-2); }
.pub-amount-value { font-family: var(--ui-font-display); font-size: 1.75rem; font-weight: 700; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.pub-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.pub-actions a { text-decoration: none; }
.pub-lines { width: 100%; margin-top: 1rem; border-collapse: collapse; font-size: .9375rem; }
.pub-lines th { padding: .5rem; font-size: .8125rem; color: var(--ui-muted); text-align: left; border-bottom: 1px solid var(--ui-line); }
.pub-lines td { padding: .55rem .5rem; border-bottom: 1px solid var(--ui-line); vertical-align: top; }
.pub-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin: .5rem 0 1rem; }
.pub-choice label { display: flex; align-items: center; gap: .55rem; padding: .8rem .9rem; border: 1px solid var(--ui-line-strong); border-radius: 10px; cursor: pointer; font-weight: 600; }
.pub-choice input { width: 18px; height: 18px; accent-color: var(--ui-ink); }
.pub-choice label:has(input:checked) { border-color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-ink); background: #f3f7fc; }
.pub-choice input:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.pub-field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.pub-result { display: flex; gap: .75rem; align-items: flex-start; }
.pub-foot { margin-top: 1.5rem; font-size: .8125rem; color: var(--ui-muted); text-align: center; }

@media (max-width: 767.98px) {
  .doc-head-main { align-items: stretch; }
  .doc-actions { width: 100%; }
  .doc-actions > * { flex: 1 1 auto; justify-content: center; }
  .doc-code-title { font-size: 1.4rem; }
  .line-num, .line-num--sm { width: 100%; }
  .doc-totals { justify-content: stretch; }
  .totals { width: 100%; }
  /* Editor de líneas en móvil: tarjeta por línea con los campos en dos columnas */
  .doc-lines-edit tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .55rem .75rem; }
  .doc-lines-edit td { min-width: 0; }
  .doc-lines-edit td.col-code { grid-column: 1; grid-row: 1; align-self: center; }
  .doc-lines-edit td.col-code::before, .doc-lines-edit td.col-actions::before { content: none !important; }
  .doc-lines-edit td.col-actions { grid-column: 2 !important; grid-row: 1; justify-self: end; width: auto; }
  .doc-lines-edit td.col-desc { grid-column: 1 / -1; }
  .doc-lines-edit td.num { grid-column: auto !important; text-align: left !important; }
  .doc-lines-edit td::before { display: block; margin-bottom: .2rem; }
  .doc-lines-edit td.line-amount { grid-column: 1 / -1 !important; text-align: right !important; font-size: 1rem; color: var(--ui-text); }
  .doc-lines-edit td.line-amount::before { display: inline; }
  .doc-lines-edit .line-desc { min-width: 0; width: 100%; }
  .pub-card { padding: 1.1rem; }
  .pub-choice { grid-template-columns: minmax(0, 1fr); }
  .pub-lines thead { display: none; }
  .pub-lines tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--ui-line); }
  .pub-lines td { padding: .1rem 0; border: 0; }
  .pub-lines td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .pub-lines td:nth-child(2) { text-align: left !important; color: var(--ui-muted); }
}
.audit-scope { margin: 0 0 .75rem; }

/* =====================================================================
   Agenda «Mi día»
   ===================================================================== */
.agenda { max-width: 960px; }
.agenda-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1rem; }
.agenda-head .page-lead { margin: 0; }
.agenda-filters { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; }
.agenda-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat--late .stat-value { color: var(--ui-error); }
.agenda-day { margin-bottom: 1.25rem; }
.agenda-day-title { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; font-size: 1rem; font-weight: 700; color: var(--ui-ink); }
.agenda-day.is-late .agenda-day-title { color: var(--ui-error); }
.agenda-count { padding: .05rem .5rem; border-radius: 999px; background: #e6ebf1; color: var(--ui-muted); font-size: .8125rem; font-weight: 600; }
.agenda-day.is-late .agenda-count { background: var(--ui-error-bg); color: var(--ui-error); }
.agenda-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.agenda-item { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) auto; align-items: center; gap: .75rem;
  padding: .75rem 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-left: 4px solid var(--ui-line-strong); border-radius: 10px; }
.agenda-item--cliente { border-left-color: #1baf7a; }
.agenda-item--potencial { border-left-color: #2a78d6; }
.agenda-day.is-late .agenda-item { background: #fffafa; }
.agenda-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ui-ink); }
.agenda-day.is-late .agenda-time { font-size: .8125rem; color: var(--ui-error); }
.agenda-main { min-width: 0; }
.agenda-main p { margin: 0; }
.agenda-name { font-weight: 700; color: var(--ui-text); text-decoration: none; }
.agenda-name:hover { color: var(--ui-focus); text-decoration: underline; }
.agenda-action { margin-top: .1rem !important; }
.agenda-meta { margin-top: .15rem !important; font-size: .8125rem; color: var(--ui-muted); }
.agenda-kind { font-weight: 600; }
.agenda-kind--cliente { color: #12754f; }
.agenda-kind--potencial { color: #1c5cab; }
.agenda-actions { display: flex; align-items: center; gap: .4rem; }
.agenda-actions a { text-decoration: none; }
.agenda-call { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--ui-line-strong); border-radius: 50%; color: var(--ui-ink); }
.agenda-call:hover { background: var(--ui-surface-2); }
.agenda-empty { padding: 2rem 1rem; text-align: center; border: 1px dashed var(--ui-line-strong); border-radius: var(--ui-radius); }
.agenda-empty p { margin: 0 0 .25rem; }

@media (max-width: 767.98px) {
  .agenda-filters, .agenda-filters .segmented { width: 100%; }
  .agenda-filters .select-inline, .agenda-filters .ui-select { width: 100%; }
  .agenda-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .agenda-summary .stat { padding: .7rem .75rem; }
  .agenda-summary .stat-value { font-size: 1.35rem; }
  .agenda-summary .stat-hint { display: none; }
  .agenda-item { grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .75rem; padding: .7rem .8rem; }
  .agenda-time { grid-column: 1 / -1; font-size: .8125rem; }
}

/* ---------- Ruta del día ---------- */
.route-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.route-back { display: inline-flex; align-items: center; gap: .25rem; text-decoration: none; }
.route-body { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.route-panel { padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.route-title { margin: 0; font-size: 1.0625rem; font-weight: 700; color: var(--ui-ink); }
.route-summary { margin: .25rem 0 .75rem; font-size: .875rem; }
.route-list { display: grid; gap: .4rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.route-stop { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; align-items: center; gap: .6rem;
  padding: .55rem .6rem; border: 1px solid var(--ui-line); border-radius: 10px; }
.route-num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 700; font-size: .875rem; }
.route-stop--cliente .route-num { background: #12754f; }
.route-stop--potencial .route-num { background: #1c5cab; }
.route-stop-main { min-width: 0; }
.route-stop-main p { margin: 0; }
.route-stop-name { font-weight: 700; color: var(--ui-text); text-decoration: none; }
.route-stop-name:hover { text-decoration: underline; color: var(--ui-focus); }
.route-stop-action { font-size: .9375rem; }
.route-stop-meta { font-size: .8125rem; color: var(--ui-muted); }
.route-move { display: flex; flex-direction: column; gap: 2px; }
.route-move .icon-btn { width: 30px; height: 26px; font-size: .9375rem; }
.route-move .icon-btn:disabled { opacity: .3; cursor: default; }
.route-links { display: grid; gap: .5rem; }
.route-links a { justify-content: center; text-decoration: none; }
.route-subtitle { margin: 1.1rem 0 .4rem; font-size: .9375rem; font-weight: 700; }
.route-unplaced { margin: 0; padding-left: 1.1rem; font-size: .9375rem; }
.route-map { min-height: 70vh; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); overflow: hidden; position: sticky; top: 1rem; }
.route-pin { display: grid !important; place-items: center; border-radius: 50%; border: 2px solid #fff; color: #fff; font: 700 13px/1 var(--ui-font);
  box-shadow: 0 1px 4px rgba(16, 40, 63, .45); }
.route-pin--cliente { background: #12754f; }
.route-pin--potencial { background: #1c5cab; }
#routeStart[aria-pressed="true"] { border-color: var(--ui-focus); color: var(--ui-focus); }

@media (max-width: 899.98px) {
  .route-body { grid-template-columns: minmax(0, 1fr); }
  .route-map { position: relative; top: 0; min-height: 52vh; order: -1; }
  .route-toolbar .select-inline, .route-toolbar .ui-select { flex: 1 1 200px; }
}
.route-links a.btn-primary, .route-links a.btn-primary:hover { color: #fff; }

/* ---------- Alertas de cartera ---------- */
.alerts-page { max-width: 1100px; }
.alert-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: .75rem; }
.alert-tab { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .8rem 1rem; border: 1px solid var(--ui-line-strong);
  border-radius: 10px; background: var(--ui-surface); color: var(--ui-text); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.alert-tab[aria-pressed="true"] { border-color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-ink); background: #f3f7fc; }
.alert-tab:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.alert-tab-count { padding: .1rem .55rem; border-radius: 999px; background: var(--ui-warn-bg); color: var(--ui-warn); font-variant-numeric: tabular-nums; }
.alerts-help { margin: 0 0 .75rem; }
.alerts-other { margin-top: .3rem; }
.alerts-foot { margin-top: 1rem; font-size: .8125rem; }
@media (max-width: 767.98px) {
  .alert-tabs { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Campana de avisos ---------- */
.notif { position: relative; margin-left: auto; }
.notif-btn { position: relative; }
.notif-count {
  position: absolute; top: 3px; right: 1px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--ui-error); color: #fff; box-shadow: 0 0 0 2px var(--ui-bg);
  font-size: .6875rem; font-weight: 700; line-height: 18px; text-align: center;
}
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  width: min(380px, calc(100vw - 2rem));
  display: flex; flex-direction: column; max-height: min(560px, calc(100vh - 90px));
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius);
  box-shadow: 0 12px 32px rgba(16, 40, 63, .16);
}
.notif-panel[hidden] { display: none; }
.notif-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--ui-line);
}
.notif-head .btn-link { padding: 0 !important; min-height: 0 !important; color: var(--ui-focus); }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  display: grid; gap: .15rem; padding: .7rem 1rem .7rem 1.1rem;
  border-bottom: 1px solid var(--ui-line); color: var(--ui-text); text-decoration: none; position: relative;
}
a.notif-item:hover, .notif-item:focus-visible { background: var(--ui-surface-2); outline: none; }
.notif-item.is-unread { background: #f2f7fc; }
.notif-item.is-unread::before {
  content: ""; position: absolute; left: .45rem; top: 1.05rem;
  width: 6px; height: 6px; border-radius: 50%; background: var(--ui-focus);
}
.notif-item.is-unread .notif-title { font-weight: 650; }
.notif-meta { font-size: .75rem; color: var(--ui-muted); }
.notif-tag { font-weight: 650; }
.notif-tag-danger { color: var(--ui-error); }
.notif-tag-warn { color: var(--ui-warn); }
.notif-tag-ok { color: var(--ui-ok); }
.notif-tag-info { color: var(--ui-ink-2); }
.notif-title { font-size: .875rem; line-height: 1.35; color: var(--ui-ink); }
.notif-detail { font-size: .8125rem; color: var(--ui-muted); line-height: 1.35; }
.notif-empty { margin: 0; padding: 1.25rem 1rem; color: var(--ui-muted); font-size: .875rem; }
.notif-foot {
  display: flex; align-items: center; gap: .5rem; margin: 0;
  padding: .7rem 1rem .7rem 3rem; border-top: 1px solid var(--ui-line);
  font-size: .8125rem; color: var(--ui-muted); background: var(--ui-surface-2);
  border-radius: 0 0 var(--ui-radius) var(--ui-radius);
}
@media (max-width: 767.98px) {
  .notif-panel { position: fixed; left: 1rem; right: 1rem; width: auto; top: 64px; }
}

/* ---------- Seguimiento de presupuestos ---------- */
.docs-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat--button {
  border: 0; text-align: left; font: inherit; cursor: pointer; color: inherit;
  position: relative;
}
.stat--button:hover { background: var(--ui-surface-2); }
.stat--button:hover .stat-label { color: var(--ui-focus); }
.stat--button:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: -2px; }
.stat--button.is-active { box-shadow: inset 0 -3px 0 var(--ui-ink); }
.stat--warn .stat-value { color: var(--ui-warn); }
.cell-sub.is-warn { color: var(--ui-warn); font-weight: 600; }
.is-late-text { color: var(--ui-error); font-weight: 600; }
.row-link--plain { font-weight: 500; }
.data-table td.col-status .doc-state { white-space: nowrap; }
@media (max-width: 1100px) {
  .docs-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
  .docs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.docs-page .col-code { width: 9.5rem; }
.docs-page a.row-link { text-decoration: none; }
.docs-page a.row-link:hover { text-decoration: underline; }
/* Duplicar: elección del potencial de destino */
.dup-target { display: grid; gap: .5rem; }
.dup-results { display: grid; gap: 2px; max-height: 240px; overflow-y: auto; border: 1px solid var(--ui-line); border-radius: 10px; }
.dup-results:empty { display: none; }
.dup-result {
  display: grid; gap: .1rem; padding: .55rem .8rem; border: 0; background: var(--ui-surface); text-align: left; cursor: pointer; font: inherit; color: var(--ui-text);
}
.dup-result:hover, .dup-result:focus-visible { background: var(--ui-surface-2); outline: none; }
.dup-result[aria-pressed="true"] { background: #eaf2fb; box-shadow: inset 3px 0 0 var(--ui-focus); }
.dup-result small { color: var(--ui-muted); }
.dup-target { margin: 0 0 1rem; padding: 0; border: 0; min-width: 0; }
.dup-target legend { margin-bottom: .35rem; }
.dup-empty { margin: 0; padding: .6rem .8rem; }
.docs-page .col-code a.row-link { white-space: nowrap; }
.docs-page td.col-status .cell-sub {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 16rem;
}
@media (max-width: 767.98px) {
  .docs-page .col-code .cell-sub { display: inline; margin-left: .4rem; }
  .docs-page td.col-status { text-align: right; max-width: 9.5rem; }
  .docs-page td.col-status .cell-sub { font-size: .75rem; margin-left: auto; }
}

/* ---------- Puntuación automática (temperatura) ---------- */
.score {
  display: inline-flex; align-items: center; gap: .2rem; min-width: 2.6rem; justify-content: center;
  padding: .1rem .5rem; border-radius: 999px; font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.score--caliente { background: #fde8e4; color: #a3271a; }
.score--templado { background: var(--ui-warn-bg); color: var(--ui-warn); }
.score--frio { background: #e8eef5; color: #3d5873; }
.score .score-icon { width: 14px; height: 14px; }
.qual-big .score { font-size: 1.375rem; padding: .15rem .75rem; }
.qual-big .score .score-icon { width: 20px; height: 20px; }
.qual-summary .link-btn { display: block; margin-top: .25rem; font-size: .8125rem; }
.toggle-chip--hot .ui-icon { color: #c2410c; }
.toggle-chip--hot[aria-pressed="true"] { background: #fde8e4; border-color: #f1b3a8; color: #a3271a; }
.score-detail { margin: 0 0 1rem; padding: .85rem 1rem; border-radius: 10px; background: var(--ui-surface-2); border: 1px solid var(--ui-line); }
.score-sum { margin: 0 0 .6rem; }
.score-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.score-list li { display: grid; grid-template-columns: 1fr auto 3.5rem; gap: .75rem; align-items: baseline; padding: .3rem 0; border-bottom: 1px solid var(--ui-line); font-size: .875rem; }
.score-list li:last-child { border-bottom: 0; }
.score-when { font-size: .8125rem; white-space: nowrap; }
.score-pts { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ui-ok); }
.score-pts.is-neg { color: var(--ui-error); }
.score-foot { margin: .6rem 0 0; font-size: .8125rem; }
.admin-block .form-section + .form-section { margin-top: 1.25rem; }

.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.filter-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; margin: 0 0 1rem; padding: .6rem 1rem; border-radius: 10px; background: #eef4fb; border: 1px solid #d5e3f2; font-size: .9375rem; }
.filter-banner[hidden] { display: none; }

/* ---------- Importación de potenciales ---------- */
.import-page { max-width: 1100px; }
.import-steps { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0 1.25rem; padding: 0; list-style: none; counter-reset: paso; }
.import-steps li {
  counter-increment: paso; display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .8rem .35rem .4rem; border-radius: 999px; background: #e6ebf1; color: var(--ui-muted); font-size: .875rem; font-weight: 600;
}
.import-steps li::before {
  content: counter(paso); display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--ui-surface); color: var(--ui-muted); font-size: .8125rem;
}
.import-steps li[aria-current="step"] { background: var(--ui-ink); color: #fff; }
.import-steps li[aria-current="step"]::before { color: var(--ui-ink); }
.import-steps li.is-done { background: var(--ui-ok-bg); color: var(--ui-ok); }
.import-steps li.is-done::before { content: "✓"; color: var(--ui-ok); }
.import-panel, .import-history { padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.import-panel[hidden] { display: none; }
.import-title { margin: 0 0 .35rem; font-size: 1.125rem; font-weight: 700; color: var(--ui-ink); }
.import-subtitle { margin: 1.5rem 0 .5rem; font-size: 1rem; font-weight: 700; color: var(--ui-ink); }
.import-drop { margin-top: 1rem; }
.import-drop-label {
  display: grid; justify-items: center; gap: .35rem; padding: 2rem 1rem; border: 2px dashed var(--ui-line-strong); border-radius: var(--ui-radius);
  background: var(--ui-surface-2); text-align: center; cursor: pointer;
}
.import-drop-label:hover, .import-drop.is-over .import-drop-label { border-color: var(--ui-focus); background: #f0f6fc; }
.import-drop:has(input:focus-visible) .import-drop-label { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.import-drop-icon { width: 32px; height: 32px; color: var(--ui-focus); }
.import-drop-text { font-weight: 600; }
.import-map tr.is-skipped td { color: var(--ui-muted); }
.import-map tr.is-skipped td:first-child strong { font-weight: 500; text-decoration: line-through; text-decoration-color: var(--ui-line-strong); }
.import-map .ui-select { min-width: 15rem; }
.import-sample { max-width: 22rem; color: var(--ui-muted); font-size: .875rem; overflow-wrap: anywhere; }
.import-dups { display: grid; gap: .35rem; margin-top: 1rem; padding: 0; border: 0; }
.import-sla { margin-top: .75rem; flex-wrap: wrap; }
.import-stats { margin-top: 1rem; }
.stat--late .stat-value { color: var(--ui-error); }
.import-tag { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: #e6ebf1; color: var(--ui-muted); }
.import-tag--error { background: var(--ui-error-bg); color: var(--ui-error); }
.import-tag--duplicado, .import-tag--repetido { background: var(--ui-warn-bg); color: var(--ui-warn); }
.import-tag--ok { background: #eef4fb; color: #245a96; }
.import-progress { width: 100%; height: 12px; margin-top: 1rem; accent-color: var(--ui-ink); }
.import-status { margin: .5rem 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.form-actions--start { justify-content: flex-start; flex-wrap: wrap; }
.import-actions { white-space: nowrap; text-align: right; }
@media (max-width: 767.98px) {
  .import-panel, .import-history { padding: 1rem; }
  .import-map .ui-select { min-width: 0; width: 100%; }
}

/* ---------- Contactos ---------- */
.drawer-section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.drawer-section-head .drawer-section-title { margin: 0; }
.contact-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.contact-card { display: grid; gap: .25rem; padding: .75rem .9rem; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-surface); }
.contact-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.contact-card-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.contact-card-notes { margin: .15rem 0 0; font-size: .875rem; color: var(--ui-muted); white-space: pre-line; }
.contact-card-actions { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-top: .15rem; }
.contact-card-actions .link-btn { padding: .2rem 0; font-size: .875rem; }
.badge--decisor { background: #efe8fb; color: #5b3a9e; }
.mail-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .4rem; font-size: .875rem; }
.chip--action { border: 1px solid var(--ui-line-strong); background: var(--ui-surface); cursor: pointer; font: inherit; font-size: .8125rem; padding: .15rem .6rem; border-radius: 999px; color: var(--ui-ink); }
.chip--action:hover { border-color: var(--ui-focus); color: var(--ui-focus); }
.col-date { white-space: nowrap; }
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 110px; margin: .75rem 0; padding: 1rem; border: 1px dashed var(--ui-line-strong); border-radius: 10px; background: #fff; }
.logo-preview img { max-width: 100%; max-height: 120px; object-fit: contain; }
label.btn-secondary { cursor: pointer; }

/* ---------- Adjuntos ---------- */
.att-section { position: relative; border-radius: 10px; transition: background-color .15s, box-shadow .15s; }
.att-section.is-drop { background: #eef4fb; box-shadow: 0 0 0 2px var(--ui-focus); }
.att-section.is-busy .att-tools { opacity: .55; pointer-events: none; }
.att-tools { display: flex; gap: .4rem; }
.att-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.att-item { display: grid; grid-template-columns: 64px 1fr; gap: .75rem; align-items: start; padding: .6rem; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-surface); }
.att-thumb { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--ui-surface-2); }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-thumb--file { flex-direction: column; gap: .15rem; color: var(--ui-muted); font-size: .6875rem; font-weight: 600; letter-spacing: .02em; }
.att-thumb--file .ui-icon { width: 22px; height: 22px; }
.att-info { display: grid; gap: .2rem; min-width: 0; }
.att-name { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-weight: 600; }
.att-name a { overflow-wrap: anywhere; }
.att-desc { margin: 0; font-size: .875rem; white-space: pre-line; }
.att-hint { margin: .5rem 0 0; font-size: .8125rem; color: var(--ui-muted); }
.att-status { margin: 0 0 .5rem; font-size: .875rem; font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .att-camera { display: none; } }
@media not ((hover: hover) and (pointer: fine)) { .att-drag { display: none; } }

/* ---------- Modo sin conexión ---------- */
.chip--alert { background: var(--ui-warn-bg); color: var(--ui-warn); }
.off-app { display: block; min-height: 100vh; padding-bottom: 3rem; }
.off-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: var(--ui-ink); color: #fff; }
.off-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; text-decoration: none; }
.app .off-brand { color: #fff; }
.off-brand img { border-radius: 7px; }
.off-net { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; font-size: .875rem; font-weight: 600; }
.off-net-dot { width: .6rem; height: .6rem; border-radius: 50%; background: #9db4cc; }
.off-net.is-online .off-net-dot { background: #4cc38a; }
.off-net.is-offline .off-net-dot { background: var(--ui-route); }
.off-net.is-checking .off-net-dot { background: #9db4cc; }
.app a.off-backcrm { color: var(--ui-ink); background: #fff; }
.off-tabs { position: sticky; top: 3.1rem; z-index: 19; display: flex; overflow-x: auto; background: var(--ui-surface); border-bottom: 1px solid var(--ui-line); }
.off-tabs a { flex: 1 1 auto; padding: .8rem .6rem; font-size: .9375rem; text-align: center; font-weight: 600; text-decoration: none; color: var(--ui-muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.app .off-tabs a { color: var(--ui-muted); }
.app .off-tabs a[aria-current="page"] { color: var(--ui-ink); border-bottom-color: var(--ui-ink); }
.off-count { display: inline-block; min-width: 1.35rem; padding: 0 .35rem; border-radius: 999px; background: var(--ui-ink); color: #fff; font-size: .75rem; line-height: 1.35rem; }
.off-count.is-warn { background: var(--ui-warn); }
.off-main { max-width: 760px; margin: 0 auto; padding: 1rem; }
.off-notice[hidden] { display: none; }
.off-notice { max-width: 760px; margin: 1rem auto 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.off-notice p { flex: 1 1 14rem; }
.off-stamp { max-width: 760px; margin: 0 auto; padding: 0 1rem; font-size: .8125rem; }
.off-title { font-size: 1.25rem; margin: .25rem 0 .75rem; }
.off-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.off-head .off-title { margin-bottom: .5rem; }
.off-main input[type=search] { width: 100%; margin-bottom: .75rem; }
.off-group { margin-bottom: 1.25rem; }
.off-group-title { font-size: .9375rem; margin-bottom: .5rem; }
.off-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-surface); overflow: hidden; }
.off-list li + li { border-top: 1px solid var(--ui-line); }
.off-row { display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem; min-height: 3.25rem; text-decoration: none; }
.app .off-row { color: var(--ui-text); }
.off-row:hover, .off-row:focus-visible { background: var(--ui-surface-2); }
.off-row-main { display: grid; gap: .15rem; flex: 1; min-width: 0; }
.off-row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.off-row-subs { display: grid; gap: .1rem; }
.off-row > .ui-icon { flex: none; width: 18px; color: var(--ui-muted); }
.off-empty { padding: .75rem 0; }
.off-note { font-size: .8125rem; }
.off-back { display: inline-flex; align-items: center; gap: .25rem; margin-bottom: .5rem; font-weight: 600; text-decoration: none; }
.off-ficha-head { margin-bottom: .75rem; }
.off-ficha-head .off-title { margin-bottom: .15rem; }
.off-errors { margin: .25rem 0 0; padding-left: 1.1rem; font-size: .875rem; color: var(--ui-error); }
.off-blank { max-width: 420px; margin: 2.5rem auto; text-align: center; display: grid; gap: .75rem; justify-items: center; }
.off-blank img { border-radius: 14px; }
.off-main .drawer-actions { margin-bottom: 1rem; }
.off-main .form-actions { position: sticky; bottom: 0; padding: .75rem 0; background: var(--ui-bg); }

/* Estado en la app en línea */
.sidebar-offline { display: flex; align-items: center; gap: .5rem; margin: 0 .75rem .5rem; padding: .5rem .65rem; border-radius: 8px; font-size: .8125rem; color: rgba(255, 255, 255, .72); text-decoration: none; }
.app a.sidebar-offline { color: rgba(255, 255, 255, .72); }
.app a.sidebar-offline:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.sidebar-offline .off-net-dot { flex: none; }
.sidebar-offline.is-ready .off-net-dot { background: #4cc38a; }
.offline-chip { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; margin-right: .5rem; padding: .3rem .7rem; border-radius: 999px; background: var(--ui-surface-2); border: 1px solid var(--ui-line-strong); font-size: .8125rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.app a.offline-chip { color: var(--ui-ink); }
.offline-chip.is-warn { background: var(--ui-warn-bg); border-color: #f0d6a8; }
.app a.offline-chip.is-warn { color: var(--ui-warn); }
.offline-chip:not([hidden]) + .notif { margin-left: 0; }
.offline-chip[hidden], .sidebar-offline[hidden] { display: none; }
.off-app [hidden] { display: none !important; }

/* ---------- Rendimiento comercial ---------- */
.perf-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.perf-month { display: inline-flex; align-items: center; gap: .25rem; }
.perf-month-title { margin: 0; min-width: 11rem; text-align: center; font-size: 1.25rem; font-family: var(--ui-font-display); }
.perf-sub { margin: 0; flex: 1 1 14rem; }
.perf-head #perfGoals { margin-left: auto; }
.perf-goals { margin-bottom: 1rem; }
.perf-goal-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.perf-goal { display: flex; flex-direction: column; gap: .35rem; padding: 1.1rem 1.2rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.perf-goal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.perf-goal-title { margin: 0; font-size: .9375rem; font-weight: 600; color: var(--ui-muted); }
.perf-goal-value { margin: 0; font-family: var(--ui-font-display); font-size: 1.75rem; font-weight: 700; line-height: 1.15; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.perf-goal-of { font-size: 1rem; font-weight: 500; color: var(--ui-muted); }
.perf-goal-bar { display: flex; align-items: center; gap: .6rem; margin-top: .2rem; }
.perf-goal-pct { min-width: 3.2rem; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.perf-goal-note { margin: 0; font-size: .875rem; }
.perf-goal-hint { margin: auto 0 0; font-size: .8125rem; color: var(--ui-muted); }
.perf-bar { position: relative; flex: 1; height: 10px; border-radius: 5px; background: #e6ebf1; overflow: visible; }
.perf-bar--sm { height: 6px; border-radius: 3px; width: 72px; flex: none; }
.perf-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: #86b6ef; }
.perf-bar-fill--ok { background: #1baf7a; }
.perf-bar-fill--info { background: #2a78d6; }
.perf-bar-fill--warn { background: #eda100; }
.perf-bar-fill--bad { background: #e34948; }
.perf-bar-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ui-ink); border-radius: 1px; }
.perf-chip { padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.perf-chip--ok { background: var(--ui-ok-bg); color: var(--ui-ok); }
.perf-chip--info { background: #eaf2fc; color: #1c5cab; }
.perf-chip--warn { background: var(--ui-warn-bg); color: var(--ui-warn); }
.perf-chip--bad { background: var(--ui-error-bg); color: var(--ui-error); }
.perf-chip--soft { background: var(--ui-surface-2); color: var(--ui-muted); }
.perf-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem 1rem; margin-bottom: .75rem; }
.perf-card-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.perf-table td.perf-cell { min-width: 9.5rem; }
.perf-cell-value { display: block; font-variant-numeric: tabular-nums; }
.perf-cell-value .cell-sub { display: inline; }
.perf-cell-bar { display: inline-flex; align-items: center; gap: .4rem; margin-top: .25rem; }
.perf-cell-pct { min-width: 2.6rem; font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.perf-cell-state { display: block; font-size: .75rem; color: var(--ui-error); font-weight: 600; }
.perf-cell-state--good { color: var(--ui-ok); }
.perf-block { display: block; }
.perf-goals-table .perf-goal-input { width: 8rem; text-align: right; }
.perf-goals-table th[scope=row] { font-weight: 600; }
.modal--wide { width: min(760px, calc(100vw - 2rem)); }
.chart-key--line { width: 14px; height: 0; border-top: 2px solid var(--ui-ink); border-radius: 0; align-self: center; }
.chart-target { stroke: var(--ui-ink); stroke-width: 2; stroke-linecap: round; }
.chart-target-halo { stroke: var(--ui-surface); stroke-width: 5; stroke-linecap: round; }
@media (max-width: 767.98px) {
  .perf-month-title { min-width: 0; font-size: 1.125rem; }
  .perf-head #perfGoals { margin-left: 0; }
  .perf-goals-table .perf-goal-input { width: 100%; }
}
.perf [hidden] { display: none !important; }

/* ---------- Revisión general ---------- */
/* El atributo hidden siempre oculta, aunque una clase fije display (no depender de que Bootstrap esté instalado) */
[hidden] { display: none !important; }
/* Objetivos táctiles cómodos (≥ 44 px) en móviles y tabletas */
@media (pointer: coarse) {
  .ui-alert-close { min-width: 44px; min-height: 44px; }
  .contact-link { display: inline-flex; align-items: center; min-height: 44px; }
  .link-btn { min-height: 44px; padding-top: .4rem; padding-bottom: .4rem; }
  .btn-sm { min-height: 44px; }
  .contact-card-actions { gap: .25rem 1.25rem; }
}

/* ---------- Planificador y «Mi día» ---------- */
.plan-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.plan-toolbar-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }
.plan-toolbar-actions a, .plan-toolbar-actions button { text-decoration: none; }
.date-nav { display: inline-flex; align-items: center; gap: .25rem; }
.date-nav-label { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 .85rem; border: 1px solid var(--ui-line-strong);
  border-radius: 10px; background: var(--ui-surface); cursor: pointer; }
.date-nav-label:focus-within { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.date-nav-text { font-family: var(--ui-font-display); font-size: 1.0625rem; font-weight: 650; color: var(--ui-ink); white-space: nowrap; }
/* El <input type="date"> cubre la etiqueta: al pulsarla se abre el calendario del sistema */
.date-nav-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; }
.date-nav-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.myday-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat--ok .stat-value { color: var(--ui-ok); }
.plan-filter { flex-wrap: wrap; margin-bottom: 1rem; }
.plan-filter-count { margin-left: .4rem; color: var(--ui-muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.myday-body { display: grid; gap: 1rem; align-items: start; }
.myday.has-map .myday-body { grid-template-columns: minmax(0, 1fr) minmax(320px, 44%); }
.myday-map { position: sticky; top: 1rem; display: grid; gap: .75rem; padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.myday-map-head { display: grid; gap: .25rem; }
.myday-map-head .route-summary { margin: 0; }
.myday-map-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .25rem; }
.myday-map-tools [aria-pressed="true"] { border-color: var(--ui-focus); color: var(--ui-focus); background: #f0f6fc; }
.myday-map-canvas { position: static; min-height: 420px; height: 55vh; }

.plan-section { margin-bottom: 1.25rem; }
.plan-section-title { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; font-size: 1rem; font-weight: 700; color: var(--ui-ink); }
.plan-section.is-late .plan-section-title { color: var(--ui-error); }
.plan-section.is-late .agenda-count { background: var(--ui-error-bg); color: var(--ui-error); }
.plan-section.is-unplanned .plan-section-title { color: var(--ui-warn); }
.plan-section-note { margin: -.25rem 0 .5rem; font-size: .875rem; }
.plan-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.plan-item { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr) auto; align-items: start; gap: .75rem; padding: .75rem .9rem;
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-left: 4px solid #2a78d6; border-radius: 10px; }
.plan-item--cliente { border-left-color: #1baf7a; }
.plan-item.is-late { background: #fffafa; }
.plan-item.is-done { background: var(--ui-surface-2); border-left-color: #b9c4cf; }
.plan-item.is-done .plan-name, .plan-item.is-done .plan-action { color: var(--ui-muted); }
.plan-item.is-cancelled { background: var(--ui-surface-2); border-left-color: #d6dde5; opacity: .8; }
.plan-item.is-cancelled .plan-name { text-decoration: line-through; color: var(--ui-muted); }
.plan-item--unplanned { border-left-style: dashed; }
.plan-when { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; padding-top: .1rem; }
.plan-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ui-ink); font-size: .9375rem; }
.plan-item.is-late .plan-time { color: var(--ui-error); font-size: .8125rem; }
.plan-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #1c5cab; color: #fff; font-weight: 700; font-size: .8125rem; }
.plan-item--cliente .plan-num { background: #12754f; }
.plan-item.is-done .plan-num { background: #8c99a6; }
.plan-main { min-width: 0; display: grid; gap: .15rem; }
.plan-main p { margin: 0; }
.plan-line { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.plan-tipo { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem .1rem .4rem; border-radius: 999px; background: #edf1f6;
  color: var(--ui-ink-2); font-size: .75rem; font-weight: 700; letter-spacing: .01em; }
.plan-tipo .ui-icon { width: 14px; height: 14px; }
.plan-tipo--visita { background: #fff1de; color: #7a4600; }
.plan-tipo--llamada { background: #e8f1fb; color: #1c5cab; }
.plan-tipo--reunion { background: #efeafd; color: #4b3aa8; }
.plan-tipo--whatsapp { background: #e6f4ec; color: #1e7a4c; }
.plan-state { display: inline-flex; align-items: center; gap: .2rem; font-size: .75rem; font-weight: 700; }
.plan-state .ui-icon { width: 14px; height: 14px; }
.plan-state--done { color: var(--ui-ok); }
.plan-state--cancelled { color: var(--ui-muted); }
.plan-name { font-weight: 700; color: var(--ui-text); text-decoration: none; overflow-wrap: anywhere; }
.plan-name:hover { color: var(--ui-focus); text-decoration: underline; }
.plan-action { color: var(--ui-text); }
.plan-notes { font-size: .875rem; color: var(--ui-muted); white-space: pre-line; }
.plan-result { font-size: .875rem; color: var(--ui-text); }
.plan-sub, .plan-meta { font-size: .8125rem; color: var(--ui-muted); }
.plan-kind { font-weight: 600; }
.plan-kind--cliente { color: #12754f; }
.plan-kind--potencial { color: #1c5cab; }
.plan-late-tag { color: var(--ui-error); font-weight: 600; }
.is-warn-text { color: var(--ui-warn); }
.plan-buttons { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .4rem; }
.plan-buttons--edit { flex-wrap: nowrap; }
.plan-call { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--ui-line-strong); border-radius: 50%; color: var(--ui-ink); }
.plan-call:hover { background: var(--ui-surface-2); }
.route-pin--done { background: #8c99a6 !important; }

/* Semana del planificador */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .4rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.week-day { display: grid; justify-items: center; gap: .1rem; width: 100%; padding: .45rem .25rem; border: 1px solid var(--ui-line); border-radius: 10px;
  background: var(--ui-surface); font: inherit; color: var(--ui-text); cursor: pointer; }
.week-day:hover { border-color: var(--ui-focus); }
.week-day:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.week-day.is-past { background: var(--ui-surface-2); color: var(--ui-muted); }
.week-day.is-today .week-day-num { color: var(--ui-focus); }
.week-day.is-selected { border-color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-ink); }
.week-day-name { font-size: .75rem; text-transform: capitalize; color: var(--ui-muted); }
.week-day-num { font-family: var(--ui-font-display); font-size: 1.125rem; font-weight: 700; }
.week-day-count { min-width: 1.5rem; padding: 0 .35rem; border-radius: 999px; font-size: .75rem; font-weight: 700; color: var(--ui-muted); text-align: center; }
.week-day-count.has-pending { background: #e8f1fb; color: #1c5cab; }

.planner-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 1rem; align-items: start; }
.planner-main { display: grid; gap: 1rem; min-width: 0; }
.planner-card { padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.planner-card-head { display: grid; gap: .2rem; margin-bottom: .75rem; }
.planner-card-title { margin: 0; font-size: 1.0625rem; font-weight: 700; color: var(--ui-ink); }
.planner-card-sub { margin: 0; font-size: .875rem; }
.planner-map { position: static; min-height: 360px; height: 46vh; margin-bottom: .75rem; }
.planner-side { position: sticky; top: 1rem; display: grid; gap: .75rem; max-height: calc(100dvh - 2rem); overflow-y: auto; }
.planner-side[hidden] { display: none !important; }
.planner-search { width: 100%; }
.planner-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.planner-tabs .segmented-btn { padding-left: .35rem; padding-right: .35rem; font-size: .8125rem; white-space: normal; line-height: 1.2; }
.planner-tab-note { margin: 0; font-size: .8125rem; }
.pick-list { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.pick-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .55rem .65rem;
  border: 1px solid var(--ui-line); border-left: 3px solid #2a78d6; border-radius: 8px; }
.pick-item--cliente { border-left-color: #1baf7a; }
.pick-main { min-width: 0; }
.pick-main p { margin: 0; }
.pick-name { font-weight: 650; color: var(--ui-text); text-decoration: none; overflow-wrap: anywhere; }
.pick-name:hover { text-decoration: underline; color: var(--ui-focus); }
.pick-sub, .pick-extra { font-size: .8125rem; color: var(--ui-muted); }
.pick-empty { padding: .5rem 0; font-size: .875rem; }

/* Propuesta de cambios de datos */
.change-box { margin: 1rem 0 0; padding: .75rem 1rem; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-surface-2); }
.change-box summary { cursor: pointer; font-weight: 650; color: var(--ui-ink); }
.change-box[open] summary { margin-bottom: .5rem; }
.change-box > * + * { margin-top: .5rem; }
.change-box textarea { width: 100%; }
.change-rows { display: grid; gap: .4rem; }
.change-row { display: grid; grid-template-columns: minmax(140px, 38%) minmax(0, 1fr) auto; gap: .4rem; align-items: center; }
.change-grid { display: grid; gap: .75rem; }
.change-card { padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-left: 4px solid var(--ui-warn); border-radius: var(--ui-radius); }
.change-card--A { border-left-color: var(--ui-ok); }
.change-card--R { border-left-color: #b9c4cf; }
.change-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .6rem; }
.change-client { font-weight: 700; font-size: 1.0625rem; color: var(--ui-text); text-decoration: none; }
.change-client:hover { text-decoration: underline; color: var(--ui-focus); }
.change-sub { margin: .1rem 0 0; font-size: .8125rem; }
.change-state { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.change-state--P { background: var(--ui-warn-bg); color: var(--ui-warn); }
.change-state--A { background: var(--ui-ok-bg); color: var(--ui-ok); }
.change-state--R { background: #edf1f6; color: var(--ui-muted); }
.change-table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.change-table th, .change-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--ui-line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.change-table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ui-muted); }
.change-table tbody th { font-weight: 600; width: 28%; }
.change-old { color: var(--ui-muted); }
.change-new { font-weight: 650; color: var(--ui-ink); }
.change-comment, .change-review { margin: .6rem 0 0; font-size: .875rem; }
.change-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
.change-mini { display: grid; gap: .35rem; margin: 0 0 .6rem; padding: 0; list-style: none; font-size: .875rem; }

@media (max-width: 1100px) {
  .planner-body { grid-template-columns: 1fr; }
  .planner-side { position: static; max-height: none; }
  .myday.has-map .myday-body { grid-template-columns: 1fr; }
  .myday-map { position: static; order: -1; }
}
@media (max-width: 767.98px) {
  .plan-toolbar-actions { margin-left: 0; width: 100%; }
  .plan-toolbar-actions > * { flex: 1 1 auto; justify-content: center; }
  .myday-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-item { grid-template-columns: 3.25rem minmax(0, 1fr); }
  .plan-buttons { grid-column: 1 / -1; justify-content: flex-start; }
  .plan-buttons--edit { justify-content: flex-end; }
  .plan-buttons--edit .route-move { flex-direction: row; gap: .25rem; margin-right: auto; }
  .week-strip { gap: .25rem; }
  .week-day { padding: .35rem .1rem; }
  .change-row { grid-template-columns: 1fr auto; }
  .change-row select { grid-column: 1 / -1; }
  .myday-map-canvas, .planner-map { height: 50vh; min-height: 300px; }
}

/* Calendario del móvil */
.cal-dialog { display: grid; gap: .75rem; }
.cal-dialog p { margin: 0; }
.cal-url-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
.cal-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8125rem; }
.modal .cal-actions { margin-top: 0; justify-content: flex-start; }
.cal-steps { padding: .75rem 1rem; border-radius: 10px; background: var(--ui-surface-2); border: 1px solid var(--ui-line); }
.cal-steps ul { margin: .35rem 0 .5rem; padding-left: 1.1rem; display: grid; gap: .35rem; font-size: .9375rem; }
.cal-title { margin: 0; font-size: .9375rem; font-weight: 700; }
.cal-note { font-size: .8125rem; }
.cal-meta { margin: 0; }
@media (max-width: 767.98px) { .cal-url-row { grid-template-columns: 1fr; } }

/* ---------- Pipeline de oportunidades ---------- */
.pipe-toolbar { flex-wrap: wrap; }
.pipe-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pipe-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.pipe-hint { margin: 0 0 0 auto; font-size: .8125rem; }
.pipe-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; align-items: start; }
.pipe-col { display: flex; flex-direction: column; gap: .5rem; min-height: 200px; padding: .6rem; background: #eef2f6; border: 2px solid transparent; border-radius: var(--ui-radius); }
.pipe-col.is-drop { border-color: var(--ui-focus); background: #e6f0fb; }
.pipe-board.is-dragging .pipe-col:not(.is-drop) { border-style: dashed; border-color: var(--ui-line-strong); }
.pipe-col--cierre { min-width: 150px; max-width: 190px; background: transparent; border: 0; padding-top: .6rem; }
.pipe-col-head { padding: .1rem .25rem .25rem; }
.pipe-col-title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin: 0; font-size: .9375rem; font-weight: 700; color: var(--ui-ink); }
.pipe-col-prob { font-size: .75rem; font-weight: 600; color: var(--ui-muted); }
.pipe-col-n { margin: .15rem 0 0; font-size: .8125rem; color: var(--ui-text); font-variant-numeric: tabular-nums; }
.pipe-col-w { margin: 0; font-size: .8125rem; font-weight: 700; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.pipe-col--1 .pipe-col-head { border-top: 3px solid #86b6ef; padding-top: .35rem; }
.pipe-col--2 .pipe-col-head { border-top: 3px solid #5598e7; padding-top: .35rem; }
.pipe-col--3 .pipe-col-head { border-top: 3px solid #2a78d6; padding-top: .35rem; }
.pipe-col--4 .pipe-col-head { border-top: 3px solid #1c5cab; padding-top: .35rem; }
.pipe-list { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; max-height: 68vh; overflow-y: auto; }
.pipe-card { display: grid; gap: .2rem; padding: .6rem .7rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: 10px; box-shadow: 0 1px 2px rgba(16, 40, 63, .06); }
.pipe-card[draggable="true"] { cursor: grab; }
.pipe-card.is-dragging { opacity: .45; }
.pipe-card.is-late { border-left: 3px solid var(--ui-error); }
.pipe-card p { margin: 0; }
.pipe-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .25rem; }
.pipe-card-name { font-weight: 700; color: var(--ui-text); text-decoration: none; overflow-wrap: anywhere; line-height: 1.25; }
.pipe-card-name:hover { color: var(--ui-focus); text-decoration: underline; }
.pipe-card-edit { width: 28px; height: 28px; flex: none; margin: -.2rem -.3rem 0 0; }
.pipe-card-edit .ui-icon { width: 16px; height: 16px; }
.pipe-card-money { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; font-variant-numeric: tabular-nums; }
.pipe-prob { font-size: .75rem; font-weight: 700; color: var(--ui-muted); }
.pipe-prob.is-own { color: var(--ui-focus); }
.pipe-card-sub, .pipe-card-meta { font-size: .8125rem; color: var(--ui-muted); }
.pipe-card-sub a { color: inherit; }
.pipe-card-alert { display: flex; align-items: center; gap: .25rem; font-size: .75rem; color: var(--ui-warn); }
.pipe-card-alert .ui-icon { width: 14px; height: 14px; flex: none; }
.pipe-empty { padding: .5rem .25rem; font-size: .8125rem; }
.pipe-more { font-size: .8125rem; font-weight: 600; padding: 0 .25rem; }
.pipe-drop { display: grid; gap: .15rem; place-items: center; min-height: 110px; padding: .75rem; text-align: center; border: 2px dashed var(--ui-line-strong); border-radius: var(--ui-radius); background: var(--ui-surface); font-size: .875rem; }
.pipe-drop--won strong { color: var(--ui-ok); }
.pipe-drop--lost strong { color: var(--ui-error); }
.pipe-drop.is-drop { border-style: solid; border-color: var(--ui-focus); background: #e6f0fb; }
.pipe-forecast { display: grid; gap: 1.25rem; }
.pipe-chart, .pipe-owners { padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); display: grid; gap: .75rem; }
.pipe-chart > p { margin: 0; font-size: .875rem; }
.pipe-section-title { margin: 0; font-size: 1.0625rem; font-weight: 700; color: var(--ui-ink); }
.pipe-table .is-late-row th, .pipe-table .is-late-row td { color: var(--ui-error); }
.pipe-table .is-muted-row th, .pipe-table .is-muted-row td { color: var(--ui-muted); }
.pipe-note { margin: 0; }
@media (max-width: 1100px) { .pipe-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 767.98px) {
  .pipe-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipe-stats .stat:last-child { grid-column: 1 / -1; }
  .pipe-board { grid-auto-columns: 82%; scroll-snap-type: x mandatory; }
  .pipe-col { scroll-snap-align: start; }
  .pipe-hint { margin-left: 0; }
}

/* ---------- Formulario público de captación (/f/…) ---------- */
.embed-body { margin: 0; font-family: var(--ui-font); color: var(--ui-text); background: transparent; }
.embed-shell { max-width: 640px; margin: 0 auto; padding: 1rem; }
.wf-title { margin: 0 0 .5rem; font-family: var(--ui-font-display); font-size: 1.5rem; font-weight: 700; color: var(--ui-ink); }
.wf-text { margin: 0 0 1rem; color: var(--ui-muted); }
.wf-form { display: grid; gap: .9rem; }
.wf-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.wf-field { display: grid; gap: .3rem; }
.wf-field > label { font-weight: 600; font-size: .9375rem; }
.wf-field .ui-input { width: 100%; box-sizing: border-box; }
.wf-check { display: flex; gap: .55rem; align-items: flex-start; font-size: .9375rem; }
.wf-check input { margin-top: .2rem; width: 18px; height: 18px; flex: none; }
.wf-submit { justify-self: start; min-width: 10rem; justify-content: center; }
.wf-note { margin: 0; font-size: .8125rem; color: var(--ui-muted); }
.wf-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.wf-done { padding: 2rem 1rem; text-align: center; }
.wf .field-error { margin: 0; }
@media (max-width: 520px) { .wf-row { grid-template-columns: 1fr; } }

/* ---------- Captación y ROI ---------- */
.cap-toolbar { flex-wrap: wrap; justify-content: space-between; }
.cap-period { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; font-size: .875rem; }
.cap-period[hidden] { display: none; }
.cap-period label { display: inline-flex; align-items: center; gap: .4rem; }
.cap-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cap-card { display: grid; gap: .5rem; margin-bottom: 1rem; padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.cap-title { margin: 0; font-size: 1.0625rem; font-weight: 700; color: var(--ui-ink); }
.cap-note { margin: 0; font-size: .8125rem; }
.cap-table th[scope="row"] { font-weight: 600; }
.cap-table th[scope="row"] .cell-sub { display: block; font-weight: 400; }
.cap-table tfoot th, .cap-table tfoot td { font-weight: 700; border-top: 2px solid var(--ui-line-strong); }
.cap-roi.is-pos { color: var(--ui-ok); font-weight: 700; }
.cap-roi.is-neg { color: var(--ui-error); font-weight: 700; }
.cap-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.cap-head p { margin: 0; flex: 1 1 24rem; }
.cap-list { display: grid; gap: .5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.cap-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .75rem .9rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: 10px; }
.cap-item.is-off { opacity: .7; }
.cap-item-main { display: grid; gap: .15rem; min-width: 0; }
.cap-item-nums { display: grid; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.cap-links { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-top: .25rem; }
.cap-forms { display: grid; gap: .75rem; }
.cap-form { display: grid; gap: .5rem; padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.cap-form.is-off { opacity: .7; }
.cap-form-head { display: flex; justify-content: space-between; gap: .75rem; }
.cap-form-head > div { display: grid; gap: .15rem; }
.cap-form-stats { margin: 0; font-size: .875rem; }
.cap-url-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .5rem; align-items: center; }
.cap-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8125rem; }
.cap-embed summary { cursor: pointer; font-weight: 600; font-size: .875rem; }
.cap-embed[open] { display: grid; gap: .5rem; }
.cap-code { margin: .5rem 0 0; padding: .75rem; overflow-x: auto; background: var(--ui-surface-2); border: 1px solid var(--ui-line); border-radius: 8px; font-size: .8125rem; white-space: pre-wrap; word-break: break-all; }
@media (max-width: 1100px) { .cap-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 767.98px) {
  .cap-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cap-item { grid-template-columns: minmax(0, 1fr) auto; }
  .cap-item-nums { grid-column: 1; text-align: left; }
  .cap-url-row { grid-template-columns: 1fr 1fr; }
  .cap-url { grid-column: 1 / -1; }
}
.cap-table th, .cap-table td { padding: .55rem .6rem; font-size: .8125rem; }
.cap-table thead th { white-space: normal; line-height: 1.2; vertical-align: bottom; }
.cap-table th[scope="row"] { min-width: 9rem; }
.cap-table th[scope="row"] { white-space: normal; max-width: 13rem; }

/* ---------------------------------------------------------------- correos */
.mail-sig { margin-top: .5rem; padding: .6rem .75rem; background: var(--ui-bg, #f3f6fa); border: 1px dashed var(--ui-line-strong); border-radius: 8px; }
.mail-sig-label { display: block; font-size: .75rem; font-weight: 600; color: var(--ui-muted); margin-bottom: .2rem; }
.mail-sig pre, .cor-body, .cor-tpl-body { margin: 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-sig pre { font-size: .8125rem; color: var(--ui-muted); }
.mail-vars { margin-top: .5rem; font-size: .8125rem; }
.mail-vars summary { cursor: pointer; font-weight: 600; color: var(--ui-ink); }
.mail-vars dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .75rem; margin: .5rem 0 0; }
.mail-vars dt { margin: 0; }
.mail-vars dd { margin: 0; color: var(--ui-muted); }
.drawer-actions .btn-secondary { display: inline-flex; align-items: center; gap: .4rem; }
.cor-filters { flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.cor-filters .ui-input { flex: 1 1 16rem; }
.cor-filters .ui-select { flex: 0 1 14rem; width: auto; }
.cor-table tbody tr.is-clickable { cursor: pointer; }
.cor-table tbody tr.is-clickable:hover, .cor-table tbody tr.is-clickable:focus-visible { background: var(--ui-hover, #f3f6fa); }
.cor-table .cell-sub .icon { width: 14px; height: 14px; vertical-align: -2px; }
.cell-nowrap { white-space: nowrap; }
.cor-meta { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; font-size: .875rem; }
.cor-meta dt { color: var(--ui-muted); font-weight: 600; }
.cor-meta dd { margin: 0; overflow-wrap: anywhere; }
.cor-subject { font-size: 1.0625rem; margin: 0 0 .5rem; }
.cor-body { padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: 8px; line-height: 1.55; max-height: 55vh; overflow: auto; }
.cor-group { margin: 1.25rem 0 .5rem; }
.cor-tpl { display: grid; gap: .4rem; padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.cor-tpl.is-off { opacity: .65; }
.cor-tpl-actions { display: flex; align-items: flex-start; gap: .5rem; }
.cor-tpl-subject { margin: 0; font-weight: 600; }
.cor-tpl-body { font-size: .875rem; color: var(--ui-ink); max-height: 9.5rem; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
/* secuencias */
.seq-card { display: flex; gap: .75rem; align-items: flex-start; justify-content: space-between; padding: .75rem .9rem; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-surface); }
.seq-card.is-active { border-left: 4px solid var(--ui-ok); background: var(--ui-ok-bg); }
.seq-card-main { display: grid; gap: .15rem; min-width: 0; font-size: .875rem; }
.seq-hint { font-size: .75rem; }
.seq-last { margin: 0 0 .5rem; font-size: .875rem; }
.seq-section .btn-secondary { display: inline-flex; align-items: center; gap: .4rem; }
.seq-form { display: grid; gap: .35rem; }
.seq-form .form-actions { margin-top: .5rem; }
.seq-steps { display: flex; flex-wrap: wrap; gap: .35rem .5rem; margin: 0; padding: 0; list-style: none; font-size: .8125rem; }
.seq-steps li { display: inline-flex; gap: .35rem; align-items: center; padding: .25rem .6rem; background: var(--ui-bg); border: 1px solid var(--ui-line); border-radius: 999px; }
.seq-step-day { font-weight: 700; color: var(--ui-ink); }
.seq-results { margin: 0; font-size: .8125rem; color: var(--ui-muted); }
.seq-results strong { color: var(--ui-ok); }
.seq-editor { display: grid; gap: .5rem; margin: 0 0 .5rem; padding: 0; list-style: none; }
.seq-editor-row { display: grid; grid-template-columns: auto 5rem auto minmax(0, 1fr) 2.25rem; gap: .5rem; align-items: center; font-size: .875rem; }
.seq-editor-label { color: var(--ui-muted); white-space: nowrap; }
@media (max-width: 560px) {
  .seq-editor-row { grid-template-columns: auto 4.5rem auto 2.25rem; }
  .seq-editor-row .ui-select { grid-column: 1 / -1; grid-row: 2; }
  .seq-card { flex-direction: column; }
}
.wf-form { margin: 1rem 0; }
.cap-head > .ui-select { width: auto; flex: 0 0 auto; }

/* ---------------------------------------------------------------- verificación en dos pasos */
.auth-card--wide { max-width: 560px; }
.auth-input--code { font-size: 1.375rem; letter-spacing: .2em; font-variant-numeric: tabular-nums; text-align: center; }
.auth-check { display: flex; gap: .6rem; align-items: flex-start; font-size: .9375rem; line-height: 1.4; cursor: pointer; }
.auth-check input { width: 1.1rem; height: 1.1rem; margin-top: .1rem; flex: none; }
.auth-hint--muted { color: var(--auth-muted, #5d6b79); }
.sec-steps { margin: 0 0 1.5rem; padding-left: 1.25rem; display: grid; gap: .6rem; line-height: 1.5; }
.sec-qr { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1.25rem; align-items: center; margin-bottom: 1.25rem; }
.sec-qr img { width: 200px; height: 200px; border: 1px solid var(--auth-line, #d6dde5); border-radius: 8px; background: #fff; }
.sec-qr p { margin: 0 0 .5rem; }
.sec-key { display: block; margin: .25rem 0 .5rem; padding: .5rem .75rem; background: #f3f6fa; border-radius: 6px; font-size: 1rem; letter-spacing: .05em; word-break: break-all; }
.sec-step2 { margin: 0 0 .75rem; }
.sec-status { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.sec-facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem; margin: 0 0 1.5rem; font-size: .9375rem; }
.sec-facts dt { font-weight: 600; }
.sec-facts dd { margin: 0; color: var(--auth-muted, #5d6b79); }
.sec-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.5rem; }
.sec-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem 1.5rem; margin: 1rem 0; padding-left: 1.5rem; }
.sec-codes code { font-size: 1.0625rem; letter-spacing: .06em; }
@media (max-width: 520px) {
  .sec-qr { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .sec-facts { grid-template-columns: 1fr; }
}
@media print {
  .guest-body .auth-legal, .guest-body .sec-actions, .guest-body .auth-submit { display: none !important; }
}

/* ---------------------------------------------------------------- duplicados */
.dup-groups { display: grid; gap: 1rem; margin-top: 1rem; }
.dup-group { display: grid; gap: .6rem; padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.dup-table tr.is-keep td { background: var(--ui-ok-bg); }
.dup-keep { display: inline-flex; align-items: center; gap: .4rem; font-size: .8125rem; font-weight: 700; color: var(--ui-ok); cursor: pointer; }
.dup-data { font-size: .8125rem; overflow-wrap: anywhere; }
.dup-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.dup-heads { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .75rem; position: relative; }
.dup-card { display: grid; gap: .25rem; padding: .75rem .9rem; border: 1px solid var(--ui-line); border-radius: 10px; font-size: .875rem; }
.dup-card--keep { border-left: 4px solid var(--ui-ok); background: var(--ui-ok-bg); }
.dup-card--dup { border-left: 4px solid var(--ui-warn); }
.dup-role { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ui-muted); }
.dup-swap { grid-column: 1 / -1; justify-self: center; }
.dup-compare th[scope="row"] { width: 11rem; font-weight: 600; vertical-align: top; }
.dup-compare td { vertical-align: top; width: 40%; }
.dup-compare tr.is-same td { color: var(--ui-muted); }
.dup-opt { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; overflow-wrap: anywhere; }
.dup-opt input { margin-top: .2rem; flex: none; }
.dup-opt.is-empty { color: var(--ui-muted); font-style: italic; cursor: default; }
.dup-note { margin: .75rem 0 0; font-size: .8125rem; color: var(--ui-muted); }
.merge-results { display: grid; gap: .25rem; margin: .5rem 0 1rem; padding: 0; list-style: none; }
.merge-results a { display: grid; gap: .1rem; padding: .6rem .75rem; border: 1px solid var(--ui-line); border-radius: 8px; color: inherit; text-decoration: none; }
.merge-results a:hover, .merge-results a:focus-visible { border-color: var(--ui-focus); background: var(--ui-bg); }
@media (max-width: 640px) { .dup-heads { grid-template-columns: 1fr; } .dup-compare th[scope="row"] { width: auto; } }
@media (max-width: 640px) {
  .dup-compare thead { display: none; }
  .dup-compare, .dup-compare tbody, .dup-compare tr, .dup-compare th, .dup-compare td { display: block; width: auto; }
  .dup-compare tr { padding: .6rem .75rem; border-bottom: 1px solid var(--ui-line); }
  .dup-compare th[scope="row"] { padding: 0 0 .35rem; border: 0; background: none; }
  .dup-compare td { padding: .25rem 0; border: 0; }
  .dup-compare td::before { content: none !important; }
}

/* ---------------------------------------------------------------- jornada */
.jor-toolbar { flex-wrap: wrap; gap: .75rem; justify-content: space-between; }
.jor-date { display: flex; align-items: center; gap: .35rem; }
.jor-date .ui-input { width: auto; }
.jor-date .icon-btn { font-size: 1.25rem; line-height: 1; }
.jor-user { width: auto; min-width: 14rem; }
.jor-export { display: flex; flex-wrap: wrap; gap: .5rem; }
.jor-export[hidden] { display: none; }
.jor-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.jor-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.jor-side { display: grid; gap: 1rem; }
.jor-card { padding: 1rem; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.jor-card .cap-title { margin-bottom: .75rem; }
.jor-timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.jor-act { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr); gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--ui-line); }
.jor-act:first-child { border-top: 0; }
.jor-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ui-ink); }
.jor-act-main { display: grid; gap: .2rem; min-width: 0; }
.jor-act-head { display: flex; flex-wrap: wrap; gap: .2rem .5rem; align-items: baseline; }
.jor-type { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ui-muted); }
.jor-act--visita .jor-type { color: var(--ui-ok); }
.jor-act--etapa .jor-type, .jor-act--documento .jor-type { color: #6b4fa0; }
.jor-act-text { margin: 0; font-size: .875rem; overflow-wrap: anywhere; }
.chip--warn { background: var(--ui-warn-bg); color: var(--ui-warn); }
.jor-map { height: 300px; border-radius: 8px; overflow: hidden; border: 1px solid var(--ui-line); }
.jor-plan { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.jor-plan li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .6rem; align-items: start; font-size: .875rem; }
.jor-plan li > div { display: grid; gap: .1rem; min-width: 0; }
.jor-team tbody tr.is-clickable { cursor: pointer; }
.jor-team tbody tr.is-clickable:hover, .jor-team tbody tr.is-clickable:focus-visible { background: var(--ui-bg); }
.jor-quiet { color: var(--ui-warn); }
@media (max-width: 900px) { .jor-grid { grid-template-columns: 1fr; } }

/* Exportación a Excel */
.export-btn[aria-busy="true"] { opacity: .7; cursor: progress; }

/* Jornada del equipo en el móvil: tarjeta por comercial con las cifras en dos columnas */
@media (max-width: 767.98px) {
  .jor-team tbody tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jor-team tbody th[scope="row"] { grid-column: 1 / -1; max-width: none; padding: 0 0 .25rem; border: 0; font-size: 1rem; background: none; position: static; }
  .jor-team tbody td.num:not(.col-name):not(.col-status) { grid-column: auto; text-align: left !important; }
}

/* Jornada → Semana: contactos por comercial y día (escala de un solo tono) */
.jor-week-title { display: flex; align-items: center; gap: .6rem; margin: 0 0 .9rem; font-size: 1.15rem; }
.jor-week-wrap { overflow-x: auto; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); }
.jor-week { width: 100%; border-collapse: collapse; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.jor-week th, .jor-week td { padding: .5rem .55rem; border-top: 1px solid var(--ui-line); vertical-align: middle; }
.jor-week thead th { border-top: 0; font-size: .75rem; font-weight: 600; color: var(--ui-muted); line-height: 1.2; vertical-align: bottom; white-space: normal; }
.jor-week thead th.jor-heat-head { text-align: center; text-transform: capitalize; min-width: 3.2rem; }
.jor-week tbody th[scope="row"], .jor-week tfoot th { text-align: left; font-weight: 600; min-width: 9rem; max-width: 13rem;
  position: sticky; left: 0; z-index: 1; background: var(--ui-surface); }
.jor-week tbody th .cell-sub { display: block; font-weight: 400; }
.jor-week tfoot th, .jor-week tfoot td { font-weight: 700; border-top: 2px solid var(--ui-line-strong); }
.jor-week .num { text-align: right; white-space: nowrap; }
.jor-week-total { font-weight: 700; color: var(--ui-ink); }
.jor-heat { text-align: center; padding: 3px !important; }
.jor-heat-btn { width: 100%; min-width: 2.6rem; min-height: 2rem; border: 0; border-radius: 6px; background: transparent; color: inherit;
  font: inherit; font-weight: 600; cursor: pointer; }
.jor-heat-btn:hover { outline: 2px solid var(--ui-focus); outline-offset: -2px; }
.jor-heat-btn:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 1px; }
.jor-heat--0 .jor-heat-btn, .jor-heat-key.jor-heat--0 { background: #f1f3f6; color: #8a96a3; }
.jor-heat--1 .jor-heat-btn, .jor-heat-key.jor-heat--1 { background: #dbe8f6; color: #10283f; }
.jor-heat--2 .jor-heat-btn, .jor-heat-key.jor-heat--2 { background: #9fc0e6; color: #10283f; }
.jor-heat--3 .jor-heat-btn, .jor-heat-key.jor-heat--3 { background: #2f6db5; color: #fff; }
.jor-heat--future { color: #c3cbd4; }
.jor-delta { font-weight: 600; color: var(--ui-muted); }
.jor-delta--up { color: var(--ui-ok); }
.jor-delta--down { color: var(--ui-error); }
.jor-warn { color: var(--ui-warn); }
.jor-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .6rem 0 0; font-size: .8125rem; }
.jor-heat-key { display: inline-block; padding: .1rem .5rem; border-radius: 5px; font-weight: 600; font-size: .75rem; }
.jor-week thead th:first-child { text-align: left; }

/* Jornada: alertas activas del equipo */
.jor-alerts { margin: 0 0 1rem; padding: .8rem 1rem; background: #fff7e6; border: 1px solid #f0d9ad; border-left: 4px solid var(--ui-warn); border-radius: var(--ui-radius); }
.jor-alerts-title { margin: 0 0 .4rem; font-size: .9375rem; color: var(--ui-warn); }
.jor-alerts-list { margin: 0; padding: 0; list-style: none; display: grid; gap: .45rem; }
.jor-alert a { font-weight: 600; color: var(--ui-ink); }
.jor-alert .cell-sub { display: block; font-size: .8125rem; color: var(--ui-muted); }

/* Jornada: ausencias */
.jor-heat--away .jor-heat-btn, .jor-heat-key.jor-heat--away {
  background: repeating-linear-gradient(135deg, #eef1f5 0 4px, #e1e6ec 4px 8px); color: #5d6b79; }
.jor-away { color: var(--ui-muted); font-style: italic; }
.jor-away-banner { display: flex; align-items: center; gap: .5rem; margin: 0 0 1rem; padding: .7rem 1rem;
  background: #eef3f9; border: 1px solid #d3deea; border-radius: var(--ui-radius); color: var(--ui-ink); font-weight: 600; }
.jor-aus-table td { vertical-align: middle; }
.jor-aus-table .cell-sub { display: block; font-size: .75rem; color: var(--ui-muted); }
.jor-aus-actions { white-space: nowrap; text-align: right; }

/* Jornada: cobertura de potenciales durante una ausencia */
.jor-cover { display: block; margin-top: .25rem; font-size: .75rem; color: var(--ui-muted); }
.jor-cover--on { color: var(--ui-ok); font-weight: 600; }
.jor-cover-opt { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .75rem; margin: .4rem 0; border: 1px solid var(--ui-line); border-radius: 8px; cursor: pointer; }
.jor-cover-opt:has(input:checked) { border-color: var(--ui-focus); background: #f3f7fc; }
.jor-cover-opt:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.jor-cover-opt input { margin-top: .2rem; }
.jor-cover-opt .cell-sub { display: block; font-size: .8125rem; color: var(--ui-muted); }

/* Presupuestos: buscador por referencia y stock */
.art-searches { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: .75rem 1rem; margin-bottom: 1rem; align-items: start; }
.art-searches .art-search { max-width: none; margin-bottom: 0; }
.art-search-field .ui-label { display: block; margin-bottom: .3rem; }
.art-search-field .field-hint { margin: .3rem 0 0; }
.art-group { padding: .5rem .7rem .2rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ui-muted); }
.art-group:not(:first-child) { margin-top: .3rem; border-top: 1px solid var(--ui-line); padding-top: .6rem; }
.art-ref { grid-column: 1; font-size: .8125rem; color: var(--ui-ink); }
.art-stock { grid-column: 1; justify-self: start; margin-top: .15rem; padding: .05rem .45rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.stock--ok { background: var(--ui-ok-bg, #e6f4ec); color: var(--ui-ok); }
.stock--short { background: var(--ui-warn-bg, #fff4e0); color: var(--ui-warn); }
.stock--none { background: #fdecea; color: var(--ui-error); }
.line-stock { display: block; margin-top: .25rem; }
.line-stock .art-stock { display: inline-block; }
@media (max-width: 767.98px) {
  .art-searches { grid-template-columns: minmax(0, 1fr); }
}

/* Presupuestos: reparaciones (complementarios y su stock) */
.stock--repair { background: #eef1f5; color: var(--ui-ink); }
.comp-list { grid-column: 1; margin: .3rem 0 0; padding: 0; list-style: none; display: grid; gap: .15rem; font-size: .8125rem; }
.comp-item { display: flex; justify-content: space-between; gap: .75rem; padding: .1rem 0 .1rem .55rem; border-left: 3px solid var(--ui-line-strong); }
.comp-name { min-width: 0; overflow-wrap: anywhere; }
.comp-code { color: var(--ui-muted); }
.comp-stock { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.comp-need { font-weight: 400; color: var(--ui-muted); }
.comp--ok { border-left-color: var(--ui-ok); }
.comp--ok .comp-stock { color: var(--ui-ok); }
.comp--short { border-left-color: var(--ui-warn); }
.comp--short .comp-stock { color: var(--ui-warn); }
.comp--none { border-left-color: var(--ui-error); }
.comp--none .comp-stock { color: var(--ui-error); }
.comp-more { padding-left: .55rem; color: var(--ui-muted); }
.line-comp { margin-top: .4rem; }
.line-comp .comp-list { margin: 0; }
.comp--labor { border-left-style: dashed; }
.comp--labor .comp-stock { color: var(--ui-muted); font-weight: 400; }
.art-avail { grid-column: 1; justify-self: start; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.art-avail .art-stock { grid-column: auto; }
.art-unverified { margin-top: .15rem; padding: .05rem .45rem; border-radius: 999px; font-size: .75rem; font-weight: 600; border: 1px dashed var(--ui-line-strong); color: var(--ui-muted); }

/* =====================================================================
   Administración → Apariencia (admin/apariencia.js)
   Todo usa las variables de marca: la muestra cambia en directo con la vista previa.
   ===================================================================== */
.look-form { max-width: 1080px; }
.look-form > .admin-block:first-child { margin-top: 0; }
.look-form .form-grid { max-width: 720px; }
.look-form > .form-actions { margin: 1.25rem 0 0; padding: .75rem 0; background: var(--ui-bg); border-top: 1px solid var(--ui-line); justify-content: flex-start; align-items: center; }

.look-presets { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.look-preset {
  display: inline-flex; align-items: center; gap: .55rem; min-height: 44px; padding: .4rem .8rem .4rem .5rem;
  border: 1px solid var(--ui-line-strong); border-radius: 10px; background: var(--ui-surface);
  color: var(--ui-text); font-size: .875rem; font-weight: 600; cursor: pointer;
}
.look-preset:hover { border-color: #aebccb; }
.look-preset:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 2px; }
.look-preset[aria-pressed="true"] { border-color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-ink); }
.look-swatches { display: inline-flex; }
.look-swatch { width: 18px; height: 28px; background: var(--sw, #ccc); }
.look-swatch:first-child { width: 22px; border-radius: 6px 0 0 6px; }
.look-swatch:last-child { border-radius: 0 6px 6px 0; }

.look-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 1.5rem; align-items: start; }
.look-colors { display: grid; gap: 1.1rem; }
.look-color { display: grid; gap: .35rem; }
.look-color-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.look-picker {
  flex: none; width: 48px; height: 42px; padding: 3px; cursor: pointer;
  border: 1px solid var(--ui-line-strong); border-radius: 10px; background: var(--ui-surface);
}
.look-picker::-webkit-color-swatch-wrapper { padding: 0; }
.look-picker::-webkit-color-swatch { border: 0; border-radius: 7px; }
.look-picker::-moz-color-swatch { border: 0; border-radius: 7px; }
.look-picker:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 2px; }
.look-hex { width: 8.5rem; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; text-transform: lowercase; }
.look-chip { padding: .2rem .55rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; white-space: nowrap; }
.look-chip.is-ok { background: var(--ui-ok-bg); color: var(--ui-ok); }
.look-chip.is-bad { background: var(--ui-error-bg); color: var(--ui-error); }
.look-color [aria-invalid="true"] { border-color: var(--ui-error); }

/* Muestra: maqueta reducida del menú lateral y de un contenido */
.look-sample-wrap { position: sticky; top: 1rem; display: grid; gap: .4rem; }
.look-sample {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); overflow: hidden;
  border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg);
}
.look-sample-side { display: flex; flex-direction: column; gap: 2px; padding: .85rem .5rem; background: var(--ui-ink); color: #fff; }
.look-sample-brand {
  margin: 0 .4rem .7rem; font-family: var(--ui-font-display); font-weight: 700; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.look-sample-link { position: relative; padding: .4rem .6rem; border-radius: 6px; font-size: .8125rem; color: rgba(255, 255, 255, .74); }
.look-sample-link.is-active { background: rgba(255, 255, 255, .1); color: #fff; font-weight: 600; }
.look-sample-link.is-active::before {
  content: ""; position: absolute; left: -.5rem; top: .35rem; bottom: .35rem;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--ui-route);
}
.look-sample-user { display: flex; align-items: center; gap: .45rem; margin-top: 1.25rem; padding: .5rem .4rem 0; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .8125rem; }
.look-sample-user .avatar { width: 26px; height: 26px; font-size: .6875rem; }
.look-sample-main { display: grid; gap: .6rem; align-content: start; padding: 1rem; font-size: .875rem; }
.look-sample-main p { margin: 0; }
.look-sample-main a { color: var(--ui-focus); }
.look-sample-input { border-color: var(--ui-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-focus) 20%, transparent); pointer-events: none; }
.look-sample-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.look-sample-actions > span { min-height: 34px; padding: .3rem .7rem; font-size: .8125rem; pointer-events: none; }

@media (max-width: 991.98px) {
  .look-layout { grid-template-columns: minmax(0, 1fr); }
  .look-sample-wrap { position: static; }
}
@media (max-width: 479.98px) {
  .look-sample { grid-template-columns: minmax(0, 1fr); }
  .look-sample-side { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .look-sample-brand { flex-basis: 100%; margin-bottom: .4rem; }
  .look-sample-link.is-active::before { display: none; }
  .look-sample-user { display: none; }
}
