/* LBM 17/10/2026 - 15:40 - v1.1.0
   Sistema visual del panel LBM WhatsApp Communities.
   Principios: superficies planas y regladas (sin sombras decorativas), papel cálido y tinta verde-negra,
   verde reservado a acciones principales y a lo que está "en directo/conectado", colores de estado solo
   para estados, cifras tabulares, monoespaciada únicamente para códigos. Sin fuentes externas (CSP). */

:root {
  --paper: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f2f1ec;
  --ink: #1b2a24;
  --ink-2: #3d4a45;
  --muted: #6b7772;
  --rule: #e4e3dd;
  --rule-strong: #cfd0c8;
  --primary: #116149;
  --primary-2: #0c4a38;
  --primary-soft: #e3f1ea;
  --primary-ink: #0a3d2e;
  --ok: #1b7a4b;
  --ok-soft: #e1f3e8;
  --warn: #9a6612;
  --warn-soft: #fbf0d6;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --info: #2756a3;
  --info-soft: #e4ecf9;
  --muted-soft: #ecebe6;
  --test: #6b3fa0;
  --r-lg: 12px;
  --r-md: 8px;
  --r-sm: 6px;
  --sidebar: 240px;
  --topbar: 52px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --focus: 0 0 0 3px rgba(17, 97, 73, .28);
  color-scheme: light;
}

/* Compatibilidad con nombres antiguos usados en vistas/JS */
:root { --bg: var(--paper); --panel: var(--surface); --panel-2: var(--surface-2); --text: var(--ink); --border: var(--rule); --radius: var(--r-lg); --shadow: none; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 14px/1.5 var(--font);
  background: var(--paper);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0 0 .6rem; line-height: 1.2; font-weight: 600; letter-spacing: -.012em; color: var(--ink); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--muted-soft); padding: 1px 5px; border-radius: 4px; word-break: break-all; color: var(--ink-2); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 1rem 0; }
small, .muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text-bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.grow { flex: 1; }
.gap { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

/* --- Estructura -------------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--surface); color: var(--ink);
  border-right: 1px solid var(--rule); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 18px 12px 30px; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; padding: 2px 8px 18px; letter-spacing: -.01em; line-height: 1.15; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; letter-spacing: .02em; flex: 0 0 32px; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; margin-top: 2px; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; font-size: 12px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-2);
  padding: 7px 10px 7px 12px; border-radius: var(--r-md); text-decoration: none; font-size: 13.5px; position: relative;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--primary); }
.nav .count { background: var(--primary); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; line-height: 18px; font-weight: 600; min-width: 18px; text-align: center; }
.nav .count:empty { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 0 24px; height: var(--topbar); background: rgba(247, 246, 242, .92);
  backdrop-filter: saturate(1.2) blur(6px); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.topbar .btn-danger { background: var(--surface); color: var(--bad); border-color: #e4b4b0; }
.topbar .btn-danger:hover { background: var(--bad-soft); }
.menu-toggle { display: none; background: none; border: 1px solid var(--rule-strong); border-radius: var(--r-sm); padding: 3px 9px; font-size: 17px; cursor: pointer; color: var(--ink); }
.content { padding: 24px; max-width: 1360px; width: 100%; }
.emergency-banner { background: var(--bad); color: #fff; padding: 10px 24px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.emergency-banner form { margin: 0; }
.emergency-banner .btn { background: #fff; color: var(--bad); border-color: #fff; }
.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .25rem; }
.page-head p { margin: 0; max-width: 70ch; }

/* --- Superficies ------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 18px 20px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .85rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

/* Franja de indicadores: una sola superficie reglada, no una colección de tarjetas. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 0; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.stat { padding: 14px 18px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: none; margin-bottom: -1px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; min-height: 92px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 1.7rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin-top: auto; }
.stat .value small { font-size: .95rem; font-weight: 400; }
.stat.bad .value { color: var(--bad); }
.stat.ok .value { color: var(--primary); }
.stat.warn .value { color: var(--warn); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; line-height: 19px; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--muted-soft); color: var(--muted); }
.badge-primary { background: var(--primary); color: #fff; }
.tag { display: inline-block; padding: 0 7px; border-radius: 5px; font-size: 11.5px; color: #fff; margin: 1px 2px 1px 0; }
.test-flag { background: var(--test); color: #fff; border-radius: 4px; font-size: 11px; padding: 0 6px; font-weight: 700; letter-spacing: .03em; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rule-strong); margin-right: 6px; vertical-align: 1px; }
.dot-connected { background: var(--ok); }
.dot-connecting, .dot-reconnecting, .dot-qr { background: var(--warn); }
.dot-disconnected, .dot-logged_out, .dot-restricted { background: var(--bad); }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.table th { background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td, .table tr:hover td { background: #fbfaf6; }
.card .table-wrap { border-radius: var(--r-sm); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.2; transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #8f1e18; }
.btn-warn { background: var(--warn-soft); border-color: #e4c478; color: var(--warn); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; font-weight: 500; cursor: pointer; font: inherit; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

.flash-stack { position: fixed; top: calc(var(--topbar) + 12px); right: 16px; z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.flash { padding: 10px 36px 10px 14px; border-radius: var(--r-md); margin: 0; border: 1px solid; border-left-width: 4px; background: var(--surface); box-shadow: 0 8px 24px rgba(20, 30, 25, .14); position: relative; pointer-events: auto; animation: flash-in .25s ease-out; font-size: 13.5px; }
.flash.flash-out { opacity: 0; transform: translateY(-6px); transition: opacity .3s, transform .3s; }
.flash-close { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 18px; line-height: 1; color: inherit; opacity: .6; cursor: pointer; padding: 2px 6px; }
.flash-close:hover { opacity: 1; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.flash-success { border-color: var(--ok); color: #14532d; }
.flash-error { border-color: var(--bad); color: #7f1d1d; }
.flash-warning { border-color: var(--warn); color: #6b4a0b; }
.flash-info { border-color: var(--info); color: #1e3a8a; }
.alert { padding: 10px 14px; border-radius: var(--r-md); margin-bottom: 12px; background: var(--info-soft); color: #1e3a8a; }
.alert-warn { background: var(--warn-soft); color: #6b4a0b; }
.alert-bad { background: var(--bad-soft); color: #7f1d1d; }
.alert-ok { background: var(--ok-soft); color: #14532d; }

/* --- Formularios ------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label, .label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field .help, .help { color: var(--muted); font-size: 12px; }
.field .error { color: var(--bad); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local],
input[type=date], input[type=time], input[type=search], select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid var(--rule-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); width: 100%;
}
select { padding-right: 28px; }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; }
.check input { margin-top: 3px; accent-color: var(--primary); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
fieldset { border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 12px 16px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 140px; }
.inline-fields { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-fields input[type=number] { width: 90px; }

/* --- Pestañas ----------------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 8px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; font-weight: 600; }
.tabs a.active { color: var(--primary-ink); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* --- Filtros por chips ----------------------------------------------------------------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink-2); font-weight: 500; font-size: 13px; }
.chip:hover { text-decoration: none; background: var(--surface-2); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-count { color: var(--muted); font-size: 12px; }
.chip.active .chip-count { color: rgba(255, 255, 255, .7); }
.chip-unread { background: var(--primary); color: #fff; border-radius: 99px; font-size: 11px; line-height: 17px; padding: 0 6px; font-weight: 600; }
.chip.active .chip-unread { background: #fff; color: var(--primary-ink); }

/* --- Línea temporal -------------------------------------------------------------------- */
.timeline-day { margin-bottom: 18px; }
.timeline-day h3 { text-transform: capitalize; font-size: .95rem; color: var(--muted); border-bottom: 1px dashed var(--rule); padding-bottom: 4px; }
.tl-item { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.tl-time { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.tl-time small { display: block; font-weight: 400; }
.tl-event { color: var(--muted); font-style: italic; }
.deliveries { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.delivery { border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 1px 7px; font-size: 12px; background: var(--surface-2); }
.delivery.sent { border-color: #a9dcc0; background: var(--ok-soft); }
.delivery.error, .delivery.uncertain { border-color: #efb2ad; background: var(--bad-soft); }

.progress { height: 6px; border-radius: 99px; background: var(--muted-soft); overflow: hidden; min-width: 80px; margin-top: 4px; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.warn > span { background: var(--warn); }
.progress.bad > span { background: var(--bad); }

/* --- Editor de automatismos ------------------------------------------------------- */
.editor { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.blocks { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }
.block { background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--primary); border-radius: var(--r-md); }
.block.timing { border-left-color: var(--rule-strong); background: var(--surface-2); }
.block.disabled { opacity: .55; }
.block.dragging { opacity: .4; }
.block.drop-target { outline: 2px dashed var(--primary); outline-offset: 2px; }
.block-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.block-head .handle { cursor: grab; color: var(--muted); font-size: 18px; user-select: none; padding: 0 4px; }
.block-head .type { font-weight: 600; white-space: nowrap; }
.block-head .when { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-head .when { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.block-body { padding: 10px 12px; display: grid; gap: 8px; }
.block-body .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.block-body .row > label { font-size: 12.5px; font-weight: 600; }
.block-body input[type=number] { width: 80px; }
.block-body select, .block-body input[type=time] { width: auto; }
.add-block { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px; border: 1px dashed var(--rule-strong); border-radius: var(--r-md); }
.sticky-panel { position: sticky; top: calc(var(--topbar) + 16px); max-height: calc(100vh - var(--topbar) - 32px); overflow-y: auto; }
.tl-preview-item { padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.tl-preview-item .rendered { background: #e7f6dc; border-radius: var(--r-md); padding: 6px 9px; margin-top: 4px; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; }
.dirty-indicator { color: var(--warn); font-weight: 600; }

/* --- Placeholders ------------------------------------------------------------------- */
.ph-wrap { position: relative; }
.ph-menu { position: absolute; z-index: 30; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: 0 12px 32px rgba(27, 42, 36, .14); width: 330px; max-height: 340px; overflow-y: auto; padding: 6px; }
.ph-menu .grp { font-size: 12px; color: var(--muted); margin: 8px 6px 2px; font-weight: 600; }
.ph-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer; font: inherit; color: var(--ink); }
.ph-menu button:hover { background: var(--primary-soft); }
.ph-menu button code { float: right; background: none; color: var(--muted); font-size: 11px; }
.ph-preview { background: #e7f6dc; border: 1px solid #c9e6b4; border-radius: var(--r-md); padding: 8px 10px; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.ph-preview .errors { color: var(--bad); font-size: 12px; margin-top: 4px; }

/* --- Inbox (conversaciones) --------------------------------------------------------------- */
.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 280px; gap: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); height: calc(100vh - var(--topbar) - 48px); min-height: 480px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--rule); overflow-y: auto; min-height: 0; }
.inbox-list .search { padding: 10px; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--surface); z-index: 2; display: grid; gap: 6px; }
.conv { display: block; padding: 10px 12px; border-bottom: 1px solid var(--rule); color: var(--ink); }
.conv:hover { background: var(--surface-2); text-decoration: none; }
.conv.active { background: var(--primary-soft); }
.conv .name { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.conv .preview { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .unread { background: var(--primary); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.thread-head { padding: 10px 14px; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.thread-body { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 12px 14px; background: #ece8df; display: flex; flex-direction: column; gap: 4px; }
.bubble { max-width: 68%; padding: 5px 9px 3px; border-radius: 9px; background: var(--surface); word-break: break-word; font-size: 13.5px; line-height: 1.35; box-shadow: 0 1px 0 rgba(0,0,0,.05); }
.bubble .text { white-space: pre-wrap; }
.bubble.out { align-self: flex-end; background: #d9f3cf; }
.bubble .meta { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 1px; line-height: 1.3; }
.bubble img, .bubble video { max-width: 260px; border-radius: 6px; display: block; }
.bubble audio { max-width: 260px; }
.thread-reply { border-top: 1px solid var(--rule); padding: 10px; display: grid; gap: 6px; }
.thread-reply textarea { min-height: 60px; }
.inbox-side { border-left: 1px solid var(--rule); overflow-y: auto; padding: 12px; }
.empty { color: var(--muted); text-align: center; padding: 48px 14px; border: 1px dashed var(--rule-strong); border-radius: var(--r-lg); background: var(--surface); }

/* --- Mensajes directos en directo (LBM 17/10/2026 - 15:40 - v1.1.0) ------------------------
   La pieza con más carácter del panel: un flujo cronológico con raíl a la izquierda, indicador
   "en directo" y entrada animada de los mensajes nuevos. */
.live-indicator { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; border: 1px solid var(--rule-strong); border-radius: 99px; background: var(--surface); font-weight: 600; font-size: 13px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(27, 122, 75, .45); animation: live-pulse 1.8s ease-out infinite; }
.live-indicator[data-state="off"] .live-dot { background: var(--rule-strong); animation: none; box-shadow: none; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(27, 122, 75, .45); } 70% { box-shadow: 0 0 0 8px rgba(27, 122, 75, 0); } 100% { box-shadow: 0 0 0 0 rgba(27, 122, 75, 0); } }
.dm-filters { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.dm-filter-right { display: flex; gap: 12px; align-items: center; }
.dm-filter-right .check { white-space: nowrap; }
.dm-filter-right input[type=search] { width: 260px; }
.dm-new-banner { position: sticky; top: calc(var(--topbar) + 8px); z-index: 10; text-align: center; margin-bottom: 10px; }
.dm-feed { position: relative; display: flex; flex-direction: column; gap: 10px; padding-left: 22px; }
.dm-feed::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--rule); border-radius: 2px; }
.dm { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 14px 16px; }
.dm::before { content: ""; position: absolute; left: -20px; top: 22px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--rule-strong); }
.dm-unread { border-color: #bfdccd; }
.dm-unread::before { background: var(--primary); border-color: var(--primary); }
.dm-replied::before { background: var(--ok); border-color: var(--ok); }
.dm-flash { animation: dm-in .9s ease-out; }
.dm-focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(17, 97, 73, .18); }
@keyframes dm-in { 0% { background: var(--primary-soft); transform: translateY(-4px); opacity: .4; } 100% { background: var(--surface); transform: none; opacity: 1; } }
.dm-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.dm-main { min-width: 0; display: grid; gap: 8px; }
.dm-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.dm-who { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.dm-name { font-weight: 600; color: var(--ink); font-size: 14.5px; }
.dm-phone { color: var(--muted); font-family: var(--mono); font-size: 12.5px; }
.dm-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12.5px; }
.dm-number { color: var(--ink-2); font-weight: 500; }
.dm-body { font-size: 14.5px; line-height: 1.5; }
.dm-text { margin: 0; white-space: pre-wrap; word-break: break-word; }
.dm-media { display: block; max-width: 320px; border-radius: var(--r-md); overflow: hidden; margin-bottom: 6px; }
.dm-media img, video.dm-media { width: 100%; display: block; }
.dm-file { display: inline-block; margin-bottom: 6px; }
.dm-reply-shown { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 6px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--r-md); border-left: 3px solid var(--ok); }
.dm-reply-arrow { color: var(--ok); font-weight: 700; }
.dm-reply-text { white-space: pre-wrap; word-break: break-word; }
.dm-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dm-reply-form { display: grid; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--rule); }
.dm-reply-form textarea { min-height: 64px; }
.dm-reply-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dm-attach { cursor: pointer; }

/* --- Mensajes históricos importados (v1.2.0) ------------------------------------------------- */
.hm-list { display: flex; flex-direction: column; gap: 6px; }
.hm { padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); max-width: 80ch; }
.hm-me { background: #e7f6dc; border-color: #c9e6b4; margin-left: auto; }
.hm-system { background: var(--surface-2); color: var(--muted); font-size: 12.5px; max-width: none; text-align: center; }
.hm-head { font-size: 13px; margin-bottom: 2px; }

/* --- Varios ----------------------------------------------------------------------------- */
.qr-box { display: grid; place-items: center; min-height: 340px; background: var(--surface-2); border: 1px dashed var(--rule-strong); border-radius: var(--r-lg); }
.qr-box img { width: 300px; height: 300px; image-rendering: pixelated; }
.kv { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.media-card { border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; }
.media-card .thumb { height: 120px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 34px; }
.media-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-card .info { padding: 8px 10px; font-size: 12.5px; }
.dropzone { display: block; cursor: pointer; border: 1px dashed var(--rule-strong); border-radius: var(--r-lg); padding: 22px 20px; text-align: center; background: var(--surface-2); color: var(--ink); font-weight: 400; font-size: 14px; }
.dropzone:hover { border-color: var(--primary); }
.dropzone .dz-label { display: block; font-weight: 600; font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.dropzone .dz-label::before { content: '⬆ '; color: var(--primary); }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.pagination { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 4px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--surface); }
.pagination .current { background: var(--ink); color: #fff; border-color: var(--ink); }
.secret { font-family: var(--mono); background: var(--ink); color: #e8efe9; padding: 10px 12px; border-radius: var(--r-md); word-break: break-all; }
.diff-added { background: var(--ok-soft); }
.diff-removed { background: var(--bad-soft); text-decoration: line-through; }
.diff-changed { background: var(--warn-soft); }
details summary { cursor: pointer; font-weight: 600; }

/* Acceso: dos paneles, el verde como presentación y el formulario en papel. */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 480px); background: var(--paper); }
.login-hero { background: var(--primary-ink); color: #e8efe9; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero .brand { color: #fff; padding: 0; }
.login-hero h1 { color: #fff; font-size: clamp(1.8rem, 3.4vw, 2.8rem); max-width: 16ch; line-height: 1.1; letter-spacing: -.02em; margin: 0 0 1rem; }
.login-hero p { max-width: 44ch; color: rgba(232, 239, 233, .8); font-size: 15px; }
.login-hero .foot { font-size: 12.5px; color: rgba(232, 239, 233, .6); }
.login-card { align-self: center; justify-self: center; width: 100%; max-width: 400px; padding: 40px 36px; }
.login-card h2 { font-size: 1.35rem; margin-bottom: 1.2rem; }
.public-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--paper); }
.public-card { max-width: 460px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 32px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .dm-flash { animation: none; }
  .btn { transition: none; }
}
@media (max-width: 1200px) {
  .inbox { grid-template-columns: 290px minmax(0, 1fr); }
  .inbox-side { display: none; }
}
@media (max-width: 1000px) {
  .editor { grid-template-columns: 1fr; }
  .sticky-panel { position: static; max-height: none; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 28px 24px; }
  .login-hero .foot { display: none; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(27, 42, 36, .3); }
  .menu-toggle { display: inline-block; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox-list { max-height: 45vh; border-right: 0; border-bottom: 1px solid var(--rule); }
  .thread-body { min-height: 50vh; max-height: 60vh; }
  .bubble { max-width: 90%; }
  .dm { grid-template-columns: 1fr; padding: 12px; }
  .dm-avatar { display: none; }
  .dm-filter-right { width: 100%; }
  .dm-filter-right input[type=search] { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* LBM 19/10/2026 - 20:35 - v1.4.0: resultados de encuestas */
.poll-results { max-width: 640px; }
.poll-results td { padding: 5px 8px; border-bottom: 1px solid var(--rule); }
.poll-results td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.poll-results .bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.poll-results .bar span { display: block; height: 100%; background: var(--primary, #1f7a4d); border-radius: 5px; }
.list-plain { list-style: none; padding: 0; margin: 6px 0 0; }
.list-plain li { padding: 3px 0; }

/* LBM 22/10/2026 - 22:05 - v1.5.0: envío directo */
.target-tree { border: 1px solid var(--rule); border-radius: var(--r-md); padding: 8px 12px; margin: 8px 0; max-height: 420px; overflow: auto; }
.target-tree.disabled { opacity: .5; }
.target-cohort { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.target-cohort:last-child { border-bottom: 0; }
.target-communities { padding-left: 26px; }
.target-communities .check { margin: 2px 0; }

/* LBM 23/10/2026 - 12:10 - v1.5.1: recibos de mensajes salientes */
.receipt { font-weight: 600; white-space: nowrap; }
.receipt-sent { color: var(--muted); }
.receipt-delivered { color: var(--ink-2); }
.receipt-read { color: #1d6fd1; }
.receipt-uncertain { color: var(--warn); }
.receipt-error { color: var(--bad); }
.receipt-pending { color: var(--muted); }
.text-warn { color: var(--warn); }

/* LBM 24/10/2026 - 09:45 - v1.6.1: vista previa del icono de comunidad */
.icon-pick { display: flex; align-items: center; gap: 12px; }
.icon-pick select { flex: 1; min-width: 0; }
.icon-preview { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 1px solid var(--rule); background: var(--surface-2); flex: 0 0 72px; }

/* LBM 25/10/2026 - 10:55 - v1.7.0: selector de archivos con búsqueda (combobox) */
.mp { position: relative; display: inline-block; min-width: 260px; max-width: 100%; flex: 1; }
.mp .mp-input { width: 100%; padding-right: 30px; }
.mp.mp-selected .mp-input { font-weight: 600; }
.mp .mp-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1; }
.mp .mp-clear:hover { color: var(--ink); }
.mp-menu { position: absolute; z-index: 40; left: 0; top: 100%; margin-top: 4px; min-width: 100%; width: max(100%, 360px); max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: 0 12px 32px rgba(27, 42, 36, .14); padding: 4px; }
.mp-item { display: grid; grid-template-columns: 36px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer; font: inherit; color: var(--ink); }
.mp-item:hover, .mp-item.active { background: var(--primary-soft); }
.mp-thumb { grid-row: 1 / span 2; width: 36px; height: 36px; object-fit: cover; border-radius: 6px; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.mp-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-meta { font-size: 11.5px; color: var(--muted); }
.mp-empty { padding: 10px 8px; color: var(--muted); font-size: 13px; }
.mp-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--rule); margin-top: 4px; padding: 6px 8px 2px; font-size: 12.5px; }
.mp-foot button { border: 0; background: none; color: var(--primary); cursor: pointer; font: inherit; font-size: 12.5px; }
.block .cond-row select { max-width: 320px; }
.block .cond-row .help { margin: 0; font-size: 12px; }

/* LBM 25/10/2026 - 17:05 - v1.7.1: barra de guardado fija al pie del editor + medios en la línea temporal */
.editor-savebar { position: sticky; bottom: 12px; z-index: 15; display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(27, 42, 36, .12); }
.editor-savebar.is-dirty { border-color: var(--warn); }
.tl-media { margin-top: 6px; }
.tl-media img { max-width: 100%; max-height: 180px; border-radius: var(--r-md); display: block; border: 1px solid var(--rule); }
.tl-media video { max-width: 100%; max-height: 220px; border-radius: var(--r-md); display: block; background: #000; }
.tl-media audio { width: 100%; display: block; }
.tl-media-name { font-size: 11.5px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* LBM 29/10/2026 - 06:50 - v1.10.0: lista de casillas (otros proyectos) */
.check-list { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 6px 0; }

/* LBM 02/11/2026 - 16:05 - v1.11.0: calendario de mensajes */
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 4px 0 12px; font-size: 13px; }
.cal-legend a { color: var(--ink); text-decoration: none; }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding: 2px 0; }
.cal-day { min-height: 96px; border: 1px solid var(--rule); border-radius: var(--r-md); padding: 4px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; }
.cal-day.other { opacity: .55; }
.cal-day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day.selected { background: var(--primary-soft); }
.cal-num { font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; align-self: flex-end; padding: 0 2px; }
.cal-ev { --c: var(--primary); display: block; font-size: 11.5px; line-height: 1.25; padding: 2px 5px; border-radius: 5px; text-decoration: none; color: #fff; background: var(--c); border: 1px solid var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev .t { opacity: .85; font-variant-numeric: tabular-nums; }
.cal-ev.st-pending { background: transparent; color: var(--c); }
.cal-ev.st-bad { background: var(--c); box-shadow: inset 0 0 0 2px #d33; }
.cal-ev.st-warn { background: var(--c); opacity: .8; }
.cal-ev.st-muted { background: transparent; color: var(--muted); border-style: dashed; text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--primary); text-decoration: none; }
@media (max-width: 900px) { .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; } .cal-day { min-height: 60px; padding: 2px; } .cal-ev { font-size: 10px; padding: 1px 3px; } .cal-ev .t { display: none; } }
.stat .value .t-ok { color: var(--ok, #1a7f37); }

/* LBM 03/11/2026 - 20:45 - v2.0.0: selector de cuenta activa (superadministrador). */
.account-switch select { font-size: .85rem; padding: .3rem .5rem; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); max-width: 260px; }
.account-name { font-size: .85rem; }
