  /* ── Octavio · Prefactibilidad (panel lateral, toggle en header) ───── */
  /* Botón toggle dentro del header del modal de la Ficha */
  #prefact-modal .pf-octavio-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px; margin: 0 6px;
    background: linear-gradient(135deg, #7c2d12, #c0392b);
    color: #fff; font-weight: 600; font-size: 12px;
    border: 0; border-radius: 999px; cursor: pointer;
    box-shadow: 0 2px 6px rgba(124, 45, 18, 0.25);
  }
  #prefact-modal .pf-octavio-toggle:hover { filter: brightness(1.05); }
  #prefact-modal .pf-octavio-toggle img { width: 16px; height: 16px; border-radius: 50%; background: #fff; padding: 1px; }
  #prefact-modal .pf-octavio-toggle.is-active {
    background: linear-gradient(135deg, #15803d, #16a34a);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  }

  #pf-octavio {
    position: fixed; top: 0; right: 0; height: 100vh; width: 400px;
    max-width: 92vw; z-index: 10003;
    background: #fff; border-left: 1px solid #e5e7eb;
    box-shadow: -16px 0 40px rgba(15, 23, 42, 0.18);
    display: flex; flex-direction: column;
    font-family: 'Inter', system-ui, sans-serif;
  }
  /* El atributo HTML `hidden` aplica `display:none` con baja specificity y
     pierde frente al `display:flex` del selector de arriba. Forzar el ocultado
     con la misma specificity asegura que octavioClose() funcione. */
  #pf-octavio[hidden] { display: none; }
  #pf-octavio .pf-oct-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #7c2d12, #c0392b); color: #fff;
  }
  #pf-octavio .pf-oct-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
  #pf-octavio .pf-oct-title img { width: 24px; height: 24px; border-radius: 50%; background: #fff; padding: 2px; }
  #pf-octavio #pf-oct-close {
    background: none; border: 0; color: #fff; font-size: 22px; line-height: 1;
    cursor: pointer; padding: 0 6px;
  }
  #pf-octavio .pf-oct-body {
    flex: 1; overflow-y: auto; padding: 12px 14px;
    background: #f9fafb;
  }
  #pf-octavio .pf-oct-empty { color: #6b7280; font-size: 13px; }
  #pf-octavio .pf-oct-empty p { margin: 0 0 8px; }
  #pf-octavio .pf-oct-empty ul { padding-left: 18px; margin: 0; }
  #pf-octavio .pf-oct-empty li { margin-bottom: 4px; line-height: 1.4; }
  #pf-octavio .pf-oct-msg {
    margin-bottom: 10px; padding: 8px 10px; border-radius: 8px;
    font-size: 13px; line-height: 1.45; max-width: 90%;
  }
  #pf-octavio .pf-oct-msg--user { background: #e5e7eb; color: #1f2937; margin-left: auto; }
  #pf-octavio .pf-oct-msg--bot  { background: #fff; border: 1px solid #e5e7eb; color: #1f2937; }
  #pf-octavio .pf-oct-msg--error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
  #pf-octavio .pf-oct-msg p { margin: 0 0 6px; }
  #pf-octavio .pf-oct-msg p:last-child { margin-bottom: 0; }

  #pf-octavio .pf-oct-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  #pf-octavio .pf-oct-chip {
    background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe;
    border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
  }
  #pf-octavio .pf-oct-chip:hover { background: #dbeafe; }
  #pf-octavio .pf-oct-chip.is-selected {
    background: #1e40af; color: #fff; border-color: #1e3a8a;
  }
  #pf-octavio .pf-oct-chip[disabled] { opacity: 0.55; cursor: default; }
  #pf-octavio .pf-oct-chip[disabled]:hover { background: #eff6ff; }
  #pf-octavio .pf-oct-batch-actions {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-top: 8px; padding-top: 6px; border-top: 1px dashed #e5e7eb;
  }
  #pf-octavio .pf-oct-batch-status {
    font-size: 11px; color: #6b7280; font-weight: 600;
  }
  #pf-octavio .pf-oct-batch-send {
    background: #0d47a1; color: #fff; border: 0; border-radius: 6px;
    padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  }
  #pf-octavio .pf-oct-batch-send:hover:not(:disabled) { background: #1565c0; }
  #pf-octavio .pf-oct-batch-send:disabled {
    background: #cbd5e1; cursor: not-allowed;
  }

  #pf-octavio .pf-oct-accion {
    background: #fff; border: 1px solid #e5e7eb; border-left: 3px solid #0d47a1;
    border-radius: 6px; padding: 8px 10px; margin: 8px 0; font-size: 12px;
  }
  #pf-octavio .pf-oct-accion.is-aplicada { border-left-color: #15803d; opacity: 0.7; }
  #pf-octavio .pf-oct-accion.is-descartada { border-left-color: #6b7280; opacity: 0.5; }
  #pf-octavio .pf-oct-accion-titulo { font-weight: 600; color: #111827; margin-bottom: 2px; }
  #pf-octavio .pf-oct-accion-nota { color: #b54708; font-size: 11px; }
  #pf-octavio .pf-oct-accion-btns { display: flex; gap: 6px; margin-top: 6px; }
  #pf-octavio .pf-oct-accion-btn {
    padding: 3px 8px; border-radius: 4px; font-size: 11px; cursor: pointer; border: 1px solid;
  }
  #pf-octavio .pf-oct-aplicar { background: #15803d; color: #fff; border-color: #15803d; }
  #pf-octavio .pf-oct-descartar { background: #fff; color: #b91c1c; border-color: #fecaca; }
  #pf-octavio .pf-oct-aplicar-todas {
    background: #0d47a1; color: #fff; border: 0; padding: 6px 12px; border-radius: 6px;
    cursor: pointer; font-size: 12px; font-weight: 600; margin-top: 4px;
  }

  #pf-octavio .pf-oct-validacion {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
    padding: 8px 10px; margin: 6px 0; font-size: 12px; display: flex; gap: 8px;
  }
  #pf-octavio .pf-oct-validacion.is-excede { border-left: 3px solid #b91c1c; }
  #pf-octavio .pf-oct-validacion.is-limite { border-left: 3px solid #b54708; }
  #pf-octavio .pf-oct-validacion.is-ok     { border-left: 3px solid #15803d; }
  #pf-octavio .pf-oct-validacion.is-info   { border-left: 3px solid #1e40af; }

  #pf-octavio .pf-oct-thinking {
    color: #6b7280; font-style: italic; font-size: 12px; padding: 4px 0;
  }

  #pf-octavio .pf-oct-foot {
    border-top: 1px solid #e5e7eb; padding: 10px 14px; background: #fff;
  }
  #pf-octavio #pf-oct-input {
    width: 100%; resize: vertical; min-height: 44px; max-height: 200px;
    padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font-family: inherit; font-size: 13px; box-sizing: border-box;
  }
  #pf-octavio .pf-oct-actions {
    display: flex; align-items: center; gap: 6px; margin-top: 8px;
    flex-wrap: wrap;
  }
  #pf-octavio .pf-oct-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; color: #6b7280; cursor: pointer; margin-right: auto;
  }
  #pf-octavio .pf-oct-btn {
    background: #fff; color: #1f4e79; border: 1px solid #b6c8ee;
    border-radius: 4px; padding: 6px 10px; cursor: pointer; font-size: 12px;
    font-weight: 600;
  }
  #pf-octavio .pf-oct-btn:hover { background: #eff4fc; }
  #pf-octavio .pf-oct-primary { background: #0d47a1; color: #fff; border-color: #0d47a1; }
  #pf-octavio .pf-oct-primary:hover { background: #1565c0; }
  #pf-octavio .pf-oct-btn:disabled { opacity: 0.5; cursor: not-allowed; }


  /* ── Modal "Skills de Octavio" (catálogo user-facing en tools-drawer) ── */
  #skills-modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 10004;
    align-items: flex-start; justify-content: center;
    padding: 6vh 16px 16px;
    overflow-y: auto;
  }
  #skills-modal .sm-card {
    background: #fff; width: 100%; max-width: 720px;
    border-radius: 14px; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    display: flex; flex-direction: column;
    font-family: 'Inter', system-ui, sans-serif;
    overflow: hidden;
  }
  #skills-modal .sm-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: #fff;
  }
  #skills-modal .sm-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.2px; }
  #skills-modal .sm-close {
    background: none; border: 0; color: #fff; font-size: 24px; line-height: 1;
    cursor: pointer; padding: 0 6px; opacity: 0.85;
  }
  #skills-modal .sm-close:hover { opacity: 1; }
  #skills-modal .sm-sub {
    padding: 12px 18px 4px;
    color: #475569; font-size: 13px; line-height: 1.45;
  }
  #skills-modal .sm-list {
    padding: 8px 18px 18px;
    display: flex; flex-direction: column; gap: 12px;
  }
  #skills-modal .sm-empty {
    padding: 24px; text-align: center; color: #6b7280; font-size: 13px;
  }

  #skills-modal .sm-card-skill {
    border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 12px 14px; background: #fafbff;
    transition: border-color .15s, background .15s;
  }
  #skills-modal .sm-card-skill:hover { border-color: #c7d2fe; background: #fff; }
  #skills-modal .sm-card-skill.is-unavailable {
    opacity: 0.55; background: #f8fafc; border-style: dashed;
  }
  #skills-modal .sm-skill-head {
    display: flex; align-items: flex-start; gap: 10px;
  }
  #skills-modal .sm-skill-icon { font-size: 24px; line-height: 1; flex-shrink: 0; }
  #skills-modal .sm-skill-headtxt { flex: 1; min-width: 0; }
  #skills-modal .sm-skill-name {
    margin: 0 0 2px; font-size: 14px; font-weight: 600; color: #0f172a;
  }
  #skills-modal .sm-skill-tag {
    margin: 0; font-size: 12.5px; color: #475569; line-height: 1.4;
  }
  #skills-modal .sm-badge-na {
    align-self: flex-start; flex-shrink: 0;
    background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
    padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
    cursor: help;
  }
  #skills-modal .sm-skill-desc {
    margin: 8px 0 0; font-size: 12.5px; color: #334155; line-height: 1.5;
  }
  #skills-modal .sm-skill-chips {
    margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px;
  }
  #skills-modal .sm-skill-chips-title {
    width: 100%; font-size: 11px; font-weight: 600; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px;
  }
  #skills-modal .sm-chip {
    background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe;
    border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer;
    font-family: inherit;
    transition: background .15s, border-color .15s, transform .08s;
  }
  #skills-modal .sm-chip:hover:not(:disabled) {
    background: #dbeafe; border-color: #93c5fd;
  }
  #skills-modal .sm-chip:active:not(:disabled) { transform: scale(0.97); }
  #skills-modal .sm-chip--long {
    background: #f0fdf4; color: #166534; border-color: #bbf7d0;
    border-radius: 8px; text-align: left; max-width: 100%;
    white-space: normal; line-height: 1.4;
  }
  #skills-modal .sm-chip--long:hover:not(:disabled) {
    background: #dcfce7; border-color: #86efac;
  }
  #skills-modal .sm-chip:disabled {
    cursor: not-allowed; opacity: 0.6;
  }
  @media (max-width: 640px) {
    #skills-modal { padding: 0; align-items: stretch; }
    #skills-modal .sm-card { max-width: 100%; border-radius: 0; min-height: 100vh; }
  }

  /* ── Popup de click derecho en mapa: "punto seleccionado" ── */
  .ctxpt-popup .maplibregl-popup-content {
    padding: 0 !important;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
    font-family: 'Inter', system-ui, sans-serif;
  }
  .ctxpt-card { padding: 12px 14px; }
  .ctxpt-title {
    font-weight: 600; color: #0f172a; font-size: 13px;
    border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; margin-bottom: 6px;
    display: flex; align-items: center; gap: 6px;
  }
  .ctxpt-title::before { content: "📍"; }
  .ctxpt-coords {
    font-family: ui-monospace, "SF Mono", monospace; font-size: 11.5px;
    color: #334155; margin-bottom: 10px;
  }
  .ctxpt-actions { display: flex; flex-direction: column; gap: 6px; }
  .ctxpt-btn {
    background: #1e3a8a; color: #fff; border: 0;
    border-radius: 6px; padding: 6px 10px; font-size: 12px; font-weight: 600;
    cursor: pointer; text-align: left;
    transition: background .12s;
    font-family: inherit;
  }
  .ctxpt-btn:hover { background: #3b82f6; }
  .ctxpt-btn--ghost {
    background: #fff; color: #1e3a8a; border: 1px solid #c7d2fe;
  }
  .ctxpt-btn--ghost:hover { background: #eff6ff; }

  /* ── FAB Octavio: único launcher del chat (sin aro azul, separado del marco) ── */
  .ia-fab {
    position: fixed;
    bottom: calc(var(--sa-bottom) + var(--space-4));
    right:  calc(var(--sa-right)  + var(--space-4));
    z-index: var(--z-overlay);
    width: 56px; height: 56px;
    border: 0; padding: 0; cursor: pointer;
    border-radius: 50%;
    background: transparent;
    box-shadow: var(--shadow-lg);
    transition: transform 0.12s ease, right var(--t-drawer);
    display: flex; align-items: center; justify-content: center;
  }
  .ia-fab img {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
  }
  .ia-fab:hover  { transform: scale(1.05); }
  .ia-fab:active { transform: scale(0.95); }
  /* En desktop el FAB respeta el sidebar Herramientas */
  @media (min-width: 1024px) {
    .ia-fab { right: calc(var(--drawer-w-desktop) + var(--space-3)); }
    body.sidebar-tools-collapsed .ia-fab { right: calc(var(--sa-right) + var(--space-4)); }
  }
