/* Panel de administración — sistema visual "Neural Architect" (el de la landing hermana).
   Estructura midnight + un acento, tipografías Space Grotesk (títulos) / Inter (cuerpo).

   Los dos colores de marca (--bg y --cyan) los sobrescribe admin/brand.js al cargar, desde
   BRAND_COLOR_INK (o BRAND_COLOR_BG, si el panel debe llevar un oscuro distinto al de los
   correos) y BRAND_COLOR_ACCENT. Los valores de aquí son los NEUTROS por defecto, no los de
   la marca propia: si un fork no configura sus variables tiene que quedarse en gris, no heredar la
   identidad de otra empresa.

   Todo lo derivado se calcula con color-mix y NO se escribe a mano. Antes había ocho valores
   sueltos —cuatro superficies y cuatro halos rgba(71,234,237,…)— y brand.js solo sobrescribía
   --cyan: el resultado era un panel con el acento del cliente y los halos y el fondo de
   la instancia propia. Si añades un halo nuevo, derívalo; no pegues un rgba. */
:root {
    --bg: #1a1d24;
    --surface: color-mix(in srgb, var(--bg) 96%, #fff);
    --surface2: color-mix(in srgb, var(--bg) 94%, #fff);
    --border: color-mix(in srgb, var(--bg) 89%, #fff);
    --cyan: #5b6b7f;
    --cyan-dim: color-mix(in srgb, var(--cyan) 12%, transparent);
    --orange: #ffb77d;
    --text: #e4e8f0;
    --muted: #7a8898;
    --error: #ff5c5c;
    --success: #4cdf90;
    --radius: 8px;
    --sidebar-w: 220px;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

/* El atributo `hidden` debe ganar a las reglas display de abajo (.auth-view y
   #appView usan display:flex; sin esto anularían [hidden]{display:none}). */
[hidden] { display: none !important; }
.hidden { display: none !important; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    /* Glow ambiental: radial suave desde el centro (firma del design system). */
    background-image: radial-gradient(ellipse at 50% 0%, var(--surface2) 0%, var(--bg) 60%);
    background-attachment: fixed;
}

h1, h2, h3, .brand { font-family: var(--font-display); letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.hint { font-size: .8rem; color: var(--muted); margin: -.3rem 0 .4rem; }
.error { color: var(--error); min-height: 1.2em; margin: .4rem 0 0; font-size: .9rem; }

/* ── Auth views ──────────────────────────────────────────────────────── */
.auth-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin: 0 0 .25rem; font-size: 1.5rem; color: var(--cyan); }
.auth-card .muted { margin-top: 0; font-size: .85rem; }
.auth-card label { display: block; margin: 1rem 0 .25rem; font-size: .85rem; color: var(--muted); }
.auth-card label.row { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; color: var(--text); }
.auth-card input[type=email],
.auth-card input[type=password],
.auth-card input[type=text] {
    width: 100%;
    padding: .65rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color .15s;
}
.auth-card input:focus { outline: none; border-color: var(--cyan); }
.auth-card button {
    width: 100%;
    margin-top: 1.25rem;
    padding: .7rem;
    background: var(--cyan);
    color: var(--bg);
    border: 0;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-display);
    cursor: pointer;
    transition: box-shadow .15s, filter .15s;
}
.auth-card button:hover { box-shadow: 0 0 15px var(--cyan-dim); filter: brightness(1.05); }
.codes {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    font-family: var(--font-display);
    line-height: 1.8;
    white-space: pre-wrap;
    color: var(--cyan);
}

/* ── App shell ───────────────────────────────────────────────────────── */
#appView { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    gap: .25rem;
}
.brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--cyan);
    margin-bottom: 1.5rem;
    padding: 0 .5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
/* El logo de la instancia (BRAND_LOGO_URL) o, sin él, la inicial de su nombre sobre el acento. */
.brand-logo { height: 26px; width: auto; max-width: 120px; }
.brand-inicial {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto;
    background: var(--cyan); color: var(--bg); font-size: .95rem;
}
.nav-item {
    /* Ancho completo, y no es cosmético: el <nav> es `display:block` y un <button> es
       inline-block, así que sin esto los items FLUYEN EN LÍNEA y se emparejan los que quepan
       juntos en el ancho de la barra. Con cuatro entradas no se notaba —ninguna pareja cabía—
       y al entrar la quinta, "Email" y "KPIs" (90 + 83 px en ~180 disponibles) aparecieron
       compartiendo fila. Parecía una lista apilada por casualidad, no por CSS. */
    display: block;
    width: 100%;
    text-align: left;
    padding: .6rem .75rem;
    background: transparent;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--muted);
    font-size: .95rem;
    font-family: inherit;
    cursor: pointer;
    transition: color .15s, background .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .03); color: var(--text); }
.nav-item.active {
    color: var(--cyan);
    background: var(--cyan-dim);
    border-left-color: var(--cyan);
}
.logout {
    padding: .55rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: inherit;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.logout:hover { color: var(--text); border-color: var(--text); }
.content { flex: 1; padding: 2.5rem; }
.panel { display: none; }
.panel.active { display: block; }
.panel h2 { margin-top: 0; font-size: 1.6rem; }

/* ── Botones reutilizables ───────────────────────────────────────────────── */
.btn-primary {
    padding: .55rem 1.1rem;
    background: var(--cyan);
    color: var(--bg);
    border: 0;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    font-family: var(--font-display);
    cursor: pointer;
    transition: filter .15s;
    white-space: nowrap;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .45; cursor: default; filter: none; }

.btn-ghost {
    padding: .5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.btn-danger {
    padding: .5rem 1rem;
    background: transparent;
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s;
}
.btn-danger:hover { background: rgba(255,92,92,.1); }

/* ── Kanban toolbar ──────────────────────────────────────────────────────── */
.kb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.kb-search {
    padding: .5rem .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    width: 180px;
    transition: border-color .15s;
}
.kb-search:focus { outline: none; border-color: var(--cyan); }
.kb-select {
    padding: .5rem .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .85rem;
    font-family: inherit;
}
.kb-select:focus { outline: none; border-color: var(--cyan); }
.kb-archived-toggle {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .82rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}
.kb-tag-archived {
    display: inline-block;
    margin-bottom: .3rem;
    padding: .1rem .4rem;
    font-size: .68rem;
    border-radius: 4px;
    background: rgba(255,92,92,.12);
    color: var(--error);
}

/* ── Kanban board ────────────────────────────────────────────────────────── */
.kb-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    min-height: calc(100vh - 210px);
    align-items: flex-start;
}

/* ── Column ──────────────────────────────────────────────────────────────── */
.kb-col {
    flex: 0 0 272px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}
.kb-col-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.kb-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kb-col-name {
    flex: 1;
    font-size: .9rem;
    font-weight: 600;
    font-family: var(--font-display);
    color: var(--text);
    cursor: default;
    user-select: none;
}
.kb-col-name:hover { color: var(--cyan); }
.kb-col-count {
    font-size: .75rem;
    color: var(--muted);
    background: var(--bg);
    padding: .1rem .45rem;
    border-radius: 20px;
}
.kb-col-del {
    background: transparent;
    border: 0;
    color: var(--border);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 .15rem;
    transition: color .15s;
}
.kb-col-del:hover { color: var(--error); }

.kb-drop-zone {
    flex: 1;
    padding: .75rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 80px;
    transition: background .15s;
}
.kb-drop-zone.drag-over { background: var(--cyan-dim); border-radius: 6px; }

.kb-add-card {
    margin: 0 .75rem .75rem;
    padding: .45rem;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: .82rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: color .15s, border-color .15s;
}
.kb-add-card:hover { color: var(--cyan); border-color: var(--cyan); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.kb-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    user-select: none;
}
.kb-card:hover { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan-dim); }
.kb-card.dragging { opacity: .35; }
.kb-card-name { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.kb-card-sub { font-size: .8rem; color: var(--muted); margin-bottom: .4rem; }
.kb-card-footer { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
.kb-card-date { font-size: .72rem; color: var(--muted); margin-left: auto; }

.kb-tag {
    display: inline-block;
    padding: .12rem .45rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: .72rem;
    color: var(--muted);
}
.kb-badge {
    display: inline-block;
    padding: .12rem .45rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
}
.badge-green  { background: rgba(76,223,144,.15); color: var(--success); }
.badge-orange { background: rgba(255,183,125,.15); color: var(--orange); }
.badge-red    { background: rgba(255,92,92,.15); color: var(--error); }
.badge-cold   { background: rgba(120,150,180,.18); color: #9bb4cc; }
.badge-lang   { background: var(--cyan-dim); color: var(--cyan); letter-spacing: .04em; }
.kb-news-dot  { color: var(--cyan); font-size: .8rem; opacity: .85; }

/* ── Detail overlay ──────────────────────────────────────────────────────── */
.kb-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 100;
    display: flex;
    justify-content: flex-end;
}
.kb-detail-overlay[hidden] { display: none !important; }
.kb-detail {
    background: var(--surface);
    border-left: 1px solid var(--border);
    width: 100%;
    max-width: 480px;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.kb-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}
.kb-detail-name {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-display);
    width: 100%;
    padding: .2rem 0;
}
.kb-detail-name:focus { outline: none; border-bottom-color: var(--cyan); }
.kb-close {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    padding: 0;
    transition: color .15s;
}
.kb-close:hover { color: var(--text); }

.kb-detail-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.kb-field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .8rem;
    color: var(--muted);
}
.kb-field input, .kb-field select, .kb-field textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    padding: .55rem .75rem;
    transition: border-color .15s;
}
.kb-field input:focus, .kb-field select:focus, .kb-field textarea:focus {
    outline: none;
    border-color: var(--cyan);
}
.kb-field select { cursor: pointer; }
.kb-field textarea { resize: vertical; }

.kb-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.kb-ai-section {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
}

/* ── Oportunidades de la ficha (migración 0020) ─────────────────────────────
   La etapa es del trato, no de la persona: una ficha puede listar varios y cada uno
   lleva su propio desplegable. Reusa .kb-ai-section para no inventar otro contenedor. */
.kb-ops-section {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
}
.kb-ops-section .kb-ai-label { justify-content: space-between; }
.kb-op-nueva { font-size: .7rem; padding: .2rem .5rem; text-transform: none; letter-spacing: 0; }
.kb-op-list { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.kb-op-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem .6rem;
    background: var(--surface);
}
.kb-op-linea1 { display: flex; gap: .4rem; align-items: center; }
.kb-op-titulo {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text);
    font-size: .9rem;
    font-weight: 600;
    padding: .25rem .35rem;
}
.kb-op-titulo:hover { border-color: var(--border); }
.kb-op-titulo:focus { outline: none; border-color: var(--cyan); background: var(--surface2); }
.kb-op-linea1 .kb-select { flex: 0 0 9rem; }
.kb-op-del {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 .25rem;
}
.kb-op-del:hover { color: var(--red, #ff5c5c); }
.kb-op-linea2 { display: flex; gap: .5rem; margin-top: .4rem; flex-wrap: wrap; }
.kb-op-linea2 label {
    flex: 1 1 7rem;
    min-width: 0;
    font-size: .7rem;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.kb-op-linea2 input {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: .8rem;
    padding: .3rem .4rem;
    width: 100%;
}
.kb-op-linea2 input:focus { outline: none; border-color: var(--cyan); }

/* Título del trato en la tarjeta del tablero, e importe en su pie. */
.kb-card-titulo { font-weight: 600; color: var(--text); }
.badge-importe { background: rgba(76, 223, 144, .15); color: #4cdf90; }

/* Aviso de teléfono duplicado en el alta: tres salidas, dentro del propio modal. */
.kb-dup {
    border: 1px solid var(--border);
    border-left: 3px solid #ffb77d;
    border-radius: var(--radius);
    background: var(--surface2);
    padding: .6rem .75rem;
    margin-top: .5rem;
}
.kb-dup-msg { margin: 0 0 .5rem; font-size: .85rem; color: var(--text); line-height: 1.5; }
.kb-dup-btns { display: flex; gap: .4rem; flex-wrap: wrap; }
.kb-dup-btns button { font-size: .8rem; padding: .35rem .7rem; }
.kb-ai-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--cyan);
    text-transform: uppercase;
    letter-spacing: .05em;
    display: flex;
    align-items: center;
    margin-bottom: .5rem;
}
.kb-resumen-lista { margin: .2rem 0 .5rem 1.1rem; padding: 0; font-size: .85rem; }
.kb-resumen-lista li { margin: .15rem 0; }
.kb-resumen-paso { font-size: .88rem; margin: .5rem 0 .25rem; }
.kb-ai-summary {
    font-size: .85rem;
    color: var(--text);
    margin: 0;
    line-height: 1.55;
}
.kb-ai-sublabel {
    font-size: .7rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .25rem;
}
.kb-ai-sublabel-spaced {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
}

/* ── Filtros del Kanban: botón + panel + chips ────────────────────────────────
   Un criterio nuevo es una fila del panel, no un control más en la barra. Los chips existen
   para que un filtro puesto y olvidado no parezca un tablero vacío. */
.kb-filtros-wrap { position: relative; }
.kb-filtros-activos { border-color: var(--cyan); color: var(--cyan); }
.kb-filtros-panel {
    position: absolute; top: calc(100% + .4rem); left: 0; z-index: 20; width: 17rem;
    display: flex; flex-direction: column; gap: .5rem; padding: .8rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.kb-filtros-panel[hidden] { display: none; }
.kb-filtro-fila {
    display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    font-size: .8rem; color: var(--muted);
}
.kb-filtro-fila .kb-select { flex: 0 1 9rem; }
.kb-filtro-check { cursor: pointer; }
.kb-filtros-pie { display: flex; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: .5rem; }

.kb-chips { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: -.4rem 0 .8rem; }
.kb-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    background: var(--cyan-dim); border: 1px solid var(--cyan); color: var(--cyan);
    border-radius: 999px; padding: .15rem .6rem; font: inherit; font-size: .74rem; cursor: pointer;
}
.kb-chip:hover { background: color-mix(in srgb, var(--cyan) 24%, transparent); }
.kb-chip-x { opacity: .7; }
.kb-chips-limpiar {
    background: none; border: none; color: var(--muted); font: inherit; font-size: .74rem;
    text-decoration: underline; cursor: pointer;
}
.kb-chips-limpiar:hover { color: var(--text); }

/* Grupo plegable del formulario de alta. */
.kb-modal-grupo { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .7rem; }
.kb-modal-grupo summary { cursor: pointer; font-size: .85rem; color: var(--text); }
.kb-modal-grupo[open] summary { margin-bottom: .5rem; }
.kb-modal-nota { color: var(--muted); font-size: .78rem; }
.kb-quiz-alta { display: flex; align-items: flex-start; gap: .6rem; justify-content: space-between; margin-bottom: .45rem; }
.kb-quiz-alta-q { font-size: .8rem; line-height: 1.35; color: var(--text); }
.kb-quiz-alta-ops { display: flex; gap: .5rem; flex: 0 0 auto; font-size: .78rem; color: var(--muted); }
.kb-quiz-alta-ops label { display: inline-flex; align-items: center; gap: .2rem; cursor: pointer; }

/* Consentimiento de newsletter en la ficha del lead: casilla + traza de evidencia. */
.kb-check {
    display: flex; align-items: center; gap: .45rem;
    font-size: .9rem; color: var(--text); cursor: pointer; user-select: none;
}
.kb-consent-trace { display: block; margin-top: .2rem; font-size: .75rem; color: var(--muted); }

/* ── Quiz de diagnóstico (detalle de lead) ───────────────────────────────── */
.kb-quiz-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.kb-quiz-item { display: flex; align-items: center; gap: .5rem; font-size: .82rem; line-height: 1.4; }
.kb-quiz-ans {
    flex: 0 0 auto; min-width: 2rem; text-align: center;
    padding: .08rem .4rem; border-radius: 6px; font-size: .72rem; font-weight: 700;
}
.kb-quiz-ans.is-no { background: rgba(255,92,92,.15); color: var(--error); }
.kb-quiz-ans.is-si { background: var(--cyan-dim); color: var(--cyan); }
.kb-quiz-ans.is-na { background: var(--surface); color: var(--muted); }
.kb-quiz-q { color: var(--text); }
.kb-quiz-meta { margin-top: .6rem; font-size: .78rem; color: var(--muted); }

/* ── Agenda (calendario de citas) ────────────────────────────────────────── */
.ag-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.ag-nav { display: flex; align-items: center; gap: .5rem; }
.ag-month { font-weight: 600; min-width: 9rem; text-align: center; text-transform: capitalize; }
/* Conexión con Google Calendar, encima de la rejilla. Conectada es una línea; si falta algo,
   crece con lo que haga falta hacer. */
.ag-google { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-bottom: 1rem;
             padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius);
             background: var(--surface2); }
.ag-google-titulo { font-weight: 600; }
.ag-google .hint, .ag-google .cal-error { flex-basis: 100%; margin: 0; overflow-wrap: anywhere; }
.ag-google select { min-width: 14rem; max-width: 100%; }
/* Rejilla mensual compartida (views/_calendargrid.js): la usan Agenda y Correos. Prefijo
   neutro cal- a propósito — con ag- parecería de la Agenda y el segundo consumidor no se
   atrevería a tocarla. */
.cal-grid-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-grid-head > div { text-align: center; font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
    min-height: 92px; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
/* Una celda desplegada crece en vez de recortar: es lo que se pidió al pulsar "+N más". */
.cal-cell-expandida { overflow: visible; height: auto; }
.cal-cell-empty { background: transparent; border: none; }
.cal-cell-today { border-color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan); }
.cal-cell-destino { border-color: var(--cyan); background: var(--cyan-dim); }
.cal-cell-num { font-size: .72rem; color: var(--muted); font-weight: 600; padding: 1px 3px; }
.cal-chip {
    font-size: .68rem; line-height: 1.25; background: var(--cyan-dim); color: var(--text);
    border-radius: 4px; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.cal-chip:hover { background: color-mix(in srgb, var(--cyan) 22%, transparent); }
.cal-chip-arrastrando { opacity: .45; }
.cal-chip-time { font-weight: 700; color: var(--cyan); }
.cal-chip-cancel { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); text-decoration: line-through; }
.cal-chip-cancel .cal-chip-time { color: var(--muted); }
/* Sin esto los chips sobrantes se perdían bajo el overflow:hidden de la celda. */
.cal-more { font-size: .66rem; color: var(--muted); padding: 1px 4px; cursor: pointer; }
.cal-more:hover { color: var(--cyan); }

.ag-up-title { margin: 1.5rem 0 .75rem; font-size: 1rem; }
.ag-up-list { display: flex; flex-direction: column; gap: .5rem; }
.ag-up-item {
    display: flex; align-items: center; gap: 1rem; background: var(--surface2);
    border: 1px solid var(--border); border-radius: 10px; padding: .6rem .9rem; cursor: pointer;
}
.ag-up-item:hover { border-color: var(--cyan); }
.ag-up-when { text-align: center; min-width: 5.5rem; }
.ag-up-date { font-size: .72rem; color: var(--muted); text-transform: capitalize; line-height: 1.2; }
.ag-up-time { font-size: 1.1rem; font-weight: 700; color: var(--cyan); }
.ag-up-main { flex: 1; min-width: 0; }
.ag-up-name { font-weight: 600; }
.ag-up-nolead { font-size: .68rem; font-weight: 500; color: var(--muted); background: var(--surface); padding: .05rem .35rem; border-radius: 6px; }
.ag-up-sub { font-size: .8rem; color: var(--muted); }
.ag-up-meet { font-size: .8rem; color: var(--cyan); text-decoration: none; white-space: nowrap; }
.ag-up-meet:hover { text-decoration: underline; }

/* ── Detalle de cita (panel lateral, mismo patrón que el de leads) ───────────── */
.ag-detail-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
    display: flex; justify-content: flex-end;
}
.ag-detail-overlay[hidden] { display: none !important; }
.ag-detail {
    background: var(--surface); border-left: 1px solid var(--border);
    width: 100%; max-width: 440px; height: 100%; overflow-y: auto;
    display: flex; flex-direction: column;
}
.ag-detail-header {
    display: flex; align-items: flex-start; gap: 1rem; padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.ag-detail-name { font-size: 1.15rem; font-weight: 700; }
.ag-detail-when { font-size: .85rem; color: var(--muted); text-transform: capitalize; margin-top: .2rem; }
.ag-cancel-tag { color: #ff7a7a; font-weight: 600; text-transform: none; }
.ag-detail-body { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: .85rem; }
.ag-detail-row { font-size: .9rem; color: var(--text); }
.ag-detail-actions-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.ag-detail-sublabel {
    font-size: .72rem; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4rem;
}
.ag-resched { border-top: 1px solid var(--border); padding-top: .85rem; }
.ag-resched-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.ag-resched-row input[type="datetime-local"] {
    flex: 1; min-width: 0; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); padding: .5rem .6rem; font-family: inherit; font-size: .85rem;
}

.kb-detail-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

.kb-timeline { margin-top: .25rem; }
.kb-timeline-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .65rem;
}
.ev-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.ev-item {
    display: flex;
    justify-content: space-between;
    padding: .5rem .75rem;
    background: var(--surface2);
    border-radius: var(--radius);
    font-size: .82rem;
    flex-wrap: wrap;
}
/* Mayúscula solo en la primera letra: `capitalize` convertía "WhatsApp enviado · …" en
   "WhatsApp Enviado · …". ::first-letter necesita un bloque, de ahí el inline-block. */
.ev-type { color: var(--text); display: inline-block; }
.ev-type::first-letter { text-transform: uppercase; }
.ev-date { color: var(--muted); font-size: .78rem; }
.ev-detalle { flex-basis: 100%; color: var(--muted); font-size: .78rem; margin-top: 2px; overflow-wrap: anywhere; }
.ev-empty { color: var(--muted); font-size: .85rem; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.kb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.kb-modal-overlay[hidden] { display: none !important; }
.kb-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.kb-modal h3 { margin: 0; font-size: 1.1rem; color: var(--cyan); }
.kb-modal label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .8rem;
    color: var(--muted);
}
.kb-modal input, .kb-modal select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    padding: .55rem .75rem;
    transition: border-color .15s;
}
.kb-modal input:focus, .kb-modal select:focus { outline: none; border-color: var(--cyan); }
.kb-modal-btns { display: flex; gap: .75rem; margin-top: .25rem; }

/* ── Password toggle ─────────────────────────────────────────────────────── */
.password-wrap { position: relative; display: flex; align-items: center; margin-top: .3rem; }
.password-wrap input { flex: 1; padding-right: 2.5rem !important; }
.password-toggle {
    position: absolute;
    right: .5rem;
    background: none !important;
    border: none !important;
    cursor: pointer;
    color: var(--muted);
    padding: .25rem !important;
    display: flex;
    align-items: center;
    width: auto !important;
    margin-top: 0 !important;
    box-shadow: none !important;
    filter: none !important;
}
.password-toggle:hover { color: var(--cyan); box-shadow: none !important; filter: none !important; }

/* ── Auth extras ─────────────────────────────────────────────────────────── */
.link-btn {
    display: block;
    width: 100%;
    background: none !important;
    border: none !important;
    color: #9baab8 !important;
    font-size: .8rem;
    cursor: pointer;
    padding: .35rem 0 !important;
    text-align: center;
    margin-top: .15rem !important;
    transition: color .15s;
    box-shadow: none !important;
    filter: none !important;
}
.link-btn:hover { color: var(--cyan) !important; box-shadow: none !important; filter: none !important; }

.success { color: var(--success); min-height: 1.2em; margin: .4rem 0 0; font-size: .9rem; }

.btn-danger-full {
    width: 100%;
    margin-top: 1rem;
    padding: .7rem;
    background: transparent;
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-display);
    cursor: pointer;
    transition: background .15s;
}
.btn-danger-full:hover { background: rgba(255,92,92,.1); }

/* ── Recovery codes view ─────────────────────────────────────────────────── */
.recovery-card { max-width: 420px !important; }
.recovery-codes-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
    margin: 1rem 0;
}
.recovery-code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .45rem .6rem;
    font-family: var(--font-display);
    font-size: .9rem;
    color: var(--cyan);
    text-align: center;
    letter-spacing: .04em;
}
.recovery-codes-actions { display: flex; gap: .5rem; margin-bottom: .75rem; }
.recovery-codes-actions .btn-ghost { flex: 1; }
.recovery-confirm {
    display: flex !important;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    color: var(--muted);
    margin: .5rem 0 .75rem;
    cursor: pointer;
    width: auto !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin-top: .5rem !important;
    box-shadow: none !important;
    filter: none !important;
}

/* ── 2FA Banner ──────────────────────────────────────────────────────────── */
.twofa-banner {
    background: color-mix(in srgb, var(--cyan) 6%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--cyan) 18%, transparent);
    padding: .6rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: .85rem;
    flex-shrink: 0;
}
.twofa-banner.hidden { display: none; }
.twofa-banner-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.twofa-banner-btn {
    padding: .28rem .7rem;
    background: var(--cyan);
    color: var(--bg);
    border: 0;
    border-radius: var(--radius);
    font-size: .8rem;
    font-weight: 600;
    font-family: var(--font-display);
    cursor: pointer;
}
.twofa-banner-link {
    background: none;
    border: none;
    color: var(--muted);
    font-size: .78rem;
    cursor: pointer;
    padding: .25rem;
}
.twofa-banner-link:hover { color: var(--text); }
.twofa-banner-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    padding: .2rem .4rem;
    line-height: 1;
}
.twofa-banner-close:hover { color: var(--text); }

/* ── App layout (with banner) ────────────────────────────────────────────── */
#appView { display: flex; flex-direction: column; min-height: 100vh; }
.app-layout { display: flex; flex: 1; min-height: 0; }
/* El menú se queda quieto mientras baja el contenido: en secciones largas (KPIs, Avisos, una
   pizarra con muchos interesados) se iba hacia arriba con la página, y con él las secciones,
   "Cuenta" y "Cerrar sesión". Si no cabe en alto, hace scroll él solo. En móvil es la
   cabecera fija de abajo (media query de 760px), que anula la altura. */
.app-layout .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0; align-self: flex-start;
    height: 100vh; overflow-y: auto;
}
.app-layout .content { flex: 1; padding: 2.5rem; overflow-y: auto; }

/* ── Account button (sidebar) ────────────────────────────────────────────── */
.account-btn {
    padding: .55rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: inherit;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    text-align: left;
    margin-top: auto;
    margin-bottom: .4rem;
}
.account-btn:hover { color: var(--text); border-color: var(--muted); }

/* ── Account modal ───────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.modal-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 0; }
.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: .2rem .4rem;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-sub { font-size: .85rem; color: var(--muted); margin: 0 0 .75rem; }
.modal-label {
    display: block;
    font-size: .85rem;
    color: var(--muted);
    margin: .75rem 0 .25rem;
}
.modal-label input[type="email"],
.modal-label input[type="text"],
.modal-label input[type="password"] {
    width: 100%;
    padding: .55rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    margin-top: .25rem;
    transition: border-color .15s;
    display: block;
}
.modal-label input:focus { outline: none; border-color: var(--cyan); }
.modal-2fa-input {
    width: 100%;
    padding: .55rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    margin-top: .75rem;
    transition: border-color .15s;
}
.modal-2fa-input:focus { outline: none; border-color: var(--cyan); }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.account-email-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem .75rem;
}
.account-email { flex: 1; font-size: .9rem; color: var(--text); word-break: break-all; }
.btn-test-email {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: .78rem;
    cursor: pointer;
    padding: .3rem .6rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color .15s, border-color .15s;
}
.btn-test-email:hover { color: var(--text); border-color: var(--muted); }
.btn-test-email:disabled { opacity: .5; cursor: default; }
.account-actions { display: flex; flex-direction: column; gap: .4rem; }
.btn-account-action {
    width: 100%;
    text-align: left;
    padding: .65rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn-account-action:hover { background: var(--surface2); border-color: var(--cyan); }

/* ── 2FA setup (in modal) ────────────────────────────────────────────────── */
.twofa-qr { text-align: center; margin: 1rem 0; }
.twofa-qr img { width: 180px; height: 180px; border-radius: var(--radius); background: #fff; padding: .4rem; }
.twofa-secret { font-size: .82rem; color: var(--muted); text-align: center; margin: .5rem 0 1rem; }
.twofa-secret code { color: var(--cyan); font-size: .82rem; display: block; margin-top: .3rem; word-break: break-all; }
.twofa-trust-row {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}
.toast {
    padding: .65rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s, transform .25s;
    pointer-events: auto;
    max-width: 280px;
}
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast.toast-success { border-color: var(--success); color: var(--success); }
.toast.toast-error { border-color: var(--error); color: var(--error); }

/* ── Panel Llamadas (agente de voz) ──────────────────────────────────────────
   Reutiliza la estructura de Agenda (.ag-up-*, .ag-detail-*): el panel lateral es
   el mismo patrón que ya comparten leads y citas. Aquí solo lo específico de voz. */
.ll-tag {
    font-size: .7rem; font-weight: 600; padding: .15rem .5rem; border-radius: 6px;
    white-space: nowrap; border: 1px solid transparent;
}
.ll-ok   { color: var(--success); border-color: var(--success); background: rgba(76, 223, 144, .1); }
.ll-warn { color: var(--orange);  border-color: var(--orange);  background: rgba(255, 183, 125, .1); }
.ll-mute { color: var(--muted);   border-color: var(--border);  background: var(--surface2); }

.ll-transcript {
    display: flex; flex-direction: column; gap: .5rem;
    max-height: 40vh; overflow-y: auto; padding-right: .25rem;
}
.ll-turn { display: flex; flex-direction: column; gap: .15rem; font-size: .85rem; line-height: 1.45; }
.ll-turn-who { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.ll-turn-agent .ll-turn-who { color: var(--cyan); }
.ll-turn-user  .ll-turn-who { color: var(--muted); }
.ll-turn-msg {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: .45rem .7rem; white-space: pre-wrap; word-break: break-word;
}
.ll-turn-agent .ll-turn-msg { border-color: var(--cyan-dim); }

/* Asociar una cita huérfana a un lead (detalle de Agenda). */
.ag-link-lead { display: flex; flex-direction: column; gap: .4rem; }
.ag-link-lead input {
    width: 100%; background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .5rem .7rem; color: var(--text); font: inherit;
}
.ag-link-lead input:focus { outline: none; border-color: var(--cyan); }
.ag-link-results { display: flex; flex-direction: column; gap: .25rem; }
.ag-link-hit {
    text-align: left; background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .4rem .6rem; color: var(--text);
    font: inherit; font-size: .82rem; cursor: pointer;
}
.ag-link-hit:hover { border-color: var(--cyan); }

/* ── Panel Correos (campañas de email marketing) ─────────────────────────────
   Igual que Llamadas, se apoya en la estructura de Agenda (.ag-toolbar, .ag-up-*,
   .ag-detail-*, y la rejilla .cal-* compartida). Aquí solo lo propio de campañas.
   Todos los tintes se derivan con color-mix: ni un rgba a mano (ver cabecera). */
.em-tabs { display: flex; gap: .25rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; }
.em-tab {
    background: none; border: none; color: var(--muted); font: inherit; font-size: .85rem;
    padding: .35rem .9rem; border-radius: 6px; cursor: pointer;
}
.em-tab:hover { color: var(--text); }
.em-tab.active { background: var(--cyan-dim); color: var(--cyan); font-weight: 600; }

.em-calnav { margin-bottom: 1rem; flex-wrap: wrap; }
.em-calhint { font-size: .8rem; }

.em-tag {
    font-size: .7rem; font-weight: 600; padding: .15rem .5rem; border-radius: 6px;
    white-space: nowrap; border: 1px solid transparent;
}
.em-ok   { color: var(--success); border-color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); }
.em-warn { color: var(--orange);  border-color: var(--orange);  background: color-mix(in srgb, var(--orange) 10%, transparent); }
.em-mute { color: var(--muted);   border-color: var(--border);  background: var(--surface2); }
/* La cuarta de la familia, añadida con el calendario editorial (Fase 5): 'fallido' y
   'canal desconectado' necesitan rojo y hasta entonces ninguna vista lo pedia. */
.em-err  { color: var(--error);   border-color: var(--error);   background: color-mix(in srgb, var(--error) 10%, transparent); }

/* Chips del calendario por estado. Los que no aparecen (draft, scheduled) se quedan con el
   aspecto por defecto de .cal-chip, que es justamente "pendiente". */
.em-chip-sending { background: color-mix(in srgb, var(--orange) 18%, transparent); }
.em-chip-sending .cal-chip-time { color: var(--orange); }
.em-chip-sent { background: color-mix(in srgb, var(--success) 15%, transparent); }
.em-chip-sent .cal-chip-time { color: var(--success); }
.em-chip-paused, .em-chip-canceled { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); }
.em-chip-canceled { text-decoration: line-through; }
.em-chip-paused .cal-chip-time, .em-chip-canceled .cal-chip-time { color: var(--muted); }

/* Pestañas de idioma del editor. */
.em-langtabs { display: flex; align-items: center; gap: .3rem; }
.em-langtab {
    background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
    font: inherit; font-size: .8rem; padding: .3rem .8rem; border-radius: var(--radius); cursor: pointer;
}
.em-langtab.active { border-color: var(--cyan); color: var(--cyan); font-weight: 600; }
.em-langhint { font-size: .72rem; color: var(--orange); margin-left: .4rem; }

/* Vista previa del cuerpo. El iframe va con sandbox vacío desde el marcado; aquí solo el
   fondo blanco, que es sobre lo que se leerá el correo de verdad. */
.em-preview {
    width: 100%; height: 320px; border: 1px solid var(--border); border-radius: var(--radius);
    background: #fff;
}
.em-previa-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.em-previa-asunto { font-size: .8rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-ejemplo { font-size: .85rem; }
.em-ejemplo summary { cursor: pointer; color: var(--muted); }
.em-ejemplo-fila { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.em-ejemplo-fila input {
    flex: 1 1 10rem; background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .35rem .6rem; color: var(--text); font: inherit; font-size: .85rem;
}
.em-ejemplo-fila input:focus { outline: none; border-color: var(--cyan); }

/* ── Editor de texto enriquecido (views/_richtext.js) ─────────────────────────
   Prefijo rt- neutro: la Fase 6b lo reutiliza para las plantillas transaccionales. */
.rt { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: relative; }
.rt-bar {
    display: flex; align-items: center; gap: .2rem; flex-wrap: wrap;
    padding: .3rem; background: var(--surface2); border-bottom: 1px solid var(--border);
}
.rt-btn {
    min-width: 1.9rem; padding: .25rem .45rem; background: none; border: 1px solid transparent;
    border-radius: 5px; color: var(--text); font: inherit; font-size: .82rem; cursor: pointer;
}
.rt-btn:hover:not(:disabled) { background: var(--cyan-dim); border-color: var(--cyan); }
.rt-btn:disabled { opacity: .35; cursor: default; }
.rt-btn-activo { background: var(--cyan-dim); border-color: var(--cyan); color: var(--cyan); }
.rt-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 .25rem; }
.rt-select {
    background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
    color: var(--text); font: inherit; font-size: .78rem; padding: .2rem .35rem;
}
/* El área editable imita el correo: fondo claro y texto oscuro. Pintarla con los colores del
   panel haría que un texto en gris claro pareciera legible aquí e invisible en el correo. */
.rt-area, .rt-fuente {
    width: 100%; min-height: 220px; max-height: 45vh; overflow-y: auto;
    padding: .9rem; background: #fff; color: #222; border: none;
}
.rt-area:focus, .rt-fuente:focus { outline: none; }
.rt-area a { color: #0b57d0; }
.rt-fuente {
    display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem;
    line-height: 1.5; resize: vertical;
}
.rt-dialogo {
    position: absolute; right: .5rem; top: 2.6rem; z-index: 5; width: min(20rem, calc(100% - 1rem));
    display: flex; flex-direction: column; gap: .5rem; padding: .8rem;
    background: var(--surface); border: 1px solid var(--cyan); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.rt-dialogo[hidden] { display: none; }
.rt-dialogo-titulo { font-weight: 600; font-size: .88rem; }
.rt-campo { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--muted); }
.rt-campo input, .rt-campo select {
    background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .35rem .6rem; color: var(--text); font: inherit; font-size: .85rem;
}
.rt-campo input:focus, .rt-campo select:focus { outline: none; border-color: var(--cyan); }
.rt-dialogo-btns { display: flex; gap: .4rem; }

.em-seg { display: flex; flex-direction: column; gap: .5rem; }
.em-seg-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; font-size: .85rem; color: var(--muted); }
.em-seg-input {
    flex: 0 1 60%; background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .35rem .6rem; color: var(--text); font: inherit; font-size: .85rem;
}
.em-seg-input:focus { outline: none; border-color: var(--cyan); }
.em-seg-checks { display: flex; gap: .6rem; flex: 0 1 60%; }
.em-seg-checks label { display: flex; align-items: center; gap: .25rem; color: var(--text); }
.em-count {
    margin: .25rem 0 0; font-size: .9rem; color: var(--text);
    background: var(--cyan-dim); border-radius: var(--radius); padding: .4rem .6rem;
}

.em-sends { display: flex; flex-direction: column; gap: .25rem; max-height: 30vh; overflow-y: auto; }
.em-send { display: flex; align-items: center; gap: .5rem; font-size: .8rem; }
.em-send-quien { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-send-estado { font-size: .68rem; font-weight: 600; color: var(--muted); }
.em-send-sent { color: var(--success); }
.em-send-failed { color: var(--error); }
.em-send-baja { font-size: .68rem; color: var(--orange); }

/* ── Panel Dashboard (views/dashboard.js) ────────────────────────────────────
   Sin biblioteca de gráficos: las formas son SVG dibujado a mano (el porqué, en la cabecera
   de views/dashboard.js). Los colores salen de las variables del tema, así que un fork con su
   BRAND_COLOR_* repinta las gráficas sin tocar una línea de aquí.                          */
.dsh-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dsh-controls { display: flex; align-items: center; gap: .35rem; }
.dsh-range, .dsh-refresh {
    background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .3rem .6rem; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer;
}
.dsh-range:hover, .dsh-refresh:hover { color: var(--text); border-color: var(--cyan); }
.dsh-range.active { color: var(--text); border-color: var(--cyan); background: var(--cyan-dim); }

.dsh-block { margin-top: 1.25rem; }
.dsh-block h3 { margin: 0 0 .6rem; font-size: .95rem; }
.dsh-block h4 { margin: 1rem 0 .5rem; font-size: .82rem; color: var(--muted); font-weight: 600; }
/* Un bloque sin fuente no es un error: se atenúa, no se pinta en rojo. */
.dsh-off { opacity: .65; }

.dsh-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.dsh-card {
    display: flex; flex-direction: column; gap: .15rem;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .7rem .8rem;
}
.dsh-card-t { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dsh-card-v { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.1; }
.dsh-card-x { font-size: .72rem; color: var(--muted); }
.dsh-up { color: var(--success); } .dsh-down { color: var(--error); } .dsh-flat { color: var(--muted); }

/* La línea estira con el contenedor (preserveAspectRatio="none"), así que el trazo se
   deformaría: vector-effect lo mantiene de grosor constante. */
/* El tooltip se posiciona dentro de este contenedor, por eso es `relative`. */
.dsh-line-wrap { position: relative; }
.dsh-line { width: 100%; height: 160px; display: block; }
/* Bandas sensibles al raton: invisibles pero capturan el puntero. `fill:transparent` y NO
   `fill:none` — con `none` el SVG no genera eventos y el tooltip no saltaria nunca. */
.dsh-hit { fill: transparent; cursor: crosshair; }
.dsh-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.dsh-tip {
    position: absolute; bottom: calc(100% - 150px); transform: translateX(-50%);
    display: flex; flex-direction: column; gap: .1rem;
    background: var(--bg); border: 1px solid var(--cyan); border-radius: var(--radius);
    padding: .45rem .6rem; font-size: .78rem; white-space: nowrap;
    pointer-events: none; z-index: 5; box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
/* `capitalize` pone mayuscula en CADA palabra y dejaba "Sabado, 8 De Agosto". Intl da el dia
   en minusculas, asi que solo hay que levantar la primera letra. */
.dsh-tip strong { font-size: .8rem; }
.dsh-tip strong::first-letter { text-transform: uppercase; }
.dsh-tip span { color: var(--cyan); }
.dsh-tip em { color: var(--muted); font-style: normal; font-size: .74rem; }
.dsh-stroke { fill: none; stroke: var(--cyan); stroke-width: 2; }
.dsh-area { fill: var(--cyan-dim); stroke: none; }
/* Los puntos son <i> y no <circle>: el SVG va estirado (preserveAspectRatio="none") y ahi un
   circulo se pinta como un ovalo. Fuera del SVG, redondos a cualquier ancho.
   `pointer-events:none` para que no roben el raton a las bandas que hay debajo. */
.dsh-dot {
    position: absolute; width: 7px; height: 7px; margin: 0 0 -3.5px -3.5px;
    border-radius: 50%; background: var(--cyan); border: 1px solid var(--surface);
    pointer-events: none; transition: width .1s, height .1s, background .1s;
}
.dsh-dot.activo {
    width: 11px; height: 11px; margin: 0 0 -5.5px -5.5px; background: var(--orange);
}
.dsh-axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: .2rem; }

.dsh-bars { display: flex; flex-direction: column; gap: .3rem; }
.dsh-bar-row { display: grid; grid-template-columns: minmax(90px, 22%) 1fr auto; align-items: center; gap: .6rem; font-size: .82rem; }
.dsh-bar-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsh-bar-track { background: var(--surface2); border-radius: 3px; height: 14px; overflow: hidden; }
.dsh-bar-fill { display: block; height: 100%; background: var(--cyan); border-radius: 3px; }
.dsh-bar-fill.dsh-ok { background: var(--success); }
.dsh-bar-fill.dsh-ko { background: var(--error); }
.dsh-bar-val { font-variant-numeric: tabular-nums; }
.dsh-bar-val em { color: var(--muted); font-style: normal; font-size: .74rem; margin-left: .3rem; }

.dsh-nota { margin: .6rem 0 0; font-size: .76rem; color: var(--muted); line-height: 1.45; }

/* ── Instagram: captación por comentarios (views/social.js) ────────────────────
   Casi todo se reutiliza: .ag-toolbar, .em-tabs, .ag-up-item, .ag-detail-overlay,
   .em-tag/.em-ok/.em-mute y las .dsh-card de la cola. Aquí solo lo que no existía.
   Los colores se DERIVAN con color-mix, como el resto de la hoja: un rgba() escrito a
   mano se queda con el acento del fabricante el día que un cliente cambie el suyo. */

/* Falta un .em-* rojo: los estados de campaña no tienen ninguno porque un envío fallido
   allí es una fila, no una etiqueta. Aquí sí, y sigue el mismo patrón que .em-ok. */
.sd-err { color: var(--error); border-color: var(--error); background: color-mix(in srgb, var(--error) 10%, transparent); }

/* Bloque contratado y sin credenciales. Va en gris (hereda .dsh-off) porque no es un
   error: es un paso del alta que el cliente todavía no ha dado. */
.sd-pendiente {
    background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .7rem .9rem; margin-bottom: 1rem; font-size: .85rem; line-height: 1.5;
}
.sd-pendiente code { font-size: .78rem; color: var(--text); }

/* Palabras clave de una automatización. */
.sd-kw {
    display: inline-block; font-size: .72rem; padding: .1rem .45rem; margin: .1rem .25rem .1rem 0;
    border-radius: 6px; background: var(--cyan-dim); color: var(--cyan); font-weight: 600;
}

/* Presupuesto de la hora. Se llena con lo GASTADO, no con lo que queda: la barra a tope
   significa "no cabe nada más", que es la lectura que se busca de un vistazo. */
.sd-presupuesto { margin-bottom: 1rem; }
.sd-barra { background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; height: 10px; overflow: hidden; }
.sd-barra-fill { height: 100%; background: var(--cyan); }

.sd-items { display: flex; flex-direction: column; gap: .5rem; }
.sd-item {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
    padding: .55rem .85rem;
}
.sd-item-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .78rem; margin-bottom: .2rem; }
.sd-item-quien { font-weight: 600; }
/* El motivo del descarte o del fallo. Es lo que se viene a leer cuando algo no salió. */
.sd-motivo { color: var(--error); }

/* ── Calendario editorial (Fase 5) ────────────────────────────────────────────
   Todo derivado con color-mix, nunca rgba a mano: los dos colores de marca los
   sobrescribe admin/brand.js y un rgba fijo dejaría halos de otra empresa. */
.cal-aviso { margin: 0 0 .75rem; }

/* Vista semanal: siete columnas altas. No trunca, así que la celda crece y hace
   scroll en vez de esconder un post del día que se está mirando. */
.cal-grid-sem { grid-template-columns: repeat(7, 1fr); }
.cal-cell-sem { min-height: 320px; height: auto; overflow-y: auto; }
.cal-sem-num { color: var(--text); font-weight: 700; }

/* Estados del chip. Reusan .cal-chip y solo cambian el color, igual que hacen
   los .em-chip-* de las campañas. */
.cal-chip-draft { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); }
.cal-chip-pending_approval { background: color-mix(in srgb, var(--orange) 18%, transparent); }
.cal-chip-pending_approval .cal-chip-time { color: var(--orange); }
.cal-chip-scheduled { background: color-mix(in srgb, var(--cyan) 18%, transparent); }
.cal-chip-published { background: color-mix(in srgb, var(--success) 15%, transparent); }
.cal-chip-published .cal-chip-time { color: var(--success); }
.cal-chip-failed { background: color-mix(in srgb, var(--error) 18%, transparent); }
.cal-chip-failed .cal-chip-time { color: var(--error); }
.cal-chip-canceled { background: color-mix(in srgb, var(--muted) 16%, transparent);
                     color: var(--muted); text-decoration: line-through; }
.cal-chip-canceled .cal-chip-time { color: var(--muted); }

/* Selector de canales del editor, con sus opciones por red debajo. */
.cal-canal { border: 1px solid var(--border); border-radius: var(--radius);
             padding: .6rem .75rem; margin-bottom: .5rem; background: var(--surface2); }
.cal-canal-on { border-color: color-mix(in srgb, var(--cyan) 55%, var(--border)); }
.cal-canal-head { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.cal-ajustes { display: flex; flex-direction: column; gap: .5rem;
               margin: .6rem 0 0 1.6rem; padding-left: .75rem;
               border-left: 2px solid color-mix(in srgb, var(--cyan) 30%, transparent); }
.cal-ajuste { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }
.cal-ajuste-ayuda { margin: 0; }
.cal-error { color: var(--error); font-size: .85rem; margin: .4rem 0 0; }
.cal-canal-link { display: inline-block; margin: .45rem 0 0 1.6rem; font-size: .85rem; color: var(--cyan); }

/* Pestaña Cuentas: un bloque por proveedor, con sus cuentas conectadas debajo. */
.cal-provs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .9rem; }
.cal-prov { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .9rem;
            background: var(--surface2); display: flex; flex-direction: column; gap: .5rem; }
.cal-prov-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.cal-prov-titulo { font-weight: 700; }
.cal-prov .hint { margin: 0; overflow-wrap: anywhere; }
.cal-cuenta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem;
              border-top: 1px solid var(--border); padding-top: .5rem; }
.cal-cuenta-nombre { font-weight: 600; }
.cal-cuenta .cal-error { flex-basis: 100%; margin: 0; }

/* Media ya elegida. */
.cal-media { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.cal-media-item { position: relative; width: 72px; height: 72px; border-radius: var(--radius);
                  overflow: hidden; border: 1px solid var(--border); display: grid;
                  place-items: center; background: var(--surface2); }
.cal-media-item img { width: 100%; height: 100%; object-fit: cover; }
.cal-media-x { position: absolute; top: 2px; right: 2px; border: none; cursor: pointer;
               border-radius: 50%; width: 18px; height: 18px; line-height: 1;
               background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--text); }
.cal-borrar { color: var(--error); margin-left: auto; }
.cal-picker { max-width: 640px; width: 92vw; }
.cal-subir { display: inline-block; margin-bottom: .75rem; cursor: pointer; }
.cal-pickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
                gap: .6rem; max-height: 55vh; overflow-y: auto; }
.cal-pick { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface2);
            padding: .3rem; cursor: pointer; display: flex; flex-direction: column; gap: .25rem;
            align-items: center; color: var(--muted); font-size: .68rem; overflow: hidden; }
.cal-pick:hover { border-color: var(--cyan); background: var(--cyan-dim); }
.cal-pick img { width: 100%; height: 72px; object-fit: cover; border-radius: 4px; }
.cal-pick span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Hermana de .ag-month pero SIN capitalize: aquí el texto es un rango de fechas
   ("24 – 30 de agosto de 2026") y capitalizarlo daría "24 – 30 De Agosto De 2026". */
.cal-rango { font-weight: 600; min-width: 16rem; text-align: center; }

/* ── Servicio suspendido (SERVICE_STATUS=suspended) ─────────────────────── */
.banner-suspension {
    background: color-mix(in srgb, var(--error) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
    color: var(--text);
    padding: .6rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .92rem;
}
.nav-item.nav-apagado { opacity: .55; }
.aviso-suspension { max-width: 560px; }
.aviso-suspension h2 { color: var(--error); }

/* ── Documentos ─────────────────────────────────────────────────────────────
   Un botón por carpeta compartida. Los colores salen de las variables de la instancia: nada de
   aquí es de una marca concreta. */
.doc-head { margin-bottom: 1.25rem; }
.doc-head h2 { margin: 0 0 .25rem; }
.doc-head p { margin: 0; font-size: .9rem; }
.doc-aviso {
    margin: 0 0 1rem; padding: .6rem .8rem; border-radius: var(--radius);
    border: 1px solid var(--error); color: var(--error); font-size: .85rem;
}
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.doc-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .5rem;
}
.doc-card h3 { margin: 0; font-size: 1rem; font-family: var(--font-display); }
.doc-card p { margin: 0; font-size: .85rem; flex: 1; }
.doc-acciones { display: flex; align-items: center; gap: .5rem; margin-top: .4rem; }
.doc-abrir { text-decoration: none; display: inline-block; }

/* ── Bandeja de WhatsApp (views/inbox.js) ────────────────────────────────────
   Solo tokens del panel: el acento es el --cyan de la marca del cliente, no el verde de
   WhatsApp. Las burbujas salientes llevan ese acento para que se lea de un vistazo quién habla. */
.wa-toolbar-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.wa-franquicia {
    font-size: .78rem; color: var(--muted); background: var(--surface2);
    border: 1px solid var(--border); border-radius: 999px; padding: .25rem .7rem;
}
.wa-franquicia-alerta { color: var(--orange); border-color: var(--orange); }
.wa-filtro { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wa-filtro button {
    background: none; border: 0; color: var(--muted); padding: .35rem .8rem; cursor: pointer; font: inherit; font-size: .85rem;
}
.wa-filtro button.active { background: var(--cyan-dim); color: var(--text); }

.wa-layout {
    display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 1rem;
    height: calc(100vh - 11rem); min-height: 420px;
}
.wa-lista {
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    overflow-y: auto; display: flex; flex-direction: column;
}
.wa-lista-vacia { padding: 1rem; font-size: .88rem; }
.wa-conv {
    display: flex; flex-direction: column; gap: .2rem; text-align: left; width: 100%;
    background: none; border: 0; border-bottom: 1px solid var(--border); color: var(--text);
    padding: .7rem .85rem; cursor: pointer; font: inherit;
}
.wa-conv:hover { background: var(--surface2); }
.wa-conv.active { background: var(--cyan-dim); }
.wa-conv-top, .wa-conv-bottom { display: flex; justify-content: space-between; align-items: center; gap: .5rem; min-width: 0; }
.wa-conv-nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-conv-hora { font-size: .72rem; color: var(--muted); flex-shrink: 0; }
.wa-conv-resumen { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-conv-meta { display: flex; align-items: center; gap: .35rem; }
.wa-badge {
    background: var(--cyan); color: var(--bg); font-size: .7rem; font-weight: 700;
    border-radius: 999px; min-width: 1.3rem; padding: 0 .35rem; text-align: center; flex-shrink: 0;
}
.wa-chip { font-size: .66rem; border: 1px solid var(--orange); color: var(--orange); border-radius: 6px; padding: 0 .3rem; }
.wa-chip-mute { border-color: var(--border); color: var(--muted); }
/* Estado del buzón de correo en la cabecera de la bandeja; en alerta si falta algo o no se lee. */
.wa-estado-correo { font-size: .78rem; }
.wa-estado-correo-alerta { color: var(--orange); }
.wa-filtro-canal { margin-right: .5rem; }
/* Canal de la conversación (WhatsApp o correo): el icono va delante del nombre. */
.wa-canal { flex-shrink: 0; margin-right: .25rem; font-size: .85em; }
/* Entrante que el agente NO contesta (ADR-E7 del ERS de correo), con su motivo. */
.wa-sin-turno { font-size: .7rem; color: var(--muted); margin-top: .25rem; }
.wa-dot { width: .5rem; height: .5rem; border-radius: 50%; display: inline-block; }
.wa-ven-abierta { background: var(--success); }
.wa-ven-poca { background: var(--orange); }
.wa-ven-cerrada { background: var(--muted); }
.wa-ven-abierta-txt { color: var(--success); }
.wa-ven-poca-txt { color: var(--orange); }
.wa-ven-cerrada-txt { color: var(--muted); }

.wa-hilo {
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.wa-vacio { margin: auto; padding: 2rem; text-align: center; }
.wa-cab {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: .75rem 1rem; border-bottom: 1px solid var(--border);
}
.wa-cab-info { min-width: 0; }
.wa-cab-nombre { font-weight: 600; font-size: 1.05rem; }
.wa-cab-sub { font-size: .78rem; color: var(--muted); }
.wa-cab-acciones { display: flex; gap: .4rem; flex-wrap: wrap; }

.wa-mensajes { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .35rem; }
.wa-dia {
    align-self: center; font-size: .72rem; color: var(--muted); background: var(--surface2);
    border-radius: 999px; padding: .15rem .7rem; margin: .6rem 0 .3rem;
}
.wa-msg {
    max-width: min(75%, 520px); padding: .45rem .7rem .3rem; border-radius: 12px;
    display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; line-height: 1.4;
}
.wa-in { align-self: flex-start; background: var(--surface2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.wa-out {
    align-self: flex-end; background: color-mix(in srgb, var(--cyan) 22%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--cyan) 35%, transparent); border-bottom-right-radius: 4px;
}
/* Lo que escribió el agente, más tenue y con borde discontinuo: de un vistazo se separa de lo
   que escribió una persona. */
.wa-out.wa-por-bot {
    background: color-mix(in srgb, var(--cyan) 9%, var(--surface));
    border-style: dashed;
}
.wa-autor.wa-autor-persona { color: var(--text); }
.wa-autor.wa-autor-sistema { color: var(--muted); }
.wa-nota {
    align-self: center; max-width: 85%; margin: 6px 0; padding: 4px 12px; border-radius: 999px;
    border: 1px dashed var(--border); color: var(--muted); font-size: .78rem; text-align: center;
}
.wa-texto { white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-transcribir {
    display: block; margin-top: 4px; padding: 2px 10px; border-radius: 999px; font-size: .75rem;
    background: transparent; color: var(--muted); border: 1px solid var(--border); cursor: pointer;
}
.wa-transcribir:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.wa-transcribir:disabled { cursor: progress; opacity: .7; }
.wa-transcripcion { font-style: italic; font-size: .85rem; color: var(--muted, inherit); margin-top: 4px; }
.wa-autor { font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--cyan); }
.wa-plantilla { font-size: .85rem; }
.wa-reaccion { font-size: 1.4rem; }
.wa-img { max-width: 260px; max-height: 320px; border-radius: 8px; display: block; }
.wa-msg audio { width: 260px; max-width: 100%; }
.wa-doc { color: var(--cyan); }
.wa-adjunto { font-size: .8rem; font-style: italic; }
.wa-media-pie { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .7rem; color: var(--muted); }
.wa-pin {
    background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--muted);
    font: inherit; font-size: .68rem; padding: .05rem .4rem; cursor: pointer; white-space: nowrap;
}
.wa-pin:hover { color: var(--text); border-color: var(--muted); }
.wa-pin.activo { color: var(--orange); border-color: var(--orange); }
.wa-error { font-size: .75rem; color: var(--error); }
.wa-pie { align-self: flex-end; font-size: .68rem; color: var(--muted); display: flex; gap: .3rem; }
.wa-tick-read { color: var(--cyan); font-weight: 700; }
.wa-tick-failed { color: var(--error); }

.wa-compositor {
    display: flex; gap: .5rem; align-items: flex-end; padding: .75rem 1rem; border-top: 1px solid var(--border);
}
.wa-compositor textarea, .wa-compositor select {
    flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font: inherit; font-size: .9rem; padding: .55rem .75rem; resize: none; max-height: 10rem;
}
.wa-compositor textarea:focus, .wa-compositor select:focus { outline: none; border-color: var(--cyan); }
.wa-compositor-cerrada { flex-direction: column; align-items: stretch; }
.wa-compositor-aviso { font-size: .8rem; color: var(--orange); }
.wa-compositor-fila { display: flex; gap: .5rem; align-items: center; }

/* Vista Archivos (views/inbox-archivos.js). `display:grid` de .wa-layout ganaría al atributo
   hidden sin esta regla, y las dos vistas se verían a la vez. */
.wa-layout[hidden], .wa-archivos[hidden] { display: none; }
.wa-arch-barra { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.wa-arch-uso { font-size: .88rem; }
.wa-arch-filtros { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.wa-arch-filtros select {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font: inherit; font-size: .85rem; padding: .35rem .6rem;
}
.wa-arch-rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.wa-arch {
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    display: flex; flex-direction: column; overflow: hidden;
}
.wa-arch-sin { opacity: .65; }
.wa-arch-thumb { display: block; height: 150px; background: var(--bg); }
.wa-arch-thumb img, .wa-arch-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.wa-arch-icono {
    height: 90px; display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem; background: var(--surface2); text-decoration: none;
}
.wa-arch audio { width: 100%; }
.wa-arch-info { padding: .5rem .7rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.wa-arch-titulo { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-arch-meta { font-size: .72rem; color: var(--muted); }
.wa-arch-acciones { display: flex; gap: .35rem; align-items: center; padding: 0 .7rem .6rem; }
.wa-arch-acciones .btn-ghost { padding: .2rem .5rem; }
.wa-arch-borrar:hover { color: var(--error); border-color: var(--error); }
.wa-arch-vacio { padding: 1rem 0; }

@media (max-width: 900px) {
    .wa-layout { grid-template-columns: 1fr; height: auto; }
    .wa-lista { max-height: 40vh; }
    .wa-hilo { min-height: 60vh; }
}

/* ── Avisos (views/avisos.js) ─────────────────────────────────────────────── */
.nav-badge {
    display: inline-block; min-width: 1.25rem; padding: 0 .35rem; margin-left: .35rem;
    border-radius: 999px; background: var(--cyan); color: var(--bg);
    font-size: .72rem; font-weight: 600; line-height: 1.25rem; text-align: center;
}
.nav-badge[hidden] { display: none; }
.av-item { cursor: pointer; }
.av-item.av-nuevo { border-left: 2px solid var(--cyan); background: var(--cyan-dim); }
.av-icono { font-size: 1.15rem; width: 1.8rem; text-align: center; flex: none; }
.av-cuando { white-space: nowrap; flex: none; }
.av-ajustes { margin-top: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.av-ajustes summary { cursor: pointer; font-weight: 600; }
.av-ajustes[open] summary { margin-bottom: .75rem; }
.av-botones { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.av-dispositivos { list-style: none; margin: .5rem 0; padding: 0; font-size: .88rem; }
.av-dispositivos li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.av-dispositivos .btn-ghost { padding: .2rem .6rem; font-size: .8rem; flex: none; }
.av-tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.av-tabla th, .av-tabla td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); text-align: left; }
.av-tabla th:not(:first-child), .av-tabla td:not(:first-child) { text-align: center; width: 6.5rem; }
.av-silencio { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .9rem; font-size: .9rem; }
.av-silencio input[type="time"] {
    background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
    color: inherit; padding: .2rem .35rem; font-family: inherit;
}

/* ── El panel en un móvil ─────────────────────────────────────────────────────
   Hasta el 2026-10-01 el panel no tenía versión estrecha: la barra lateral conservaba su ancho
   y aplastaba el contenido. No importaba mientras se usaba en un ordenador; instalado como app
   en un teléfono (avisos + notificaciones) es lo primero que se ve.
   Aquí va SOLO el armazón: la barra pasa arriba, con la marca y la cuenta en una fila y las
   secciones en otra que se desliza de lado. Cada vista (Kanban, Agenda…) sigue con su propio
   diseño, que en parte está pensado para pantalla ancha: eso es trabajo aparte. */
@media (max-width: 760px) {
    .app-layout { flex-direction: column; }
    .app-layout .sidebar {
        width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center;
        padding: .5rem .75rem 0; gap: .4rem;
        border-right: 0; border-bottom: 1px solid var(--border);
        position: sticky; top: 0; z-index: 50;
        height: auto; overflow: visible;   /* anula el alto de pantalla del menú de escritorio */
    }
    .sidebar .brand { margin: 0; padding: 0; font-size: 1.05rem; flex: 1; min-width: 0; }
    .sidebar .account-btn, .sidebar .logout { margin: 0; padding: .35rem .6rem; font-size: .8rem; }
    .sidebar nav {
        order: 3; flex: 0 0 100%; display: flex; gap: .15rem;
        overflow-x: auto; white-space: nowrap; scrollbar-width: none;
        margin: 0 -.75rem; padding: 0 .5rem;
    }
    .sidebar nav::-webkit-scrollbar { display: none; }
    .sidebar .nav-item {
        display: inline-block; width: auto; flex: none; padding: .55rem .7rem;
        border-left: 0; border-bottom: 2px solid transparent; border-radius: 0;
    }
    .sidebar .nav-item.active { border-left: 0; border-bottom-color: var(--cyan); }
    .app-layout .content { padding: 1rem; }
    .panel h2 { font-size: 1.3rem; }
    .twofa-banner { flex-wrap: wrap; }

    /* Avisos: el texto manda; la fecha baja a su propia línea en vez de comerle el ancho. */
    .av-item { flex-wrap: wrap; gap: .5rem .75rem; align-items: flex-start; }
    .av-item .ag-up-main { flex: 1 1 0; min-width: 0; }
    .av-item .av-cuando { flex: 0 0 100%; padding-left: 2.55rem; margin-top: -.25rem; }
    .av-botones > button { flex: 1 1 100%; }
    .av-tabla th:not(:first-child), .av-tabla td:not(:first-child) { width: 4.2rem; font-size: .8rem; }
}

/* ── Llamar a un lead (views/llamar.js) ───────────────────────────────────── */
.ll-call-grupo { display: inline-flex; align-items: center; gap: .35rem; }
.ll-call-modo {
    background: var(--bg); color: inherit; border: 1px solid var(--border);
    border-radius: 8px; padding: .4rem .5rem; font-size: .8rem; max-width: 11rem;
}
.ll-call-barra {
    position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); z-index: 1200;
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    max-width: min(30rem, calc(100vw - 2rem));
    background: var(--surface2); border: 1px solid var(--cyan); border-radius: 12px;
    padding: .7rem .9rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); font-size: .9rem;
}
.ll-call-texto { flex: 1 1 12rem; }
@media (max-width: 760px) {
    .ll-call-barra { left: 1rem; }
}

/* ── Recorrido de bienvenida (views/recorrido.js) ─────────────────────────────
   La tarjeta la coloca el JS junto a lo que explica (left/top), lo iluminado lo marca un
   recuadro cuya sombra enorme oscurece el resto, y el botón del menú de la sección se resalta.
   El recuadro no captura clics: lo iluminado se puede usar (la práctica de la pizarra se
   arrastra a través de él). Por encima de la ficha (100) y de los modales (200). */
.recorrido-luz {
    position: fixed; z-index: 990; pointer-events: none;
    border: 2px solid var(--orange); border-radius: var(--radius);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
    transition: top .2s, left .2s, width .2s, height .2s;
}
.recorrido-luz[hidden] { display: none; }
.recorrido-prueba {
    margin-bottom: .6rem; padding: .75rem .85rem; cursor: grab;
    background: var(--surface2); border: 2px dashed var(--orange); border-radius: var(--radius);
}
.recorrido-prueba.dragging { opacity: .5; }
.recorrido-op-prueba { margin: 0; cursor: default; }
.recorrido-prueba-nombre { font-weight: 600; }
.recorrido-prueba-sub { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.recorrido .recorrido-hecho { color: var(--success); font-weight: 600; margin-top: -.4rem; }
.recorrido-btn { margin-top: auto; }
.recorrido-btn + .account-btn { margin-top: 0; }
.nav-item.recorrido-foco {
    outline: 2px solid var(--orange);
    outline-offset: 2px;
    color: var(--text);
}
.recorrido {
    position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 1000;   /* hasta que el JS la coloca */
    transition: left .2s, top .2s;
    width: min(26rem, calc(100vw - 2rem));
    padding: 1.1rem 1.2rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--orange);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
    color: var(--text);
}
.recorrido-cabecera { display: flex; align-items: baseline; gap: .75rem; }
.recorrido-cabecera h3 { margin: 0; font-family: var(--font-display); font-size: 1.05rem; flex: 1; }
.recorrido-paso { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.recorrido p { margin: .6rem 0 1rem; line-height: 1.5; font-size: .92rem; }
.recorrido-acciones { display: flex; align-items: center; gap: .5rem; }
.recorrido-hueco { flex: 1; }
.recorrido-saltar {
    background: none; border: 0; padding: .3rem 0; cursor: pointer;
    color: var(--muted); font: inherit; font-size: .85rem; text-decoration: underline;
}
.recorrido-saltar:hover { color: var(--text); }
@media (max-width: 760px) {
    .recorrido { right: auto; bottom: auto; }
    /* En la cabecera del móvil no cabe una palabra más junto a la marca: solo el icono. */
    .recorrido-btn-texto { display: none; }
}

/* ── Cartera (views/cartera.js, bloque `cartera`) ─────────────────────────── */
.ct-pestanas, .ct-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .75rem 0; }
.ct-toolbar .muted { font-size: .8rem; flex: 1 1 18rem; }
.ct-importar { cursor: pointer; }
.ct-form { display: flex; flex-direction: column; gap: .75rem; margin: .75rem 0; }
.ct-form h3 { margin: 0; font-family: var(--font-display); font-size: 1rem; }
.ct-extras { display: flex; flex-wrap: wrap; gap: .4rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; font-size: .85rem; }
.ct-tabla th:not(:first-child), .ct-tabla td:not(:first-child) { text-align: left; width: auto; }
.ct-apagada td { opacity: .55; }
