/* ============================================================
   Sitio de Tiendas — UI operadoras
   Dirección: soft fintech, claro y calmo (Mercury/Ramp-ish)
   Display: Bricolage Grotesque · Body: Hanken Grotesk · Datos: JetBrains Mono
   ============================================================ */

:root {
  /* superficie */
  --bg:        #faf8f4;   /* off-white cálido */
  --surface:   #ffffff;
  --surface-2: #f5f2ec;   /* paneles sutiles / burbuja operador */
  --border:    #ece8e0;
  --border-strong: #ddd7cc;

  /* texto */
  --ink:       #211d17;   /* casi negro cálido */
  --ink-soft:  #5c564c;
  --muted:     #98917f;

  /* acento verde (logo Sitio de Tiendas) */
  --accent:    #5ca52d;
  --accent-700:#478021;
  --accent-100:#edf6e3;

  /* semánticos */
  --ok:        #4f9d69;
  --ok-bg:     #ecf5ee;
  --err:       #c0432f;
  --err-bg:    #fbeae6;
  --err-border:#f0cdc4;

  /* forma */
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(40,30,15,.05), 0 1px 1px rgba(40,30,15,.04);
  --shadow-md: 0 1px 2px rgba(40,30,15,.05), 0 6px 20px rgba(40,30,15,.06);
  --shadow-lg: 0 2px 4px rgba(40,30,15,.05), 0 18px 44px rgba(40,30,15,.10);

  --ease: cubic-bezier(.2, .7, .25, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Hanken Grotesk", ui-sans-serif, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  /* atmósfera: dos halos cálidos muy sutiles, no color plano */
  background-image:
    radial-gradient(900px 500px at 12% -8%, rgba(92,165,45,.07), transparent 60%),
    radial-gradient(800px 600px at 100% 0%, rgba(45,120,160,.05), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.wrap { max-width: 960px; margin: 0 auto; padding: 28px 24px 64px; }

/* mono para datos numéricos / ids */
.mono, .id, .meta-num {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-feature-settings: "tnum" 1;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.brand-logo img { height: 54px; width: auto; display: block; }
.page-title {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
  font-size: 26px; letter-spacing: -.02em; color: var(--ink); margin: 0 0 22px;
}
.brand {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 700; font-size: 30px; letter-spacing: -.02em;
  color: var(--ink); margin: 0; line-height: 1.05;
}
.brand .dot { color: var(--accent); }
.brand small {
  display: block; font-family: "Hanken Grotesk", sans-serif;
  font-weight: 500; font-size: 12.5px; letter-spacing: .02em;
  color: var(--muted); margin-top: 4px; text-transform: uppercase;
}
.userbar { font-size: 13.5px; color: var(--ink-soft); white-space: nowrap; }
.userbar .who { font-weight: 600; color: var(--ink); }
.userbar .sep { color: var(--border-strong); margin: 0 8px; }

/* ---------- Panel "nuevo cliente" ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 26px;
}
.panel-label {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 600; font-size: 14px; letter-spacing: .01em;
  color: var(--ink); margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.panel-label::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-100);
}
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-row .grow { flex: 1; min-width: 140px; }

/* ---------- Inputs / botones ---------- */
input, select, textarea, button { font: inherit; }

.field, input[type="text"], input:not([type]), select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 10px 13px;
  color: var(--ink);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
input::placeholder { color: var(--muted); }
.field:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-100);
}
select { cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2398917f' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.id-input { font-family: "JetBrains Mono", monospace; letter-spacing: .08em; width: 110px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--r-md); padding: 10px 18px;
  font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
}
.btn:hover { background: var(--accent-700); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.full { width: 100%; }

/* ---------- Grid de clientes ---------- */
.section-head {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px;
}
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}
.client-card {
  display: block; position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: transform .18s var(--ease), box-shadow .22s var(--ease), border-color .18s var(--ease);
  /* entrada escalonada */
  animation: rise .5s var(--ease) both;
}
.client-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  color: var(--ink);
}
.client-card .cid {
  font-family: "JetBrains Mono", monospace; font-weight: 600;
  font-size: 19px; letter-spacing: .04em; color: var(--ink);
}
.client-card .alias {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 600;
  font-size: 16px; margin: 3px 0 12px; color: var(--ink);
}
.client-card .arrow {
  position: absolute; top: 18px; right: 16px; color: var(--muted);
  transition: transform .2s var(--ease), color .2s var(--ease);
}
.client-card:hover .arrow { transform: translateX(3px); color: var(--accent); }

/* Link que cubre la card: el texto queda debajo (navega igual); los botones
   van por encima con z-index mayor para ser clickeables. */
.card-link { position: absolute; inset: 0; z-index: 1; border-radius: var(--r-lg); }
.client-card .cid,
.client-card .alias,
.client-card .chips { position: relative; z-index: 0; pointer-events: none; }

.card-edit {
  position: absolute; top: 14px; right: 40px; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  cursor: pointer; opacity: 0;
  transition: opacity .16s var(--ease), background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.client-card:hover .card-edit { opacity: 1; }
.card-edit:hover,
.card-edit.active {
  opacity: 1; background: var(--accent-100);
  border-color: var(--border); color: var(--accent-700);
}

.card-menu {
  position: relative; z-index: 2; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.card-del {
  width: 100%; padding: 9px 12px; border-radius: var(--r-md, 10px);
  background: #fdecea; border: 1px solid #f3c6c0; color: #a8331f;
  font-family: "Hanken Grotesk", sans-serif; font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: background .16s var(--ease), border-color .16s var(--ease);
}
.card-del:hover { background: #f9ddd9; border-color: #e7a89f; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--border);
}
.chip.num { font-family: "JetBrains Mono", monospace; letter-spacing: .02em; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.ok::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }

.empty {
  text-align: center; color: var(--muted);
  padding: 56px 20px; border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg); background: rgba(255,255,255,.4);
}
.empty .big { font-family: "Bricolage Grotesque", sans-serif; font-size: 17px; color: var(--ink-soft); }

/* mensajes de error de formulario */
.form-error {
  margin: 12px 0 0; padding: 9px 13px; border-radius: var(--r-sm);
  background: var(--err-bg); color: var(--err); border: 1px solid var(--err-border);
  font-size: 13.5px; font-weight: 500;
}

/* ============================================================
   Pantalla de cliente / chat  (2 columnas: chat + panel archivos)
   ============================================================ */
.client-layout {
  max-width: 1340px; margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: 244px minmax(0, 1fr) 320px; gap: 20px;
  align-items: start;
}
.chat-col {
  min-width: 0; min-height: 100vh;
  display: flex; flex-direction: column;
}
@media (max-width: 1140px) {
  .client-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .files-col { grid-column: 2; position: static !important; }
}
@media (max-width: 760px) {
  .client-layout { grid-template-columns: 1fr; }
  .clients-rail, .files-col { grid-column: 1; position: static !important; }
}

/* ---------- Rail de clientes (izquierda) ---------- */
.clients-rail {
  position: sticky; top: 18px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - 36px);
}
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px; }
.rail-head .rail-brand { display: inline-flex; align-items: center; }
.rail-head .rail-brand img { height: 40px; width: auto; display: block; }
.rail-new {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--accent); color: #fff; font-size: 19px; line-height: 1;
  box-shadow: var(--shadow-sm); transition: background .16s var(--ease);
}
.rail-new:hover { background: var(--accent-700); color: #fff; }
.rail-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; padding-right: 2px; }
.rail-item {
  display: block; padding: 9px 11px; border-radius: var(--r-md);
  color: var(--ink); border: 1px solid transparent;
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.rail-item:hover { background: var(--surface); color: var(--ink); }
.rail-item.active {
  background: var(--surface); border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.rail-item.active .ri-id { color: var(--accent); }
.rail-item .ri-id {
  font-family: "JetBrains Mono", monospace; font-weight: 600; font-size: 13px;
}
.rail-item .ri-alias {
  font-size: 12.5px; color: var(--ink-soft); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-empty { font-size: 12.5px; color: var(--muted); padding: 10px 4px; }

/* ---------- Panel de archivos (derecha) ---------- */
.files-col {
  position: sticky; top: 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.files-title {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 600;
  font-size: 14px; margin: 0; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.files-title::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-100);
}
.upload-form { display: flex; flex-direction: column; gap: 9px; }
.upload-form .dropzone {
  flex-direction: column; text-align: center; gap: 8px;
  padding: 20px 12px; border-radius: var(--r-md);
}
.upload-form .dz-text { font-size: 13px; }
.dz-hint { font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--muted); }
.htmx-indicator { opacity: 0; color: var(--muted); transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.files-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.file-card {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 9px 11px;
}
.file-ico.sm { width: 26px; height: 26px; border-radius: 7px; }
.file-meta { min-width: 0; flex: 1; }
.file-card .file-name {
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-tag { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.file-del {
  position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px; border-radius: 50%; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--err); color: #fff; border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm); cursor: pointer;
  opacity: 0; transform: scale(.7);
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
.file-card:hover .file-del { opacity: 1; transform: scale(1); }
.file-del:hover { background: #a8331f; }
.files-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 18px 8px; }
.process-form { margin-top: 2px; }

.chat-wrap { /* legacy, sin uso tras el layout 2-col */ display: contents; }
.chat-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 18px 4px 16px;
  background: linear-gradient(var(--bg) 72%, transparent);
}
.back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--ink); box-shadow: var(--shadow-sm);
  transition: background .16s var(--ease), transform .12s var(--ease);
}
.back:hover { background: var(--surface-2); color: var(--ink); }
.back:active { transform: translateY(1px); }
.chat-title { flex: 1; min-width: 0; }
.chat-title .cid {
  font-family: "JetBrains Mono", monospace; font-weight: 600;
  font-size: 17px; letter-spacing: .04em;
}
.chat-title .alias {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 600; font-size: 17px;
}
.chat-title .ccy {
  font-family: "JetBrains Mono", monospace; font-size: 12px;
  color: var(--muted); margin-left: 6px;
}
.chat-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.pl-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ok);
  background: var(--ok-bg); padding: 7px 12px; border-radius: 999px;
}
.pl-link:hover { color: var(--ok); filter: brightness(.96); }

/* hilo */
.thread {
  flex: 1; display: flex; flex-direction: column; gap: 10px;
  padding: 8px 2px 18px;
}
.msg {
  max-width: 76%; padding: 10px 14px; border-radius: var(--r-lg);
  font-size: 14.5px; line-height: 1.45; position: relative;
  white-space: pre-wrap; word-wrap: break-word;
  box-shadow: var(--shadow-sm);
  /* sin animación de entrada: el polling re-renderiza el hilo y re-dispararía
     la animación en cada tick (parpadeo). */
}
.msg .time {
  display: block; margin-top: 5px;
  font-family: "JetBrains Mono", monospace; font-size: 10.5px;
  color: var(--muted); opacity: .8;
}
/* operador → derecha, crema cálido */
.msg.op {
  align-self: flex-end; background: var(--surface-2);
  border: 1px solid var(--border); border-bottom-right-radius: 5px;
  color: var(--ink);
}
/* sistema → izquierda, blanco */
.msg.sys {
  align-self: flex-start; background: var(--surface);
  border: 1px solid var(--border); border-bottom-left-radius: 5px;
}
/* error → rojo cálido */
.msg.err {
  align-self: flex-start; background: var(--err-bg);
  border: 1px solid var(--err-border); border-bottom-left-radius: 5px;
  color: #7d2b1d;
}
/* resumen → verde suave */
.msg.ok {
  align-self: flex-start; background: var(--ok-bg);
  border: 1px solid #cde6d4; border-bottom-left-radius: 5px;
  color: #2f5c41;
}
/* agente (asistente IA) → izquierda, blanco con franja de acento */
.msg.agent {
  align-self: flex-start; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-bottom-left-radius: 5px; color: var(--ink);
}
/* Markdown renderizado dentro de la burbuja del agente */
.msg.agent .md-body,
.msg.analisis .md-body { display:block; }
.msg.agent .md-body > :first-child,
.msg.analisis .md-body > :first-child { margin-top:0; }
.msg.agent .md-body > :last-child,
.msg.analisis .md-body > :last-child { margin-bottom:0; }
.msg.agent .md-body h1,
.msg.analisis .md-body h1,
.msg.agent .md-body h2,
.msg.analisis .md-body h2,
.msg.agent .md-body h3,
.msg.analisis .md-body h3,
.msg.agent .md-body h4,
.msg.analisis .md-body h4 {
  font-size:13.5px; font-weight:700; margin:12px 0 5px; color:var(--ink);
}
.msg.agent .md-body p,
.msg.analisis .md-body p { margin:6px 0; }
.msg.agent .md-body ul,
.msg.analisis .md-body ul,
.msg.agent .md-body ol,
.msg.analisis .md-body ol { margin:6px 0; padding-left:20px; }
.msg.agent .md-body li,
.msg.analisis .md-body li { margin:2px 0; }
.msg.agent .md-body strong,
.msg.analisis .md-body strong { font-weight:700; }
.msg.agent .md-body code,
.msg.analisis .md-body code {
  font-family:"JetBrains Mono",monospace; font-size:12px;
  background:var(--surface-2); padding:1px 5px; border-radius:5px;
}
.msg.agent .md-body table,
.msg.analisis .md-body table { border-collapse:collapse; margin:8px 0; font-size:13px; }
.msg.agent .md-body th,
.msg.analisis .md-body th,
.msg.agent .md-body td,
.msg.analisis .md-body td {
  border:1px solid var(--border); padding:5px 10px; text-align:left;
}
.msg.agent .md-body th,
.msg.analisis .md-body th { background:var(--surface-2); font-weight:600; }
.msg.agent .md-body a,
.msg.analisis .md-body a { color:var(--accent-700); }
/* chip de archivo dentro de burbuja del operador */
.msg.file { display: inline-flex; align-items: center; gap: 9px; padding-right: 16px; }
.file-ico {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-100); color: var(--accent);
}
.file-name { font-family: "JetBrains Mono", monospace; font-size: 13px; }

.thread-empty {
  margin: auto; text-align: center; color: var(--muted); padding: 40px 0;
}

/* ---------- Composer ---------- */
.composer {
  position: sticky; bottom: 0;
  background: linear-gradient(transparent, var(--bg) 24%);
  padding: 10px 0 18px;
}
.composer-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.composer-row { display: flex; gap: 9px; align-items: center; }
.composer-row .msg-input {
  flex: 1; border: none; background: transparent; padding: 8px 6px;
}
.composer-row .msg-input:focus { box-shadow: none; }
.send-btn {
  width: 40px; height: 40px; padding: 0; border-radius: 11px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.composer-tools {
  display: flex; gap: 9px; align-items: stretch;
  border-top: 1px solid var(--border); padding-top: 10px;
}
.dropzone {
  flex: 1; display: flex; align-items: center; gap: 10px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  padding: 8px 12px; cursor: pointer; color: var(--ink-soft);
  font-size: 13.5px; transition: border-color .16s var(--ease), background .16s var(--ease);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-100); }
.dropzone input[type="file"] { display: none; }
.dropzone .dz-ico { color: var(--accent); display: inline-flex; }
.dropzone .dz-file { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--ink); }
.process-btn { white-space: nowrap; }

/* ---------- Composer: cards de adjunto (estilo Claude) + botón + ---------- */
.attach-chips { display:flex; gap:8px; overflow-x:auto; padding:6px 2px 10px; }
.attach-card {
  position:relative; flex:0 0 auto; width:150px;
  display:flex; flex-direction:column; gap:16px;
  background:var(--surface-2); border:1px solid var(--border);
  border-radius:11px; padding:10px 11px;
}
.ac-name {
  font-size:12px; color:var(--ink); line-height:1.3;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
  overflow:hidden; word-break:break-word;
}
.ac-ext {
  align-self:flex-start; font-family:"JetBrains Mono",monospace; font-size:9.5px;
  color:var(--muted); border:1px solid var(--border-strong);
  border-radius:5px; padding:1px 6px; text-transform:uppercase;
}
.ac-del {
  position:absolute; top:-7px; right:-7px; width:20px; height:20px;
  border-radius:50%; padding:0; display:inline-flex; align-items:center; justify-content:center;
  background:var(--err); color:#fff; border:2px solid var(--surface);
  font-size:14px; line-height:1; cursor:pointer;
  opacity:0; transform:scale(.7);
  transition:opacity .14s var(--ease), transform .14s var(--ease);
}
.attach-card:hover .ac-del { opacity:1; transform:scale(1); }
.ac-del:hover { background:#a8331f; }

/* ---------- Archivos enviados (grid de cards en el hilo) ---------- */
.files-grid {
  align-self:flex-end; max-width:86%;
  display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end;
}
.sent-card {
  width:150px; display:flex; flex-direction:column; gap:16px;
  background:var(--surface-2); border:1px solid var(--border);
  border-radius:11px; padding:10px 11px;
}
.sc-name {
  font-size:12px; color:var(--ink); line-height:1.3;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
  overflow:hidden; word-break:break-word;
}
.sc-ext {
  align-self:flex-start; font-family:"JetBrains Mono",monospace; font-size:9.5px;
  color:var(--muted); border:1px solid var(--border-strong);
  border-radius:5px; padding:1px 6px; text-transform:uppercase;
}

/* ---------- Loader "pensando" con estados rotativos ---------- */
.thinking { display:flex; align-items:center; gap:11px; padding:8px 4px; align-self:flex-start; }
.thinking-dot {
  width:16px; height:16px; flex:none; border-radius:50%;
  border:2px solid var(--accent-100); border-top-color:var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thinking-rotate {
  position:relative; display:inline-block; height:1.45em; min-width:280px;
  font-size:14px; color:var(--ink-soft);
}
.thinking-rotate span {
  position:absolute; left:0; top:0; white-space:nowrap; opacity:0;
  animation: rotate-text 10s infinite;
}
.thinking-rotate span:nth-child(1) { animation-delay: 0s; }
.thinking-rotate span:nth-child(2) { animation-delay: 2s; }
.thinking-rotate span:nth-child(3) { animation-delay: 4s; }
.thinking-rotate span:nth-child(4) { animation-delay: 6s; }
.thinking-rotate span:nth-child(5) { animation-delay: 8s; }
@keyframes rotate-text {
  0%  { opacity:0; transform:translateY(4px); }
  3%  { opacity:1; transform:translateY(0); }
  17% { opacity:1; transform:translateY(0); }
  20% { opacity:0; transform:translateY(-4px); }
  100%{ opacity:0; }
}
@media (prefers-reduced-motion: reduce) {
  .thinking-rotate span { animation: none; }
  .thinking-rotate span:nth-child(1) { opacity:1; }
}
.attach-btn { width:40px; height:40px; flex:none; display:inline-flex; align-items:center; justify-content:center; line-height:1; padding:0; border:1px solid var(--border-strong); border-radius:11px; font-size:22px; color:var(--accent); cursor:pointer; background:var(--surface); }
.attach-btn:hover { background:var(--accent-100); }

/* ---------- Burbujas de pregunta con opciones ---------- */
/* ---------- Pregunta estilo Claude (card ancha + filas numeradas) ---------- */
.question-card {
  align-self:stretch; width:100%;
  background:var(--surface); border:1px solid var(--border-strong);
  border-radius:var(--r-lg); box-shadow:var(--shadow-sm);
  margin:2px 0; overflow:hidden;
}
.question-card.question-stale { opacity:.55; }
.q-head { display:flex; align-items:flex-start; gap:14px; justify-content:space-between; padding:14px 16px 12px; }
.q-title-wrap { min-width:0; }
.q-title { font-size:14.5px; line-height:1.45; color:var(--ink); }
.q-detail { font-size:13px; color:var(--muted); margin-top:4px; font-family:"JetBrains Mono",monospace; white-space:pre-wrap; overflow-wrap:anywhere; }
.q-nav { flex:none; display:flex; align-items:center; gap:8px; padding-top:2px; }
.q-arrow {
  width:20px; height:22px; padding:0; border:none; background:transparent;
  color:var(--muted); cursor:pointer; font-size:17px; line-height:1;
  display:inline-flex; align-items:center; justify-content:center; transition:color .12s var(--ease);
}
.q-arrow:hover { color:var(--ink); }
.q-counter {
  flex:none; font-family:"JetBrains Mono",monospace; font-size:12px;
  color:var(--muted); white-space:nowrap;
}
.q-rows { display:flex; flex-direction:column; }
.q-row {
  display:flex; align-items:center; gap:13px; width:100%; text-align:left;
  background:transparent; border:none; border-top:1px solid var(--border);
  padding:12px 16px; cursor:pointer; color:var(--ink); font-size:14px;
  transition:background .12s var(--ease);
}
.q-row:hover:not(:disabled) { background:var(--surface-2); }
.q-row:disabled { cursor:default; opacity:.5; }
.q-row.picked { background:var(--accent-100); }
.q-row.picked .q-num { background:var(--accent); color:#fff; border-color:var(--accent); }
.q-row .q-row-go { font-size:13px; }
.q-row.picked .q-row-go { opacity:1; color:var(--accent); }
.q-num {
  flex:none; width:26px; height:26px; display:inline-flex; align-items:center; justify-content:center;
  border-radius:7px; background:var(--surface-2); border:1px solid var(--border);
  font-family:"JetBrains Mono",monospace; font-size:12px; color:var(--ink-soft);
  transition:background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.q-row:hover:not(:disabled) .q-num { background:var(--accent); color:#fff; border-color:var(--accent); }
.q-row-text { flex:1; }
.q-row-go { flex:none; color:var(--accent); opacity:0; transition:opacity .12s var(--ease); }
.q-row:hover:not(:disabled) .q-row-go { opacity:1; }
.q-free {
  display:flex; align-items:center; gap:11px; border-top:1px solid var(--border);
  padding:10px 16px 12px;
}
.q-pencil { flex:none; width:26px; height:26px; display:inline-flex; align-items:center; justify-content:center; color:var(--muted); }
.q-free input { flex:1; border:none; background:transparent; padding:6px 2px; font-size:14px; }
.q-free input:focus { outline:none; box-shadow:none; }
.q-free-go {
  flex:none; width:32px; height:32px; padding:0; border-radius:9px; border:none;
  background:var(--accent); color:#fff; display:inline-flex; align-items:center; justify-content:center;
  cursor:pointer; line-height:1; transition:background .14s var(--ease);
}
.q-free-go:hover { background:var(--accent-700); }
.q-foot {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  border-top:1px solid var(--border); padding:11px 16px;
}
.q-progress { font-size:13px; color:var(--muted); }
.q-progress #qdone { color:var(--ink); font-weight:600; }
#qsend:disabled { opacity:.45; cursor:default; }
/* Spinner en "Enviar respuestas" mientras procesa (regenera el P&L) */
.qsend-dot {
  display:none; width:13px; height:13px; margin-right:8px; vertical-align:-2px;
  border:2px solid rgba(255,255,255,.5); border-top-color:#fff; border-radius:50%;
  animation: spin .7s linear infinite;
}
.htmx-request .qsend-dot { display:inline-block; }
.q-send-form.htmx-request #qsend { opacity:.9; cursor:progress; }
/* Spinner en el botón del composer mientras el agente responde */
.send-dot {
  display:none; width:13px; height:13px;
  border:2px solid rgba(255,255,255,.5); border-top-color:#fff; border-radius:50%;
  animation: spin .7s linear infinite;
}
.composer-row.htmx-request .send-dot { display:inline-block; }
.composer-row.htmx-request .send-arrow { display:none; }
.composer-row.htmx-request .send-btn { cursor:progress; }
/* Al responder la última pregunta, un pulso llama la atención al botón Enviar */
@keyframes qpulse { 0%,100%{ box-shadow:var(--shadow-sm); } 50%{ box-shadow:0 0 0 4px rgba(92,165,45,.28); } }
.q-send-ready { animation: qpulse 1.1s ease-in-out 2; }

/* Chips toggleables (duda de bancos: tildar conceptos a excluir) */
.q-chips { display:flex; flex-wrap:wrap; gap:8px; padding:6px 16px 2px; }
.q-chip {
  display:inline-flex; align-items:center; gap:7px; max-width:100%;
  padding:7px 12px; border:1px solid var(--border-strong); border-radius:999px;
  background:var(--surface-2); color:var(--ink); font-size:12.5px; cursor:pointer;
  transition:background .12s, border-color .12s, color .12s;
}
.q-chip:hover { border-color:var(--muted); }
.q-chip .q-chip-mark { flex:none; font-weight:700; color:var(--muted); line-height:1; }
.q-chip .q-chip-mark::before { content:"＋"; }
.q-chip .q-chip-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.q-chip.excluded {
  background:var(--err-bg); border-color:var(--err-border); color:var(--err);
  text-decoration:line-through;
}
.q-chip.excluded .q-chip-mark { color:var(--err); }
.q-chip.excluded .q-chip-mark::before { content:"✕"; }
.q-chips-hint { font-size:12px; color:var(--muted); padding:2px 16px 6px; margin:0; }

/* ---------- Card de archivo procesado ---------- */
.card-msg { display:flex; align-items:center; justify-content:space-between; gap:14px; max-width:92%; }
.card-file { display:flex; align-items:center; gap:11px; min-width:0; }
.cf-name { font-family:"JetBrains Mono",monospace; font-size:13px; }
.cf-sub { font-size:12px; color:var(--muted); }
.card-actions { display:flex; gap:8px; flex:none; }
.card-btn { display:inline-flex; align-items:center; gap:7px; padding:7px 13px; border-radius:9px; font-size:13px; font-weight:600; border:1px solid var(--border-strong); color:var(--ink); }
.card-btn:hover { background:var(--surface-2); }
.card-btn.icon { padding:7px 9px; }
.card-btn.primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.card-btn.primary:hover { background:var(--accent-700); color:#fff; }

/* ============================================================
   Login
   ============================================================ */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; box-shadow: var(--shadow-lg);
  padding: 44px 36px 38px;
  animation: rise .55s var(--ease) both;
}
.login-logo { height: 72px; width: auto; margin: 0 auto 18px; display: block; }
.login-card h1 {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
  font-size: 25px; letter-spacing: -.02em; margin: 0 0 6px; color: var(--ink);
}
.login-card .lede { color: var(--muted); font-size: 14px; margin: 0 0 26px; }

/* ---------- animaciones ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop  { from { opacity: 0; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: none; } }

/* stagger de las primeras cards */
.grid .client-card:nth-child(1) { animation-delay: .02s; }
.grid .client-card:nth-child(2) { animation-delay: .06s; }
.grid .client-card:nth-child(3) { animation-delay: .10s; }
.grid .client-card:nth-child(4) { animation-delay: .14s; }
.grid .client-card:nth-child(5) { animation-delay: .18s; }
.grid .client-card:nth-child(6) { animation-delay: .22s; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Panel Diccionario ---------- */
.nav-link {
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 13px;
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); margin-right: 14px; transition: all .15s var(--ease);
}
.nav-link:hover { border-color: var(--border-strong); color: var(--ink); }
.userbar { display: inline-flex; align-items: center; }

.page-sub {
  max-width: 780px; margin: -8px 0 24px; color: var(--ink-soft);
  font-size: 14px; line-height: 1.6;
}

.voc-channel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-sm);
  margin-bottom: 14px; overflow: hidden;
}
.voc-ch-head {
  cursor: pointer; padding: 15px 18px; font-weight: 700; font-size: 15.5px;
  color: var(--ink); list-style: none; user-select: none;
  font-family: "Bricolage Grotesque", sans-serif;
}
.voc-ch-head::-webkit-details-marker { display: none; }
.voc-ch-head::before { content: "▸"; color: var(--muted); margin-right: 10px; font-size: 11px; }
details[open] > .voc-ch-head::before { content: "▾"; }
.voc-ch-head:hover { background: var(--bg); }

.voc-kind { padding: 2px 18px 16px; border-top: 1px solid var(--border); }
.voc-kind-head { margin: 14px 0 10px; }
.voc-kind-head h3 {
  margin: 0; font-size: 12px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .05em;
}
.voc-help { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.voc-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.voc-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.voc-term {
  flex: 1 1 auto; min-width: 0; font-size: 13.5px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.voc-set, .voc-delf { flex: 0 0 auto; margin: 0; }
.voc-set select, .voc-add select {
  font: inherit; font-size: 13px; padding: 5px 9px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  cursor: pointer;
}
.voc-badge {
  flex: 0 0 auto; font-size: 11px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; white-space: nowrap;
}
.voc-badge.base { background: #f0ede6; color: var(--muted); }
.voc-badge.learned { background: var(--ok-bg); color: var(--ok); }
.voc-del {
  width: 26px; height: 26px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--err); font-size: 17px; line-height: 1;
  cursor: pointer; transition: all .15s var(--ease);
}
.voc-del:hover:not(:disabled) { background: var(--err-bg); border-color: var(--err-border); }
.voc-del:disabled { color: var(--border-strong); cursor: not-allowed; }

.voc-empty { font-size: 13px; color: var(--muted); font-style: italic; margin: 0 0 12px; }

.voc-add { display: flex; gap: 8px; align-items: center; }
.voc-add-key {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: 13.5px;
  padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
}
.btn.sm { padding: 7px 15px; font-size: 13px; }

.voc-note {
  margin: 18px 0 40px; font-size: 13px; color: var(--ink-soft);
  padding: 12px 15px; background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}

/* Informe del analista externo: misma burbuja que el agente pero con banda
   ámbar, para que se distinga de una respuesta del chat a simple vista. */
.msg.analisis {
  align-self: flex-start; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid #d99a2b;
  border-bottom-left-radius: 5px; color: var(--ink); max-width: 92%;
}
.msg.analisis table { width:100%; border-collapse:collapse; margin:8px 0; font-size:12.5px; }
.msg.analisis th, .msg.analisis td { border:1px solid var(--border); padding:4px 7px; text-align:right; }
.msg.analisis th:first-child, .msg.analisis td:first-child { text-align:left; }
.msg.analisis del { color: var(--muted); }

/* ---------- Correcciones sugeridas por el analista ----------
   Tarjeta propia (no chips): cada ajuste necesita monto, línea destino y dos
   acciones claras. Banda ámbar como el informe, para que se lea como parte
   del mismo hilo de análisis. */
.ajustes-card {
  align-self: stretch; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid #d99a2b;
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 16px 18px; margin: 6px 0 2px;
  animation: rise .45s var(--ease) both;
}
.aj-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 4px; }
.aj-badge {
  flex: 0 0 auto; min-width: 24px; height: 24px; border-radius: 999px;
  background: #fdf3e0; color: #a06b12; font-size: 12.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 7px;
}
.aj-title {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
  font-size: 14.5px; color: var(--ink);
}
.aj-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.aj-item { border-top: 1px solid var(--border); padding: 13px 0 3px; margin-top: 10px; }
.aj-item-top { display: flex; align-items: baseline; gap: 12px; justify-content: space-between; }
.aj-concepto { font-weight: 600; font-size: 14px; color: var(--ink); }
.aj-monto {
  font-family: "JetBrains Mono", monospace; font-feature-settings: "tnum" 1;
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.aj-monto.pos { color: var(--accent-700); }
.aj-monto.neg { color: var(--err); }

.aj-destino { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.aj-linea {
  font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft);
}
.aj-meses {
  font-family: "JetBrains Mono", monospace; font-size: 11.5px; color: var(--muted);
}
.aj-motivo { margin: 8px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }

.aj-detalle { margin-top: 7px; }
.aj-detalle summary {
  cursor: pointer; font-size: 12.5px; color: var(--ink-soft);
  list-style: none; display: inline-flex; align-items: center; gap: 5px;
}
.aj-detalle summary::-webkit-details-marker { display: none; }
.aj-detalle summary::before { content: "▸"; color: var(--muted); font-size: 10px; }
.aj-detalle[open] summary::before { content: "▾"; }
.aj-detalle summary:hover { color: var(--ink); }
.aj-detalle p {
  margin: 7px 0 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.55;
  padding-left: 13px; border-left: 2px solid var(--border);
}

.aj-acciones { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.aj-acciones form { margin: 0; }
.btn.sm { padding: 7px 15px; font-size: 13px; }
.aj-descartar {
  background: none; border: none; color: var(--muted); font-size: 13px;
  cursor: pointer; padding: 7px 4px; transition: color .15s var(--ease);
}
.aj-descartar:hover { color: var(--err); text-decoration: underline; }

/* El detalle plegable dentro del informe del analista */
.msg.analisis details { margin-top: 10px; }
.msg.analisis summary {
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--accent-700);
  list-style: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 0;
}
.msg.analisis summary::-webkit-details-marker { display: none; }
.msg.analisis summary::before { content: "▸"; font-size: 10px; }
.msg.analisis details[open] summary::before { content: "▾"; }
.msg.analisis sub { color: var(--muted); font-size: 11.5px; }

/* ---------- Aviso de revisión en profundidad en curso ----------
   El P&L ya está y reconcilió: esto NO dice "el número puede estar mal", dice
   que hay una segunda lectura corriendo que puede sugerir correcciones. */
.revision {
  align-self: stretch; display: flex; align-items: flex-start; gap: 10px;
  background: #fdfaf3; border: 1px dashed #e3c98f; border-radius: var(--r-md);
  padding: 11px 14px; margin: 6px 0 2px;
  font-size: 13px; color: var(--ink-soft); line-height: 1.5;
}
.revision b { color: var(--ink); font-weight: 600; }
.revision.demorada { background: var(--surface-2); border-color: var(--border-strong); }
.rev-ico { flex: none; font-size: 14px; line-height: 1.4; }
.rev-dot {
  flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px;
  background: #d99a2b; animation: revpulse 1.4s ease-in-out infinite;
}
@keyframes revpulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

/* ---------- Resumen previo al envío de respuestas ----------
   Reemplaza a los slides cuando ya están todas contestadas: se ve qué se va a
   mandar, sin dejar a la vista una pregunta re-clickeable. */
.q-resumen { padding: 4px 0 2px; }
.qr-head {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent-700); margin-bottom: 9px;
}
.qr-list { display: flex; flex-direction: column; gap: 6px; }
.qr-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.qr-q {
  flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qr-a {
  flex: 0 0 auto; font-size: 12.5px; font-weight: 600; color: var(--ink);
  background: var(--accent-100); border-radius: 999px; padding: 2px 10px;
  max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qr-edit {
  flex: 0 0 auto; background: none; border: none; padding: 2px 4px;
  font-size: 12px; color: var(--muted); cursor: pointer; text-decoration: underline;
}
.qr-edit:hover { color: var(--accent-700); }
