/* Atlas · panel lateral de Excel — estética sobria de banca de inversión.
   Paleta 414: navy #002545, teal #07AAA5. Tipografía del sistema (no se carga
   ninguna fuente externa: un CDN de tipografías más en un task pane no vale la
   pena y ensuciaría el CSP). Densidad alta: el panel mide 320–450 px y el
   analista necesita ver la tabla de cambios sin hacer scroll. */

:root {
  --navy:      #002545;
  --navy-2:    #06355f;
  --teal:      #07AAA5;
  --teal-osc:  #05807c;
  --texto:     #17242f;
  --tenue:     #5d6d7c;
  --borde:     #dde2e8;
  --fondo:     #ffffff;
  --panel:     #f5f7f9;
  --panel-2:   #eef1f5;
  --ok:        #1d7a45;
  --alerta:    #9a6a00;
  --error:     #a32020;
  --nuevo-bg:  #eefaf6;
  --viejo-bg:  #fbf1f1;
  --radio:     4px;
  --sombra:    0 1px 2px rgba(0, 37, 69, .10), 0 4px 12px rgba(0, 37, 69, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --texto:    #e8edf2;
    --tenue:    #9dabb8;
    --borde:    #2b3946;
    --fondo:    #141b22;
    --panel:    #1b242d;
    --panel-2:  #222d37;
    --ok:       #4cc985;
    --alerta:   #d8a83a;
    --error:    #ef8080;
    --nuevo-bg: #11312a;
    --viejo-bg: #33201f;
    --sombra:   0 1px 2px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--fondo);
  color: var(--texto);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ───────────────────────────── barra superior ───────────────────────────── */
.barra {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--navy);
  color: #fff;
  flex: 0 0 auto;
}

.marca { display: flex; align-items: baseline; gap: 6px; }
.marca-punto {
  width: 8px; height: 8px; border-radius: 1px;
  background: var(--teal);
  align-self: center;
}
.marca-texto { font-weight: 600; letter-spacing: .14em; font-size: 12px; }
.marca-sub { font-size: 11px; color: #9fb6c9; letter-spacing: .04em; }

.barra-derecha { display: flex; align-items: center; gap: 6px; }
.quien {
  font-size: 11px; color: #c3d3df;
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.icono {
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: var(--radio);
}
.icono:hover { background: rgba(255, 255, 255, .12); }
.seleccion .icono { color: var(--tenue); }
.seleccion .icono:hover { background: var(--panel-2); }

.menu {
  position: absolute;
  top: 100%; right: 8px;
  z-index: 40;
  background: var(--fondo);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  min-width: 190px;
  padding: 4px;
}
.menu button {
  display: block; width: 100%;
  text-align: left;
  background: none; border: 0;
  color: var(--texto);
  font: inherit;
  padding: 7px 9px;
  border-radius: 3px;
  cursor: pointer;
}
.menu button:hover { background: var(--panel-2); }

/* ──────────────────────────────── vistas ────────────────────────────────── */
.vista { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.vista[hidden] { display: none; }

.vista-entrar { padding: 16px 14px; gap: 4px; overflow-y: auto; }
.entrar-intro { margin: 0 0 12px; color: var(--tenue); }
.vista-entrar label {
  display: block; margin: 10px 0 3px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--tenue);
}
.vista-entrar input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--fondo);
  color: var(--texto);
  font: inherit;
}
.vista-entrar input:focus { outline: 2px solid var(--teal); outline-offset: -1px; }
.pie-nota { margin-top: 16px; font-size: 11px; color: var(--tenue); }

/* ─────────────────────────────── botones ────────────────────────────────── */
button.primario, button.secundario, button.mini, button.mini-teal {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radio);
  border: 1px solid transparent;
}
button.primario {
  background: var(--navy); color: #fff;
  padding: 7px 14px; font-weight: 600;
}
button.primario:hover:not(:disabled) { background: var(--navy-2); }
button.secundario {
  background: var(--fondo); color: var(--texto);
  border-color: var(--borde);
  padding: 7px 12px;
}
button.secundario:hover:not(:disabled) { background: var(--panel-2); }
button.ancho { width: 100%; margin-top: 16px; }
button:disabled { opacity: .5; cursor: default; }
button.mini, button.mini-teal {
  padding: 4px 9px; font-size: 12px;
  background: var(--fondo); color: var(--texto); border-color: var(--borde);
}
button.mini-teal { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
button.mini-teal:hover:not(:disabled) { background: var(--teal-osc); }
button.mini:hover:not(:disabled) { background: var(--panel-2); }

/* ─────────────────────────── barra de selección ─────────────────────────── */
.seleccion {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--borde);
  font-size: 12px;
}
.seleccion-icono { color: var(--teal); }
.seleccion-texto {
  flex: 1 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.seleccion-texto.vacia { color: var(--tenue); font-style: italic; }
.aviso-recorte {
  flex: 0 0 auto; margin: 0;
  padding: 5px 10px;
  background: #fff6e0; color: #6b4e00;
  border-bottom: 1px solid var(--borde);
  font-size: 11.5px;
}
@media (prefers-color-scheme: dark) {
  .aviso-recorte { background: #33290f; color: #f0d79a; }
}

/* ──────────────────────────── conversación ─────────────────────────────── */
.conversacion {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex; flex-direction: column; gap: 10px;
}

.msg { max-width: 100%; }
.msg-yo {
  align-self: flex-end;
  background: var(--navy);
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--radio);
  max-width: 88%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-yo .contexto-chip {
  display: block;
  margin-top: 4px;
  font-size: 10.5px;
  color: #9fc9d8;
  letter-spacing: .02em;
}
.msg-atlas { overflow-wrap: anywhere; }
.msg-atlas p { margin: 0 0 8px; }
.msg-atlas p:last-child { margin-bottom: 0; }
.msg-atlas ul { margin: 0 0 8px; padding-left: 18px; }
.msg-atlas li { margin-bottom: 2px; }
.msg-atlas code {
  background: var(--panel-2);
  padding: 1px 4px; border-radius: 3px;
  font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  font-size: 12px;
}
.msg-atlas .pendiente::after {
  content: "▍";
  color: var(--teal);
  animation: parpadeo 1s steps(2) infinite;
}
@keyframes parpadeo { 50% { opacity: 0; } }

.estado {
  display: flex; align-items: center; gap: 6px;
  color: var(--tenue); font-size: 12px;
}
.estado::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal);
  animation: pulso 1.2s ease-in-out infinite;
  flex: 0 0 auto;
}
@keyframes pulso { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.estado.fijo::before { animation: none; opacity: .5; }

.herramientas { display: flex; flex-wrap: wrap; gap: 4px; }
.herramienta {
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 1px 8px;
  color: var(--tenue);
}

.nota { font-size: 12px; color: var(--tenue); }
.error {
  color: var(--error);
  background: var(--viejo-bg);
  border-left: 3px solid var(--error);
  padding: 6px 9px;
  border-radius: 0 var(--radio) var(--radio) 0;
  margin: 0;
}
.aviso {
  color: var(--alerta);
  background: var(--panel);
  border-left: 3px solid var(--alerta);
  padding: 6px 9px;
  border-radius: 0 var(--radio) var(--radio) 0;
  font-size: 12px;
}

/* ───────────────────────── tarjeta de propuesta ────────────────────────── */
.propuesta {
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--fondo);
  box-shadow: var(--sombra);
  overflow: hidden;
}
.propuesta-cab {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 9px;
  background: var(--panel);
  border-bottom: 1px solid var(--borde);
}
.propuesta-titulo { font-weight: 600; font-size: 12px; }
.propuesta-titulo small { display: block; font-weight: 400; color: var(--tenue); font-size: 11px; }
.propuesta-acciones { display: flex; gap: 5px; flex: 0 0 auto; }

.cambio { border-bottom: 1px solid var(--borde); }
.cambio:last-of-type { border-bottom: 0; }
.cambio-cab {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 9px;
  font-size: 12px;
  background: var(--fondo);
}
.cambio-cab input[type=checkbox] { margin: 0; flex: 0 0 auto; }
.cambio-rango {
  font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  font-weight: 600;
}
.cambio-tipo {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--tenue);
}
.cambio-ir { margin-left: auto; }
.cambio-nota { padding: 0 9px 5px 26px; font-size: 11.5px; color: var(--tenue); }

table.diff {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
}
table.diff th {
  text-align: left;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--tenue);
  padding: 2px 9px;
  background: var(--panel-2);
}
table.diff td {
  padding: 3px 9px;
  border-top: 1px solid var(--borde);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
table.diff th.c-celda, table.diff td.c-celda { width: 22%; }
table.diff td.c-celda {
  font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color: var(--tenue);
}
table.diff td.c-viejo { background: var(--viejo-bg); }
table.diff td.c-nuevo { background: var(--nuevo-bg); font-weight: 600; }
table.diff td.vacio { color: var(--tenue); font-style: italic; }
.diff-mas { padding: 4px 9px; font-size: 11px; color: var(--tenue); background: var(--panel); }

.propuesta-pie {
  padding: 6px 9px;
  font-size: 11.5px;
  border-top: 1px solid var(--borde);
  background: var(--panel);
}
.propuesta-pie.ok { color: var(--ok); }
.propuesta-pie.mal { color: var(--error); }

/* ───────────────────────── tarjeta de encargo ──────────────────────────── */
.encargo {
  border: 1px solid var(--borde);
  border-left: 3px solid var(--teal);
  border-radius: var(--radio);
  padding: 7px 9px;
  background: var(--panel);
}
.encargo-titulo { font-weight: 600; font-size: 12px; }
.encargo-folio {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px; color: var(--tenue);
}
.encargo-pasos { margin: 5px 0 0; padding-left: 16px; font-size: 11.5px; color: var(--tenue); }
.encargo-acciones { margin-top: 6px; display: flex; gap: 5px; }

/* ──────────────────────────────── redactor ─────────────────────────────── */
.redactor {
  flex: 0 0 auto;
  border-top: 1px solid var(--borde);
  padding: 7px 10px 9px;
  background: var(--panel);
}
.sugerencias {
  display: flex; gap: 5px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.sugerencias button {
  flex: 0 0 auto;
  font: inherit; font-size: 11.5px;
  background: var(--fondo);
  border: 1px solid var(--borde);
  border-radius: 11px;
  padding: 2px 10px;
  color: var(--texto);
  cursor: pointer;
  white-space: nowrap;
}
.sugerencias button:hover { border-color: var(--teal); color: var(--teal-osc); }

.redactor textarea {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  padding: 7px 9px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--fondo);
  color: var(--texto);
  font: inherit;
}
.redactor textarea:focus { outline: 2px solid var(--teal); outline-offset: -1px; }

.redactor-pie {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; gap: 8px;
}
.encargo-check {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--tenue);
  cursor: pointer;
}
.redactor-botones { display: flex; gap: 6px; }

[hidden] { display: none !important; }
