/* ================= Sirbex IA — estilos ================= */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,900&family=Public+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #05070c;
  --bg-2: #0a0e16;
  --panel: #0e1320;
  --panel-2: #131a2a;
  --line: #20293c;
  --ink: #eef2fa;
  --ink-dim: #9aa6bd;
  --ink-faint: #5b667c;
  --accent: #c9a44e;      /* dorado champán */
  --accent-soft: #e3c987; /* dorado claro para detalles */
  --accent-2: #4a82f2;    /* azul */
  --accent-2-soft: #7aa6ff;
  --danger: #e06a5a;
  --radius: 14px;
  --mono: 'JetBrains Mono', monospace;
  --body: 'Public Sans', system-ui, sans-serif;
  --display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 560px at 82% -12%, rgba(74,130,242,0.10), transparent 60%),
    radial-gradient(820px 460px at -8% 8%, rgba(201,164,78,0.06), transparent 55%),
    radial-gradient(900px 700px at 50% 120%, rgba(74,130,242,0.05), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); }
.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  padding-top: calc(14px + env(safe-area-inset-top));
  padding-left: calc(28px + env(safe-area-inset-left));
  padding-right: calc(28px + env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: rgba(12,13,16,0.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--display); font-weight: 900; font-size: 22px; letter-spacing: -0.02em; }
.brand .dot { color: var(--accent); }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.topbar .who { color: var(--ink-dim); font-size: 13px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 32px 28px 80px; }
.wrap-narrow { max-width: 720px; }

h1 { font-family: var(--display); font-weight: 600; font-size: 32px; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 32px 0 14px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.subtitle { color: var(--ink-dim); margin: 0 0 24px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--body); font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); cursor: pointer;
  transition: 0.15s; text-decoration: none;
}
.btn:hover { border-color: var(--ink-faint); text-decoration: none; }
.btn-primary { background: var(--accent); color: #1a1505; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; padding-left: 6px; padding-right: 6px; }
.btn-danger:hover { background: rgba(224,106,90,0.1); }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---------- Tarjetas / paneles ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.tag {
  display: inline-block; font-family: var(--mono); font-size: 11px;
  padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line);
  color: var(--ink-dim); background: var(--bg-2);
}
.tag.on { color: var(--accent-2); border-color: rgba(111,210,196,0.4); }
.tag.off { color: var(--ink-faint); }

/* ---------- Formularios ---------- */
label.field { display: block; margin: 16px 0 0; }
label.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--ink-dim); }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  font-family: var(--body); font-size: 14px;
}
textarea { resize: vertical; min-height: 90px; font-family: var(--body); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 9px; margin: 14px 0 0; }
.check input { width: auto; }
.hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.actions { display: flex; gap: 12px; margin-top: 24px; align-items: center; }

.alert { padding: 12px 14px; border-radius: 10px; background: rgba(224,106,90,0.12); border: 1px solid rgba(224,106,90,0.4); color: #f0b3a8; margin-bottom: 18px; }

/* ---------- Tabla simple ---------- */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item .meta { color: var(--ink-dim); font-size: 13px; }

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { font-size: 30px; margin-bottom: 4px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-faint); margin: 22px 0; font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.google-btn { width: 100%; justify-content: center; background: #fff; color: #222; border: none; }

/* ================= FRONT del cliente: agentes + chat ================= */
/* Un solo agente a la vez (carrusel) + pestañas, igual en escritorio y móvil. */
.agents-grid {
  display: flex; gap: 0; align-items: stretch;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.agents-grid::-webkit-scrollbar { display: none; }
.agent-window {
  flex: 0 0 100%; width: 100%;
  scroll-snap-align: center; scroll-snap-stop: always;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; height: min(72vh, 760px); overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.agent-head {
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2);
  display: flex; align-items: center; gap: 10px;
}
.agent-meta { flex: 1; min-width: 0; }
.agent-head .name { font-family: var(--display); font-weight: 600; font-size: 17px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-head .spec { font-size: 12.5px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-head .speaker {
  cursor: pointer; color: var(--ink-faint); font-size: 17px;
  background: none; border: none; flex: 0 0 auto; width: 36px; height: 36px;
  border-radius: 9px; transition: 0.15s;
}
.agent-head .speaker:hover { background: var(--bg-2); }
.agent-head .speaker.active { color: var(--accent); }

.chat { flex: 1; overflow-y: auto; min-height: 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 94%; padding: 8px 12px; border-radius: 15px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: #1a1505; border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--bg-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.proactive { border-left: 3px solid var(--accent-2); }
.msg .badge { font-family: var(--mono); font-size: 10px; color: var(--accent-2); display: block; margin-bottom: 4px; letter-spacing: 0.08em; }
.msg img { max-width: 100%; max-height: 320px; width: auto; height: auto; object-fit: contain; border-radius: 10px; margin-top: 4px; margin-bottom: 0; display: block; cursor: zoom-in; }
.msg .caption { font-size: 11px; color: var(--ink-faint); margin-top: 2px; font-family: var(--mono); }
/* Markdown renderizado dentro de las burbujas del asistente */
.msg.assistant .msg-text { white-space: normal; }
.msg.user .msg-text { white-space: pre-wrap; }
.msg-text > :first-child { margin-top: 0; }
.msg-text > :last-child { margin-bottom: 0; }
.msg-text p { margin: 0 0 8px; }
.msg-text h1, .msg-text h2, .msg-text h3, .msg-text h4, .msg-text h5, .msg-text h6 { margin: 12px 0 6px; line-height: 1.25; font-weight: 700; }
.msg-text h1 { font-size: 1.22em; }
.msg-text h2 { font-size: 1.13em; }
.msg-text h3 { font-size: 1.05em; }
.msg-text h4, .msg-text h5, .msg-text h6 { font-size: 1em; }
.msg-text ul, .msg-text ol { margin: 6px 0; padding-left: 20px; }
.msg-text li { margin: 2px 0; }
.msg-text code { font-family: var(--mono); font-size: 0.9em; background: rgba(127,127,127,.16); padding: 1px 5px; border-radius: 5px; }
.msg-text pre { background: rgba(127,127,127,.12); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; margin: 8px 0; }
.msg-text pre code { background: none; padding: 0; font-size: 12.5px; }
.msg-text blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-dim); }
.msg-text hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.msg-text a { color: var(--accent-2); text-decoration: underline; }
.msg-text table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; }
.msg-text th, .msg-text td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.msg-text th { background: rgba(127,127,127,.12); font-weight: 600; }
.typing { align-self: flex-start; color: var(--ink-faint); font-size: 13px; font-style: italic; }

/* Botones de sugerencia sobre la caja de texto */
.suggest-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px 0; flex: 0 0 auto; }
.suggest-bar:empty { display: none; }
.suggest-chip {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-dim);
  font-size: 13px; padding: 6px 11px; border-radius: 14px; cursor: pointer;
  white-space: normal; text-align: left; line-height: 1.3; font-family: inherit;
}
.suggest-chip:hover { border-color: var(--accent-2); color: var(--ink); }

.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px;
  border-top: 1px solid var(--line); background: var(--panel-2); flex: 0 0 auto;
}
.composer textarea {
  flex: 1; min-height: 0; height: 44px; max-height: 140px; padding: 11px 14px;
  border-radius: 22px; resize: none; line-height: 1.35; overflow-y: auto;
}
.composer .attach-btn,
.composer [data-send] {
  flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.composer .attach-btn { font-size: 18px; background: var(--bg-2); }
.composer [data-send] { color: #1a1505; }
.composer [data-send] svg { width: 19px; height: 19px; display: block; }
.composer [data-send]:disabled { opacity: 0.55; cursor: default; }

.empty { color: var(--ink-faint); font-size: 13px; text-align: center; margin: auto; padding: 20px; }

/* ===== Barra de pestañas de agentes (escritorio y móvil) ===== */
.agent-tabs {
  display: flex; flex-direction: column; gap: 10px;
  flex: 0 0 auto; padding: 0 0 14px;
}
.agent-tabs-track {
  display: flex; gap: 8px; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.agent-tabs-track::-webkit-scrollbar { display: none; }
.agent-tab {
  position: relative; flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--ink-dim); font-family: var(--body);
  font-weight: 600; font-size: 13px; padding: 8px 16px;
  border-radius: 999px; white-space: nowrap; cursor: pointer;
  transition: 0.18s;
}
.agent-tab:hover { border-color: var(--ink-faint); color: var(--ink); }
.agent-tab.active { background: var(--accent); color: #1a1505; border-color: var(--accent); }
.agent-tab.has-unread {
  border-color: var(--accent-2); color: var(--ink);
  background: color-mix(in srgb, var(--accent-2) 16%, var(--panel-2));
}
.agent-tab.has-unread::after {
  content: ''; position: absolute; top: 2px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 0 2px var(--panel);
}
.agent-tab.active.has-unread { background: var(--accent); color: #1a1505; border-color: var(--accent); }
.agent-tab.active.has-unread::after { display: none; }
.agent-dots { display: none; justify-content: center; gap: 6px; }
.agent-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: 0.25s; }
.agent-dot.active { background: var(--accent); width: 20px; border-radius: 3px; }

@media (max-width: 560px) {
  .wrap { padding: 20px 16px 60px; }
  .topbar {
    padding: 13px 16px;
    padding-top: calc(13px + env(safe-area-inset-top));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
}

@media (max-width: 760px) {
  /* La página de agentes se comporta como una app a pantalla completa.
     Usamos unidades de viewport dinámicas: dvh/svh ya descuentan las barras del
     navegador y, junto con interactive-widget=resizes-content, el teclado. Así no
     hace falta recalcular la altura con JS (eso causaba saltos al hacer scroll). */
  body:has(.agent-window) {
    height: 100vh;                 /* respaldo navegadores viejos */
    height: 100svh;                /* base estable: el alto más pequeño (con barras visibles) */
    height: var(--app-h, 100svh);  /* si el JS midió el área visible real, manda esa */
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  body:has(.agent-window) .topbar { position: static; flex: 0 0 auto; }
  /* En la vista de chat la barra va compacta: marca + Salir, sin que se encime el nombre */
  body:has(.agent-window) .brand { font-size: 18px; }
  body:has(.agent-window) .topbar .who { display: none; }
  body:has(.agent-window) .topbar nav { gap: 10px; }
  body:has(.agent-window) .wrap {
    flex: 1 1 auto; min-height: 0;
    max-width: none; margin: 0; padding: 0;
    display: flex; flex-direction: column;
  }
  /* El saludo se oculta para ganar pantalla (el nombre ya aparece arriba) */
  body:has(.agent-window) .wrap > .label,
  body:has(.agent-window) .wrap > h1,
  body:has(.agent-window) .wrap > .subtitle { display: none; }

  /* En móvil la barra de pestañas va pegada arriba, con fondo y safe-area */
  .agent-tabs {
    padding: 11px 12px 9px;
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
    border-bottom: 1px solid var(--line);
    background: rgba(20,22,27,0.88); backdrop-filter: blur(8px);
  }
  .agent-dots { display: flex; }

  /* Carrusel a pantalla completa */
  .agents-grid {
    flex: 1 1 auto; min-height: 0;
    overscroll-behavior-x: none;     /* no encadenar al gesto 'atrás' del navegador */
    touch-action: pan-x pan-y;
  }
  .agent-window {
    height: 100%;
    border-radius: 0; border-top: none; border-left: none; border-right: none;
  }
  .chat { overscroll-behavior: contain; }

  /* Caja de texto fija abajo, cómoda y respetando el notch */
  .composer {
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
    box-shadow: 0 -6px 16px rgba(0,0,0,0.18);
  }
  .composer textarea { font-size: 16px; } /* evita el zoom automático de iOS al enfocar */

  /* Pista de "desliza" que aparece una vez */
  .swipe-hint {
    position: fixed; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: rgba(20,22,27,0.95); border: 1px solid var(--line);
    color: var(--ink-dim); font-size: 12.5px; font-family: var(--mono);
    padding: 8px 14px; border-radius: 999px; z-index: 40;
    pointer-events: none; opacity: 0; transition: opacity 0.4s;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }
  .swipe-hint.show { opacity: 1; }
}

/* ================= Landing / login público ================= */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(12,13,16,0.75); backdrop-filter: blur(8px); z-index: 20;
}
.navbar .logo { font-family: var(--display); font-weight: 900; font-size: 22px; color: var(--ink); letter-spacing: -0.02em; text-decoration: none; }
.navbar .logo .dot { color: var(--accent); }
.navbar .nav-links { display: flex; gap: 12px; align-items: center; }

.landing { max-width: 560px; margin: 0 auto; padding: 56px 24px 80px; }
.hero { text-align: center; margin-bottom: 36px; }
.hero h1 { font-family: var(--display); font-weight: 900; font-size: 44px; line-height: 1.05; letter-spacing: -0.03em; margin: 0 0 14px; }
.hero .subtitle { font-size: 16px; color: var(--ink-dim); margin: 0 auto; max-width: 420px; }

.auth-container { max-width: 420px; margin: 0 auto; }
.btn-full { width: 100%; justify-content: center; }
.btn-oauth {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 16px; border-radius: 10px; font-weight: 600; font-size: 15px;
  text-decoration: none; cursor: pointer; transition: 0.15s;
}
.btn-oauth:hover { text-decoration: none; filter: brightness(0.97); }
.btn-google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.btn-google svg { flex: none; }

.divider-text { display: flex; align-items: center; gap: 12px; color: var(--ink-faint); margin: 20px 0; font-size: 12px; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-alt { text-align: center; margin-top: 18px; color: var(--ink-dim); font-size: 14px; }

.alert-error { background: rgba(224,106,90,0.12); border: 1px solid rgba(224,106,90,0.4); color: #f0b3a8; }
.alert-info { background: rgba(111,210,196,0.1); border: 1px solid rgba(111,210,196,0.35); color: #aef0e6; padding: 12px 14px; border-radius: 10px; margin-bottom: 18px; }

@media (max-width: 560px) { .navbar { padding: 14px 16px; } .hero h1 { font-size: 34px; } .landing { padding: 36px 16px 60px; } }

/* ===== Subida de fotos en el chat ===== */
.attach-btn { padding: 8px 11px; font-size: 18px; line-height: 1; }
.previews { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 12px; }
.previews:not(:empty) { padding-top: 10px; }
.preview { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-x {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.65); color: #fff; font-size: 11px; line-height: 1;
  cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center;
}

/* Documentos: preview en el compositor y chip dentro del mensaje */
.preview:has(> .preview-doc) { width: auto; }
.preview-doc {
  display: flex; align-items: center; height: 56px; padding: 0 26px 0 12px;
  font-size: 11px; font-family: var(--mono); color: var(--ink-dim);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--bg-2);
}
.msg .file-chip {
  display: inline-block; margin-top: 6px; padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--line); font-size: 12px; font-family: var(--mono);
  color: var(--ink); text-decoration: none; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.msg .file-chip:hover { border-color: var(--ink-faint); }

/* ===== Visor de imágenes (lightbox) ===== */
.msg img { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6,7,9,0.92); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: calc(58px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}
.lightbox.show { display: flex; }
.lb-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  background:
    repeating-conic-gradient(#2a2f3a 0% 25%, transparent 0% 50%) 50% / 22px 22px; /* tablero para PNG transparente */
}
.lb-bar {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 14px;
  display: flex; gap: 10px; z-index: 101;
}
.lb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--body); font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(24,27,34,0.9); color: var(--ink);
  text-decoration: none; transition: 0.15s;
}
.lb-btn:hover { border-color: var(--ink-faint); text-decoration: none; }
a.lb-btn { color: var(--accent); }

/* ===== Archivos de trabajo (workspace) ===== */
.ws-btn {
  cursor: pointer; background: none; border: none; font-size: 17px; color: var(--ink-faint);
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 9px; transition: 0.15s;
}
.ws-btn:hover { background: var(--bg-2); color: var(--ink); }
.ws-overlay {
  position: fixed; inset: 0; z-index: 90; display: none;
  background: rgba(6,7,9,0.6); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
}
.ws-overlay.show { display: flex; }
.ws-modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  width: 100%; max-width: 920px; height: 100%; max-height: 760px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.ws-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.ws-title { font-family: var(--display); font-weight: 600; font-size: 16px; }
.ws-x { background: none; border: none; color: var(--ink-dim); font-size: 16px; cursor: pointer; }
.ws-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ws-act { font-size: 12.5px; font-family: var(--body); font-weight: 600; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); cursor: pointer; }
.ws-act:hover { border-color: var(--ink-faint); }
.ws-status { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); margin-left: auto; }
.ws-body { flex: 1; min-height: 0; display: flex; }
.ws-list { width: 44%; min-width: 220px; overflow-y: auto; border-right: 1px solid var(--line); padding: 6px; }
.ws-editor { flex: 1; min-width: 0; display: none; flex-direction: column; }
.ws-editor.open { display: flex; }
.ws-empty { color: var(--ink-faint); font-size: 13px; padding: 18px; text-align: center; }
.ws-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.ws-row:hover { background: var(--bg-2); }
.ws-name { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.ws-size { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }
.ws-del { background: none; border: none; cursor: pointer; opacity: 0.55; font-size: 13px; }
.ws-del:hover { opacity: 1; }
.ws-dl { background: none; border: none; cursor: pointer; opacity: 0.55; font-size: 13px; }
.ws-dl:hover { opacity: 1; }
.ws-dl-ed { background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 12px; padding: 4px 8px; color: var(--ink-dim); }
.ws-dl-ed:hover { color: var(--ink); }
.ws-ed-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.ws-ed-name { flex: 1; font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-path { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 7px; font-family: var(--mono); font-size: 12.5px; }
.ws-save { font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 7px; border: none; background: var(--accent); color: #1a1505; cursor: pointer; }
.ws-copy { font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 7px; border: 1px solid var(--accent-2); background: none; color: var(--accent-2); cursor: pointer; }
.ws-copy:hover { background: color-mix(in srgb, var(--accent-2) 14%, transparent); }
.ws-close-ed { font-size: 12.5px; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); background: none; color: var(--ink-dim); cursor: pointer; }
.ws-text { flex: 1; width: 100%; border: none; border-radius: 0; resize: none; padding: 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: var(--bg); color: var(--ink); }
@media (max-width: 680px) {
  .ws-modal { max-height: none; border-radius: 0; }
  .ws-body { flex-direction: column; }
  .ws-list { width: auto; border-right: none; border-bottom: 1px solid var(--line); max-height: 38%; }
  .ws-editor.open { min-height: 50%; }
}

/* ===== Agenda / calendario (📅) ===== */
.ag-modal { max-width: 920px; }
.ag-bar { gap: 6px; }
.ag-month { font-family: var(--display); font-weight: 600; font-size: 14px; min-width: 130px; text-align: center; }
.ag-google { margin-left: auto; display: flex; gap: 6px; }
.ag-gconnect { text-decoration: none; }
.ag-body { flex: 1; min-height: 0; display: flex; }
.ag-cal { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 8px; }
.ag-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.ag-dow span { text-align: center; font-size: 11px; color: var(--ink-faint); font-weight: 600; }
.ag-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; gap: 4px; min-height: 0; }
.ag-cell { border: 1px solid var(--line); border-radius: 8px; padding: 4px; min-height: 64px; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; gap: 2px; background: var(--bg); }
.ag-cell.empty { border: none; background: transparent; cursor: default; }
.ag-cell:hover { border-color: var(--accent-2); }
.ag-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ag-num { font-size: 11px; color: var(--ink-dim); font-weight: 600; }
.ag-ev { font-size: 10.5px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--ink); border-radius: 4px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ag-more { font-size: 10px; color: var(--ink-faint); }
.ag-side { width: 300px; min-width: 240px; border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; }
.ag-list { padding: 8px; }
.ag-list-h, .ag-form-h { font-family: var(--display); font-weight: 600; font-size: 13px; color: var(--accent-2); margin: 4px 0 8px; }
.ag-li { padding: 7px 8px; border-radius: 7px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.ag-li:hover { background: var(--bg-2); }
.ag-li b { font-size: 13px; }
.ag-li span { font-size: 11.5px; color: var(--ink-faint); }
.ag-form { padding: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 7px; }
.ag-form:empty { display: none; }
.ag-in { width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 13px; }
.ag-chk { font-size: 12.5px; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; }
.ag-form-actions { display: flex; gap: 6px; align-items: center; }
.ag-del { color: #e06666; border-color: #e0666644; }
@media (max-width: 760px) {
  .ag-body { flex-direction: column; }
  .ag-side { width: auto; border-left: none; border-top: 1px solid var(--line); }
  .ag-cell { min-height: 48px; }
}

/* ===== Hojas tipo Excel (📊) ===== */
.sh-modal { max-width: 960px; }
.sh-body { flex-direction: row; }
.sh-list { width: 200px; min-width: 150px; }
.sh-grid-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.sh-name { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.sh-title { font-family: var(--display); font-weight: 600; font-size: 15px; background: transparent; border: none; color: var(--ink); width: 100%; }
.sh-scroll { flex: 1; overflow: auto; }
.sh-table { border-collapse: collapse; font-size: 12.5px; }
.sh-table th, .sh-table td { border: 1px solid var(--line); padding: 0; }
.sh-table th { background: var(--panel-2); position: sticky; top: 0; z-index: 1; padding: 3px 4px; min-width: 90px; }
.sh-colL { display: block; font-size: 10px; color: var(--ink-faint); text-align: center; }
.sh-head { width: 100%; background: transparent; border: none; color: var(--ink); font-weight: 600; font-size: 12px; text-align: center; padding: 2px; }
.sh-rownum { background: var(--panel-2); color: var(--ink-faint); font-size: 11px; text-align: center; min-width: 30px; }
.sh-cell { width: 100%; min-width: 90px; border: none; background: var(--bg); color: var(--ink); font-family: var(--mono); font-size: 12.5px; padding: 5px 6px; }
.sh-cell:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.sh-cell.sh-agent { background: color-mix(in srgb, var(--accent-2) 16%, transparent); }
.sh-cell.sh-user { background: var(--bg); }
.sh-legend { padding: 6px 10px; font-size: 11px; color: var(--ink-faint); border-top: 1px solid var(--line); }
.sh-legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.sh-legend .lg-agent { background: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.sh-legend .lg-user { background: var(--bg-2); border: 1px solid var(--line); }
@media (max-width: 760px) {
  .sh-body { flex-direction: column; }
  .sh-list { width: auto; border-right: none; border-bottom: 1px solid var(--line); max-height: 30%; }
}

/* ===== Botón que "brilla" cuando el agente lo señala ===== */
@keyframes zwpi-glow {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); }
}
.agent-head .glow, .composer .glow {
  animation: zwpi-glow 1.1s ease-in-out infinite;
  color: var(--accent) !important;
  border-radius: 8px;
  position: relative;
}

/* ===== Ventana del bot de WhatsApp (aislada) ===== */
.wa-window .wa-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 16px; }
.wa-sec-title { font-family: var(--display); font-weight: 600; font-size: 13px; color: var(--accent-2); margin-bottom: 8px; }
.wa-conn-card { text-align: center; }
.wa-state { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 13px; margin-bottom: 10px; }
.wa-dot { width: 9px; height: 9px; border-radius: 50%; background: #888; display: inline-block; }
.wa-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.wa-dot.off { background: #ef4444; }
.wa-dot.wait { background: #eab308; }
.wa-qr { width: 220px; height: 220px; margin: 8px auto; border-radius: 12px; background: #fff; padding: 10px; }
.wa-qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.wa-qr.empty { display: flex; align-items: center; justify-content: center; color: #999; font-size: 12px; border: 1px dashed var(--line); background: var(--bg-2); }
.wa-me { font-size: 13px; margin: 6px 0; }
.wa-me b { color: var(--accent); }
.wa-actions { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.wa-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 10px; line-height: 1.4; }
.wa-spin { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent); border-radius: 50%; margin: 24px auto; animation: waspin 1s linear infinite; }
@keyframes waspin { to { transform: rotate(360deg); } }
.wa-field { display: block; margin-bottom: 10px; }
.wa-field > span { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 4px; }
.wa-field input, .wa-field textarea { width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 13px; }
.wa-help { font-size: 11px; color: var(--ink-faint); margin-top: 3px; }
.wa-cfg-status { font-size: 12px; color: var(--ink-faint); margin-left: 8px; }
.wa-pause-add { display: flex; gap: 8px; margin-bottom: 8px; }
.wa-pause-add input { flex: 1; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.wa-paused-list { display: flex; flex-direction: column; gap: 6px; }
.wa-prow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, #eab308 8%, transparent); border-left: 3px solid #eab308; font-size: 13px; }
.wa-feed { height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.wa-feed .wa-row { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 8px; background: var(--bg-2); }
.wa-feed .wa-row .t { color: var(--ink-faint); font-size: 11px; white-space: nowrap; }
.wa-feed .wa-row.in { border-left: 3px solid #38bdf8; }
.wa-feed .wa-row.out, .wa-feed .wa-row.success { border-left: 3px solid #22c55e; }
.wa-feed .wa-row.error { border-left: 3px solid #ef4444; }
.wa-feed .wa-row.warning { border-left: 3px solid #eab308; }
.wa-empty { color: var(--ink-faint); font-size: 12.5px; text-align: center; padding: 14px; }

/* ===== Espejo de admin del bot de WhatsApp ===== */
.wa-grid-admin { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .wa-grid-admin { grid-template-columns: 1fr; } }

/* ================================================================
   Shell de la app del cliente (pantalla completa, pestañas, menú)
   Paleta: negros azulados + azul + dorado champán.
   ================================================================ */
html, body { height: 100%; }
body:has(.appshell) { overflow: hidden; }

.appshell {
  /* Anclado al área realmente visible. En móvil el teclado reduce el visual
     viewport (y en iOS desplaza la página); con position:fixed + el JS que ajusta
     top/alto, la caja de texto deja de trabarse. En escritorio el offset es 0,
     así que se comporta exactamente igual que antes (pantalla completa). */
  position: fixed;
  top: 0; left: 0; width: 100%;
  height: 100vh;
  height: 100svh;
  height: var(--app-h, 100svh);
  display: flex; flex-direction: column; overflow: hidden;
}

/* --- Barra superior --- */
.appbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  padding-top: calc(10px + env(safe-area-inset-top));
  padding-left: calc(18px + env(safe-area-inset-left));
  padding-right: calc(18px + env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19,26,42,0.92), rgba(8,11,18,0.92));
  backdrop-filter: blur(10px); z-index: 30;
}
.appbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: 0 0 auto; }
.appbar .brand:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; display: block; box-shadow: 0 0 0 1px var(--line); }
.brand-word { font-family: var(--display); font-weight: 900; font-size: 20px; letter-spacing: -0.02em; color: var(--ink); }
.brand-word .dot { color: var(--accent); }

.apptabs { flex: 1 1 auto; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; min-width: 0; padding: 3px 2px; }
.apptabs::-webkit-scrollbar { display: none; }
.apptab {
  position: relative; flex: 0 0 auto; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink-dim);
  font-family: var(--body); font-weight: 600; font-size: 13px;
  padding: 8px 16px; border-radius: 999px; white-space: nowrap; cursor: pointer; transition: .18s;
}
.apptab:hover { border-color: var(--accent-2); color: var(--ink); }
.apptab.active {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--accent-2), #2f56b8);
  box-shadow: 0 3px 14px rgba(74,130,242,.35);
}
.apptab.has-unread::after {
  content: ''; position: absolute; top: 2px; right: 7px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel);
}
.apptab.active.has-unread::after { display: none; }

.appbar-right { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }
.appbar-right .who { color: var(--ink-dim); font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Cuerpo: menú lateral + chat --- */
.appbody { flex: 1 1 auto; min-height: 0; display: flex; }

.sidemenu {
  flex: 0 0 auto; width: 196px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14,19,32,0.65), rgba(6,8,13,0.65));
  padding: 12px 8px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto;
}
.sidemenu-title { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); padding: 2px 8px 8px; }
.sidemenu-empty { color: var(--ink-faint); font-size: 12.5px; padding: 10px 8px; }
.sidemenu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 7px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--ink-dim); cursor: pointer;
  font-family: var(--body); font-size: 13.5px; font-weight: 600; text-align: left; transition: .15s;
}
.sidemenu-item:hover { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
.sidemenu-item.active {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent-2) 55%, transparent);
  background: color-mix(in srgb, var(--accent-2) 14%, transparent);
}
.sidemenu-ico { font-size: 17px; width: 22px; text-align: center; flex: 0 0 auto; }
.sidemenu-item.glow { animation: zwpi-glow 1.1s ease-in-out infinite; color: var(--accent) !important; border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

/* --- Zona de chat: una ventana a la vez, a pantalla completa --- */
.appmain { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; }
.appmain .agents-grid { flex: 1; display: block; overflow: hidden; min-height: 0; }
.appmain .agent-window {
  display: none; width: 100%; height: 100%;
  border: none; border-radius: 0; box-shadow: none; background: transparent;
}
.appmain .agent-window.is-active { display: flex; flex-direction: column; }
/* Las herramientas se manejan desde el menú lateral: ocultamos los botones del encabezado */
.appmain .agent-head .speaker,
.appmain .agent-head .ws-btn { display: none; }
.appmain .agent-head {
  background: linear-gradient(180deg, rgba(19,26,42,0.5), transparent);
  border-bottom: 1px solid var(--line);
}
.appmain .agent-head .name { color: var(--ink); }
.appmain .chat { background: transparent; }

/* La burbuja del usuario en azul (dorado queda para detalles finos) */
.appmain .msg.user { background: linear-gradient(135deg, var(--accent-soft), var(--accent)); color: #1a1505; }
.appmain .msg.assistant { background: var(--panel-2); border-color: var(--line); }
.appmain .composer { background: linear-gradient(0deg, rgba(19,26,42,0.55), transparent); }
.appmain .composer [data-send] { background: var(--accent); }

/* --- Móvil: el menú lateral se vuelve un riel angosto de iconos --- */
@media (max-width: 760px) {
  .appbar { gap: 10px; padding: 9px 12px; padding-top: calc(9px + env(safe-area-inset-top)); }
  .brand-word { font-size: 17px; }
  .appbar-right .who { display: none; }
  .sidemenu { width: 60px; padding: 12px 8px; }
  .sidemenu-title { display: none; }
  .sidemenu-lbl { display: none; }
  .sidemenu-item { justify-content: center; padding: 11px 0; gap: 0; }
  .sidemenu-empty { display: none; }
}

/* ===== Panel del sitio web (🌐) — reutiliza estilos .ws-* ===== */
.site-info { padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); font-size: 12.5px; color: var(--ink-dim); display: flex; flex-direction: column; gap: 4px; }
.site-row span:first-child { color: var(--ink-faint); margin-right: 6px; }
.site-link { color: var(--accent-2-soft); font-family: var(--mono); font-size: 12px; word-break: break-all; }
.site-link.off { color: var(--ink-faint); }
.site-note { color: var(--accent-soft); }

/* ===== Menú lateral: herramientas bloqueadas, separador, Configuración ===== */
.sidemenu-item { position: relative; }
.sidemenu-item.locked { color: var(--ink-faint); opacity: .82; }
.sidemenu-item.locked .sidemenu-ico { filter: grayscale(1) opacity(.6); }
.sidemenu-item.locked:hover { color: var(--ink-dim); border-color: var(--line); background: var(--panel-2); opacity: 1; }
.sidemenu-lock { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 11px; opacity: .8; }
.sidemenu-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.sidemenu-config { color: var(--ink-dim); }
.sidemenu-config .sidemenu-ico { color: var(--accent-2-soft); }
@media (max-width: 760px) {
  .sidemenu-lock { right: 4px; top: 6px; transform: none; }
  .sidemenu-sep { margin: 8px 4px; }
}

/* ===== Ventanas de venta / configuración (overlay) ===== */
.svc-overlay {
  position: fixed; inset: 0; z-index: 120; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(3, 5, 10, 0.72); backdrop-filter: blur(6px);
}
.svc-overlay.show { display: flex; }
.svc-modal {
  position: relative; width: min(560px, 96vw); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6), 0 0 0 1px rgba(74,130,242,.08);
  padding: 26px 26px 30px;
}
.svc-x {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink-dim); cursor: pointer; font-size: 14px; line-height: 1;
}
.svc-x:hover { color: var(--ink); border-color: var(--accent-2); }
.svc-img { margin: -6px -6px 16px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.svc-img img { display: block; width: 100%; height: auto; max-height: 260px; object-fit: cover; }
.svc-icon-big { font-size: 38px; line-height: 1; margin-bottom: 6px; }
.svc-title { font-family: var(--display); font-weight: 900; font-size: 24px; margin: 0 0 10px; color: var(--ink); }
.svc-desc { color: var(--ink-dim); font-size: 15px; line-height: 1.6; margin: 0 0 16px; }
.svc-trial { color: var(--ink-dim); font-size: 13px; line-height: 1.5; margin: 6px 0 14px; padding: 10px 12px; background: rgba(127,127,127,.08); border-radius: 10px; }
.cfg-h3 { font-size: 15px; font-weight: 700; margin: 4px 0 10px; }
.cfg-sep { border: none; border-top: 1px solid var(--line); margin: 20px 0 16px; }
.cfg-active-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.cfg-active-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; }
.cfg-ic { font-size: 18px; }
.cfg-name { flex: 1; font-weight: 600; font-size: 14px; }
.cfg-price { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); }
.cfg-tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.cfg-courtesy { background: rgba(120,180,120,.18); color: #6aa06a; }
.cfg-off { background: none; border: 1px solid var(--line); color: var(--ink-dim); font-size: 12px; padding: 5px 10px; border-radius: 9px; cursor: pointer; }
.cfg-off:hover:not(:disabled) { border-color: #d98; color: #d77; }
.cfg-off:disabled { opacity: .6; cursor: default; }
.cfg-msg { font-size: 13px; color: var(--ink-dim); margin-top: 8px; min-height: 1em; }
/* Botón de guía bajo el mensaje del agente */
.guide-btn { display: inline-block; margin-top: 8px; background: var(--bg-2); border: 1px solid var(--accent-2); color: var(--ink); font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 12px; cursor: pointer; font-family: inherit; }
.guide-btn:hover { background: var(--accent-2); color: #1a1a1a; }
.guide-steps { margin: 6px 0 14px; padding-left: 20px; color: var(--ink-dim); font-size: 14px; line-height: 1.55; }
.guide-steps li { margin: 4px 0; }
.guide-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.guide-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; }
.guide-row .cfg-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.guide-rec { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 9px; background: rgba(200,162,74,.18); color: var(--accent-2); }
.guide-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.guide-price { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); }
.svc-price {
  display: inline-block; font-family: var(--display); font-weight: 900; font-size: 26px;
  color: var(--accent-soft); margin-bottom: 18px;
}
.svc-price span { font-family: var(--body); font-weight: 600; font-size: 14px; color: var(--ink-faint); }
.svc-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.svc-buy {
  font-size: 15px; padding: 13px 26px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft)); color: #1a1505;
  border: none; font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px rgba(201,164,78,.3);
}
.svc-buy:hover { filter: brightness(1.05); }
.svc-buy:disabled { opacity: .7; cursor: default; }
.svc-soon { color: var(--ink-faint); font-size: 13.5px; }
.svc-msg { color: var(--danger); font-size: 13px; min-height: 16px; }
.svc-site-url { font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim); word-break: break-all; margin-top: 2px; }
.svc-site-adv { margin-top: 16px; }
.svc-files-link { background: none; border: none; color: var(--ink-faint); font-size: 12.5px; text-decoration: underline; cursor: pointer; padding: 0; }
.svc-files-link:hover { color: var(--ink-dim); }
.svc-form-wrap { margin-top: 8px; text-align: left; }
.svc-cred-group { margin-bottom: 18px; }
.svc-cred-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--gold, #c8a24a); margin-bottom: 8px; font-weight: 600; }
.svc-cred-field { display: block; margin-bottom: 10px; }
.svc-cred-field > span { display: block; font-size: 12.5px; color: var(--ink-dim); margin-bottom: 4px; }
.svc-cred-field input, .svc-cred-field textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg-soft, rgba(255,255,255,.04)); color: var(--ink); font-size: 14px; font-family: inherit;
}
.svc-cred-field textarea { resize: vertical; min-height: 64px; }
.svc-cred-field input:focus, .svc-cred-field textarea:focus { outline: none; border-color: var(--gold, #c8a24a); }
.svc-help { text-align: left; margin-top: 8px; color: var(--ink-dim); font-size: 14px; }
.svc-help ul { margin: 8px 0; padding-left: 18px; }
.svc-help li { margin: 5px 0; }
.svc-help-note { color: var(--ink-faint); font-size: 13px; margin-top: 10px; }
.svc-cfg-text { color: var(--ink-dim); font-size: 15px; line-height: 1.7; margin-bottom: 16px; white-space: normal; }
.svc-cfg-img { margin: 12px 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.svc-cfg-img img { display: block; width: 100%; height: auto; }

/* ===== Login: fondo a pantalla completa desvanecido + recuadros de servicios ===== */
.login-bg {
  position: fixed; inset: 0; z-index: -1;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  /* Se desvanece hacia abajo hasta el color de fondo */
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.85) 0%, rgba(0,0,0,.5) 38%, rgba(0,0,0,0) 78%);
          mask-image: linear-gradient(180deg, rgba(0,0,0,.85) 0%, rgba(0,0,0,.5) 38%, rgba(0,0,0,0) 78%);
  opacity: .55;
}
.login-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(5,7,12,.35) 0%, rgba(5,7,12,.7) 60%, var(--bg) 100%);
}

.login-services { max-width: 1040px; margin: 8px auto 60px; padding: 0 20px; }
.login-services-title {
  text-align: center; font-family: var(--display); font-weight: 900; font-size: 26px;
  color: var(--ink); margin: 10px 0 22px;
}
.login-svc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.login-svc-box {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.login-svc-img { margin: -4px -4px 12px; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); }
.login-svc-img img { display: block; width: 100%; height: 140px; object-fit: cover; }
.login-svc-box h3 { font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--accent-soft); margin: 0 0 6px; }
.login-svc-box p { color: var(--ink-dim); font-size: 14px; line-height: 1.55; margin: 0; }

/* ===== Panel de Tareas (⏰) — reutiliza .ws-* ===== */
.tasks-info { padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); font-size: 12.5px; color: var(--ink-dim); }
.tasks-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
.task-item { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: var(--panel-2); }
.task-main { min-width: 0; flex: 1; }
.task-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.task-desc { font-size: 12.5px; color: var(--ink-dim); margin-top: 2px; }
.task-sched { font-size: 11.5px; color: var(--accent-2-soft); font-family: var(--mono); margin-top: 5px; }
.task-actions { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.tasks-new { border-top: 1px solid var(--line); padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 9px; }
.tasks-new-title { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ink); }
.tasks-new input[type=text], .tasks-new textarea, .tasks-new select, .tasks-new input[type=time] {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 14px;
}
.tasks-new textarea { resize: vertical; min-height: 52px; }
.task-f-row { display: flex; gap: 8px; }
.task-f-row .task-f-when { flex: 1; }
.task-f-row .task-f-time { width: 120px; }
.tasks-new .task-f-save { align-self: flex-start; }

/* Pestañas del modal de Configuración */
.cfg-tabs { display: flex; gap: 8px; margin: 6px 0 16px; }
.cfg-tab { flex: 1; padding: 9px 10px; border-radius: 9px; border: 1px solid rgba(255,255,255,.14); background: transparent; color: inherit; cursor: pointer; font-weight: 600; font-size: 14px; }
.cfg-tab:hover { border-color: var(--accent-soft); }
.cfg-tab-active { background: var(--accent); color: #1a1505; border-color: var(--accent); }

/* Mensajes: video y audio generados con IA */
.msg-video { max-width: 100%; max-height: 360px; border-radius: 10px; margin-top: 4px; display: block; }
.msg-audio { width: 100%; margin-top: 4px; }

/* Ventana de Video con IA */
.media-modal { max-width: 560px; }
.media-body { display: block; padding: 16px 18px; overflow-y: auto; }
.media-help { color: var(--ink-dim); font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
.media-l { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 5px; }
.media-prompt { width: 100%; resize: vertical; }
.media-row { display: flex; gap: 10px; margin-top: 10px; }
.media-l2 { flex: 1; display: flex; flex-direction: column; font-size: 12px; font-weight: 600; gap: 4px; }
.media-img { margin-top: 6px; font-size: 13px; }
.media-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.media-msg { font-size: 13px; color: var(--accent-soft); }
.media-status { background: rgba(201,164,78,.12); border: 1px solid rgba(201,164,78,.4); color: var(--accent-soft); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 10px; }
.media-err { background: rgba(220,80,80,.12); border: 1px solid rgba(220,80,80,.4); color: #f1a6a6; border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 10px; }
.media-hist { margin-top: 18px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; }
.media-hist-t { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.media-hist video { max-width: 180px; max-height: 120px; border-radius: 8px; margin: 0 8px 8px 0; }

/* Conectar Facebook (OAuth) en el panel de credenciales */
.fb-connect-box { margin: 0 0 14px; padding: 12px; border: 1px solid rgba(74,130,242,.35); border-radius: 10px; background: rgba(74,130,242,.08); }
.fb-ok { color: #7ed99a; font-size: 13px; margin-bottom: 8px; }
.fb-connect { text-decoration: none; display: inline-block; }
.fb-disconnect { margin-left: 8px; }
.fb-hint { color: var(--ink-dim); font-size: 12px; margin-top: 8px; line-height: 1.45; }

/* Música: checkbox instrumental */
.media-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 12px; cursor: pointer; }
.media-estilo, .media-letra { width: 100%; }
.media-hist audio { display: block; width: 100%; margin: 0 0 8px; }

/* Nota pequeña bajo un campo de media */
.media-mini { color: var(--ink-faint); font-size: 11px; margin-top: 5px; line-height: 1.4; }

/* Botón de descargar media (chat e historial) */
.media-dl { display: inline-block; margin: 3px 0 1px; padding: 5px 12px; border-radius: 7px; border: 1px solid rgba(201,164,78,.4); background: rgba(201,164,78,.1); color: var(--accent-soft); font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; }
.media-dl:hover { background: rgba(201,164,78,.2); border-color: var(--accent); }
.media-hist-item { margin-bottom: 12px; }
.media-hist-item audio { display: block; width: 100%; margin-bottom: 4px; }

/* Borrar generación en la ventana */
.media-hist-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.media-del { padding: 5px 12px; border-radius: 7px; border: 1px solid rgba(220,80,80,.4); background: rgba(220,80,80,.1); color: #f1a6a6; font-size: 12px; font-weight: 600; cursor: pointer; }
.media-del:hover { background: rgba(220,80,80,.2); border-color: rgba(220,80,80,.7); }

/* Filas de imágenes de referencia (video) */
.media-refs { margin-top: 6px; }
.media-ref-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.media-ref-img { flex: 0 0 auto; font-size: 11px; max-width: 130px; }
.media-ref-desc { flex: 1; min-width: 0; }
.media-ref-x { flex: 0 0 auto; background: transparent; border: 1px solid rgba(255,255,255,.18); color: var(--ink-dim); border-radius: 6px; padding: 5px 9px; cursor: pointer; }
.media-ref-x:hover { border-color: rgba(220,80,80,.6); color: #f1a6a6; }
.media-add-ref { margin-top: 2px; font-size: 13px; }

/* Sin huecos sobrantes al final de la burbuja / texto vacío oculto */
.msg > :last-child { margin-bottom: 0; }
.msg-text:empty { display: none; }
