/* gestionclaude — estándar visual de cydin.cl:
   minimalista, tipografía Inter, paleta navy con acento cian, y responsivo. */

:root {
  --fondo: #0f172a;
  --fondo-alto: #1e293b;
  --superficie: rgba(30, 41, 59, .55);
  --borde: rgba(148, 163, 184, .16);
  --borde-vivo: rgba(148, 163, 184, .3);
  --texto: #e2e8f0;
  --tenue: #94a3b8;
  --apagado: #64748b;
  --acento: #38bdf8;
  --ok: #34d399;
  --aviso: #fbbf24;
  --peligro: #f87171;
  --radio: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

/* El degradado va en <html> y no en <body> con background-attachment:fixed:
   así cubre el documento entero por largo que sea, y se evita el repintado
   con tirones que provoca un fondo fijo en Safari de iOS. */
html {
  min-height: 100%;
  background: linear-gradient(165deg, #0f172a 0%, #172033 50%, #0f172a 100%);
  background-repeat: no-repeat;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }

.csrf { display: none; }

/* --- Barra superior ---------------------------------------------------- */

.barra {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 23, 42, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--borde);
}
.barra-int {
  max-width: 1080px; margin: 0 auto; padding: .9rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  /* Red de seguridad: si algún día se añade otra entrada al menú, baja de
     línea en lugar de empujar la página y provocar scroll horizontal. */
  flex-wrap: wrap;
}
.marca {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 600; letter-spacing: -.01em; color: var(--texto);
}
.marca:hover { text-decoration: none; }
.punto {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--acento); box-shadow: 0 0 12px var(--acento);
}
.barra nav { display: flex; align-items: center; gap: 1.25rem; }
.barra nav a, .enlace {
  font-size: .875rem; color: var(--tenue);
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: inherit;
}
.barra nav a:hover, .enlace:hover { color: var(--texto); text-decoration: none; }
.barra nav form { display: inline; }

/* --- Estructura --------------------------------------------------------- */

.contenido { max-width: 1080px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }

h1 {
  margin: 0 0 .4rem; font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 600; letter-spacing: -.02em;
}
h2 {
  margin: 2.75rem 0 1rem; font-size: 1.05rem; font-weight: 600;
  letter-spacing: -.01em;
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
}
h2 .cuenta { font-size: .8rem; font-weight: 400; color: var(--apagado); }
.subtitulo { margin: 0 0 2rem; color: var(--tenue); font-weight: 300; line-height: 1.6; }

.seccion-cab {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}

/* --- Tarjetas ----------------------------------------------------------- */

.rejilla {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: .85rem;
  transition: border-color .2s ease;
}
.tarjeta:hover { border-color: var(--borde-vivo); }

.tarjeta-cab {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem;
}
.tarjeta h3 {
  margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -.01em;
  word-break: break-word;
}
.tarjeta .sub { margin: .2rem 0 0; font-size: .8rem; color: var(--apagado); }

.datos {
  display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem;
  font-size: .8rem; color: var(--tenue);
}
.datos dt { color: var(--apagado); }
.datos dd { margin: 0; }

/* --- Distintivos -------------------------------------------------------- */

.pastilla {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .72rem; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
}
.pastilla::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.pastilla.disponible { color: var(--ok); background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.25); }
.pastilla.archivado  { color: var(--apagado); background: rgba(100,116,139,.12); border-color: rgba(100,116,139,.3); }
.pastilla.caido      { color: var(--peligro); background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.28); }
.pastilla.inexistente{ color: var(--aviso); background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.25); }

/* Consumo de memoria: cada chat abierto pesa, así que se muestra sin tener
   que ir a buscarlo. */
.recursos {
  display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; align-items: baseline;
  margin: -.35rem 0 1.1rem; padding: .7rem 1rem;
  border: 1px solid var(--borde); border-radius: 10px;
  background: rgba(148,163,184,.05);
  font-size: .8rem; color: var(--tenue);
}
.recursos strong { color: var(--texto); font-weight: 600; }
.recursos-nota { color: var(--apagado); }
.recursos.apretado {
  border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.07);
}
.recursos.apretado .recursos-nota { color: var(--aviso); }

.etiquetas { display: flex; flex-wrap: wrap; gap: .4rem; }
.etiqueta {
  font-size: .7rem; padding: .18rem .5rem; border-radius: 6px;
  color: var(--tenue); background: rgba(148,163,184,.1);
  border: 1px solid var(--borde);
}
.etiqueta.si { color: var(--acento); border-color: rgba(56,189,248,.3); background: rgba(56,189,248,.08); }

/* --- Interruptor de encendido de un chat ---------------------------------- */

.interruptor-fila {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem 0; border-top: 1px solid var(--borde);
}

.interruptor {
  flex: none; width: 40px; height: 23px; padding: 0;
  border-radius: 999px; cursor: pointer;
  background: rgba(100,116,139,.35);
  border: 1px solid var(--borde-vivo);
  position: relative;
  transition: background .18s ease, border-color .18s ease;
}
.interruptor::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%;
  background: #e2e8f0;
  transition: transform .18s ease;
}
.interruptor.activado {
  background: rgba(52,211,153,.35); border-color: rgba(52,211,153,.5);
}
.interruptor.activado::after { transform: translateX(17px); background: var(--ok); }
.interruptor:disabled { cursor: progress; opacity: .6; }

.interruptor.bloqueado {
  background: rgba(52,211,153,.18); border-color: rgba(52,211,153,.3);
  cursor: not-allowed;
}
.interruptor.bloqueado::after {
  transform: translateX(17px); background: var(--apagado);
}

.interruptor-etiqueta {
  display: flex; flex-direction: column; gap: .1rem;
  font-size: .82rem; font-weight: 500; color: var(--texto);
}
.interruptor-nota { font-size: .73rem; font-weight: 300; color: var(--apagado); }

/* --- Botones ------------------------------------------------------------ */

.acciones { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: auto; padding-top: .35rem; }

.boton {
  font-family: inherit; font-size: .8rem; font-weight: 500;
  padding: .45rem .85rem; border-radius: 9px; cursor: pointer;
  color: var(--texto); background: rgba(148,163,184,.1);
  border: 1px solid var(--borde-vivo);
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.boton:hover:not(:disabled) { background: rgba(148,163,184,.18); }
.boton:disabled { opacity: .45; cursor: progress; }
.boton.principal {
  color: #06222f; background: var(--acento); border-color: var(--acento);
  font-weight: 600;
}
.boton.principal:hover:not(:disabled) { background: #7dd3fc; }
.boton.peligro { color: var(--peligro); border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.08); }
.boton.peligro:hover:not(:disabled) { background: rgba(248,113,113,.16); }

/* --- Avisos ------------------------------------------------------------- */

.aviso {
  padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1.25rem;
  font-size: .875rem; border: 1px solid var(--borde-vivo);
  background: rgba(148,163,184,.08);
}
.aviso.error { color: #fecaca; border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.1); }
.aviso.ok    { color: #bbf7d0; border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.1); }

.vacio {
  padding: 2.5rem 1.5rem; text-align: center; color: var(--apagado);
  border: 1px dashed var(--borde-vivo); border-radius: var(--radio);
  font-size: .9rem; font-weight: 300;
}

/* --- Formularios -------------------------------------------------------- */

.formulario { display: flex; flex-direction: column; gap: 1.25rem; max-width: 34rem; }
.campo { display: flex; flex-direction: column; gap: .4rem; }
.campo label { font-size: .85rem; font-weight: 500; }
.campo .pista { font-size: .78rem; color: var(--apagado); font-weight: 300; line-height: 1.5; }

input[type=text], input[type=email], input[type=password], textarea, select {
  font-family: inherit; font-size: .9rem;
  padding: .65rem .8rem; border-radius: 10px;
  color: var(--texto); background: rgba(15,23,42,.6);
  border: 1px solid var(--borde-vivo);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--acento);
  box-shadow: 0 0 0 3px rgba(56,189,248,.15);
}
textarea { resize: vertical; min-height: 6.5rem; line-height: 1.6; }

.opciones { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.casilla { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.casilla input { width: auto; }

/* --- Acceso -------------------------------------------------------------- */

.acceso { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1.5rem; }
.acceso-caja {
  width: 100%; max-width: 24rem;
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: 18px; padding: 2.25rem;
}
.acceso-caja h1 { font-size: 1.35rem; margin-bottom: .35rem; }
.acceso-caja .subtitulo { margin-bottom: 1.75rem; font-size: .875rem; }

/* --- Consola de registros ------------------------------------------------ */

.consola {
  margin-top: 1rem; padding: 1rem 1.15rem; border-radius: 12px;
  background: rgba(2, 6, 23, .75); border: 1px solid var(--borde);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .78rem; line-height: 1.65; color: #cbd5e1;
  white-space: pre-wrap; word-break: break-word;
  max-height: 26rem; overflow-y: auto;
}
.consola:empty::before { content: 'Sin salida todavía…'; color: var(--apagado); }

/* --- Tabla de auditoría --------------------------------------------------- */

.tabla-envoltura { overflow-x: auto; border: 1px solid var(--borde); border-radius: var(--radio); }
table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 34rem; }
th, td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--borde); }
th { color: var(--apagado); font-weight: 500; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
td.fallo, td.error { color: var(--peligro); }

/* --- Ventana modal -------------------------------------------------------- */

.modal {
  position: fixed; inset: 0; z-index: 50;
  display: none; place-items: center; padding: 1.5rem;
  background: rgba(2, 6, 23, .7); backdrop-filter: blur(4px);
}
.modal.visible { display: grid; }
.modal-caja {
  width: 100%; max-width: 27rem;
  background: var(--fondo-alto); border: 1px solid var(--borde-vivo);
  border-radius: 16px; padding: 1.75rem;
}
.modal-caja h3 { margin: 0 0 .6rem; font-size: 1.05rem; }
.modal-caja p { margin: 0 0 1.1rem; font-size: .875rem; color: var(--tenue); line-height: 1.6; }

/* --- Documentación (CLAUDE.md) -------------------------------------------- */

.docs { display: grid; grid-template-columns: 16rem 1fr; gap: 1.5rem; align-items: start; }

.docs-indice {
  position: sticky; top: 5rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.docs-grupo {
  margin: .9rem 0 .3rem; font-size: .7rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .1em; color: var(--apagado);
}
.docs-grupo:first-child { margin-top: 0; }

.docs-enlace {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .65rem .8rem; border-radius: 10px;
  border: 1px solid transparent; color: var(--texto);
}
.docs-enlace:hover { background: rgba(148,163,184,.08); text-decoration: none; }
.docs-enlace.activo {
  background: rgba(56,189,248,.1); border-color: rgba(56,189,248,.3);
}
.docs-titulo { font-size: .875rem; font-weight: 500; }
.docs-desc { font-size: .75rem; color: var(--apagado); line-height: 1.45; font-weight: 300; }

.docs-cuerpo {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 1.75rem 2rem; min-width: 0;
}
.docs-cab {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding-bottom: 1.1rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--borde);
}
.docs-ruta { font-size: .78rem; color: var(--apagado); word-break: break-all; }

/* --- Markdown renderizado -------------------------------------------------- */

.md { line-height: 1.7; font-weight: 300; color: #cbd5e1; min-width: 0; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 {
  color: var(--texto); font-weight: 600; letter-spacing: -.01em; line-height: 1.35;
}
.md h1 { font-size: 1.5rem; margin: 2rem 0 .8rem; }
.md h2 {
  font-size: 1.15rem; margin: 2.25rem 0 .8rem;
  padding-bottom: .45rem; border-bottom: 1px solid var(--borde);
}
.md h3 { font-size: 1rem; margin: 1.75rem 0 .6rem; }
.md h4 { font-size: .9rem; margin: 1.4rem 0 .5rem; color: var(--tenue); }
.md p { margin: 0 0 1rem; }
.md ul, .md ol { margin: 0 0 1rem; padding-left: 1.4rem; }
.md li { margin-bottom: .4rem; }
.md li > ul, .md li > ol { margin-top: .4rem; }
.md strong { color: var(--texto); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--borde); margin: 2rem 0; }

.md code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .84em; padding: .12em .4em; border-radius: 5px;
  background: rgba(2,6,23,.6); border: 1px solid var(--borde);
  color: #7dd3fc; word-break: break-word;
}
.md pre {
  margin: 0 0 1.15rem; padding: 1rem 1.15rem; border-radius: 10px;
  background: rgba(2,6,23,.75); border: 1px solid var(--borde);
  overflow-x: auto;
}
.md pre code {
  padding: 0; background: none; border: 0; color: #cbd5e1;
  font-size: .8rem; line-height: 1.65; word-break: normal;
}

.md blockquote {
  margin: 0 0 1.15rem; padding: .1rem 0 .1rem 1.1rem;
  border-left: 3px solid var(--acento); color: var(--tenue);
}
.md blockquote p:last-child { margin-bottom: 0; }

/* Las tablas del registro son anchas: scrollean dentro de su caja. */
.md table {
  display: block; overflow-x: auto; white-space: nowrap;
  margin: 0 0 1.15rem; min-width: 0;
}
.md th { color: var(--tenue); }
.md td, .md th { border-bottom: 1px solid var(--borde); }

@media (max-width: 860px) {
  .docs { grid-template-columns: 1fr; }
  .docs-indice { position: static; }
  .docs-cuerpo { padding: 1.4rem 1.25rem; }
}

@media (max-width: 560px) {
  .contenido { padding: 1.75rem 1.15rem 3rem; }
  .barra-int { padding: .8rem 1.15rem; }
  .barra nav { gap: .9rem; }
  .acciones .boton { flex: 1 1 auto; text-align: center; }
  .md h1 { font-size: 1.3rem; }
  .md h2 { font-size: 1.05rem; }
}
