@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #0b1220;
  --muted: #667085;
  --line: #e4e7ec;
  --line-2: #f2f4f7;
  --primary: #0052ff;
  --primary-dark: #003fd6;
  --primary-soft: #eef3ff;
  --ok: #039855;
  --ok-bg: #ecfdf3;
  --warn: #dc6803;
  --warn-bg: #fffaeb;
  --bad: #d92d20;
  --bad-bg: #fef3f2;
  --ia: #7a5af8;
  --ia-bg: #f4f3ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 248px;
  --sidebar-collapsed: 72px;
  --topbar-h: 64px;
  --font: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }

/* ─── App shell ─── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
}
.app.sidebar-collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
.app.sidebar-collapsed .brand-copy,
.app.sidebar-collapsed .org-select,
.app.sidebar-collapsed .nav-label,
.app.sidebar-collapsed .nav-badge,
.app.sidebar-collapsed .help-link span,
.app.sidebar-collapsed .user-meta { display: none; }
.app.sidebar-collapsed .nav-item { justify-content: center; padding-inline: .55rem; }
.app.sidebar-collapsed .sidebar-brand { justify-content: center; }
.app.sidebar-collapsed .user-card { justify-content: center; padding: .45rem; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1rem .9rem .75rem;
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
}
.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, #3d7cff, #0052ff);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: -.02em;
  flex: 0 0 auto;
  box-shadow: 0 4px 12px rgba(0, 82, 255, 0.28);
}
.brand-copy { min-width: 0; flex: 1; }
.brand-copy strong {
  display: block;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-copy em {
  display: block;
  font-style: normal;
  font-size: .65rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: .1rem;
}
.org-select {
  margin: .7rem .85rem 0;
  width: calc(100% - 1.7rem);
  max-width: 100%;
  border: 1px solid var(--line);
  background: var(--line-2);
  border-radius: var(--radius-sm);
  padding: .5rem .6rem;
  font-size: .75rem;
  color: var(--ink);
  font-weight: 500;
}
.sidebar-nav {
  padding: .75rem .55rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #344054;
  padding: .55rem .65rem;
  border-radius: 9px;
  text-decoration: none;
  font-size: .84rem;
  font-weight: 500;
  min-width: 0;
}
.nav-item:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.nav-item.is-active:not(.wa-active) {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
}
.nav-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  opacity: .9;
  display: grid;
  place-items: center;
}
.nav-ico svg { width: 16px; height: 16px; }
.nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-badge {
  flex: 0 0 auto;
  max-width: 72px;
  font-size: .65rem;
  font-weight: 700;
  padding: .12rem .4rem;
  border-radius: 999px;
  background: #eef2ff;
  color: #3538cd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-badge.purple { background: var(--ia-bg); color: var(--ia); }
.nav-item.wa-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 82, 255, 0.25);
}
.nav-item.wa-active:hover { background: var(--primary-dark); color: #fff; }
.nav-item.wa-active .nav-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  max-width: 88px;
}

.sidebar-foot {
  padding: .65rem .7rem .85rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: .5rem;
  flex: 0 0 auto;
}
.help-link {
  display: flex;
  gap: .45rem;
  align-items: center;
  color: var(--muted);
  font-size: .78rem;
  padding: .3rem .4rem;
  text-decoration: none;
  font-weight: 500;
}
.help-link:hover { color: var(--ink); text-decoration: none; }
.user-card {
  display: flex;
  gap: .55rem;
  align-items: center;
  padding: .5rem .55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-width: 0;
}
.user-meta { display: grid; line-height: 1.25; min-width: 0; }
.user-meta strong {
  font-size: .78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta span { color: var(--muted); font-size: .75rem; display: flex; flex-wrap: wrap; gap: .15rem .35rem; }
.user-meta a { color: inherit; text-decoration: none; }
.user-meta a:hover { color: var(--primary); text-decoration: underline; }
.nav-backdrop { display: none; }
.menu-btn { display: grid; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: grid;
  place-items: center;
  font-size: .68rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  overflow-x: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: var(--topbar-h);
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(12px);
  min-width: 0;
}
.crumbs {
  display: flex;
  gap: .35rem;
  align-items: center;
  color: var(--muted);
  font-size: .8rem;
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.crumbs strong { color: var(--ink); font-weight: 600; }
.top-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex: 0 0 auto;
  min-width: 0;
}
.search-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: min(280px, 28vw);
  min-width: 160px;
  padding: .45rem .65rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: .8rem;
  text-align: left;
}
.search-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-pill kbd {
  font-size: .65rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1rem .3rem;
  background: var(--line-2);
  color: #98a2b3;
  flex: 0 0 auto;
}
.wa-number {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: .74rem;
  font-weight: 600;
  color: #344054;
  white-space: nowrap;
}
.wa-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(3, 152, 85, 0.18);
  flex: 0 0 auto;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #344054;
}
.icon-btn svg { width: 16px; height: 16px; }
.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: .58rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}
.region-select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 .55rem;
  background: #fff;
  font-size: .78rem;
  font-weight: 600;
  color: #344054;
}

.content {
  padding: 1.25rem 1.35rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 36px;
  padding: .4rem .85rem;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-size: .82rem;
  white-space: nowrap;
  flex: 0 0 auto;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-dark { background: #101828; color: #fff; }
.btn-dark:hover { background: #0b1220; color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: var(--line-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-sm { min-height: 30px; padding: .2rem .55rem; font-size: .75rem; }

/* ─── Page head ─── */
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  min-width: 0;
}
.page-head > div:first-child { min-width: 0; flex: 1; }
.page-head h1 {
  margin: 0;
  font-size: clamp(1.15rem, 1.8vw, 1.45rem);
  letter-spacing: -.025em;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.page-head p {
  margin: .35rem 0 0;
  color: var(--muted);
  font-size: .88rem;
  max-width: 46rem;
  line-height: 1.45;
}
.page-actions {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
  align-items: center;
  flex: 0 0 auto;
}

.status-chip {
  display: inline-flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .65rem .85rem;
  border-radius: 10px;
  border: 1px solid #a6f4c5;
  background: #ecfdf3;
  color: #027a48;
  font-size: .78rem;
  font-weight: 600;
  flex: 0 0 auto;
  max-width: 260px;
}
.status-chip small {
  display: block;
  color: #475467;
  font-weight: 500;
  margin-top: .12rem;
}

/* ─── KPI cards ─── */
.kpi-3, .kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .85rem;
  min-width: 0;
}
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi-card, .kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.kpi-card .k-label,
.kpi .label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.kpi-card .k-value,
.kpi .value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.kpi-card .k-sub { margin-top: .4rem; color: var(--muted); font-size: .76rem; }
.kpi-card .k-foot {
  margin-top: .7rem;
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  align-items: center;
  font-size: .76rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.progress {
  margin-top: .65rem;
  height: 7px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  max-width: 100%;
}
.progress.purple > i { background: var(--ia); }
.mini-stats {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .7rem;
}
.mini-stats span {
  background: var(--line-2);
  border-radius: 7px;
  padding: .28rem .5rem;
  font-size: .72rem;
  color: #344054;
  font-weight: 600;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--ok-bg);
  color: #027a48;
  border-radius: 999px;
  padding: .18rem .5rem;
  font-size: .68rem;
  font-weight: 700;
}
.live-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

/* ─── Panels ─── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.05rem;
  min-width: 0;
  overflow: hidden;
}
.panel-flush { padding: 0; }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: .85rem;
  min-width: 0;
}
.panel-head > div:first-child { min-width: 0; }
.panel-head h2 {
  margin: 0;
  font-size: .95rem;
  letter-spacing: -.01em;
  font-weight: 700;
}
.panel-head p {
  margin: .22rem 0 0;
  color: var(--muted);
  font-size: .8rem;
}
.conv-rate {
  font-size: .76rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: .28rem .65rem;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* ─── Funnel (horizontal, contained scroll) ─── */
.funnel-h {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: .25rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.funnel-step {
  flex: 0 0 132px;
  width: 132px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .65rem;
  background: #fff;
  position: relative;
  min-height: 124px;
  scroll-snap-align: start;
}
.funnel-step::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-top: 1.5px solid #98a2b3;
  border-right: 1.5px solid #98a2b3;
  transform: translateY(-50%) rotate(45deg);
  z-index: 1;
}
.funnel-step:last-child { flex-basis: 148px; width: 148px; }
.funnel-step:last-child::after { content: none; }
.funnel-step .n {
  font-size: .68rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: .3rem;
}
.funnel-step strong {
  display: block;
  font-size: .8rem;
  line-height: 1.25;
  margin-bottom: .35rem;
  font-weight: 700;
}
.funnel-step .meta { font-size: .72rem; color: var(--muted); line-height: 1.35; }
.funnel-step .meta b { color: var(--ink); font-weight: 700; }
.funnel-step .split { display: grid; gap: .18rem; margin-top: .35rem; font-size: .7rem; }
.funnel-step .split b.ok { color: var(--ok); }
.funnel-step .split b.warn { color: var(--warn); }
.funnel-step .split b.bad { color: var(--bad); }

/* Legacy vertical funnel used in whatsapp.php */
.funnel { display: grid; gap: .55rem; }
.funnel-row {
  display: grid;
  grid-template-columns: minmax(0, 140px) minmax(0, 1fr) auto;
  gap: .65rem;
  align-items: center;
  font-size: .82rem;
}
.funnel-track {
  height: 8px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
}
.funnel-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}
.funnel-meta { color: var(--muted); font-size: .74rem; white-space: nowrap; }

.dash-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, .9fr);
  gap: 1rem;
  align-items: stretch;
  min-width: 0;
}

.table-tabs {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.table-tabs .tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: .28rem .65rem;
  font-size: .72rem;
  font-weight: 650;
  color: #475467;
}
.table-tabs .tab.is-on {
  background: var(--primary-soft);
  border-color: #c7d7fe;
  color: var(--primary-dark);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.panel-flush .table-wrap { border: 0; border-radius: 0; }
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
table.data th,
table.data td {
  padding: .7rem .8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: .82rem;
}
table.data th {
  background: #f9fafb;
  color: var(--muted);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafbfd; }
table.data td {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.data td.wrap {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.person {
  display: flex;
  gap: .55rem;
  align-items: center;
  min-width: 0;
}
.person .av {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3538cd;
  display: grid;
  place-items: center;
  font-size: .68rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.person .meta {
  display: grid;
  gap: .06rem;
  min-width: 0;
}
.person strong {
  font-size: .84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person span {
  color: var(--muted);
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: .14rem .45rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-ok { background: var(--ok-bg); color: #027a48; }
.badge-warn { background: var(--warn-bg); color: #b54708; }
.badge-bad { background: var(--bad-bg); color: #b42318; }
.badge-info { background: #eff8ff; color: #175cd3; }
.badge-neutral { background: #f2f4f7; color: #475467; }
.badge-pdf { background: #fef3f2; color: #b42318; }
.badge-word { background: #eff8ff; color: #175cd3; }
.badge-ocr { background: #fffaeb; color: #b54708; }
.badge-ia { background: var(--ia-bg); color: var(--ia); }

/* ─── Chat ─── */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: 640px;
  padding: 0;
  overflow: hidden;
}
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.chat-head strong { display: block; font-size: .86rem; }
.chat-head > div span { color: var(--muted); font-size: .72rem; }
.chat-stream {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  background: #ece5dd;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.35) 0 1px, transparent 2px),
    radial-gradient(circle at 80% 40%, rgba(0,0,0,.03) 0 1px, transparent 2px);
  padding: .85rem;
  overflow: auto;
  min-height: 0;
}
.bubble {
  max-width: 86%;
  padding: .55rem .7rem;
  border-radius: 10px;
  font-size: .78rem;
  line-height: 1.4;
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.06);
}
.bubble.bot {
  background: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.bubble.user {
  background: #d9fdd3;
  color: #111b21;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.chat-input {
  display: flex;
  gap: .4rem;
  padding: .7rem .85rem;
  border-top: 1px solid var(--line);
  background: #fff;
}
.chat-input input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .4rem .85rem;
  background: #f9fafb;
}
.webhook-line {
  padding: .45rem .85rem .7rem;
  font-size: .68rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
  background: #fff;
  border-top: 1px solid var(--line-2);
}
.webhook-line code {
  background: var(--line-2);
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: .65rem;
}

/* ─── Forms / misc ─── */
.toolbar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .75rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.toolbar input[type="search"],
.toolbar select,
.field input,
.field select,
.field textarea {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .35rem .6rem;
  background: #fff;
  max-width: 100%;
}
.toolbar input[type="search"] { min-width: min(240px, 100%); flex: 1; }
.filters-drawer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .65rem;
}
.field { display: grid; gap: .28rem; font-size: .74rem; color: var(--muted); font-weight: 600; }
.field textarea { min-height: 88px; resize: vertical; }
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 1rem;
  min-width: 0;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  min-width: 0;
}
.cards-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .85rem;
  min-width: 0;
}
.soft-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 1rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.soft-card h3 { margin: 0 0 .35rem; font-size: .9rem; }
.soft-card p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.4; }
.criteria { display: grid; gap: .4rem; }
.criteria-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .82rem;
  min-width: 0;
}
.criteria-row span { color: var(--muted); flex: 0 1 auto; }
.criteria-row strong {
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.match-ring {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: .5rem auto 1rem;
  background:
    radial-gradient(circle at center, #fff 58%, transparent 59%),
    conic-gradient(var(--ok) var(--p), #e4e7ec 0);
  font-weight: 700;
  font-size: 1.25rem;
}
.timeline { display: grid; gap: .75rem; }
.timeline-item { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: .6rem; }
.timeline-item i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: .35rem;
}
.timeline-item strong { display: block; font-size: .84rem; }
.timeline-item span { color: var(--muted); font-size: .72rem; }
.empty {
  padding: 1.75rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .88rem;
}
.wa-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-weight: 600;
  color: #027a48;
}

.cmdk {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(560px, 92vw);
  box-shadow: var(--shadow);
  background: #fff;
}
.cmdk input {
  width: 100%;
  border: 0;
  outline: none;
  padding: 1rem 1.1rem;
  font-size: 1rem;
}
dialog.cmdk:not([open]) { display: none; }
dialog.cmdk[open] { display: block; }
dialog.cmdk::backdrop { background: rgba(16, 24, 40, .45); }
.cmdk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  border-top: 1px solid var(--line);
  padding: .45rem .7rem .55rem 0;
}
.cmdk-hint {
  margin: 0;
  padding: .55rem 1.1rem;
  color: var(--muted);
  font-size: .78rem;
  border-top: 0;
}
.collapse-btn { margin-left: auto; }

/* ─── Reports (TalentPulse tokens) ─── */
.rp { display: grid; gap: 1rem; min-width: 0; }
.rp-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}
.rp-sidebar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: calc(var(--topbar-h) + .75rem);
  max-height: calc(100vh - 5.5rem);
  overflow: auto;
  min-width: 0;
}
.rp-side-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .6rem;
}
.rp-side-top h2 { margin: 0; font-size: .95rem; }
.rp-link {
  border: 0;
  background: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  font-size: .8rem;
  padding: 0;
}
.rp-acc {
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: .5rem;
  background: #fafbfc;
}
.rp-acc > summary {
  list-style: none;
  cursor: pointer;
  padding: .65rem .75rem;
  font-weight: 600;
  font-size: .84rem;
  display: flex;
  justify-content: space-between;
  gap: .5rem;
}
.rp-acc > summary::-webkit-details-marker { display: none; }
.rp-acc > summary::after { content: "+"; color: var(--muted); }
.rp-acc[open] > summary::after { content: "–"; }
.rp-acc > summary em {
  font-style: normal;
  color: var(--muted);
  font-weight: 500;
  font-size: .75rem;
}
.rp-acc-body {
  padding: .7rem .75rem .8rem;
  display: grid;
  gap: .55rem;
  border-top: 1px solid var(--line);
}
.rp-field { display: grid; gap: .25rem; font-size: .74rem; color: var(--muted); font-weight: 600; }
.rp-field input,
.rp-field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .4rem .55rem;
  background: #fff;
  color: var(--ink);
}
.rp-two { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.rp-status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.rp-chip-check {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  padding: .4rem .5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: .78rem;
  cursor: pointer;
}
.rp-chip-check:has(input:checked) {
  border-color: #b2ccff;
  background: var(--primary-soft);
}
.rp-chip-check input { accent-color: var(--primary); }
.rp-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .55rem; }
.rp-chip {
  border: 1px solid #c7d7fe;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: .22rem .55rem;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
}
.rp-main { display: grid; gap: 1rem; min-width: 0; }
.rp-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.rp-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: .75rem;
}
.rp-panel-head h2 { margin: 0; font-size: 1rem; }
.rp-panel-sub { margin: .2rem 0 0; color: var(--muted); font-size: .8rem; }
.rp-inline-field {
  display: grid;
  gap: .2rem;
  font-size: .72rem;
  color: var(--muted);
  min-width: 160px;
}
.rp-inline-field select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .35rem .5rem;
  background: #fff;
}
.rp-bars { display: grid; gap: .65rem; }
.rp-bar-top {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-size: .8rem;
  margin-bottom: .25rem;
}
.rp-bar-top span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #344054;
}
.rp-bar-track {
  height: 8px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
}
.rp-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  max-width: 100%;
}
.rp-cols { position: relative; }
.rp-cols > summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .45rem .7rem;
  background: #fff;
  font-size: .8rem;
  font-weight: 600;
}
.rp-cols > summary::-webkit-details-marker { display: none; }
.rp-cols-menu {
  position: absolute;
  right: 0;
  top: calc(100% + .35rem);
  z-index: 20;
  width: 240px;
  max-height: 280px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: .55rem;
  display: grid;
  gap: .3rem;
}
.rp-cols-menu label {
  display: flex;
  gap: .4rem;
  align-items: center;
  font-size: .8rem;
  margin: 0;
}
.rp-table-scroll {
  overflow: auto;
  max-height: 62vh;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.rp-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.rp-table th,
.rp-table td {
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: .82rem;
}
.rp-table th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  color: var(--muted);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  z-index: 1;
}
.rp-table tbody tr:hover { background: #fafbfd; }
.rp-name { color: var(--primary); font-weight: 600; text-decoration: none; }
.rp-name:hover { text-decoration: underline; }
.rp-muted { color: var(--muted); font-size: .74rem; margin-top: .12rem; }
.rp-status {
  display: inline-flex;
  padding: .16rem .45rem;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
  background: #f2f4f7;
}
.rp-status.s-NEW { background: #eff8ff; color: #175cd3; }
.rp-status.s-INTERVIEWING { background: #fffaeb; color: #b54708; }
.rp-status.s-WAITING_FOR_CV { background: #fffaeb; color: #b54708; }
.rp-status.s-COMPLETED { background: #ecfdf3; color: #027a48; }
.rp-status.s-ABANDONED { background: #fef3f2; color: #b42318; }
.rp-progress {
  width: 72px;
  height: 6px;
  background: #eef2f6;
  border-radius: 99px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: .3rem;
}
.rp-progress span { display: block; height: 100%; background: var(--primary); max-width: 100%; }
.rp-pill {
  display: inline-flex;
  padding: .12rem .4rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
}
.rp-pill.yes { background: #ecfdf3; color: #027a48; }
.rp-pill.no { background: #f2f4f7; color: #475467; }
.rp-empty { padding: 1.25rem; color: var(--muted); text-align: center; }
.rp-loading-row td { color: var(--muted); }
.rp-qa-group { display: grid; gap: .5rem; padding-top: .3rem; }
.rp-qa-group + .rp-qa-group {
  margin-top: .5rem;
  border-top: 1px dashed var(--line);
  padding-top: .7rem;
}
.rp-qa-group h3 {
  margin: 0;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* ─── Responsive ─── */
@media (max-width: 1280px) {
  .hide-lg { display: none !important; }
  .search-pill { width: 180px; min-width: 140px; }
}
@media (max-width: 1100px) {
  .kpi-3,
  .dash-bottom,
  .grid-2,
  .grid-3,
  .cards-3 { grid-template-columns: 1fr; }
  .rp-shell { grid-template-columns: 1fr; }
  .rp-sidebar { position: static; max-height: none; }
  .hide-md { display: none !important; }
}
@media (max-width: 900px) {
  .app,
  .app.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    height: 100vh;
    transform: translateX(-110%);
    transition: transform .2s ease;
    box-shadow: none;
  }
  .app.nav-open .sidebar { transform: none; box-shadow: 12px 0 32px rgba(16, 24, 40, .18); }
  .app.nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .45);
    z-index: 35;
  }
  .sidebar { z-index: 40; }
  .topbar {
    flex-wrap: wrap;
    padding: .65rem .9rem;
    min-height: 0;
  }
  .top-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .search-pill { width: 100%; min-width: 0; }
  .content { padding: 1rem .9rem 1.5rem; }
  .funnel-row { grid-template-columns: 1fr; gap: .25rem; }
}
@media (max-width: 640px) {
  .page-head { flex-direction: column; }
  .status-chip { max-width: 100%; }
}

/* ===== Mensajería TalentPulse (bandeja + chat compartido) ===== */
:root {
  --msg-green: #079780;
  --msg-teal: #24BFA7;
  --msg-dark: #252B2A;
  --msg-dark-2: #303635;
  --msg-bg: #F5F7F6;
  --msg-surface: #FFFFFF;
  --msg-ink: #182523;
  --msg-muted: #7B8986;
  --msg-line: #E5EBE8;
  --msg-soft: #E8F7F3;
  --msg-bubble-out: #D8F3EC;
  --msg-bubble-bot: #E6F4F1;
  --msg-bubble-in: #FFFFFF;
  --msg-thread: #F7FAF9;
  --msg-radius: 12px;
  --msg-shadow: 0 1px 2px rgba(24, 37, 35, 0.04), 0 8px 24px rgba(24, 37, 35, 0.06);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Página bandeja: ocupa el alto útil del shell; solo el hilo hace scroll */
body.page-inbox {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}
body.page-inbox .content {
  padding: 0;
  gap: 0;
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  max-height: calc(100vh - var(--topbar-h));
  max-height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
  background: var(--msg-bg);
}
body.page-inbox .app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
body.page-inbox .main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
body.page-inbox .topbar { flex: 0 0 auto; }

.inbox-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  color: var(--msg-ink);
}

.inbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .7rem 1rem;
  background: var(--msg-surface);
  border-bottom: 1px solid var(--msg-line);
  flex: 0 0 auto;
}
.inbox-toolbar-brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--msg-ink);
}
.inbox-toolbar-brand p {
  margin: .15rem 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  font-size: .78rem;
  color: var(--msg-muted);
}
.inbox-toolbar .wa-badge { color: var(--msg-green); }
.inbox-toolbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.inbox-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--msg-bg);
}

.inbox-list,
.inbox-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--msg-surface);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.inbox-list { border-right: 1px solid var(--msg-line); }
.inbox-main { background: var(--msg-thread); }

.inbox-search {
  padding: .75rem .85rem .5rem;
  border-bottom: 0;
  background: var(--msg-surface);
}
.inbox-search input {
  width: 100%;
  border: 1px solid var(--msg-line);
  border-radius: 10px;
  padding: .65rem .85rem;
  font: inherit;
  font-size: .88rem;
  background: var(--msg-bg);
  color: var(--msg-ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.inbox-search input:focus {
  outline: none;
  border-color: var(--msg-teal);
  box-shadow: 0 0 0 3px rgba(36, 191, 167, 0.18);
  background: #fff;
}

.inbox-filters {
  display: flex;
  gap: .35rem;
  padding: .35rem .85rem .75rem;
  border-bottom: 1px solid var(--msg-line);
  background: var(--msg-surface);
}
.inbox-filters a {
  flex: 1;
  text-align: center;
  font-size: .78rem;
  font-weight: 600;
  padding: .4rem .55rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--msg-muted);
  background: transparent;
  transition: background .15s ease, color .15s ease;
}
.inbox-filters a:hover { background: var(--msg-bg); color: var(--msg-ink); text-decoration: none; }
.inbox-filters a.is-on {
  background: var(--msg-green);
  color: #fff;
}

.inbox-list-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
  background: var(--msg-surface);
  -webkit-overflow-scrolling: touch;
}

.inbox-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: .7rem;
  padding: .7rem .9rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--msg-line);
  align-items: center;
  cursor: pointer;
  transition: background .12s ease;
}
.inbox-item:hover { background: var(--msg-bg); text-decoration: none; }
.inbox-item.is-active {
  background: var(--msg-soft);
  box-shadow: inset 3px 0 0 var(--msg-green);
}
.inbox-item-meta { min-width: 0; }
.inbox-item-meta strong {
  display: block;
  font-size: .88rem;
  font-weight: 650;
  color: var(--msg-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-item-meta span {
  display: block;
  font-size: .78rem;
  color: var(--msg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: .12rem;
}
.inbox-item.has-unread .inbox-item-meta strong { font-weight: 700; }
.inbox-item.has-unread .inbox-item-meta span { color: var(--msg-ink); font-weight: 550; }
.inbox-item.has-unread strong::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--msg-teal);
  margin-left: .4rem;
  vertical-align: middle;
}
.inbox-item .av,
.av {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: linear-gradient(145deg, #3A4543, var(--msg-dark));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  flex: 0 0 auto;
}
.av-lg { width: 40px; height: 40px; font-size: .7rem; }
.inbox-item em {
  font-style: normal;
  font-size: .7rem;
  color: var(--msg-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .25rem;
  white-space: nowrap;
}
.unread-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 .3rem;
  border-radius: 999px;
  background: var(--msg-green);
  color: #fff;
  font-size: .68rem;
  font-style: normal;
  font-weight: 700;
}
.inbox-empty { padding: 2rem 1rem; }

.inbox-empty-state {
  flex: 1;
  display: grid;
  place-content: center;
  gap: .45rem;
  text-align: center;
  padding: 2rem;
  color: var(--msg-muted);
}
.inbox-empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto .4rem;
  border-radius: 999px;
  background: var(--msg-soft);
  color: var(--msg-green);
  display: grid;
  place-items: center;
}
.inbox-empty-state strong {
  color: var(--msg-ink);
  font-size: 1.05rem;
}
.inbox-empty-state p { margin: 0; font-size: .88rem; max-width: 28rem; }

.inbox-chat {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--msg-thread);
}

.inbox-main-head {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--msg-line);
  background: var(--msg-surface);
  flex: 0 0 auto;
  flex-wrap: wrap;
  position: relative;
  z-index: 5;
}
.inbox-back {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  color: var(--msg-ink);
  text-decoration: none;
  background: var(--msg-bg);
  flex: 0 0 auto;
  transition: background .15s ease;
}
.inbox-back:hover { background: var(--msg-line); text-decoration: none; }
.inbox-head-meta {
  min-width: 0;
  flex: 1 1 140px;
}
.inbox-head-meta strong {
  display: block;
  font-size: .95rem;
  font-weight: 700;
  color: var(--msg-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-head-sub {
  display: block;
  font-size: .75rem;
  color: var(--msg-muted);
  margin-top: .15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-head-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.inbox-head-secondary {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.inbox-more { position: relative; display: none; }
.inbox-more > summary {
  list-style: none;
  cursor: pointer;
}
.inbox-more > summary::-webkit-details-marker { display: none; }
.inbox-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + .35rem);
  z-index: 30;
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--msg-line);
  border-radius: 10px;
  box-shadow: var(--msg-shadow);
  padding: .35rem;
  display: grid;
  gap: .15rem;
}
.inbox-more-menu a,
.inbox-more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: .5rem .65rem;
  border-radius: 8px;
  font: inherit;
  font-size: .82rem;
  color: var(--msg-ink);
  cursor: pointer;
  text-decoration: none;
}
.inbox-more-menu a:hover,
.inbox-more-menu button:hover { background: var(--msg-bg); }

.ctrl-bar {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  align-items: center;
  padding: .65rem .9rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--msg-line);
  flex: 0 0 auto;
}
.ctrl-bar.is-bot { background: #EEF6F4; }
.ctrl-bar.is-human { background: var(--msg-soft); }
.ctrl-bar strong { display: block; font-size: .88rem; color: var(--msg-ink); }
.ctrl-bar span {
  display: block;
  font-size: .75rem;
  color: var(--msg-muted);
  margin-top: .12rem;
  max-width: 36rem;
}
.ctrl-bar .btn-primary {
  background: var(--msg-green);
  border-color: var(--msg-green);
}
.ctrl-bar .btn-primary:hover { background: #067a68; }

.inbox-thread {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--msg-thread);
  padding: 1rem .95rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.bubble {
  max-width: min(72%, 520px);
  padding: .55rem .75rem .45rem;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(24, 37, 35, 0.05);
}
.bubble.in {
  align-self: flex-start;
  background: var(--msg-bubble-in);
  border: 1px solid var(--msg-line);
  border-top-left-radius: 4px;
}
.bubble.out {
  align-self: flex-end;
  background: var(--msg-bubble-out);
  border: 1px solid #C5E8DE;
  border-top-right-radius: 4px;
}
.bubble.out.bot {
  background: var(--msg-bubble-bot);
  border-color: #CDE6E1;
}
.bubble.out.agent {
  background: var(--msg-bubble-out);
  border-color: #A8D9CB;
}
.bubble-meta {
  font-size: .68rem;
  color: var(--msg-muted);
  margin-bottom: .2rem;
}
.bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--msg-ink);
}

.quick-replies {
  display: flex;
  flex-wrap: nowrap;
  gap: .4rem;
  padding: .45rem .85rem 0;
  overflow-x: auto;
  background: var(--msg-surface);
  border-top: 1px solid var(--msg-line);
  scrollbar-width: thin;
  flex: 0 0 auto;
  position: relative;
  z-index: 4;
}
.quick-replies button,
.facts-actions button {
  border: 1px solid var(--msg-line);
  background: #fff;
  color: var(--msg-ink);
  border-radius: 999px;
  padding: .35rem .75rem;
  font: inherit;
  font-size: .75rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: border-color .15s ease, background .15s ease;
}
.quick-replies button:hover,
.facts-actions button:hover {
  border-color: var(--msg-teal);
  background: var(--msg-soft);
}

.inbox-compose {
  display: flex;
  gap: .45rem;
  align-items: flex-end;
  padding: .65rem .85rem;
  border-top: 0;
  background: var(--msg-surface);
  flex: 0 0 auto;
  position: relative;
  z-index: 5;
}
.inbox-compose.is-bot { opacity: .78; background: #F3F6F5; }
.inbox-compose.is-human { background: var(--msg-surface); }
.inbox-compose textarea {
  flex: 1;
  border: 1px solid var(--msg-line);
  border-radius: 12px;
  padding: .7rem .85rem;
  font: inherit;
  resize: none;
  min-height: 2.7rem;
  max-height: 120px;
  background: var(--msg-bg);
  color: var(--msg-ink);
  line-height: 1.35;
}
.inbox-compose textarea:focus {
  outline: none;
  border-color: var(--msg-teal);
  box-shadow: 0 0 0 3px rgba(36, 191, 167, 0.16);
  background: #fff;
}
.inbox-compose .btn-primary {
  background: var(--msg-green);
  border-color: var(--msg-green);
  min-height: 42px;
  border-radius: 12px;
  padding-inline: 1rem;
}
.inbox-compose .btn-primary:hover { background: #067a68; }
.inbox-compose .clip-btn,
.inbox-compose .voice-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  flex: 0 0 auto;
  border-color: var(--msg-line);
  background: var(--msg-bg);
}
.inbox-hint {
  margin: 0 .85rem .65rem;
  font-size: .78rem;
  color: var(--msg-muted);
  min-height: 1.1em;
  background: var(--msg-surface);
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  color: var(--msg-muted);
}
.live-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #98A2B3;
}
.live-status[data-state="live"]::before {
  background: var(--msg-teal);
  box-shadow: 0 0 0 3px rgba(36, 191, 167, 0.2);
}
.live-status[data-state="offline"]::before { background: #F79009; }

.call-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .65rem .9rem;
  background: #FFFAEB;
  border: 0;
  border-bottom: 1px solid #FEDF89;
  border-radius: 0;
  margin: 0;
  flex: 0 0 auto;
}
.call-banner strong { display: block; color: var(--msg-ink); }
.call-banner span { display: block; font-size: .78rem; color: var(--msg-muted); }

.window-banner {
  margin: 0;
  padding: .4rem .9rem;
  font-size: .76rem;
  text-align: center;
  flex: 0 0 auto;
}
.window-banner.is-open { background: var(--msg-soft); color: #067647; }
.window-banner.is-closed { background: #FFFAEB; color: #B54708; }

.team-fold {
  border-bottom: 1px solid var(--msg-line);
  padding: .35rem .9rem .5rem;
  background: var(--msg-surface);
  flex: 0 0 auto;
}
.team-fold summary {
  cursor: pointer;
  font-size: .8rem;
  color: var(--msg-muted);
  padding: .25rem 0;
  font-weight: 600;
}
body.page-inbox .team-fold:not([open]) {
  padding: 0;
  border: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
}
body.page-inbox .team-fold[open] {
  padding: .55rem .9rem .65rem;
  border-bottom: 1px solid var(--msg-line);
  max-height: none;
  overflow: visible;
}
body.page-inbox .team-fold > summary {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.team-fold .chat-tools { border-bottom: 0; padding: .45rem 0 0; }
.chat-tools {
  display: grid;
  gap: .45rem;
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--msg-line);
  font-size: .82rem;
  background: var(--msg-surface);
}
.chat-tools label { display: grid; gap: .2rem; color: var(--msg-muted); }
.chat-tools select,
.chat-tools textarea {
  width: 100%;
  font: inherit;
  border: 1px solid var(--msg-line);
  border-radius: 8px;
  padding: .4rem .55rem;
  color: inherit;
  background: #fff;
}

.voice-btn.is-recording { background: #F04438; color: #fff; border-color: #F04438; }
.inbox-compose.is-voicing > :not(.rec-bar) { display: none !important; }
.rec-bar { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; }
.rec-bar[hidden] { display: none !important; }
.rec-cancel,
.rec-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  flex: 0 0 auto;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.rec-cancel { background: transparent; color: #F04438; font-size: 1.2rem; }
.rec-send { background: var(--msg-green); color: #fff; }
.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #F04438;
  flex: 0 0 auto;
  animation: tp-rec 1s ease-in-out infinite;
}
.rec-time { font-variant-numeric: tabular-nums; font-size: .85rem; min-width: 2.5rem; }
.rec-wave { display: flex; align-items: center; gap: 2px; height: 32px; flex: 1; min-width: 0; }
.rec-wave i {
  display: block;
  width: 3px;
  flex: 1 1 auto;
  max-width: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--msg-teal);
}
@keyframes tp-rec { 50% { opacity: .3; } }

.ticks { margin-left: .35rem; letter-spacing: -.12em; color: #98A2B3; }
.ticks.is-read { color: var(--msg-green); }
.ticks.is-fail { color: #F04438; letter-spacing: 0; }
.bubble img { max-width: 220px; border-radius: 8px; display: block; }
.media-open { border: 0; padding: 0; background: transparent; cursor: pointer; }
.media-file { display: inline-block; margin-top: .35rem; font-size: .8rem; color: var(--msg-green); }
#media-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .82);
  display: grid;
  place-items: center;
  z-index: 80;
}
#media-lightbox[hidden] { display: none; }
#media-lightbox img { max-width: 92vw; max-height: 92vh; }
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

.doc-text {
  white-space: pre-wrap;
  background: var(--line-2);
  border-radius: 8px;
  padding: .75rem;
  font-size: .85rem;
  max-height: 260px;
  overflow: auto;
  margin-top: .5rem;
}
.day-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.day-row {
  display: block;
  padding: .55rem .2rem;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.day-row span { display: block; color: var(--muted); font-size: .78rem; }

/* Tablet */
@media (max-width: 1023px) {
  .inbox-layout { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
  .bubble { max-width: min(82%, 480px); }
}

/* Móvil: vistas separadas lista ↔ chat */
@media (max-width: 767px) {
  body.page-inbox .content {
    height: calc(100dvh - var(--topbar-h));
    max-height: calc(100dvh - var(--topbar-h));
  }
  body.page-inbox .topbar .search-pill,
  body.page-inbox .topbar .wa-number,
  body.page-inbox .topbar #push-btn,
  body.page-inbox .topbar > .top-actions > .btn-primary { display: none; }

  .inbox-toolbar {
    padding: .55rem .85rem;
  }
  .inbox-toolbar-brand h1 { font-size: .98rem; }
  .inbox-toolbar-actions .btn { min-height: 32px; font-size: .75rem; padding: .25rem .6rem; }
  .inbox-shell:has(.inbox-layout.is-open) .inbox-toolbar { display: none; }
  .inbox-shell:has(.inbox-layout.is-open) {
    height: 100%;
    min-height: 0;
  }

  .inbox-layout {
    grid-template-columns: 1fr;
    position: relative;
    height: 100%;
    min-height: 0;
  }
  .inbox-layout.is-open .inbox-list { display: none; }
  .inbox-layout:not(.is-open) .inbox-main { display: none; }
  .inbox-layout.is-open .inbox-main,
  .inbox-layout.is-open .inbox-chat {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .inbox-back { display: inline-flex; }
  .inbox-head-secondary { display: none; }
  .inbox-more { display: block; }
  .inbox-main-head {
    padding: .55rem .7rem;
    gap: .5rem;
    flex-wrap: nowrap;
  }
  .inbox-head-actions { margin-left: 0; flex: 0 0 auto; }
  .inbox-item {
    grid-template-columns: 48px 1fr auto;
    padding: .85rem .9rem;
    min-height: 68px;
  }
  .inbox-item .av { width: 48px; height: 48px; font-size: .78rem; }
  .bubble { max-width: 86%; }
  .inbox-compose {
    padding: .55rem .7rem calc(.55rem + env(safe-area-inset-bottom, 0px));
  }
  .quick-replies {
    padding-left: .7rem;
    padding-right: .7rem;
  }
  .ctrl-bar { padding: .55rem .7rem; }
  .ctrl-bar .btn { width: 100%; }
  .ctrl-bar { align-items: stretch; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .inbox-head-secondary .btn { padding-inline: .45rem; }
  .inbox-more { display: none; }
}

@media (max-width: 900px) {
  .day-board { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .inbox-item,
  .inbox-search input,
  .inbox-filters a,
  .quick-replies button { transition: none; }
  .rec-dot { animation: none; }
}

/* ============================================================
   Cadra Soft (2026-10-22) — mismo UI/UX que control_rq v4/v5
   Crema cálido, tinta negra, pill nav, KPI negra + sky,
   cards blancas r24, acento naranja, motion soft.
   Solo presentación: no cambia IDs, JS ni APIs.
   ============================================================ */
:root {
  --bg: #f5f1e8;
  --surface: #ffffff;
  --ink: #171310;
  --muted: #78716c;
  --line: #e9e2d4;
  --line-2: #f3eee3;
  --primary: #171310;
  --primary-dark: #2b2520;
  --primary-soft: #ffebe3;
  --accent: #e4572e;
  --accent-dark: #c94f30;
  --sky: #d3e6f7;
  --sky-deep: #2f6da3;
  --shadow: 0 1px 2px rgba(87, 64, 35, .05), 0 8px 24px rgba(87, 64, 35, .05);
  --shadow-md: 0 2px 4px rgba(87, 64, 35, .05), 0 18px 44px rgba(87, 64, 35, .10);
  --radius: 24px;
  --radius-sm: 16px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --ease-soft: cubic-bezier(.22, 1, .36, 1);
  --msg-bg: #f7f3ea;
  --msg-thread: #faf7f0;
  --msg-line: #e9e2d4;
  --msg-radius: 16px;
}
body {
  background:
    radial-gradient(900px 420px at 85% -80px, rgba(211, 230, 247, .55), transparent 60%),
    radial-gradient(700px 380px at -120px 12%, rgba(255, 214, 190, .45), transparent 55%),
    var(--bg);
}
::selection { background: #ffd9c7; }
a { color: var(--accent-dark); }

/* Motion soft */
@keyframes cadra-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cadra-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.content > * { animation: cadra-rise .65s var(--ease-soft) backwards; }
.content > *:nth-child(2) { animation-delay: .06s; }
.content > *:nth-child(3) { animation-delay: .12s; }
.content > *:nth-child(4) { animation-delay: .18s; }
.content > *:nth-child(n+5) { animation-delay: .24s; }

/* Sidebar + marca */
.sidebar { background: rgba(255,255,255,.94); border-right-color: var(--line); }
.sidebar-brand { border-bottom-color: #f0e9db; }
.logo-mark { background: var(--ink); border-radius: 12px; box-shadow: 0 8px 18px rgba(23,19,16,.22); }
.brand-copy em { color: var(--accent); }
.nav-item { border-radius: 999px; transition: background .3s var(--ease-soft), color .3s var(--ease-soft), transform .3s var(--ease-soft); }
.nav-item:hover { background: #f3eee3; transform: translateY(-1px); }
.nav-item.is-active:not(.wa-active) { background: var(--ink); color: #fff; box-shadow: 0 8px 18px rgba(23,19,16,.20); }
.nav-item.is-active:not(.wa-active) .nav-ico { color: #ffb59d; }
.nav-badge { background: var(--accent); color: #fff; }
.user-card { background: #faf7f0; border: 1px solid var(--line); border-radius: 16px; }
.avatar { background: var(--ink); color: #fff; border-radius: 12px; }
.user-meta a { color: var(--accent-dark); }

/* Topbar flotante pill */
.topbar {
  position: sticky; top: 12px; z-index: 30;
  margin: 14px 18px 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 8px 12px;
}
.crumbs strong { letter-spacing: -.01em; }
.search-pill { background: #faf7f0; border-color: var(--line); border-radius: 999px; transition: all .3s var(--ease-soft); }
.search-pill:hover { background: #f3eee3; transform: translateY(-1px); }
.wa-number { color: var(--msg-green, #079780); }

/* Botones pill: primario negro */
.btn { border-radius: 999px; transition: all .3s var(--ease-soft); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 10px 22px rgba(23,19,16,.20); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 14px 28px rgba(23,19,16,.24); text-decoration: none; }
.btn-secondary { background: #fff; border-color: #ddd3bf; color: var(--ink); }
.btn-secondary:hover { background: #f7f1e5; color: var(--ink); text-decoration: none; }
.icon-btn { border-radius: 12px; transition: all .28s var(--ease-soft); }
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* Títulos y panels */
.page-head h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.04em; }
.panel { border-color: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: box-shadow .38s var(--ease-soft); }
.panel:hover { box-shadow: var(--shadow-md); }
.panel-head { border-bottom-color: #f0e9db; }

/* KPI Cadra: 1ª negra, 2ª sky, resto blancas */
.kpi-grid .kpi-card:first-child, .kpi-3 .kpi-card:first-child,
.kpi-grid .kpi:first-child, .kpi-3 .kpi:first-child { background: var(--ink); border-color: var(--ink); color: #fff; }
.kpi-grid .kpi-card:first-child .k-label, .kpi-3 .kpi-card:first-child .k-label,
.kpi-grid .kpi:first-child .label, .kpi-3 .kpi:first-child .label { color: rgba(255,255,255,.62); }
.kpi-grid .kpi-card:first-child .k-value, .kpi-3 .kpi-card:first-child .k-value,
.kpi-grid .kpi:first-child .value, .kpi-3 .kpi:first-child .value { color: #fff; }
.kpi-grid .kpi-card:first-child .k-sub, .kpi-3 .kpi-card:first-child .k-sub { color: rgba(255,255,255,.62); }
.kpi-grid .kpi-card:nth-child(2), .kpi-3 .kpi-card:nth-child(2),
.kpi-grid .kpi:nth-child(2), .kpi-3 .kpi:nth-child(2) { background: var(--sky); border-color: #bfd9f2; }
.kpi-card, .kpi { border-radius: var(--radius); border-color: var(--line); transition: transform .38s var(--ease-soft), box-shadow .38s var(--ease-soft); }
.kpi-card:hover, .kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

/* Tabs / chips */
.table-tabs { border-radius: 999px; border-color: var(--line); box-shadow: var(--shadow); padding: 5px; background: #fff; }
.table-tabs .tab { border-radius: 999px; transition: all .3s var(--ease-soft); }
.table-tabs .tab:hover { background: #f3eee3; }
.table-tabs .tab.is-on { background: var(--ink); color: #fff; box-shadow: 0 8px 18px rgba(23,19,16,.18); }
.status-chip { border-radius: 999px; }

/* Formularios y tablas */
.field input, .field select, .field textarea,
.criteria input.field, .chat-tools select, .chat-tools textarea {
  border-radius: 14px; border-color: #ddd5c3; background: #fffefa;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.field input:focus, .field select:focus, .field textarea:focus,
.criteria input.field:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(228,87,46,.14); outline: none; }
table.data thead th, .data thead th { background: #faf7f0; color: #8a8175; }
table.data tbody tr, .data tbody tr { transition: background .25s ease; }
table.data tbody tr:hover td, .data tbody tr:hover td { background: #faf6ec; }
.badge { letter-spacing: .02em; }
.empty { color: var(--muted); }

/* Bandeja WhatsApp sobre crema cálido (se conserva el verde WA) */
.inbox-shell { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.inbox-search input { border-radius: 999px; background: #faf7f0; }
.inbox-filters a { border-radius: 999px; transition: all .3s var(--ease-soft); }
.inbox-filters a:hover { transform: translateY(-1px); }
.call-banner { border-radius: 16px; }

:focus-visible { outline: 3px solid rgba(228,87,46,.45); outline-offset: 2px; }
@media (max-width: 767px) {
  .topbar { margin: 10px 10px 0; border-radius: 20px; top: 8px; }
  .page-head h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ===== UX producción: filtros flotantes, paginación, targets ===== */
.toolbar {
  position: sticky; top: 84px; z-index: 20;
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow); padding: 10px 12px; margin-bottom: 14px;
}
.toolbar .btn, .toolbar select, .toolbar input { min-height: 44px; }
.pagination {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin: 14px 0 4px;
}
.pagination-info { color: var(--muted); font-size: .85rem; font-weight: 600; }
.pagination-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pagination-links .btn { min-width: 40px; min-height: 40px; justify-content: center; }
.pagination-gap { color: var(--muted); padding: 0 2px; }
.panel-head { flex-wrap: wrap; gap: 8px; }
.table-wrap { -webkit-overflow-scrolling: touch; }
@media (max-width: 767px) {
  .toolbar { top: 74px; border-radius: 18px; }
  .pagination { justify-content: center; }
  .pagination-info { width: 100%; text-align: center; }
  .btn, button.btn { min-height: 44px; }
  .inbox-list-item, .conv-item { min-height: 56px; }
}
