:root {
  --fondo: #f4f5f7;
  --panel: #ffffff;
  --borde: #dfe2e7;
  --texto: #1d2129;
  --suave: #687080;
  --acento: #2f4bd8;
  --acento-suave: #e8ecfd;
  --gpt: #0f8a6a;
  --gpt-suave: #e3f4ee;
  --claude: #c0622f;
  --claude-suave: #f9ece4;
  --humano: #3d4554;
  --verde: #12804a;
  --rojo: #c4282d;
  --amarillo: #a86b00;
  --fila-sel: #dfe6ff;
  --radio: 8px;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--fondo); color: var(--texto); font-size: 14px; line-height: 1.45;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
kbd {
  font-family: inherit; font-weight: 600; font-size: 11px; padding: 1px 5px;
  border: 1px solid var(--borde); border-bottom-width: 2px; border-radius: 4px; background: #fff; color: var(--suave);
}

/* ---------- ingreso ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg, #1b2240 0%, #2f4bd8 100%); }
.login-caja { width: 100%; max-width: 360px; background: #fff; border-radius: 14px; padding: 28px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-caja label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.login-caja input { padding: 10px 12px; border: 1px solid var(--borde); border-radius: var(--radio); font-weight: 400; width: 100%; }
.login-sub { margin: -8px 0 4px; color: var(--suave); }
.clave { display: flex; gap: 6px; }
.error { color: var(--rojo); min-height: 1.2em; margin: 0; }

/* ---------- marca y barra ---------- */
.marca { font-weight: 800; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.marca-punto { width: 12px; height: 12px; border-radius: 50%;
  background: conic-gradient(var(--gpt) 0 50%, var(--claude) 50% 100%); }
.barra { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: #141a33; color: #fff; }
.proyectos { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.proyectos button { background: transparent; border: 1px solid transparent; color: #c9d0ee; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; white-space: nowrap; font-weight: 600; }
.proyectos button:hover { background: rgba(255,255,255,.08); }
.proyectos button.activo { background: #fff; color: #141a33; }
.proyectos button kbd { margin-left: 6px; background: transparent; color: inherit; border-color: currentColor; opacity: .6; }
.usuario { display: flex; align-items: center; gap: 10px; color: #c9d0ee; white-space: nowrap; }
.usuario .btn-ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.atajos { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 16px; background: #fff; border-bottom: 1px solid var(--borde);
  color: var(--suave); font-size: 12px; }

.cuerpo { display: flex; height: calc(100vh - 86px); min-height: 0; }
.menu { width: 190px; flex: none; background: #fff; border-right: 1px solid var(--borde); padding: 10px 8px;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.menu button { display: flex; justify-content: space-between; align-items: center; text-align: left; border: 0; background: transparent;
  padding: 9px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.menu button:hover { background: var(--fondo); }
.menu button.activo { background: var(--acento-suave); color: var(--acento); }
.contenido { flex: 1; min-width: 0; overflow: auto; padding: 18px 20px; outline: none; }

/* ---------- botones y formularios ---------- */
.btn-primario, .btn, .btn-ghost, .btn-peligro {
  border-radius: var(--radio); padding: 8px 14px; cursor: pointer; font-weight: 600; border: 1px solid var(--borde); background: #fff; }
.btn-primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn-primario:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: transparent; }
.btn-peligro { color: var(--rojo); border-color: #f0c6c7; }
.btn-gpt { background: var(--gpt); border-color: var(--gpt); color: #fff; }
.btn-claude { background: var(--claude); border-color: var(--claude); color: #fff; }
.btn:hover, .btn-ghost:hover { background: var(--fondo); }
.fila-botones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.campo { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.campo input, .campo select, .campo textarea, .filtros input, .filtros select {
  padding: 8px 10px; border: 1px solid var(--borde); border-radius: var(--radio); background: #fff; font-weight: 400; }
.campo textarea { min-height: 110px; resize: vertical; }
.campo { min-width: 0; }
.campo input, .campo select, .campo textarea { width: 100%; min-width: 0; }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.filtros label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--suave); font-weight: 600; }

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
.sub { color: var(--suave); margin: 0 0 14px; }
.encabezado { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- tablas tipo Excel ---------- */
.tabla-caja { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); overflow: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { position: sticky; top: 0; background: #f8f9fb; text-align: left; font-weight: 700; color: var(--suave);
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla td { padding: 7px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.tabla tbody tr { cursor: pointer; }
.tabla tbody tr:hover { background: #f6f8ff; }
.tabla tbody tr.sel { background: var(--fila-sel); outline: 2px solid var(--acento); outline-offset: -2px; }
.tabla tfoot td { font-weight: 700; background: #f8f9fb; border-top: 2px solid var(--borde); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.egreso { color: var(--rojo); }
.ingreso { color: var(--verde); }
.vacio { padding: 24px; text-align: center; color: var(--suave); }
.recorte { max-width: 560px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.etiqueta { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; font-weight: 600; background: #eef0f3; white-space: nowrap; }
.e-gpt { background: var(--gpt-suave); color: var(--gpt); }
.e-claude { background: var(--claude-suave); color: var(--claude); }
.e-ok { background: #e2f3ea; color: var(--verde); }
.e-mal { background: #fbe4e4; color: var(--rojo); }
.e-espera { background: #fdf1dc; color: var(--amarillo); }

.pestanas { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.pestanas button { border: 1px solid var(--borde); background: #fff; border-radius: 99px; padding: 5px 12px; cursor: pointer; font-weight: 600; }
.pestanas button.activo { background: var(--texto); color: #fff; border-color: var(--texto); }

/* ---------- resumen ---------- */
.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.indicador { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px 14px; cursor: pointer; }
.indicador b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.indicador span { color: var(--suave); font-size: 12px; font-weight: 600; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 320px 1fr; gap: 14px; height: calc(100vh - 124px); min-height: 0; }
.chat-lista { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chat-lista .tabla-caja { flex: 1; }
.chat-panel { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); min-height: 0; }
.chat-cab { padding: 10px 14px; border-bottom: 1px solid var(--borde); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #fafbfc; }
.msg { max-width: 860px; border-radius: 10px; padding: 10px 14px; border: 1px solid var(--borde); background: #fff; }
.msg.human { align-self: flex-end; background: var(--acento-suave); border-color: #cdd6fb; }
.msg.chatgpt { border-left: 4px solid var(--gpt); }
.msg.claude { border-left: 4px solid var(--claude); }
.msg.system { align-self: center; background: #fff7e6; border-color: #f3d9a4; font-size: 13px; }
.msg-quien { font-size: 12px; font-weight: 700; margin-bottom: 4px; display: flex; gap: 8px; color: var(--suave); }
.msg.chatgpt .msg-quien b { color: var(--gpt); }
.msg.claude .msg-quien b { color: var(--claude); }
.msg-texto { overflow-wrap: anywhere; }
.msg-texto p { margin: 0 0 8px; }
.msg-texto p:last-child { margin-bottom: 0; }
.msg-texto pre { background: #151a2c; color: #e6e9f5; padding: 10px 12px; border-radius: 6px; overflow-x: auto; position: relative; font-size: 13px; }
.msg-texto code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.msg-texto :not(pre) > code { background: #eef0f3; padding: 1px 4px; border-radius: 4px; }
.msg-texto pre .copiar { position: absolute; top: 6px; right: 6px; font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: rgba(255,255,255,.12); color: #fff; border: 0; cursor: pointer; }
.msg-texto h3, .msg-texto h4 { margin: 8px 0 4px; font-size: 15px; }
.msg-texto ul, .msg-texto ol { margin: 4px 0 8px; padding-left: 22px; }
.chat-escribir { border-top: 1px solid var(--borde); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.chat-escribir textarea { flex: 1; resize: none; min-height: 52px; max-height: 220px; padding: 10px; border: 1px solid var(--borde); border-radius: var(--radio); }
.pensando { align-self: flex-start; color: var(--suave); font-style: italic; }

/* ---------- voz ---------- */
.voz { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
.voz-centro { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.orbe { width: 150px; height: 150px; border-radius: 50%; border: 0; cursor: pointer; color: #fff; font-weight: 700; font-size: 15px;
  background: radial-gradient(circle at 35% 30%, #4b66f0, #141a33); box-shadow: 0 10px 30px rgba(47,75,216,.35); transition: transform .15s; }
.orbe.activa { background: radial-gradient(circle at 35% 30%, #19b38a, #0b4f3e); animation: latido 1.6s infinite; }
.orbe.hablando { transform: scale(1.08); }
@keyframes latido { 0%,100% { box-shadow: 0 0 0 0 rgba(15,138,106,.45); } 50% { box-shadow: 0 0 0 18px rgba(15,138,106,0); } }
.voz-estado { font-weight: 700; }
.voz-tiempo { font-variant-numeric: tabular-nums; color: var(--suave); }
.voz-trans { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; overflow-y: auto; max-height: calc(100vh - 170px); display: flex; flex-direction: column; gap: 10px; }

/* ---------- consumo ---------- */
.proveedores { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 14px; }
.proveedor { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; }
.proveedor h3 { margin: 0 0 10px; font-size: 15px; display: flex; justify-content: space-between; }
.barra-uso { height: 8px; background: #eef0f3; border-radius: 99px; overflow: hidden; margin: 4px 0 10px; }
.barra-uso i { display: block; height: 100%; background: var(--acento); }
.barra-uso i.alta { background: var(--rojo); }
.grilla-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grilla-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ---------- modal y aviso ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,20,40,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-caja { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 12px; }
.modal-caja pre { background: #f6f7f9; padding: 10px; border-radius: 6px; overflow: auto; font-size: 12px; max-height: 50vh; }
.aviso { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #141a33; color: #fff; padding: 10px 16px;
  border-radius: 8px; z-index: 60; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.aviso.mal { background: var(--rojo); }

/* ---------- celular ---------- */
@media (max-width: 860px) {
  :root { font-size: 15px; }
  .barra { flex-wrap: wrap; gap: 8px; }
  .proyectos { order: 3; flex-basis: 100%; }
  .atajos { display: none; }
  .cuerpo { flex-direction: column; height: auto; min-height: calc(100vh - 100px); }
  .menu { width: 100%; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--borde); padding: 6px; }
  .menu button { white-space: nowrap; }
  .menu kbd, .proyectos kbd, .contenido kbd { display: none; }
  .contenido { padding: 12px; }
  .chat, .voz { grid-template-columns: 1fr; height: auto; }
  .chat-lista .tabla-caja { max-height: 220px; }
  .chat-panel { height: 72vh; }
  .grilla-2, .grilla-3 { grid-template-columns: 1fr; }
  .recorte { max-width: 220px; }
  button, input, select, textarea { min-height: 40px; }
}
