/* ==========================================================
   Pricing Tool — Apple-like Corporate (Light + Orange Accent)
   (Resumen simplificado + tarjeta principal más ancha + % input mejorado)
   ========================================================== */

:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --brand: #ff7a1a;
  --brand-600: #ff6a00;
  --brand-700: #e65f00;
  --brand-100: #fff1e6;
  --ok: #16a34a;
  --warn: #f59e0b;
  --err: #ef4444;
  --shadow-1: 0 6px 18px rgba(17, 24, 39, .06);
  --shadow-2: 0 10px 28px rgba(17, 24, 39, .08);
  --ring: 0 0 0 4px rgba(255, 122, 26, .18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --radius: 14px;
  --radius-sm: 10px;
  --speed: .22s;
  --bezier: cubic-bezier(.22, 1, .36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

h1 {
  margin: 0;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .2px;
}

h2 {
  margin: 0 0 12px 0;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

h3 {
  margin: 12px 0 8px;
  font-size: 16px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-footer {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 18px;
}

/* Layout 3 columnas — principal más ancha */
.layout {
  display: grid;
  grid-template-columns: 220px 1.35fr 340px;
  /* principal más ancha, panel derecho algo más compacto */
  gap: 16px;
  max-width: 1680px;
  /* antes: 1440px, ahora más ancho para respirar */
  margin: 16px auto;
  padding: 0 18px;
}

.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-link {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--speed), background var(--speed), border-color var(--speed);
}

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

.side-link.active {
  border-color: var(--brand-600);
  box-shadow: var(--ring);
}

.main {
  min-width: 0;
}

.summary-panel {
  position: sticky;
  top: 76px;
  align-self: start;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--speed) var(--bezier), transform var(--speed) var(--bezier);
}

.card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.grid>* {
  grid-column: span 12;
}

@media (min-width:760px) {
  .grid>* {
    grid-column: span 6;
  }
}

@media (min-width:1024px) {
  .grid>* {
    grid-column: span 4;
  }
}

/* Controles */
input,
select,
button {
  width: 100%;
  appearance: none;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  transition: border-color var(--speed), box-shadow var(--speed), transform var(--speed);
  outline: none;
  font-size: 14px;
}

input::placeholder {
  color: #9aa3b2;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(1em - 2px), calc(100% - 12px) calc(1em - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus,
select:focus {
  border-color: var(--brand-600);
  box-shadow: var(--ring);
}

:disabled {
  background: #fafafa !important;
  color: #9aa3b2 !important;
  cursor: not-allowed !important;
  opacity: .85;
}

button {
  background: linear-gradient(180deg, var(--brand), var(--brand-600));
  color: #fff;
  font-weight: 700;
  letter-spacing: .2px;
  border: none;
  box-shadow: 0 6px 16px rgba(255, 122, 26, .25);
  cursor: pointer;
}

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

button:active {
  transform: translateY(0);
}

button:disabled {
  background: #ececec;
  color: #9aa3b2;
  box-shadow: none;
  transform: none;
}

button.ghost {
  background: #fff;
  color: var(--brand-600);
  border: 1px solid var(--brand-600);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--brand-100);
}

button.danger {
  background: linear-gradient(180deg, #ff5a5f, #e04449);
  box-shadow: 0 6px 16px rgba(224, 68, 73, .25);
}

/* Listados */
.results,
.items,
.summary {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 52px;
}

.result-row,
.item-row,
.history-row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  transition: background var(--speed), transform var(--speed);
}

.result-row:last-child,
.item-row:last-child,
.history-row:last-child {
  border-bottom: none;
}

.result-row:hover,
.item-row:hover,
.history-row:hover {
  background: #fff7f0;
  transform: translateY(-1px);
}

/* Resumen – KPIs compactos */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  box-shadow: var(--shadow-1);
}

.kpi .title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi .value {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .2px;
}

.kpi .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi.ok {
  background: #ecfdf5;
  border-color: #bbf7d0;
}

/* verde claro */
.kpi.warn {
  background: #fff7ed;
  border-color: #fed7aa;
}

/* ámbar claro */
.kpi.err {
  background: #fef2f2;
  border-color: #fecaca;
}

/* rojo claro */

/* Opciones del resumen */
.summary-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

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

.toggle input {
  width: auto;
}

.mini-input {
  max-width: 160px;
}

/* un poco más ancho para % global */

/* Login */
.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-form {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 12px;
}

/* Utilidades */
.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Badge base + variantes */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
}

.badge--approved {
  background: #ecfdf5;
  color: #065f46;
}

.badge--pending {
  background: #fff7ed;
  color: #9a3412;
}

.badge--rejected {
  background: #fef2f2;
  color: #991b1b;
}

.badge--issued {
  background: #eef2ff;
  color: #3730a3;
}

.ok {
  color: var(--ok);
}

.warn {
  color: var(--warn);
}

.err {
  color: var(--err);
}

a {
  color: var(--brand-700);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: #444;
}

/* Focus */
:focus-visible {
  outline: none !important;
  box-shadow: var(--ring) !important;
  border-color: var(--brand-600) !important;
}

/* Transiciones */
.card,
input,
select,
button,
.side-link,
.result-row,
.item-row,
.history-row,
.kpi {
  transition: all var(--speed) var(--bezier);
}

/* Selección fila items */
.row-selected {
  background: #ffe9d6 !important;
  border-left: 4px solid var(--brand-600);
  box-shadow: inset 0 0 0 1px rgba(255, 122, 26, .15);
}

/* Botón icono (por defecto: conserva el estilo NARANJA de <button>) */
.icon-btn {
  width: auto;
  padding: 6px 10px;
  border-radius: 8px;
}

/* Variante "danger" compacta (fondo claro) */
.icon-btn.danger {
  background: #fff;
  border: 1px solid #ffd0d0;
  color: #cc0011;
}

.icon-btn.danger:hover {
  background: #ffeff0;
  border-color: #ffb7b7;
}

/* Autocomplete fijo */
.suggest-dropdown {
  position: fixed;
  z-index: 9999;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  overflow: auto;
  max-height: 340px;
  scrollbar-gutter: stable both-edges;
}

.suggest-dropdown::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 24px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
  box-shadow: -2px -2px 3px rgba(17, 24, 39, .02);
}

.suggest-item {
  padding: 10px 12px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 2px;
}

.suggest-item+.suggest-item {
  border-top: 1px solid var(--border);
}

.suggest-item:hover,
.suggest-item.is-active {
  background: #fff7f0;
}

.sugg-title {
  font-weight: 600;
  color: var(--text);
  letter-spacing: .2px;
}

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

/* Input % línea mejorado */
.pct-group {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

.pct-input {
  border: 0 !important;
  width: 110px;
  padding: 10px 10px;
  outline: none;
  box-shadow: none !important;
}

.pct-suffix {
  padding: 0 10px;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  background: #fafafa;
}

/* Responsive */
@media (max-width:1200px) {
  .layout {
    grid-template-columns: 200px 1fr 320px;
    max-width: 1400px;
  }
}

@media (max-width:980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .summary-panel {
    position: static;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== FIX: Tabla de items ordenada + % visible ===== */

/* Mantener 9 columnas en desktop (forzamos por si otro bloque lo pisa) */
.items .item-row,
.items .result-row,
.items .history-row {
  display: grid !important;
  grid-template-columns: 1.6fr 1fr .8fr .8fr .9fr .9fr .9fr .9fr .8fr !important;
  align-items: center;
}

/* Misma degradación que tenías antes */
@media (max-width: 960px) {
  .items .item-row {
    grid-template-columns: 1.4fr 1fr .9fr .9fr 1fr 1fr !important;
  }
}

@media (max-width: 720px) {
  .items .item-row {
    grid-template-columns: 1.2fr 1fr 1fr !important;
  }
}

/* Acciones en una sola línea (dto% + papelera) */
.actions-flex {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

/* Cajita de % compacta y legible */
.pct-group {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

/* % más pequeño (−40%) */
.pct-input {
  width: 66px !important;
  /* antes ~110px */
  padding: 8px 8px !important;
  font-size: 13px;
}

.pct-suffix {
  padding: 0 8px !important;
}

#loginScreen {
  background: var(--bg);
}

#loginScreen .card {
  margin: 20px;
}

/* Brand en header */
.brand {
  display: flex;
  align-items: center;
  gap: 10px
}

.brand-logo {
  height: 78px;
  width: auto;
  display: block
}

@media (min-width:1024px) {
  .brand-logo {
    height: 62px
  }
}

/* ===== Historial en tabla ===== */
.history-table .history-row {
  display: grid;
  /* Fecha, Cliente, Creador, Oferta, Estado, Acciones */
  grid-template-columns: 1.2fr 1.8fr 1.2fr 1.2fr 0.9fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.history-table .history-row.head {
  background: var(--brand-100);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 700;
}

.history-table .history-row .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ====== Tabla de USUARIOS (mismo estilo que historial) ====== */
#srvExpenses .inline select,
#srvExpenses .inline input {
  width: auto;
  min-width: 160px
}

#srvExpenses .inline .srv-exp-price {
  min-width: 110px
}

#srvExpenses .inline .srv-exp-qty {
  min-width: 80px
}

.tab-pane.hidden {
  display: none
}

#usersList.history-table .history-row {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr 0.9fr 0.5fr 1.1fr 0.9fr;
  /* Nombre, Email, Rol, 2FA, Creado, Acciones */
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
}

#usersList .history-row.head {
  background: #fff7ed;
  color: #6b7280;
  font-weight: 600;
}

#usersList .history-row> :nth-child(4) {
  text-align: center;
}

/* columna 2FA */
#usersList .history-row .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

/* === Servicios: tareas y técnicos === */
.srv-task {
  border: 1px dashed #ddd;
  padding: 8px;
  margin-top: 8px;
  border-radius: 8px;
}

.srv-task header {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.srv-task header .left {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.srv-tech-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

.srv-tech-row select,
.srv-tech-row input {
  min-width: 120px;
}

/* === SOLO en Servicios/Gastos queremos botones "textuales" (transparentes) === */
.srv-task .icon-btn,
#srvExpenses .icon-btn {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 4px 6px;
  color: inherit;
}

.srv-task .icon-btn.danger,
#srvExpenses .icon-btn.danger {
  background: transparent;
  border: none;
  color: #b30000;
}

.srv-task .icon-btn.primary,
#srvExpenses .icon-btn.primary {
  color: #0b5fff;
}

/* Aprobaciones: subcards de tipo */
#apprTypeCard .card {
  border: 1px solid #eee;
}

#apprTypeCard h3 {
  margin: 0 0 6px;
}

/* Aprobaciones por tipo: mini tabla */
.appr-type-table {
  width: 100%;
  border-collapse: collapse;
}

.appr-type-table th,
.appr-type-table td {
  border: 1px solid #eee;
  padding: 8px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.appr-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: #f2f2f2;
}

.appr-type-ok {
  background: #e6ffed;
}

.appr-type-off {
  background: #fff3e6;
}

#apprTypeList button[data-action="delete"] {
  color: #b00020;
}

/* Modo bloqueado: inputs deshabilitados, aspecto gris */
.offer-locked input,
.offer-locked select,
.offer-locked textarea,
.offer-locked button[data-edit="1"] {
  pointer-events: none;
  opacity: 0.55;
}

/* === Fix: botón “X” en los chips de asignación === */
#assignChips .chip-x {
  width: auto !important;
  /* anula width:100% global */
  padding: 2px 6px !important;
  /* compacto */
  background: transparent !important;
  border: 0 !important;
  color: var(--text-muted) !important;
  /* que se vea sobre fondo blanco */
  line-height: 1;
  font-weight: 700;
  border-radius: 999px;
  /* forma de píldora */
  box-shadow: none !important;
  /* sin sombra/ring */
  cursor: pointer;
}

#assignChips .chip-x:hover {
  background: var(--brand-100) !important;
  color: var(--brand-700) !important;
}

/* === Historial: 7 columnas (incluye “Asignada a”) === */
#historyList.history-table .history-row {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 1fr 0.9fr 1.6fr auto;
  /* última col = acciones */
  gap: 10px;
  align-items: center;
}

#historyList.history-table .history-row>div {
  min-width: 0;
  /* permite que el texto rompa correctamente */
}

#historyList.history-table .history-row.head {
  font-weight: 600;
}

/* Que “Asignada a” pueda partir línea si hay varios nombres */
#historyList.history-table .history-row>div:nth-child(6) {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Un pelín más ancho el contenedor del historial */
#section-history .history-table {
  max-width: 1280px;
}

/* === Historial: rejilla centrada y más ancha === */
#historyList {
  width: 100%;
  overflow-x: auto;
  /* por si en pantallas estrechas no cabe */
}

/* Fila como grid: ajusta anchos de columnas */
#historyList.history-table .history-row {
  display: grid;
  grid-template-columns:
    170px
    /* Últ. modificación / Creación */
    1.2fr
    /* Cliente */
    1fr
    /* Creador */
    2fr
    /* Oferta (id) */
    120px
    /* Estado */
    1.2fr
    /* Asignada a */
    170px;
  /* Acciones */
  align-items: center;
  gap: 10px;
}

/* Centrado por defecto en todas las celdas */
#historyList.history-table .history-row>div {
  text-align: center;
}

/* Estas columnas van mejor alineadas a la izquierda (legibilidad) */
#historyList.history-table .history-row>div:nth-child(2),
#historyList.history-table .history-row>div:nth-child(3),
#historyList.history-table .history-row>div:nth-child(4) {
  text-align: left;
}

/* Cabecera un pelín más marcada */
#historyList.history-table .history-row.head {
  font-weight: 600;
}

/* El id de la oferta ya lo marcas con .mono; mantenemos la tipografía y left */
#historyList.history-table .history-row .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  text-align: left;
}

/* Centrar el grupo de botones de acciones */
#historyList.history-table .history-row .actions {
  display: flex;
  justify-content: center;
  gap: 6px;
}

/* Ajuste suave para pantallas más estrechas */
@media (max-width: 1200px) {
  #historyList.history-table .history-row {
    grid-template-columns: 160px 1fr 0.9fr 1.6fr 110px 1fr 150px;
  }
}

/* === Asistente COTIA / Chat base === */
.ai-chat {
  height: 360px;
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  /* más limpio que #fafafa */
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.ai-input {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.ai-input textarea {
  flex: 1 1 auto;
  min-height: 60px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.ai-input button {
  flex: 0 0 auto;
  width: auto !important;
  /* anula button{width:100%} global */
  min-width: 120px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
}

.ai-msg {
  display: flex;
  margin: 8px 0;
}

.ai-user {
  justify-content: flex-end;
}

.ai-bot {
  justify-content: flex-start;
}

.ai-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  white-space: pre-wrap;
  line-height: 1.35;
}

.ai-user .ai-bubble {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.ai-bot .ai-bubble {
  background: #f9fafb;
}

/* ===== Asistente (beta) en sección ===== */
.ai-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.ai-input-row #aiMessage {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.ai-input-row #aiSend {
  flex: 0 0 auto;
  width: auto !important;
  /* evita botón gigante */
  min-width: 140px;
  white-space: nowrap;
  padding: 12px 16px;
  border-radius: 10px;
}

.ai-options-row {
  margin-top: 6px;
}

.ai-options-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* ===== Ocultar el botón del menú lateral (ya no se usa) ===== */
#navAssistant {
  display: none !important;
}

/* === COTIA (widget flotante arriba-derecha) === */
.cotia-fab {
  position: fixed;
  top: 76px;
  right: 20px;
  bottom: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ff6a00;
  color: #fff;
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 10000;
  transition: transform .06s ease, filter .06s ease;
}

.cotia-fab:hover {
  transform: translateY(-1px);
  filter: brightness(.98);
}

/* Panel flotante (soporta .cotia-panel y .cotia-modal) */
.cotia-panel,
.cotia-modal {
  position: fixed;
  top: 144px;
  right: 20px;
  bottom: auto;
  width: 380px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 170px);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
  display: none;
  flex-direction: column;
  z-index: 10000;
}

.cotia-panel.open {
  display: flex;
}

/* Cabecera del panel */
.cotia-panel header,
.cotia-modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  font-weight: 600;
}

.cotia-panel header .close,
.cotia-modal header .close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

/* Área de chat */
.cotia-chat {
  padding: 10px;
  height: 340px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  border-radius: 12px;
}

/* Mensajes del widget (la función appendMsg pone estilos inline;
   los sobreescribimos con !important usando selectores de estructura) */
#cotia-modal .cotia-chat>div>div,
#aiChat>div>div {
  border-radius: 12px !important;
  border: 1px solid #e5e7eb !important;
}

/* Pie con input y opciones (widget con .cotia-input del JS actual) */
.cotia-panel footer {
  padding: 10px;
  border-top: 1px solid #f3f4f6;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cotia-input {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-top: 1px solid #f1f5f9;
}

.cotia-input input[type="text"],
#cotia-modal #cotia-msg {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.cotia-input button,
#cotia-modal #cotia-send {
  flex: 0 0 auto;
  width: auto !important;
  /* anula width:100% global */
  min-width: 120px;
  padding: 12px 16px;
  font-weight: 600;
  border: none;
  background: #ff6a00;
  color: #fff;
  border-radius: 10px;
}

/* “Incluir oferta actual” perfectamente alineado */
.cotia-mini,
.cotia-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
  padding: 0 2px;
}

.cotia-mini input,
.cotia-toggle input {
  width: 16px;
  height: 16px;
}

/* === CotIA: botón + SVG del nuevo icono =============================== */
#cotiaFab {
  position: fixed;
  right: 20px;
  top: var(--cotia-top, 76px);
  z-index: 10000;
  /* IMPORTANTE: el SVG ya tiene círculo + sombra; el botón va transparente */
  background: transparent !important;
  box-shadow: none !important;
  border: 0;
  padding: 0;
  width: 56px;
  height: 56px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: transform .15s ease, filter .15s ease;
}

#cotiaFab:hover {
  transform: translateY(-1px);
}

#cotiaFab:active {
  transform: translateY(0);
}

/* Tamaño/comportamiento del botón contenedor */
.ia-badge {
  width: 100%;
  height: 100%;
}

/* El SVG escalará con el botón */
.icon-ia {
  width: 100%;
  height: 100%;
}

/* (Opcional) Modo oscuro */
@media (prefers-color-scheme: dark) {
  #cotiaFab {
    filter: saturate(1.1);
  }
}

/* CotIA: FAB más grande */
.cotia-fab.ia-badge {
  width: 72px;
  height: 72px;
}

/* el svg ya escala al 100%, no toca nada más */
.cotia-fab.ia-badge .icon-ia {
  width: 100%;
  height: 100%;
}

/* opcional: un poco menos grande en móviles muy pequeños */
@media (max-width: 480px) {
  .cotia-fab.ia-badge {
    width: 60px;
    height: 60px;
  }
}

/* FAB con SVG — limpio y grande */
.cotia-fab.ia-badge {
  width: 72px;
  height: 72px;
  padding: 0;
  background: transparent;
  /* usamos la moneda del SVG, no fondo del botón */
  border: none;
  box-shadow: none;
  /* la sombra la pone el filtro del SVG */
  display: inline-grid;
  place-items: center;
}

.icon-cotia {
  width: 100%;
  height: 100%;
  display: block;
}

.cotia-fab.ia-badge:hover {
  transform: translateY(-1px);
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .25));
}

.cotia-fab.ia-badge:focus-visible {
  outline: none;
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) drop-shadow(0 0 0 rgba(0, 0, 0, 0));
  box-shadow: 0 0 0 4px rgba(255, 122, 26, .22);
  /* ring accesible */
  border-radius: 999px;
}

/* tamaño algo menor en móviles estrechos */
@media (max-width: 480px) {
  .cotia-fab.ia-badge {
    width: 60px;
    height: 60px;
  }
}

/* micro-animaciones opcionales */
@keyframes cotia-blink {

  0%,
  92%,
  100% {
    transform: scaleY(1);
  }

  95% {
    transform: scaleY(0.1);
  }
}

.cotia-eyes {
  transform-origin: center;
  animation: cotia-blink 5s infinite;
}

@keyframes cotia-glint-anim {
  0% {
    opacity: .6;
    transform: translate(70px, 22px) rotate(0deg) scale(1);
  }

  50% {
    opacity: .9;
    transform: translate(70px, 22px) rotate(12deg) scale(1.05);
  }

  100% {
    opacity: .6;
    transform: translate(70px, 22px) rotate(0deg) scale(1);
  }
}

.cotia-glint {
  animation: cotia-glint-anim 4.5s ease-in-out infinite;
}

/* Botón + SVG escalable */
.cotia-fab.ia-badge {
  width: 76px;
  height: 76px;
  padding: 0;
  border: none;
  background: transparent;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: transform .15s ease;
}

.cotia-fab.ia-badge:hover {
  transform: translateY(-1px);
}

.icon-cotia {
  width: 100%;
  height: 100%;
  display: block;
}

/* Animaciones del personaje */
#cotiaFab .ct-eyes {
  transform-origin: 60px 46px;
  animation: ct-blink 5.2s infinite;
}

@keyframes ct-blink {

  0%,
  94%,
  100% {
    transform: scaleY(1);
  }

  96% {
    transform: scaleY(0.12);
  }
}

#cotiaFab .ct-glint {
  animation: ct-glint 4.6s ease-in-out infinite;
}

@keyframes ct-glint {
  0% {
    opacity: .6;
    transform: translate(84px, 26px) rotate(0deg) scale(1);
  }

  50% {
    opacity: .95;
    transform: translate(84px, 26px) rotate(12deg) scale(1.05);
  }

  100% {
    opacity: .6;
    transform: translate(84px, 26px) rotate(0deg) scale(1);
  }
}

/* Mano que saluda de vez en cuando */
#cotiaFab .ct-arm-right {
  transform-box: fill-box;
  transform-origin: 0% 0%;
  animation: ct-wave 7s ease-in-out infinite;
}

@keyframes ct-wave {

  0%,
  84%,
  100% {
    transform: rotate(0deg);
  }

  86% {
    transform: rotate(18deg);
  }

  88% {
    transform: rotate(0deg);
  }

  90% {
    transform: rotate(14deg);
  }

  92% {
    transform: rotate(0deg);
  }
}

/* Sutileza de vida al conjunto (micro-bob) */
#cotiaFab .icon-cotia {
  animation: ct-bob 6s ease-in-out infinite;
}

@keyframes ct-bob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-1.2px);
  }
}

/* Responsivo */
@media (max-width: 480px) {
  .cotia-fab.ia-badge {
    width: 64px;
    height: 64px;
  }
}

/* ===== Colaboración / Presencia ===== */
.presence-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 2px 0 8px;
}

.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  /* online */
}

/* ====== CotIA chat: estilo “bocadillo” (WhatsApp-like) ====== */
#cotiaPanel {
  --cotia-accent: #FF8A2B;
  /* naranja corporativo */
  --cotia-accent-strong: #FF6A00;
  /* variante más intensa */
  --cotia-soft: #FFEBDC;
  /* naranja clarito para fondo de user */
  --cotia-soft-border: #FFC99A;
  /* borde suave */
  --cotia-white: #FFFFFF;
  --cotia-gray: #F4F6F8;
  --cotia-text: #2B2B2B;
  --cotia-muted: #6B7280;
}

/* CotIA: panel un poco más ancho pero respetando móviles */
#cotiaPanel {
  width: clamp(360px, 28vw, 520px);
  max-width: 94vw;
}

@media (min-width: 1280px) {
  #cotiaPanel {
    width: 560px;
  }
}

#cotiaPanel header {
  background: linear-gradient(180deg, #FFF4EB 0%, #FFEBDC 100%);
  border-bottom: 1px solid var(--cotia-soft-border);
  color: #7A4313;
}

#cotiaPanel .cotia-chat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 8px;
  height: 320px;
  /* ajusta si quieres más alto */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(18px 18px at 20% 15%, rgba(255, 168, 112, 0.08) 0%, rgba(255, 168, 112, 0) 70%) no-repeat,
    radial-gradient(22px 22px at 80% 85%, rgba(255, 162, 99, 0.10) 0%, rgba(255, 162, 99, 0) 72%) no-repeat,
    var(--cotia-white);
  border-bottom: 1px solid #EFEFEF;
}

/* Fila mensaje: izquierda AI, derecha usuario */
#cotiaPanel .cotia-msg {
  display: flex;
  max-width: 82%;
}

#cotiaPanel .cotia-msg.ai {
  justify-content: flex-start;
  margin-right: auto;
}

#cotiaPanel .cotia-msg.user {
  justify-content: flex-end;
  margin-left: auto;
}

/* Bocadillo base */
#cotiaPanel .cotia-msg .bubble {
  position: relative;
  padding: 10px 12px;
  border-radius: 16px;
  line-height: 1.35;
  font-size: 14px;
  color: var(--cotia-text);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  word-break: break-word;
  white-space: pre-wrap;
  /* respeta saltos de línea si los hay */
}

/* Bocadillo AI (izquierda): blanco suave */
#cotiaPanel .cotia-msg.ai .bubble {
  background: var(--cotia-white);
  border: 1px solid #EDEDED;
}

#cotiaPanel .cotia-msg.ai .bubble::after {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 6px;
  border-width: 8px;
  border-style: solid;
  border-color: transparent var(--cotia-white) transparent transparent;
  filter: drop-shadow(0 0 0 #EDEDED);
}

/* Bocadillo Usuario (derecha): naranja clarito */
#cotiaPanel .cotia-msg.user .bubble {
  background: var(--cotia-soft);
  border: 1px solid var(--cotia-soft-border);
}

#cotiaPanel .cotia-msg.user .bubble::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: 6px;
  border-width: 8px;
  border-style: solid;
  border-color: transparent transparent transparent var(--cotia-soft);
  filter: drop-shadow(0 0 0 var(--cotia-soft-border));
}

/* Footer/input con acento naranja */
#cotiaPanel footer {
  background: var(--cotia-white);
}

#cotiaPanel .cotia-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px 8px;
}

#cotiaPanel #cotiaInput {
  border: 1px solid #E6E6E6;
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
}

#cotiaPanel #cotiaInput:focus {
  border-color: var(--cotia-soft-border);
  box-shadow: 0 0 0 3px rgba(255, 154, 77, 0.18);
}

#cotiaPanel #cotiaSend {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, var(--cotia-accent) 0%, var(--cotia-accent-strong) 100%);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

#cotiaPanel #cotiaSend:hover {
  filter: brightness(0.98);
}

#cotiaPanel .cotia-mini {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--cotia-muted);
  padding: 0 12px 10px;
}

/* ====== CotIA: indicador "pensando..." ====== */
#cotiaPanel .cotia-msg.typing .bubble {
  opacity: 0.92;
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#cotiaPanel .cotia-emoji {
  display: inline-block;
  font-size: 16px;
  line-height: 1;
  animation: cotia-bob 1.8s ease-in-out infinite;
  transform-origin: 50% 100%;
}

#cotiaPanel .cotia-dots .dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 3px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  animation: cotia-blink 1.2s infinite;
}

#cotiaPanel .cotia-dots .dot:nth-child(2) {
  animation-delay: .2s;
}

#cotiaPanel .cotia-dots .dot:nth-child(3) {
  animation-delay: .4s;
}

@keyframes cotia-blink {

  0%,
  20% {
    opacity: 0.2;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-1px);
  }

  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
}

@keyframes cotia-bob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-2px);
  }
}

/* CotIA: close button más pequeño y con naranja fuerte */
#cotiaPanel #cotiaClose,
#cotiaPanel .cotia-close,
#cotiaPanel header button[aria-label="Cerrar"],
#cotiaPanel header .btn-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--cotia-accent-strong, #FF6A00);
  /* naranja más fuerte */
  width: 24px;
  /* tamaño del botón (clickable) */
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-size: 14px;
  /* tamaño del símbolo “×” si es texto */
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease, filter .15s ease;
  margin-left: auto;
  /* empuja a la derecha del header (si cabe) */
}

/* Estados: hover/focus/active para mejor visibilidad y accesibilidad */
#cotiaPanel #cotiaClose:hover,
#cotiaPanel .cotia-close:hover,
#cotiaPanel header button[aria-label="Cerrar"]:hover,
#cotiaPanel header .btn-close:hover {
  background: rgba(255, 106, 0, 0.10);
  /* halo naranja suave */
  filter: contrast(1.1);
}

#cotiaPanel #cotiaClose:focus-visible,
#cotiaPanel .cotia-close:focus-visible,
#cotiaPanel header button[aria-label="Cerrar"]:focus-visible,
#cotiaPanel header .btn-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.28);
  /* anillo de enfoque */
}

#cotiaPanel #cotiaClose:active,
#cotiaPanel .cotia-close:active,
#cotiaPanel header button[aria-label="Cerrar"]:active,
#cotiaPanel header .btn-close:active {
  transform: scale(0.94);
}

/* Si la “X” es un SVG, hereda el color y ajusta el icono */
#cotiaPanel #cotiaClose svg,
#cotiaPanel .cotia-close svg,
#cotiaPanel header button[aria-label="Cerrar"] svg,
#cotiaPanel header .btn-close svg {
  width: 14px;
  /* icono más pequeño */
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}