/* ============================================================
   PRINDIA CLOUD — la plataforma interna. Sistema visual.

   EL ACENTO ES VIOLETA A PROPÓSITO: el azul es de Prindia Home, que es la cara pública del
   producto. Aquí se gestionan clientes y se toca el cerebro del agente, y con las dos ventanas
   abiertas hay que saber en cuál estás ANTES de pulsar nada.

   Tipos: Spectral (serif) · Instrument Sans (UI) · IBM Plex Mono (meta)
   ============================================================ */

:root {
  /* Neutros fríos (gris-slate) — paleta enterprise "Slate + Azul corporativo" */
  --paper:      oklch(0.985 0.004 255);
  --paper-2:    oklch(0.966 0.005 256);
  --surface:    oklch(0.999 0.001 255);
  --surface-2:  oklch(0.977 0.004 256);

  --ink:        oklch(0.28 0.022 260);
  --ink-2:      oklch(0.44 0.020 261);
  --ink-3:      oklch(0.58 0.016 262);
  --ink-4:      oklch(0.70 0.013 264);

  --line:       oklch(0.910 0.008 258);
  --line-2:     oklch(0.856 0.010 258);

  /* Acento: azul corporativo */
  --accent:     oklch(0.52 0.130 300);
  --accent-ink: oklch(0.45 0.142 300);
  --accent-soft:oklch(0.955 0.028 300);
  --accent-line:oklch(0.860 0.055 300);

  --ok:         oklch(0.52 0.075 162);
  --ok-soft:    oklch(0.953 0.030 162);
  --warn:       oklch(0.62 0.110 70);
  --warn-soft:  oklch(0.955 0.050 75);
  --danger:     oklch(0.53 0.150 28);
  --danger-soft:oklch(0.953 0.042 32);
  --info:       oklch(0.55 0.090 232);
  --info-soft:  oklch(0.955 0.030 232);

  --r:    11px;
  --r-sm: 7px;
  --r-lg: 16px;

  --serif: 'Spectral', Georgia, 'Times New Roman', serif;
  --sans:  'Instrument Sans', system-ui, -apple-system, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, monospace;

  --sh-sm: 0 1px 2px oklch(0.3 0.02 260 / 0.06), 0 1px 1px oklch(0.3 0.02 260 / 0.05);
  --sh:    0 1px 3px oklch(0.3 0.02 260 / 0.07), 0 8px 24px oklch(0.3 0.02 260 / 0.06);
}

/* ---- Zona B (consola técnica, oscura) ---- */
.tech {
  --paper:      oklch(0.205 0.014 255);
  --paper-2:    oklch(0.178 0.014 255);
  --surface:    oklch(0.247 0.015 255);
  --surface-2:  oklch(0.288 0.016 255);

  --ink:        oklch(0.945 0.006 255);
  --ink-2:      oklch(0.745 0.011 255);
  --ink-3:      oklch(0.605 0.013 255);
  --ink-4:      oklch(0.520 0.014 255);

  --line:       oklch(0.330 0.015 255);
  --line-2:     oklch(0.405 0.016 255);

  --accent:     oklch(0.72 0.120 300);
  --accent-ink: oklch(0.82 0.100 300);
  --accent-soft:oklch(0.320 0.070 300);
  --accent-line:oklch(0.440 0.090 300);

  --ok:         oklch(0.74 0.095 162);
  --ok-soft:    oklch(0.300 0.050 162);
  --warn:       oklch(0.78 0.105 72);
  --warn-soft:  oklch(0.330 0.060 72);
  --danger:     oklch(0.68 0.130 32);
  --danger-soft:oklch(0.320 0.070 32);
  --info:       oklch(0.74 0.080 250);
  --info-soft:  oklch(0.310 0.050 250);

  --sh-sm: 0 1px 2px oklch(0 0 0 / 0.30);
  --sh:    0 1px 3px oklch(0 0 0 / 0.30), 0 10px 30px oklch(0 0 0 / 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ============================================================
   Estructura de pantalla
   ============================================================ */
.screen {
  width: 100%; height: 100%;
  display: flex;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: relative;
}

/* Sidebar de navegación */
.sb {
  width: 305px; flex: 0 0 305px;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 16px 16px;
}
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 22px; cursor: pointer; }
.sb-brand:hover .brand-name { color: var(--accent-ink); }
.brand-tag { margin-left: auto; font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.brandmark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 30px;
}
.brandmark.tech-mark { background: var(--surface-2); border: 1px solid var(--line-2); color: var(--accent); }
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); line-height: 1.1; }
.brand-sub  { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-top: 2px; }

.sb-group-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-4); padding: 14px 10px 7px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  cursor: pointer; position: relative;
  transition: background .12s ease, color .12s ease;
}
.sb-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.85; }
.sb-item .sb-badge { margin-left: auto; }
.sb-item:hover { background: var(--surface-2); color: var(--ink); }
.sb-item.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); font-weight: 600; }
.sb-item.is-active svg { opacity: 1; color: var(--accent); }
.sb-item.is-active::before {
  content: ''; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent);
}

/* sección Asistente (mitad inferior del menú) */
.sb-asistente { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--line); }
.sb-asistente-title { font-family: var(--mono); font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--ink-4); font-weight: 500; padding: 2px 10px 7px; }
/* botón "Nueva conversación" a lo ancho, con aire */
.sb-newchat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 14px; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--surface); color: var(--ink);
  font-size: 13.5px; font-weight: 600; cursor: default;
  box-shadow: var(--sh-sm);
}
.sb-newchat:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.sb-newchat svg { color: var(--accent); }
.sb-consultas { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
/* scroll discreto de las conversaciones: fino y casi invisible (aparece sutil al pasar el ratón) */
.sb-consultas { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sb-consultas:hover { scrollbar-color: var(--line-2) transparent; }
.sb-consultas::-webkit-scrollbar { width: 6px; }
.sb-consultas::-webkit-scrollbar-track { background: transparent; }
.sb-consultas::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.sb-consultas:hover::-webkit-scrollbar-thumb { background: var(--line-2); }
.sb-consulta-group { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4); padding: 9px 10px 4px; }

.sb-foot { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line); }
.tech .sb-foot { margin-top: auto; }
.sb-status { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); }
.sb-status .lbl { font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.sb-status .lbl b { color: var(--ink); font-weight: 600; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px; }

/* Topbar */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.tb {
  height: 70px; flex: 0 0 70px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--paper) 75%, transparent);
  display: flex; align-items: center; gap: 18px;
  padding: 0 32px;
}
.tb-center { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-width: 0; }
.tb-titles { display: flex; flex-direction: column; gap: 2px; }
.tb-eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
/* Migas de pan dentro del rótulo: el nivel actual queda apagado y los anteriores son enlaces. */
.tb-eyebrow .miga { color: var(--ink-3); text-decoration: none; }
.tb-eyebrow .miga:hover { color: var(--ink); text-decoration: underline; }
.tb-eyebrow .miga-sep { margin: 0 5px; opacity: 0.5; }
.tb-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.tb-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tb-search {
  display: flex; align-items: center; gap: 9px;
  width: 280px; height: 38px; padding: 0 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink-3); font-size: 13px;
}
.tb-search svg { width: 15px; height: 15px; }

.content { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.pad { padding: 30px 32px; }

/* ============================================================
   Tipografía utilitaria
   ============================================================ */
.eyebrow { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.serif { font-family: var(--serif); }
.mono  { font-family: var(--mono); }
.h-display { font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.12; color: var(--ink); }
.h-sec { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; color: var(--ink); }
.muted { color: var(--ink-3); }
.muted-2 { color: var(--ink-2); }

/* ============================================================
   Tarjetas
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 11px; }
.card-head .h-sec { flex: 1 1 auto; }

/* franja de estado a la izquierda de tarjetas de aviso */
.alert-card { position: relative; overflow: hidden; }
.alert-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.alert-card.is-danger::before { background: var(--danger); }
.alert-card.is-warn::before   { background: var(--warn); }
.alert-card.is-info::before   { background: var(--info); }
.alert-card.is-ok::before     { background: var(--ok); }

/* ============================================================
   Píldoras / estados
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 23px; padding: 0 9px; border-radius: 999px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 500;
  border: 1px solid transparent; white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill-ok     { background: var(--ok-soft);     color: var(--ok);     }
.pill-warn   { background: var(--warn-soft);   color: var(--warn);   }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info   { background: var(--info-soft);   color: var(--info);   }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill-muted  { background: var(--surface-2);   color: var(--ink-3); border-color: var(--line); }
.pill-ok .dot{background:var(--ok)} .pill-warn .dot{background:var(--warn)} .pill-danger .dot{background:var(--danger)} .pill-info .dot{background:var(--info)}

.dot-pulse { position: relative; }
.dot-pulse::after { content:''; position:absolute; inset:-4px; border-radius:50%; border:1.5px solid currentColor; opacity:.35; }

/* ============================================================
   Botones
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 9px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease, opacity .12s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled], .btn.is-disabled, .btn:disabled { opacity: 0.5; cursor: default; }
.btn[disabled]:hover, .btn:disabled:hover { background: var(--surface); }
.btn-primary[disabled]:hover, .btn-primary:disabled:hover { background: var(--accent); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.icon-btn svg { width: 17px; height: 17px; }

/* ============================================================
   Confianza (barra segmentada)
   ============================================================ */
.conf { display: inline-flex; align-items: center; gap: 8px; }
.conf-track { display: flex; gap: 2px; }
.conf-seg { width: 13px; height: 5px; border-radius: 2px; background: var(--line-2); }
.conf-val { font-family: var(--mono); font-size: 11px; color: var(--ink-2); letter-spacing: 0.02em; }
.conf.lv-high  .conf-seg:nth-child(-n+5){ background: var(--ok); }
.conf.lv-good  .conf-seg:nth-child(-n+4){ background: var(--ok); }
.conf.lv-mid   .conf-seg:nth-child(-n+3){ background: var(--warn); }
.conf.lv-low   .conf-seg:nth-child(-n+2){ background: var(--warn); }
.conf.lv-vlow  .conf-seg:nth-child(-n+1){ background: var(--danger); }

/* Etiqueta de fuente / procedencia */
.src {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.02em; color: var(--ink-3);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 8px; white-space: nowrap;
}
.src svg { width: 12px; height: 12px; opacity: 0.8; flex: 0 0 12px; }
.src.src-inferred { color: var(--info); background: var(--info-soft); border-color: transparent; }
.src.src-chat { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }

/* Avatares */
.avt {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-weight: 600; font-size: 13px;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid var(--accent-line);
}
.avt.sq { border-radius: 9px; }
.avt-sm { width: 26px; height: 26px; flex-basis: 26px; font-size: 11px; }

/* ============================================================
   Tablas / listas
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 500; padding: 0 16px 11px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .t-strong { color: var(--ink); font-weight: 600; }

.rowflex { display: flex; align-items: center; gap: 12px; }

/* segmentos de filtro */
.segs { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg { padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--ink-3); border: none; background: transparent; cursor: pointer; transition: background .12s ease, color .12s ease; }
.seg:hover:not(.is-active) { color: var(--ink); background: var(--surface); }
.seg.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); font-weight: 600; }

/* ============================================================
   Chat
   ============================================================ */
.thread { display: flex; flex-direction: column; gap: 26px; }
.msg { display: flex; gap: 14px; max-width: 760px; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-body { display: flex; flex-direction: column; gap: 9px; }
.bubble-user {
  background: var(--accent); color: #fff; padding: 12px 16px; border-radius: 14px 14px 4px 14px;
  font-size: 14.5px; line-height: 1.5;
}
.bubble-asst { font-size: 14.5px; line-height: 1.62; color: var(--ink); }
.bubble-asst p { margin-bottom: 11px; }
.bubble-asst p:last-child { margin-bottom: 0; }
.bubble-asst strong { font-weight: 600; color: var(--ink); }
.cite-ref { font-family: var(--mono); font-size: 9.5px; vertical-align: super; color: var(--accent-ink); background: var(--accent-soft); padding: 1px 4px; border-radius: 4px; margin: 0 1px; }

.sources-box { margin-top: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); overflow: hidden; }
.sources-head { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-bottom: 1px solid var(--line); }
.sources-head .eyebrow { color: var(--ink-2); }
.sources-list { padding: 7px; display: flex; flex-direction: column; gap: 4px; }
.source-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.source-item svg { width: 15px; height: 15px; color: var(--ink-3); flex: 0 0 15px; }
.source-item .si-main { font-size: 12.5px; color: var(--ink); font-weight: 500; }
.source-item .si-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-left: auto; }

/* Composer */
.composer { border: 1px solid var(--line-2); background: var(--surface); border-radius: 14px; padding: 14px 16px; box-shadow: var(--sh); }
.composer-input { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 15px; }
.composer-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.composer-tools { display: flex; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.chip:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.chip svg { width: 14px; height: 14px; color: var(--accent); }

.hist-item { padding: 10px 12px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 13px; cursor: pointer; line-height: 1.35; transition: background .12s ease, color .12s ease; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-item:hover { background: var(--surface-2); }
.hist-item.is-active { background: var(--surface); box-shadow: var(--sh-sm); color: var(--ink); }
.hist-item .hi-time { font-family: var(--mono); font-size: 9.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; }

/* fila de conversación con menú (renombrar/borrar) que aparece al pasar el ratón */
.sb-search { width: 100%; height: 32px; padding: 0 11px; margin: 2px 0 8px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px; outline: none; }
.sb-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sb-search::placeholder { color: var(--ink-4); }
.hist-row { position: relative; display: flex; align-items: center; border-radius: var(--r-sm); }
.hist-row.is-active { background: var(--surface); box-shadow: var(--sh-sm); }
.hist-row.is-active .hist-item, .hist-row .hist-item:hover { background: transparent; }
.hist-row:hover { background: var(--surface-2); }
.hist-menu-btn { flex: 0 0 auto; width: 26px; height: 26px; margin-right: 4px; border: none; background: transparent; color: var(--ink-4); border-radius: 6px; cursor: pointer; display: none; align-items: center; justify-content: center; }
.hist-row:hover .hist-menu-btn { display: inline-flex; }
.hist-menu-btn:hover { background: var(--line); color: var(--ink); }
.hist-menu { position: absolute; top: calc(100% - 4px); right: 6px; z-index: 40; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--sh); padding: 5px; display: flex; flex-direction: column; gap: 2px; min-width: 130px; }
.hist-menu button { text-align: left; padding: 8px 10px; border: none; background: transparent; border-radius: 6px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.hist-menu button:hover { background: var(--surface-2); color: var(--ink); }
.hist-menu button.danger { color: var(--danger); }
.hist-menu button.danger:hover { background: var(--danger-soft); }

/* ============================================================
   Líneas de tiempo / actividad
   ============================================================ */
.tl { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.tl-item:not(:last-child)::before { content:''; position:absolute; left: 5px; top: 16px; bottom: -2px; width: 1.5px; background: var(--line-2); }
.tl-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 11px; margin-top: 4px; background: var(--surface); border: 2px solid var(--accent); position: relative; z-index: 1; }
.tl-dot.muted { border-color: var(--line-2); }
.tl-body { flex: 1 1 auto; }
.tl-time { font-family: var(--mono); font-size: 10px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; }

/* claves / valores en fichas */
.kv { display: flex; flex-direction: column; gap: 14px; }
.kv-row { display: grid; grid-template-columns: 160px 1fr; gap: 18px; align-items: start; }
.kv-key { font-size: 13px; color: var(--ink-3); padding-top: 1px; }
.kv-val { font-size: 14px; color: var(--ink); font-weight: 500; }
.kv-foot { display: flex; align-items: center; gap: 10px; margin-top: 7px; }

/* relaciones */
.rel { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; transition: background .12s ease, border-color .12s ease; }
.rel:hover { background: var(--surface-2); border-color: var(--line-2); }
.rel .rel-role { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-4); }
.rel .rel-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }

/* divisores */
.hr { height: 1px; background: var(--line); border: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }

/* barra de distribución (cartera de clientes) + leyenda */
.dist { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.dist-seg { height: 100%; }
.dist-seg.s-active, .legend-dot.s-active { background: var(--ok); }
.dist-seg.s-at_risk, .legend-dot.s-at_risk { background: var(--danger); }
.dist-seg.s-dormant, .legend-dot.s-dormant { background: var(--warn); }
.dist-seg.s-prospect, .legend-dot.s-prospect { background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.legend-n { font-weight: 600; color: var(--ink); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }

/* ============================================================
   Formularios (Zona B)
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input {
  height: 42px; padding: 0 13px; border-radius: 9px;
  background: var(--paper-2); border: 1px solid var(--line-2); color: var(--ink);
  font-family: var(--sans); font-size: 14px; display: flex; align-items: center; gap: 9px;
}
.input.mono { font-family: var(--mono); font-size: 13px; }
.input .ph { color: var(--ink-4); }
.input.is-focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toggle-grp { display: flex; gap: 10px; }
.toggle {
  flex: 1 1 0; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--paper-2); cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.toggle:hover:not(.is-on) { border-color: var(--ink-4); background: var(--surface-2); }
.toggle .tg-t { font-size: 14px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 9px; }
.toggle .tg-d { font-size: 12px; color: var(--ink-3); margin-top: 5px; padding-left: 27px; }
.toggle.is-on { border-color: var(--accent); background: var(--accent-soft); }
.toggle .radio { width: 17px; height: 17px; border-radius: 50%; border: 2px solid var(--line-2); flex: 0 0 17px; }
.toggle.is-on .radio { border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--accent); }

.select {
  height: 42px; padding: 0 13px; border-radius: 9px; background: var(--paper-2);
  border: 1px solid var(--line-2); color: var(--ink); font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 9px;
}
.select svg { width: 15px; height: 15px; color: var(--ink-3); }

.banner {
  display: flex; align-items: center; gap: 13px; padding: 13px 18px; border-radius: var(--r);
  font-size: 13.5px;
}
.banner svg { width: 19px; height: 19px; flex: 0 0 19px; }
.banner-restricted { background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); }
.banner-ok     { background: var(--ok-soft);     color: var(--ok); }
.banner-warn   { background: var(--warn-soft);   color: var(--warn); }
.banner-locked { background: var(--surface-2); border: 1px dashed var(--line-2); color: var(--ink-3); }

/* paso de prueba de conexión */
.test-result { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--r-sm); }
.test-ok   { background: var(--ok-soft);     color: var(--ok); }
.test-fail { background: var(--danger-soft); color: var(--danger); }
.test-result svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }

/* candado / paso bloqueado */
.locked-step { border: 1px dashed var(--line-2); border-radius: var(--r-lg); background: var(--paper-2); position: relative; }
.lock-badge { width: 52px; height: 52px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; color: var(--ink-3); }
.lock-badge svg { width: 24px; height: 24px; }

.checklist { display: flex; flex-direction: column; gap: 10px; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 13px 15px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); }
.check-mark { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 22px; }
.check-mark svg { width: 13px; height: 13px; }
.check-mark.done { background: var(--ok); color: #fff; }
.check-mark.pending { background: var(--surface-2); border: 1.5px solid var(--line-2); color: var(--ink-4); }

/* utilidades de espaciado */
.gap6{gap:6px}.gap8{gap:8px}.gap10{gap:10px}.gap12{gap:12px}.gap14{gap:14px}.gap16{gap:16px}.gap18{gap:18px}.gap20{gap:20px}.gap24{gap:24px}
.mt4{margin-top:4px}.mt6{margin-top:6px}.mt8{margin-top:8px}.mt10{margin-top:10px}.mt12{margin-top:12px}.mt14{margin-top:14px}.mt16{margin-top:16px}.mt18{margin-top:18px}.mt20{margin-top:20px}.mt24{margin-top:24px}.mt28{margin-top:28px}
.f1{flex:1 1 auto;min-width:0}
.ac{align-items:center}.jb{justify-content:space-between}.col{flex-direction:column}
.wrap{flex-wrap:wrap}

/* ============================================================
   Resumen — briefing diario del analista
   ============================================================ */
.briefing-hero { border-left: 3px solid var(--accent); }
.briefing-narr { font-size: 14.5px; line-height: 1.7; color: var(--ink); }
.briefing-narr p { margin-bottom: 11px; }
.briefing-narr p:last-child { margin-bottom: 0; }
.briefing-narr strong { font-weight: 600; }

.titular {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 15px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); text-align: left; font-family: var(--sans); cursor: pointer;
}
.titular:hover { background: var(--surface-2); border-color: var(--line-2); }
.tit-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.tit-dot.danger { background: var(--danger); }
.tit-dot.ok { background: var(--ok); }
.tit-dot.info { background: var(--info); }

.accion { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.accion-link { border: none; background: transparent; color: var(--ink-4); cursor: pointer; display: inline-flex; padding: 2px; }
.accion-link:hover { color: var(--accent); }

.cifras { display: flex; flex-wrap: wrap; gap: 28px; padding: 4px 2px; }
.cifra { display: flex; flex-direction: column; gap: 3px; }
.cifra-v { font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--ink); }

/* ============================================================
   Login / autenticación
   ============================================================ */
.auth-screen {
  width: 100%; min-height: 100%;
  display: flex;
  background: var(--paper);
}

/* Lado de marca (hero): qué es PRINDIA en dos frases */
.auth-hero {
  flex: 1 1 56%;
  display: flex; flex-direction: column;
  padding: 56px 60px;
  background:
    radial-gradient(120% 90% at 0% 0%, var(--accent-soft) 0%, transparent 55%),
    linear-gradient(160deg, var(--paper-2) 0%, var(--surface) 100%);
  border-right: 1px solid var(--line);
}
.auth-hero-brand { display: flex; align-items: center; gap: 13px; }
.auth-hero-brand .brandmark { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; }
.auth-hero-lines { margin-top: auto; margin-bottom: auto; max-width: 520px; padding: 40px 0; }
.auth-hero-head {
  font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em;
  font-size: 38px; line-height: 1.18; color: var(--ink);
}
.auth-hero-sub { margin-top: 18px; font-size: 17px; line-height: 1.55; color: var(--ink-2); max-width: 460px; }
.auth-hero-foot { margin-top: auto; }

/* Lado del formulario */
.auth-side {
  flex: 1 1 44%;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}
.auth-card { width: 100%; max-width: 400px; padding: 34px; }

@media (max-width: 880px) {
  .auth-screen { flex-direction: column; }
  .auth-hero { flex: 0 0 auto; padding: 40px 32px; border-right: none; border-bottom: 1px solid var(--line); }
  .auth-hero-lines { padding: 26px 0; margin: 0; }
  .auth-hero-head { font-size: 28px; }
  .auth-hero-sub { font-size: 15px; }
  .auth-hero-foot { display: none; }
  .auth-side { flex: 1 1 auto; padding: 28px 24px 44px; align-items: flex-start; }
}

/* input nativo con el estilo .input */
input.input, input.input:focus { outline: none; width: 100%; }
input.input::placeholder { color: var(--ink-4); }
input.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* textarea con el estilo .input: a diferencia del input de una línea, ocupa todo el
   ancho y crece en alto (el base .input es flex de 42px, pensado para una sola línea). */
textarea.input { display: block; width: 100%; height: auto; box-sizing: border-box; padding: 11px 13px; align-items: initial; outline: none; }
textarea.input::placeholder { color: var(--ink-4); }
textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* menú de cuenta/opciones (engranaje del pie del sidebar) */
.usermenu { position: relative; flex: 0 0 auto; }
.usermenu-trigger {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.usermenu-trigger:hover { background: var(--surface-2); color: var(--ink); }
.usermenu-trigger svg { width: 16px; height: 16px; }
.usermenu-pop {
  position: absolute; bottom: calc(100% + 8px); right: 0; width: 196px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--sh); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.usermenu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: none; background: transparent; border-radius: 7px;
  font-family: var(--sans); font-size: 13.5px; color: var(--ink-2); cursor: pointer; text-align: left;
}
.usermenu-item svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--ink-3); }
.usermenu-item:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.usermenu-item:disabled { cursor: default; color: var(--ink-3); }
.usermenu-item .soon { margin-left: auto; font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); }
.usermenu-item.danger { color: var(--danger); }
.usermenu-item.danger svg { color: var(--danger); }
.usermenu-item.danger:hover { background: var(--danger-soft); }
.usermenu-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* cockpit del técnico (centro de control) */
.cockpit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.kpi-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 15px 17px; display: flex; flex-direction: column; gap: 7px; }
.kpi-card .kpi-top { display: flex; align-items: center; gap: 8px; }
.kpi-card .kpi-top svg { width: 15px; height: 15px; color: var(--accent); }
.kpi-val { font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--ink); line-height: 1.15; }
.kpi-sub { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.guide-item {
  display: flex; align-items: center; gap: 13px; padding: 14px 16px;
  border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r-sm); background: var(--surface);
  cursor: pointer; transition: background .12s ease, border-color .12s ease;
}
.guide-item:hover { background: var(--surface-2); }
.guide-item.sev-danger { border-left-color: var(--danger); }
.guide-item.sev-warn { border-left-color: var(--warn); }
.guide-item.sev-info { border-left-color: var(--info); }
.guide-icon { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.guide-icon svg { width: 16px; height: 16px; }
.sev-danger .guide-icon { background: var(--danger-soft); color: var(--danger); }
.sev-warn .guide-icon { background: var(--warn-soft); color: var(--warn); }
.sev-info .guide-icon { background: var(--info-soft); color: var(--info); }
.guide-cta { font-size: 13px; font-weight: 600; color: var(--accent-ink); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; flex: 0 0 auto; }
.guide-ok { display: flex; align-items: center; gap: 11px; padding: 16px 18px; border: 1px solid var(--ok); background: var(--ok-soft); border-radius: var(--r-sm); }

/* campana de avisos (barra superior) */
.notif { position: relative; display: inline-flex; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-family: var(--mono); font-size: 9.5px; font-weight: 600; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--paper);
}
.notif-pop {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-height: 420px; z-index: 30;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh);
}
/* el display:flex de arriba anulaba el atributo [hidden] → el popover salía siempre abierto */
.notif-pop[hidden] { display: none; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px 9px; }
.notif-empty { display: flex; align-items: center; gap: 9px; padding: 18px 16px 22px; color: var(--ink-3); font-size: 13px; }
.notif-list { overflow-y: auto; padding: 4px; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 11px; border-radius: 8px;
  cursor: pointer; transition: background .12s ease;
}
.notif-item:hover { background: var(--surface-2); }
.notif-title { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.notif-detail {
  display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.notif-ts { font-size: 11px; color: var(--ink-4); white-space: nowrap; flex: 0 0 auto; margin-top: 2px; }

/* interruptor de activar/desactivar (perfil de setup) */
.toggle-pill {
  width: 34px; height: 19px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--line-2); position: relative; transition: background .15s; padding: 0;
}
.toggle-pill.is-on { background: var(--accent); }
.toggle-knob {
  position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; transition: left .15s; box-shadow: var(--sh-sm);
}
.toggle-pill.is-on .toggle-knob { left: 17px; }
.tbl .sans { font-family: var(--sans); }

/* ── Relleno de altura para Next (App Router) ── */
html, body { height: 100%; margin: 0; background: var(--paper); }
body > .screen, #__next > .screen { height: 100%; }
a { color: inherit; text-decoration: none; transition: color .12s ease, opacity .12s ease; }
/* enlaces de texto con color de acento (los que no son componentes con su propio hover) */
a[style*="accent"]:hover { text-decoration: underline; text-underline-offset: 2px; }
.link { color: var(--accent-ink); cursor: pointer; transition: opacity .12s ease; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; opacity: 0.85; }

/* ── Pie de respuesta (N1+N2): fuentes/en-vivo a la izquierda, acciones a la derecha, una fila ── */
.msg-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.msg-footer-left { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; }
.trust-live { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ok); }
.trust-live .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
/* (reservado para el futuro panel de debug "cómo lo calculó") */
.trust-detail { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.trust-model { font-size: 12px; color: var(--ink-3); margin-bottom: 9px; }
.trust-steps { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; counter-reset: ts; }
.trust-steps li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--ink-2); }
.trust-steps li::before { counter-increment: ts; content: counter(ts); width: 18px; height: 18px; flex: 0 0 18px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); }
.trust-steps .ts-src { font-weight: 600; color: var(--ink); }
.trust-note { font-size: 11px; color: var(--ink-4); margin: 10px 0 0; line-height: 1.4; }

/* ── Acciones de respuesta (N2): copiar + 👍/👎 (a la derecha del pie) ── */
.msg-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.msg-act { width: 28px; height: 28px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--ink-4); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background .12s ease, color .12s ease, border-color .12s ease; }
.msg-act:hover { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.msg-act.is-ok { color: var(--ok); }
.msg-act.is-up { color: var(--ok); background: var(--ok-soft); }
.msg-act.is-down { color: var(--danger); background: var(--danger-soft); }
/* botón de enviar en modo DETENER mientras transmite */
.btn.is-stop { background: var(--surface); border-color: var(--line-2); color: var(--danger); }
.btn.is-stop:hover { background: var(--danger-soft); border-color: var(--danger); }

/* ── Sidebar colapsable (igual que ceomind): flecha en el borde derecho del lateral; oculta el
   sidebar entero; persiste en localStorage (aplicado en <head> antes de pintar → sin parpadeo). ── */
.sb-toggle {
  position: absolute; top: 50%; left: 305px; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--sh-sm); transition: left .22s ease, background .12s ease, color .12s ease;
}
.sb-toggle:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.sb-toggle svg { width: 15px; height: 15px; transform: rotate(180deg); transition: transform .22s ease; }
html.sb-collapsed .sb { display: none; }
html.sb-collapsed .sb-toggle { left: 14px; }
html.sb-collapsed .sb-toggle svg { transform: rotate(0deg); }

/* la búsqueda oculta filas con [hidden]; .hist-row tiene display:flex y lo anulaba (mismo bug que el bell) */
.hist-row[hidden] { display: none; }

/* ── Layout "contenido + rail contextual" para las pestañas de Configuraciones ── */
.cfg-split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.cfg-main { min-width: 0; }
.cfg-rail { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 4px; }
.rail-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 16px; box-shadow: var(--sh-sm); }
.rail-title { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 11px; display: flex; align-items: center; gap: 7px; }
.rail-title svg { width: 13px; height: 13px; opacity: .8; }
.rail-kv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 12.5px; }
.rail-kv + .rail-kv { border-top: 1px solid var(--line); }
.rail-kv .k { color: var(--ink-3); }
.rail-kv .v { color: var(--ink); font-weight: 600; white-space: nowrap; }
.rail-preview { font-size: 12px; line-height: 1.55; color: var(--ink-2); white-space: pre-wrap; max-height: 340px; overflow-y: auto; }
.rail-note { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }
@media (max-width: 980px) { .cfg-split { grid-template-columns: 1fr; } .cfg-rail { position: static; } }

/* ── Modales propios (confirm/prompt), en vez de los diálogos del navegador ── */
.pm-overlay { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 20px; background: oklch(0.2 0.02 260 / 0.45); }
.pm-box { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px oklch(0.2 0.02 260 / 0.3); overflow: hidden; }
.pm-body { padding: 22px 24px 18px; }
.pm-head { font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.pm-msg { margin-top: 10px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.pm-input { margin-top: 16px; width: 100%; }
.pm-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 4px 24px 20px; }
.pm-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.pm-danger:hover { background: var(--danger); border-color: var(--danger); filter: brightness(0.94); }

/* ── Toasts (avisos efímeros de acciones: renombrar, borrar, …) ── */
#toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 10px; background: var(--ink); color: var(--paper); font-size: 13.5px; font-weight: 500; box-shadow: var(--sh); opacity: 0; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; }
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast.is-danger { background: var(--danger); color: #fff; }

/* ── Estado "pensando" del asistente: pulso sutil ── */
@keyframes think-pulse { 0%,100%{opacity:.55} 50%{opacity:1} }
.bubble-asst .think { animation: think-pulse 1.2s ease-in-out infinite; }
.bubble-asst ul, .bubble-asst ol { margin: 4px 0 10px; }
.bubble-asst li { margin-bottom: 4px; }

/* ── Barra de impersonación ("ver como"): visible en toda la app mientras dure ── */
.imp-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; font-size: 13px;
  background: #fff7ed; color: #7c2d12; border-bottom: 1px solid #fdba74;
}
.imp-bar svg { width: 15px; height: 15px; flex: none; }
.imp-bar strong { font-weight: 700; }
.imp-exit {
  margin-left: auto; font-weight: 600; font-size: 12.5px;
  color: #7c2d12; text-decoration: underline; text-underline-offset: 2px;
  padding: 3px 8px; border-radius: 7px;
}
.imp-exit:hover { background: rgba(124,45,18,.09); }

/* ── Pestañas de sección (Configuración y Ajustes comparten este diseño) ────────────────────
   Antes vivían inline en configuraciones/_layout; se comparten aquí para que las dos zonas
   usen LITERALMENTE el mismo diseño y no se desincronicen. */
.cfg-tabs{display:flex;gap:2px;border-bottom:1px solid var(--line);margin:-8px 0 26px}
.cfg-tabs a{position:relative;display:flex;align-items:center;gap:8px;padding:11px 16px;color:var(--ink-3);font-size:14px;font-weight:500;text-decoration:none;border-bottom:2px solid transparent;margin-bottom:-1px;line-height:1;transition:color .12s ease}
.cfg-tabs a svg{width:16px;height:16px;opacity:.8}
.cfg-tabs a:hover{color:var(--ink)}
.cfg-tabs a.active{color:var(--ink);font-weight:600;border-bottom-color:var(--accent)}
.cfg-tabs a.active svg{opacity:1;color:var(--accent)}
@media (max-width:640px){.cfg-tabs{overflow-x:auto;scrollbar-width:none}.cfg-tabs a{white-space:nowrap}}

/* Sub-pestañas (dentro de una pestaña): estilo pill, distinto del subrayado para marcar
   jerarquía. Vale para <a> (navegación) y <button> (paneles JS); el activo lleva .on. */
.subtabs{display:flex;gap:6px;flex-wrap:wrap;margin:0 0 22px}
.subtabs a,.subtabs button{font:inherit;padding:7px 15px;border-radius:8px;font-size:13px;font-weight:500;text-decoration:none;color:var(--ink-3);background:var(--surface-2);border:1px solid var(--line);cursor:pointer;line-height:1.2;transition:color .12s ease,background .12s ease}
.subtabs a:hover,.subtabs button:hover{color:var(--ink)}
.subtabs a.on,.subtabs button.on{background:var(--accent);color:#fff;border-color:var(--accent)}
.subtabs .tab-count{opacity:.7;font-weight:400}

/* ── Ayuda de una etiqueta (partials/_ayuda.html.twig) ──────────────────────────────────────
   Un "?" pequeño al lado de un rótulo de configuración que, al pasar por encima o al enfocarlo
   con el tabulador, explica en lenguaje llano qué es esa cosa. Sin JavaScript.
   Se abre con :hover Y con :focus-within para que funcione con teclado, no solo con ratón. */
.ayuda{position:relative;display:inline-flex;vertical-align:middle;margin-left:6px}
.ayuda-btn{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;
  padding:0;border-radius:50%;border:1px solid var(--line-2);background:var(--surface-2);
  color:var(--ink-3);font:600 11px/1 inherit;cursor:help;transition:color .12s ease,border-color .12s ease}
.ayuda-btn:hover,.ayuda:focus-within .ayuda-btn{color:var(--ink);border-color:var(--ink-3)}
.ayuda-txt{position:absolute;left:50%;bottom:calc(100% + 8px);transform:translateX(-50%);
  z-index:40;width:max-content;max-width:300px;padding:9px 11px;border-radius:8px;
  border:1px solid var(--line);background:var(--surface);color:var(--ink-2);
  font-size:12.5px;font-weight:400;line-height:1.5;text-align:left;white-space:normal;
  box-shadow:0 6px 20px rgba(0,0,0,.13);opacity:0;visibility:hidden;transition:opacity .12s ease}
.ayuda:hover .ayuda-txt,.ayuda:focus-within .ayuda-txt{opacity:1;visibility:visible}
/* Cerca del borde izquierdo la burbuja se saldría de la pantalla: se ancla al botón. */
@media (max-width:720px){.ayuda-txt{left:0;transform:none;max-width:min(300px,80vw)}}

/* ============================================================
   Responsive del armazón (barra lateral, cabecera, rejillas)
   Breakpoints: móvil ≤640 · tablet 641–1024 · escritorio >1024
   El copiloto (icono en cabecera) vive en _copilot_widget.html.twig.
   ============================================================ */

/* Hamburguesa (abre el cajón) y fondo oscuro: ocultos en escritorio. */
.sb-ham { display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 38px; height: 38px; flex: 0 0 38px; padding: 0 9px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.sb-ham span { height: 2px; border-radius: 2px; background: var(--ink-2); }
.sb-ham:hover { background: var(--surface-2); }
.sb-ham:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sb-backdrop { display: none; position: fixed; inset: 0; z-index: 110; background: oklch(0.2 0.02 260 / 0.44); }

/* — Tablet + móvil (≤1024): la barra lateral pasa a CAJÓN deslizante sobre el contenido — */
@media (max-width: 1024px) {
  .sb {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
    width: 300px; max-width: 86vw;
    transform: translateX(-100%);
    transition: transform .24s ease;
    box-shadow: 10px 0 40px oklch(0 0 0 / 0.26);
  }
  html.sb-open .sb { transform: translateX(0); }
  html.sb-open .sb-backdrop { display: block; }
  /* En móvil/tablet manda el cajón: se anula el colapso de escritorio y su flecha. */
  html.sb-collapsed .sb { display: flex; }
  .sb-toggle { display: none; }
  .sb-ham { display: flex; }
  .tb { padding: 0 18px; gap: 12px; }
  .pad { padding: 22px 20px; }
}
@media (prefers-reduced-motion: reduce) { .sb { transition: none; } }

/* — Tablet estrecha: rejillas de 3/4 a 2 columnas — */
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* — Móvil (≤640): una columna, cabecera compacta, tablas con scroll — */
@media (max-width: 640px) {
  .tb { height: 56px; flex-basis: 56px; padding: 0 12px; gap: 10px; }
  .tb-title { font-size: 16px; }
  .tb-eyebrow { font-size: 9.5px; }
  .pad { padding: 16px 14px; }
  /* .cockpit-grid ya es fluida (auto-fill minmax 210px); aquí colapsan las rejillas fijas. */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  /* Tablas anchas: scroll horizontal dentro de su caja; la página nunca se mueve de lado. */
  .tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* La búsqueda de la cabecera (si la hay) deja de tener ancho fijo. */
  .tb-search { width: auto; flex: 1 1 auto; min-width: 0; }
  /* Barra de impersonación: que envuelva si no cabe. */
  .imp-bar { flex-wrap: wrap; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   LISTADOS Y DIÁLOGOS (2026-07-29)

   La regla nueva del panel: una lista es una TABLA, no un montón de tarjetas —y
   menos aún tarjetas dentro de tarjetas. Una tabla se lee en diagonal, se ordena
   con la vista y cabe el triple de filas en la misma pantalla; las tarjetas
   gastan el ancho en bordes y aire, que es justo lo que sobraba.

   El detalle de una fila se abre en un DIÁLOGO. Así la lista se queda como está
   —sin perder el sitio ni el desplazamiento— y el detalle puede ser todo lo
   largo que haga falta sin estirar la página de debajo.
   ───────────────────────────────────────────────────────────────────────────── */

/* Caja de una tabla: el borde y el redondeo que antes ponía la tarjeta, sin su relleno. */
.lista { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.lista + .lista { margin-top: 16px; }
.lista-cab { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.lista-cab .t { font-size: 13px; font-weight: 650; color: var(--ink); }
.lista-cab .n { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.lista-cab .sp { margin-left: auto; }
.lista-vacia { padding: 22px 16px; font-size: 13px; color: var(--ink-3); }
.lista .tbl td, .lista .tbl th { padding: 9px 16px; }
.lista .tbl td { font-size: 13px; }

/* Fila que se abre: toda la fila es el objetivo, no un enlace diminuto al final. */
.tbl tr.abre { cursor: pointer; }
.tbl tr.abre:hover td { background: var(--surface-2); }

/* Números alineados a la derecha y en cifras de ancho fijo, para poder compararlos de un vistazo. */
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Diálogo: mismo aspecto que los modales de confirmación que ya había. */
/* `margin: auto` VA EXPLÍCITO. Un diálogo modal se centra solo... salvo que algo le quite el
   margen, y arriba del todo hay un `* { margin: 0 }` que se lo lleva por delante: sin esto el
   diálogo sale pegado a la esquina superior izquierda. */
dialog.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 0; margin: auto; background: var(--surface);
  box-shadow: 0 18px 50px oklch(0.2 0.02 260 / 0.3); width: min(680px, calc(100vw - 32px)); max-height: 86vh; overflow: auto; }
dialog.dlg::backdrop { background: oklch(0.2 0.02 260 / 0.45); }
dialog.dlg .dlg-cab { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog.dlg .dlg-cab .t { font-size: 15px; font-weight: 600; color: var(--ink); }
dialog.dlg .dlg-cuerpo { padding: 18px 20px; }
dialog.dlg .dlg-pie { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
dialog.dlg .cerrar { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--ink-3); font-size: 20px; line-height: 1; padding: 0 4px; }
dialog.dlg .cerrar:hover { color: var(--ink); }

/* Cifras sueltas de una cabecera (consumo, totales): en línea, sin una tarjeta por número. */
.cifras { display: flex; gap: 28px; flex-wrap: wrap; align-items: baseline; }
.cifras .c .k { font-size: 11.5px; color: var(--ink-3); display: block; }
.cifras .c .v { font-size: 20px; font-weight: 640; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Dentro de una caja de lista, lo que NO es una tabla necesita su propio margen: la caja no lleva
   relleno a propósito (una tabla debe pegarse al borde), así que un párrafo o un formulario sueltos
   se quedarían tocando la línea. */
.lista > :not(.lista-cab):not(table) { padding-left: 16px; padding-right: 16px; }
.lista > :not(.lista-cab):not(table):first-child { padding-top: 14px; }
.lista > :not(.lista-cab):not(table):last-child { padding-bottom: 14px; }
.lista > .lista-vacia { padding-left: 16px; padding-right: 16px; }
/* Formularios dentro de la caja: que respiren sin heredar el margen dos veces. */
.lista > form { padding-bottom: 14px; }

/* EL BOTÓN DE VOLVER. Va en la barra de arriba, a la izquierda del título y siempre en el mismo
   sitio: una flecha que cambia de posición según la pantalla no sirve para volver sin mirar.
   Ver templates/partials/_volver.html.twig y assets/volver.js. */
.tb-volver { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  flex: none; border-radius: 9px; border: 1px solid var(--line); background: var(--card, #fff);
  color: var(--ink-3); text-decoration: none; margin-right: 10px; }
.tb-volver:hover { color: var(--ink); border-color: var(--ink-3); }
/* El foco se ve: a esta flecha se llega con el tabulador desde el teclado. */
.tb-volver:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
