/* Nexo · tema claro y cálido. Texto mínimo de 12px, áreas táctiles de 40px. */
:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #1c2b2e;
  --muted: #5d6e70;
  --soft: #8a999b;
  --line: #e2e9e5;
  --brand: #12896b;
  --brand-strong: #0c6f56;
  --brand-soft: #e3f3ec;
  --brand-ink: #0b5c48;
  --warm: #f59e2e;
  --warm-soft: #fff3df;
  --warm-ink: #8a5a12;
  --danger: #c4483d;
  --danger-soft: #fdebe8;
  --sky-soft: #e8f1fd;
  --sky-ink: #2c5c9a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px #1c2b2e0a, 0 6px 20px #1c2b2e0d;
  --shadow-lg: 0 24px 60px #1c2b2e2e;
  --sidebar-w: 256px;
  /* Compatibilidad con nombres anteriores */
  --green: var(--brand);
  --red: var(--danger);
  --paper: var(--bg);
  --white: var(--surface);
  --sidebar: var(--surface);
}
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
a {
  color: var(--brand);
  text-decoration: none;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
:focus-visible {
  outline: 3px solid #12896b55;
  outline-offset: 2px;
}
.hidden,
[hidden] {
  display: none !important;
}
h1 {
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.8px;
  margin: 0 0 6px;
  font-weight: 700;
}
h2 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.3px;
  margin: 0;
}
h3 {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
}
p {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}
.eyebrow {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.4px;
  color: var(--brand);
  margin-bottom: 6px;
  text-transform: none;
}

/* ---------- Estructura ---------- */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 14px 16px;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 26px;
  letter-spacing: -1px;
  font-weight: 750;
  padding: 0 10px;
}
.brandmark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #1aa37f, #0c6f56);
  color: white;
  font-size: 22px;
  line-height: 36px;
  text-align: center;
  font-weight: 700;
  box-shadow: 0 6px 14px #12896b40;
}
.brand-dot {
  font-size: 9px;
  color: var(--warm);
  align-self: flex-end;
  margin: 0 0 9px -8px;
}
.workspace {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 20px 0 10px;
  padding: 11px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
}
.workspace small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}
.workspace-icon {
  flex: 0 0 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-radius: 10px;
  font-weight: 700;
}
.sidebar nav {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  margin: 4px -4px 0;
  padding: 0 4px;
  scrollbar-width: thin;
  scrollbar-color: #cfdad5 transparent;
}
.nav-group {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--soft);
  padding: 16px 12px 6px;
}
nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  min-height: 42px;
  color: #3d5053;
  font-size: 14.5px;
  font-weight: 550;
  border-radius: 11px;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}
nav a.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 650;
}
nav a .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  line-height: 1;
}
nav a .nav-count {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--warm);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.sidebar .brand,
.workspace,
.nav-title,
.sidebar-bottom {
  flex-shrink: 0;
}
.sidebar-bottom {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding: 12px 10px 0;
}
.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.live-dot {
  height: 9px;
  width: 9px;
  border-radius: 50%;
  background: #2bb673;
  box-shadow: 0 0 0 4px #2bb67322;
  flex: 0 0 9px;
}
.live-dot.offline {
  background: var(--warm);
  box-shadow: 0 0 0 4px #f59e2e26;
}
.logout {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 10px 0 6px;
  font-size: 14px;
  font-weight: 550;
}
.logout:hover {
  color: var(--danger);
}
.sidebar-bottom small {
  display: block;
  font-size: 12px;
  color: var(--soft);
}
main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 40px;
  background: #f4f7f5e6;
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.topbar #breadcrumb {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar #breadcrumb span {
  color: #b9c6c1;
  padding: 0 8px;
}
.topbar-end {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--soft);
}
.avatar {
  display: grid;
  place-items: center;
  background: var(--warm-soft);
  color: var(--warm-ink);
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  width: 40px;
  height: 40px;
}
.icon-button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 19px;
  color: var(--muted);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}
.icon-button:hover {
  color: var(--brand);
  border-color: #bfd8cd;
}
#menu-toggle {
  display: none;
}
.page {
  padding: 34px 40px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 26px;
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
footer {
  display: flex;
  justify-content: space-between;
  padding: 18px 40px;
  font-size: 13px;
  color: var(--soft);
  border-top: 1px solid var(--line);
}

/* ---------- Botones ---------- */
.primary,
.secondary,
.danger,
.mini {
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  min-height: 42px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.primary:active,
.secondary:active,
.danger:active,
.mini:active {
  transform: translateY(1px);
}
.primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 4px 12px #12896b33;
}
.primary:hover {
  background: var(--brand-strong);
}
.secondary {
  background: var(--surface);
  border-color: #d4dfda;
  color: var(--ink);
}
.secondary:hover {
  border-color: var(--brand);
  color: var(--brand-ink);
}
.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f5cfc9;
  margin-top: 14px;
}
.danger:hover {
  background: #fbdcd7;
}
.mini {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.mini:hover {
  background: #d3ece1;
}
.text-link {
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  border: 0;
  background: none;
  padding: 0;
}
.text-link:hover {
  text-decoration: underline;
}

/* ---------- Tarjetas y paneles ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat {
  min-width: 0;
  overflow-wrap: anywhere;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow);
}
a.stat {
  color: inherit;
  display: block;
  transition: transform 0.15s, box-shadow 0.15s;
}
a.stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px #1c2b2e14;
}
.stat-icon {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  font-size: 21px;
}
.stat-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 550;
  margin-bottom: 8px;
  padding-right: 48px;
}
.stat-value {
  font-size: 34px;
  letter-spacing: -1px;
  font-weight: 750;
  line-height: 1.1;
}
.stat-note {
  font-size: 13px;
  color: var(--soft);
  margin-top: 6px;
}
.stat-note strong {
  color: var(--brand);
}
.welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 28px 32px;
  background: linear-gradient(120deg, #e3f3ec 0%, #f1f8f4 55%, #fff6e8 100%);
  border: 1px solid #d5ebe0;
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
}
.welcome h2 {
  font-size: 22px;
  letter-spacing: -0.5px;
  max-width: 520px;
}
.welcome p {
  font-size: 15px;
  max-width: 520px;
  margin: 8px 0 18px;
}
.welcome.compact {
  padding: 22px 26px;
}
.welcome.compact h2 {
  font-size: 20px;
}
.welcome-art {
  position: relative;
  flex: 0 0 150px;
  height: 100px;
  display: grid;
  place-items: center;
}
.orb {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  background: white;
  transform: rotate(-8deg);
  box-shadow: 14px 12px 0 #cfe9dc, 0 10px 24px #12896b22;
  display: grid;
  place-items: center;
  font-size: 40px;
}
.float-card {
  position: absolute;
  right: -6px;
  bottom: -4px;
  background: white;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-ink);
  box-shadow: var(--shadow);
  transform: rotate(4deg);
}
.grid-two {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.grid-two + .panel,
.panel + .panel,
.panel + .result-panel {
  margin-top: 20px;
}
.grid-two > .panel + .panel {
  margin-top: 0;
}
.panel.padded {
  padding: 26px;
}
.panel.padded p {
  margin: 8px 0;
}
.panel.padded .secondary {
  margin-top: 12px;
}
.panel-head {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head p {
  font-size: 13px;
}
.summary-note {
  font-size: 14px;
  padding: 14px 18px;
  background: var(--sky-soft);
  border: 1px solid #d3e3f8;
  border-radius: 12px;
  margin-bottom: 20px;
  color: var(--sky-ink);
  display: block;
}
.summary-note .mini {
  margin-left: 6px;
  vertical-align: middle;
}
details.summary-note > summary {
  cursor: pointer;
  font-weight: 650;
  list-style-position: inside;
}
details.summary-note[open] > summary {
  margin-bottom: 6px;
}
.setup {
  background: var(--warm-soft);
  border-color: #f6dfb6;
  color: var(--warm-ink);
}
.setup nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.setup nav a {
  min-height: 0;
  padding: 6px 12px;
  margin: 0;
  border-radius: 999px;
  background: white;
  color: var(--warm-ink);
  font-size: 13px;
}
.setup nav a.current {
  background: var(--warm);
  color: white;
  text-decoration: none;
}
.setup p {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--warm-ink);
}

/* ---------- Bandeja de pendientes ---------- */
.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.todo-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}
.todo-list li:last-child {
  border-bottom: 0;
}
.todo-list li > div {
  flex: 1;
  min-width: 0;
}
.todo-list strong {
  display: block;
  font-size: 15px;
}
.todo-list small {
  display: block;
  font-size: 13px;
  color: var(--muted);
}
.todo-count {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--warm-soft);
  color: var(--warm-ink);
  font-weight: 750;
  display: grid;
  place-items: center;
  font-size: 17px;
}
.todo-count.late {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Tablas ---------- */
.table-wrap {
  overflow: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
}
th {
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 650;
  color: var(--soft);
  padding: 12px 20px;
  white-space: nowrap;
}
td {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
  vertical-align: middle;
}
tbody tr:hover td {
  background: #fbfcfb;
}
td strong {
  color: var(--ink);
  font-weight: 650;
}
td small {
  display: block;
  color: var(--soft);
  font-size: 12.5px;
  margin-top: 2px;
}
td.actions {
  white-space: nowrap;
}
td.actions > * + * {
  margin-left: 6px;
}
.name-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.account-avatar {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e2f5ea;
  color: #1d7a4b;
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
}
.badge.warn {
  background: var(--warm-soft);
  color: var(--warm-ink);
}
.badge.red {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge.neutral {
  background: #eef1f0;
  color: var(--muted);
}
.badge.link-badge {
  margin-left: 6px;
  cursor: help;
}
.channel-card {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}
.channel-card:last-child {
  border-bottom: 0;
}
.channel-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--sky-soft);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.channel-icon.market {
  background: var(--warm-soft);
}
.channel-icon.groups {
  background: var(--brand-soft);
}
.channel-card .badge {
  margin-left: auto;
}

/* ---------- Filtros y búsqueda ---------- */
.section-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 18px;
  gap: 12px;
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  min-height: 44px;
  max-width: 380px;
  width: 100%;
  color: var(--soft);
  font-size: 17px;
}
.search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px #12896b1f;
}
.search input {
  border: 0;
  outline: 0;
  width: 100%;
  padding: 0;
  margin: 0;
  box-shadow: none;
  font-size: 14.5px;
}
.search input:focus {
  box-shadow: none;
}
.section-bar > select,
.inbox-search select {
  width: auto;
  margin: 0;
}
.count-label {
  font-size: 13px;
  color: var(--soft);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.section-bar .chips,
.inbox-tools .chips {
  margin-bottom: 0;
}
.chip {
  border: 1px solid #d4dfda;
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  min-height: 38px;
  font-size: 14px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chip:hover {
  border-color: var(--brand);
}
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.chip-count {
  font-size: 12px;
  font-weight: 700;
  background: #1c2b2e12;
  border-radius: 999px;
  padding: 0 7px;
  line-height: 20px;
}
.chip.active .chip-count {
  background: #ffffff33;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.toolbar label {
  margin: 0;
  min-width: 200px;
}
.toolbar input,
.toolbar select {
  margin-top: 6px;
}
.weekdays {
  align-items: center;
  gap: 14px;
  margin: 12px 0 4px;
}
.metrics-filter label {
  max-width: 200px;
}

/* ---------- Estados vacíos y carga ---------- */
.empty {
  padding: 48px 24px;
  text-align: center;
}
.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  font-size: 30px;
}
.empty h3 {
  font-size: 17px;
}
.empty p {
  max-width: 380px;
  margin: 6px auto 18px;
  font-size: 14px;
}
.loading {
  padding: 48px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.loading:before {
  content: "";
  display: block;
  width: 30px;
  height: 30px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid var(--brand-soft);
  border-top-color: var(--brand);
  animation: spin 0.9s infinite linear;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Catálogo, grupos, creatividades ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.product-card,
.group-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.product-card:hover,
.group-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px #1c2b2e14;
}
.group-card {
  padding: 20px;
}
.group-card h3 {
  margin: 12px 0 4px;
}
.product-visual {
  height: 120px;
  background: linear-gradient(135deg, #e3f3ec, #fff3df);
  display: grid;
  place-items: center;
  font-size: 44px;
}
.creative-image {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: var(--surface-2);
}
.product-info {
  padding: 18px 20px 20px;
}
.product-info .badge {
  float: right;
}
.product-info .eyebrow {
  color: var(--soft);
}
.product-info h3 {
  margin: 4px 0 6px;
  font-size: 16px;
}
.product-info p {
  font-size: 14px;
  min-height: 22px;
}
.channel-label {
  font-size: 13px;
  color: var(--soft);
  margin-top: 6px;
}
.product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.product-bottom > span {
  display: inline-flex;
  gap: 6px;
}
.price {
  font-size: 21px;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.group-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.flow-chip {
  display: inline-block;
  margin: 6px 6px 0 0;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--muted);
}
.result-panel {
  margin-top: 20px;
}
.result-body {
  padding: 20px 22px;
  max-height: 600px;
  overflow: auto;
}
.post-card {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}
.post-card:first-child {
  padding-top: 0;
}
.post-card p {
  white-space: pre-wrap;
}
.post-card a {
  font-size: 13px;
  font-weight: 600;
}
.job-result-pre {
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 14px;
}

/* ---------- Métricas ---------- */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
}
.metric-cards .panel {
  margin: 0;
}
.metric-card h2 {
  font-size: 16px;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.kpi {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
}
.kpi:nth-child(odd) {
  border-right: 1px solid var(--line);
}
.kpi span {
  display: block;
  font-size: 13px;
  color: var(--muted);
}
.kpi strong {
  font-size: 24px;
  font-weight: 750;
}
.kpi small {
  display: block;
  font-size: 12.5px;
  color: var(--soft);
}

/* ---------- Conversaciones ---------- */
.inbox-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.inbox-search {
  display: flex;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
  min-width: 240px;
}
.inbox-search input {
  margin: 0;
  max-width: 300px;
}
.inbox {
  display: grid;
  grid-template-columns: 330px 1fr;
  min-height: 560px;
}
.conversation-list {
  border-right: 1px solid var(--line);
  max-height: 680px;
  overflow: auto;
  background: var(--surface-2);
}
.conversation-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  padding: 16px 18px;
  background: transparent;
  cursor: pointer;
  color: inherit;
}
.conversation-item:hover {
  background: white;
}
.conversation-item.active {
  background: white;
  border-left-color: var(--brand);
}
.conversation-item h3 {
  font-size: 15px;
}
.conversation-item p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13.5px;
  margin-top: 2px;
}
.conversation-item small {
  font-size: 12px;
  color: var(--soft);
}
.dot-warn {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warm);
  vertical-align: middle;
  margin-left: 6px;
}
.list-empty {
  padding: 20px;
}
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.chat-head h3 {
  font-size: 17px;
}
.chat-head h3 .badge {
  vertical-align: middle;
  margin-left: 6px;
}
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.fields-strip {
  display: flex;
  gap: 10px 18px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 12px 22px;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.fields-strip label {
  margin: 0;
  min-width: 240px;
  font-size: 13px;
}
.fields-strip select {
  margin-top: 4px;
  min-height: 38px;
  padding: 6px 10px;
}
.strip-source {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}
.chat-history {
  padding: 22px;
  background: #fbfcfb;
  flex: 1;
  overflow: auto;
  max-height: 480px;
}
.bubble {
  padding: 10px 14px;
  max-width: 78%;
  width: fit-content;
  font-size: 14.5px;
  line-height: 1.5;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  margin: 0 auto 12px 0;
  white-space: pre-wrap;
  color: var(--ink);
  box-shadow: 0 1px 2px #1c2b2e0a;
}
.bubble.assistant {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  margin: 0 0 12px auto;
  border-radius: 16px 16px 4px 16px;
}
.bubble small {
  display: block;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--soft);
  margin-bottom: 2px;
}
.bubble.assistant small {
  color: #d5f0e5;
}
.bubble.pending {
  opacity: 0.7;
  border-style: dashed;
}
.chat-compose {
  display: flex;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: white;
}
.chat-compose input {
  margin: 0;
  border-radius: 999px;
  padding-left: 18px;
}
.chat-compose .primary {
  border-radius: 999px;
}

/* ---------- Formularios ---------- */
label {
  display: block;
  font-size: 14px;
  color: #34474a;
  font-weight: 600;
  margin: 14px 0;
}
input,
select,
textarea {
  border: 1px solid #d4dfda;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 44px;
  background: white;
  color: var(--ink);
  display: block;
  width: 100%;
  margin-top: 6px;
  outline: none;
  font-size: 15px;
  font-weight: 400;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px #12896b1f;
}
input:disabled {
  background: var(--surface-2);
  color: var(--soft);
}
input:user-invalid,
textarea:user-invalid {
  border-color: var(--danger);
}
textarea {
  resize: vertical;
  min-height: 96px;
}
select[multiple] {
  min-height: 110px;
  padding: 6px;
}
select[multiple] option {
  padding: 6px 8px;
  border-radius: 6px;
}
label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  min-height: 32px;
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  accent-color: var(--brand);
}
input[type="file"] {
  padding: 8px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.full {
  grid-column: 1/-1;
}
.hint {
  display: block;
  font-size: 13px;
  color: var(--soft);
  font-weight: 400;
  margin-top: 6px;
}
.error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 550;
}
.editor-step {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 14px;
  padding: 16px;
  background: var(--surface-2);
}
.step-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.step-heading strong {
  font-size: 15px;
}
details.form-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  margin: 16px 0;
  background: var(--surface-2);
}
details.form-section > summary {
  cursor: pointer;
  font-size: 15px;
  font-weight: 650;
  min-height: 28px;
}

/* ---------- Diálogos y avisos ---------- */
dialog {
  border: 0;
  border-radius: 20px;
  padding: 26px;
  width: min(680px, calc(100vw - 24px));
  max-height: 90vh;
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop {
  background: #1c2b2e66;
  backdrop-filter: blur(3px);
}
.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.modal-heading h2 {
  font-size: 21px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 20px;
}
.modal-sections {
  position: sticky;
  top: -26px;
  z-index: 2;
  background: white;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line);
}
#modal-fields > h3 {
  margin: 24px 0 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 17px;
  scroll-margin-top: 70px;
}
dialog.confirm {
  width: min(440px, calc(100vw - 24px));
}
dialog.confirm h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
dialog.confirm p {
  font-size: 15px;
  color: var(--muted);
}
.toast {
  position: fixed;
  right: 24px;
  top: 76px;
  cursor: pointer;
  background: var(--ink);
  color: white;
  padding: 14px 20px;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  font-size: 15px;
  font-weight: 550;
  z-index: 50;
  max-width: min(460px, calc(100vw - 32px));
  animation: rise 0.2s ease-out;
}
.toast:before {
  content: "✓ ";
  color: #7fe0b7;
}
.toast.error {
  background: var(--danger);
}
.toast.error:before {
  content: "⚠ ";
  color: white;
}
@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

/* ---------- Acceso ---------- */
.login {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.login-art {
  padding: 52px;
  background: linear-gradient(150deg, #12896b 0%, #0c6f56 60%, #0a5847 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  position: relative;
  overflow: hidden;
}
.login-art:after {
  content: "";
  position: absolute;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  right: -180px;
  bottom: -160px;
  background: #ffffff10;
  box-shadow: 0 0 0 70px #ffffff0a, 0 0 0 140px #ffffff06;
  pointer-events: none;
}
.login-art .brand {
  color: white;
}
.login-art .brandmark {
  background: white;
  color: var(--brand);
}
.login-art h1 {
  font-size: 44px;
  line-height: 1.15;
  letter-spacing: -1.5px;
}
.login-art .eyebrow {
  color: #ffd79a;
  margin-bottom: 18px;
}
.login-art p {
  color: #d5efe4;
  font-size: 17px;
  margin-top: 18px;
}
.art-foot {
  font-size: 13px;
  font-weight: 600;
  color: #bfe6d5;
}
.login-form {
  max-width: 420px;
  width: 100%;
  margin: auto;
  padding: 36px;
  background: white;
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.login-form h2 {
  font-size: 28px;
  margin-bottom: 6px;
}
.login-form p {
  font-size: 15px;
  margin-bottom: 8px;
}
.login-form label {
  margin-top: 18px;
}
.login-form .hint {
  margin: 10px 0 18px;
}
.login-form .primary {
  width: 100%;
  min-height: 50px;
  font-size: 16px;
}
.login-form .text-link {
  margin-top: 12px;
}
#login-error {
  color: var(--danger);
  font-weight: 550;
}

/* ---------- Pantallas grandes y pequeñas ---------- */
@media (max-width: 1180px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-two {
    grid-template-columns: 1fr;
  }
  .grid-two > .panel + .panel {
    margin-top: 0;
  }
  .inbox {
    grid-template-columns: 280px 1fr;
  }
}
@media (max-width: 860px) {
  :root {
    --sidebar-w: 280px;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  main {
    margin-left: 0;
  }
  #menu-toggle {
    display: grid;
  }
  .topbar {
    padding: 0 16px;
    height: 62px;
  }
  .topbar-end {
    margin-left: auto;
    gap: 8px;
  }
  #last-update {
    display: none;
  }
  .page {
    padding: 22px 16px 36px;
  }
  .page-heading {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 20px;
  }
  .page-actions > * {
    flex: 1;
  }
  h1 {
    font-size: 25px;
  }
  .stats {
    gap: 10px;
  }
  .stat {
    padding: 16px;
  }
  .stat-icon {
    width: 34px;
    height: 34px;
    font-size: 17px;
    right: 12px;
    top: 12px;
  }
  .stat-value {
    font-size: 28px;
  }
  .welcome {
    padding: 22px;
  }
  .welcome-art {
    display: none;
  }
  .inbox {
    grid-template-columns: 1fr;
  }
  .conversation-list {
    max-height: 240px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .chat-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .chat-actions {
    justify-content: flex-start;
  }
  .chat-history {
    padding: 16px;
  }
  .bubble {
    max-width: 90%;
  }
  .inbox-search {
    flex-wrap: wrap;
    min-width: 0;
    width: 100%;
  }
  .inbox-search input,
  .inbox-search select {
    flex: 1 1 100%;
    max-width: none;
    width: 100%;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .full {
    grid-column: auto;
  }
  .todo-list li {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .metric-cards {
    grid-template-columns: 1fr;
  }
  .metrics-filter label,
  .toolbar label {
    max-width: none;
    width: 100%;
  }
  .toolbar > .primary,
  .toolbar > .secondary {
    flex: 1;
  }
  th,
  td {
    padding: 12px 14px;
  }
  td.actions {
    white-space: normal;
  }
  td.actions > * {
    margin: 2px 0;
  }
  td.actions > * + * {
    margin-left: 0;
  }
  dialog {
    padding: 20px;
    border-radius: 18px;
  }
  .modal-sections {
    top: -20px;
  }
  .login {
    grid-template-columns: 1fr;
  }
  .login-art {
    min-height: 0;
    padding: 28px 24px;
    gap: 18px;
  }
  .login-art h1 {
    font-size: 28px;
  }
  .login-art .eyebrow,
  .art-foot,
  .login-art p {
    display: none;
  }
  .login-form {
    margin: -18px 16px 24px;
    width: auto;
    padding: 26px 22px;
    position: relative;
  }
  footer {
    padding: 14px 16px;
  }
  footer span {
    display: none;
  }
  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Iconos ---------- */
.ic {
  width: 1em;
  height: 1em;
  display: block;
  flex: 0 0 auto;
}
nav a .nav-icon {
  font-size: 20px;
  display: grid;
  place-items: center;
  color: var(--soft);
}
nav a:hover .nav-icon,
nav a.active .nav-icon {
  color: var(--brand);
}
.stat-icon {
  color: var(--brand);
}
.empty-icon {
  color: var(--brand);
}
.orb {
  color: var(--brand);
  font-size: 42px;
}
.product-visual {
  color: #7fb39d;
  font-size: 48px;
}
.todo-count .ic {
  font-size: 20px;
}
.channel-icon {
  color: var(--brand);
}
.float-card,
.panel-head .text-link {
  white-space: nowrap;
}
.todo-count.ok {
  background: var(--brand-soft);
  color: var(--brand);
}
.ai-card {
  margin-bottom: 20px;
}
.ai-card .todo-count .ic {
  font-size: 20px;
}

/* ---------- Publicaciones de Marketplace ---------- */
.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sync-list {
  list-style: none;
  margin: 0;
  padding: 14px 16px;
  min-width: 0;
  max-width: 380px;
  background: #ffffffb3;
  border: 1px solid #d5ebe0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: grid;
  gap: 8px;
}
.sync-list li {
  display: grid;
  gap: 2px;
}
.sync-list span {
  color: var(--muted);
}
.spinner-inline {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}
.listing-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.listing-filter .ic {
  width: 18px;
  height: 18px;
}
details.more-tools {
  padding: 16px 20px;
}
details.more-tools > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
}
details.more-tools[open] > summary {
  margin-bottom: 14px;
}
.photo-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.photo-pick {
  position: relative;
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--line);
  cursor: pointer;
}
.photo-pick:has(input:checked) {
  border-color: var(--brand);
}
.photo-pick input {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 18px;
  height: 18px;
  min-height: 0;
}
.photo-pick img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
@media (max-width: 760px) {
  .welcome:has(.sync-list) {
    flex-wrap: wrap;
  }
  .welcome .sync-list {
    max-width: none;
    width: 100%;
  }
}
.chat-import {
  margin-bottom: 16px;
}
.chat-import > summary {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-import > summary .ic {
  width: 18px;
  height: 18px;
}
.chat-import > summary .mini {
  margin-left: auto;
}
.chat-import .sync-list {
  max-width: none;
  margin-top: 8px;
}

/* ---------- Bandeja de chats (rediseño) ---------- */
.inbox {
  grid-template-columns: 360px 1fr;
  min-height: 640px;
}
.conversation-list {
  max-height: 760px;
}
.conversation-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
}
.conversation-item.unread .conv-top strong {
  font-weight: 800;
}
.conv-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
}
.conv-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.conv-avatar.big {
  flex-basis: 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.conv-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.conv-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.conv-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14.5px;
}
.conv-top time {
  flex: none;
  font-size: 12px;
  color: var(--soft);
}
.conv-listing,
.conv-last {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-listing {
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.conv-listing > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-listing .ic {
  flex: none;
  width: 13px;
  height: 13px;
}
.conv-last {
  color: var(--muted);
}
.conv-flags {
  display: grid;
  gap: 6px;
  justify-items: end;
}
.chat-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.chat-title p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.listing-ref {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--warm-soft);
  flex-wrap: wrap;
}
.listing-ref img,
.listing-ref-icon {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: white;
  display: grid;
  place-items: center;
  flex: none;
}
.listing-ref-info {
  flex: 1;
  min-width: 160px;
  display: grid;
  gap: 2px;
}
.listing-ref-info small {
  color: var(--warm-ink);
  font-size: 12px;
}
.listing-ref-info strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.listing-ref-info span {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-ink);
}
.listing-ref-bot {
  font-size: 12px;
  display: grid;
  gap: 2px;
}
.listing-ref-bot select {
  min-height: 34px;
  padding: 4px 8px;
}
.mode-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.mode-bar > div {
  flex: 1;
  display: grid;
}
.mode-bar small {
  color: var(--muted);
}
.mode-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--soft);
}
.mode-ai .mode-dot {
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.mode-human {
  background: var(--warm-soft);
}
.mode-human .mode-dot {
  background: var(--warm);
}
.chat-details > summary {
  padding: 8px 22px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.chat-history {
  max-height: 520px;
  min-height: 260px;
}
.bubble small {
  display: block;
}
.bubble.team {
  background: #e8f1fd;
  border-color: #cfe0f7;
  color: var(--ink);
  margin: 0 0 12px auto;
  border-radius: 16px 16px 4px 16px;
}
.bubble.team small {
  color: var(--sky-ink);
}
.chat-compose {
  flex-direction: column;
  gap: 8px;
}
.compose-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.compose-tools .ic {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}
.compose-tools select {
  width: auto;
  min-height: 34px;
  padding: 4px 10px;
  font-size: 13px;
}
.compose-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.compose-row textarea {
  margin: 0;
  flex: 1;
  resize: vertical;
  min-height: 46px;
  max-height: 200px;
  border-radius: 14px;
}
.chat-compose > .hint {
  margin: 0;
  font-size: 12px;
}
.quick-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.quick-list[hidden] {
  display: none;
}
.quick-list .hint {
  margin: 6px 8px;
}
.quick-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.quick-item small {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.quick-item.active,
.quick-item:hover {
  background: var(--brand-soft);
}

/* ---------- Asistente y negocio ---------- */
.meter {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  margin: 10px 0;
}
.meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #3fb98f);
}
.assistant-top {
  margin-bottom: 18px;
}
.section-title {
  margin: 22px 0 12px;
}
.biz-score {
  display: grid;
  gap: 6px;
}
.biz-score .meter {
  margin: 0;
}
.biz-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 10px;
}
.biz-row input,
.biz-row textarea {
  margin: 0;
}
.sticky-save {
  position: sticky;
  bottom: 0;
  padding: 14px 0;
  background: linear-gradient(transparent, var(--bg) 35%);
}
@media (max-width: 860px) {
  .inbox {
    grid-template-columns: 1fr;
  }
  .conversation-list {
    max-height: 300px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .biz-row {
    grid-template-columns: 1fr;
  }
  .listing-ref,
  .mode-bar,
  .chat-head {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* ---------- Motor de respuestas y grupos ---------- */
.radio-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
}
.radio-row:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.radio-row input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin-top: 3px;
}
.radio-row span {
  display: grid;
  gap: 2px;
}
.radio-row small {
  color: var(--muted);
}
.profile-list {
  list-style: none;
  margin: 0;
  display: grid;
  gap: 10px;
}
.profile-list li {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: center;
}
.profile-list small {
  color: var(--muted);
}
.image-engine,
.groups-panel {
  margin-bottom: 18px;
}
.ai-group.off {
  opacity: 0.85;
  background: var(--surface-2);
}
.ai-group-head {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------- Ajustes de usabilidad ---------- */
.hint {
  color: var(--muted);
}
:focus-visible {
  outline: 3px solid var(--brand-strong);
  outline-offset: 2px;
}
/* The chat fills the screen so the box to write stays visible. */
.inbox {
  height: calc(100dvh - 300px);
  min-height: 520px;
}
.inbox .conversation-list {
  max-height: none;
  overflow: auto;
}
.inbox .chat {
  min-height: 0;
}
.inbox .chat-history {
  max-height: none;
  min-height: 0;
  flex: 1;
}
.chat-back {
  display: none;
}
@media (max-width: 860px) {
  .inbox {
    height: auto;
    min-height: 0;
  }
  .inbox .conversation-list {
    max-height: 70dvh;
  }
  .inbox .chat {
    display: none;
  }
  .inbox.show-chat .conversation-list {
    display: none;
  }
  .inbox.show-chat .chat {
    display: flex;
    min-height: 80dvh;
  }
  .chat-back {
    display: inline-flex;
  }
  .toast {
    top: 12px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
}

/* ---------- Modelos de atención ---------- */
.attention-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.att-stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-align: left;
  font: inherit;
  min-width: 0;
}
.att-stat strong {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: -0.5px;
}
.att-stat > span:last-child {
  grid-column: 2;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.att-stat small {
  font-size: 13px;
}
.att-icon {
  grid-row: 1 / span 2;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.att-icon .ic {
  width: 22px;
  height: 22px;
}
.att-stat.ai .att-icon {
  background: var(--sky-soft);
  color: var(--sky-ink);
}
.att-stat.team .att-icon {
  background: var(--warm-soft);
  color: var(--warm-ink);
}
button.att-stat {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
button.att-stat:hover {
  border-color: var(--warm);
  box-shadow: 0 10px 28px #1c2b2e14;
}
.models-panel {
  margin-bottom: 20px;
}
.models-panel > .result-body {
  max-height: none;
  overflow: visible;
}
.models-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.models-tools .chips {
  margin-bottom: 0;
}
.models-tools input {
  margin: 0;
  max-width: 260px;
}
.model-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.model-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  min-width: 0;
}
.model-card.on {
  border-left-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.model-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.model-top .badge {
  margin-left: auto;
  flex: none;
}
.model-thumbs {
  display: flex;
  flex: none;
}
.model-thumbs img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid var(--surface);
  background: var(--surface-2);
}
.model-thumbs img + img {
  margin-left: -16px;
}
.model-thumbs.no-photo .ic {
  width: 22px;
  height: 22px;
}
.model-thumbs.no-photo {
  align-self: flex-start;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
}
.model-title {
  min-width: 0;
}
.model-title h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.model-price {
  margin: 2px 0 0;
  font-weight: 700;
  color: var(--brand-ink);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.model-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.model-meta div {
  min-width: 0;
}
.model-meta div:first-child {
  grid-column: 1 / -1;
}
.model-meta dt {
  font-size: 12px;
  color: var(--muted);
}
.model-meta dd {
  margin: 0;
  font-weight: 650;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.model-card .hint,
.model-note {
  margin: 0;
}
.model-note {
  font-size: 13px;
  color: var(--warm-ink);
  background: var(--warm-soft);
  border-radius: 8px;
  padding: 6px 10px;
}
.model-listings {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
}
.model-listings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.model-listings h4 {
  margin: 0;
  font-size: 13px;
}
.model-listings ul {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.model-listings li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
}
.model-listings li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.model-listings li small {
  color: var(--muted);
  flex: none;
}
.model-listings .hint {
  margin: 6px 0 0;
}
.model-actions {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* Interruptor accesible: un checkbox real con role="switch". */
.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.switch-row input {
  position: absolute;
  z-index: 1;
  opacity: 0;
  width: 46px;
  height: 26px;
  margin: 0;
  cursor: pointer;
}
.switch {
  flex: none;
  width: 46px;
  height: 26px;
  border-radius: 99px;
  background: #c9d4d0;
  position: relative;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px #1c2b2e40;
  transition: transform 0.15s;
}
.switch-row input:checked + .switch {
  background: var(--brand);
}
.switch-row input:checked + .switch::after {
  transform: translateX(20px);
}
.switch-row input:focus-visible + .switch {
  outline: 3px solid var(--brand-strong);
  outline-offset: 2px;
}
.switch-row input:disabled + .switch {
  opacity: 0.5;
}
.switch-row:has(input:checked) {
  border-color: #bfe3d3;
  background: var(--brand-soft);
}
.switch-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.switch-text strong {
  font-size: 14px;
}
.switch-text small {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}
.model-extra {
  margin-top: 18px;
  padding: 12px 16px;
  border: 1px dashed #cdd9d4;
  border-radius: var(--radius-sm);
}
.model-extra > summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}
.model-extra .ic {
  width: 18px;
  height: 18px;
}
.model-extra .meter {
  margin: 10px 0 4px;
}
.engine-tools {
  margin-top: 20px;
}
.engine-tools > summary {
  display: flex;
  align-items: center;
  gap: 8px;
}
.engine-tools .ic {
  width: 18px;
  height: 18px;
}
.engine-tools .panel {
  box-shadow: none;
}
.engine-tools .ai-card {
  margin-bottom: 16px;
}
.rules-list {
  list-style: none;
  margin: 0;
  display: grid;
  gap: 12px;
}
.rules-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--muted);
}
.rules-list li strong {
  color: var(--ink);
}
.rules-list .ic {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--brand);
  margin-top: 2px;
}
/* Editor de modelo */
.compose-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--sky-soft);
}
.compose-status {
  flex: 1 1 260px;
  margin: 0;
  font-size: 13px;
  color: var(--sky-ink);
}
.compose-status.busy {
  font-weight: 600;
}
.compose-status.ok {
  color: var(--brand-ink);
  font-weight: 600;
}
.compose-status.failed {
  color: var(--danger);
  font-weight: 600;
}
#modal-fields .switch-row {
  margin-top: 8px;
}
/* Demo */
.demo-note {
  margin-bottom: 12px;
}
.demo-chat {
  min-height: 200px;
  max-height: 44vh;
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line);
}
.demo-chat .bubble {
  max-width: 85%;
}
.demo-empty {
  margin: 60px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.demo-human {
  display: block;
  margin-top: 8px;
  padding: 2px 8px;
  width: fit-content;
  border-radius: 99px;
  background: var(--warm-soft);
  color: var(--warm-ink);
  font-size: 12px;
  font-weight: 700;
}
.demo-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.demo-tools .suggestions {
  margin: 0;
}
.demo-tools .chip {
  min-height: 34px;
  font-size: 13px;
}
/* Asignar publicaciones */
.assign-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.assign-tools input {
  margin: 0;
  flex: 1 1 200px;
}
.assign-tools .chips {
  margin: 0;
}
.assign-count {
  font-size: 13px;
  font-weight: 650;
  color: var(--brand-ink);
  margin: 10px 0 6px;
}
.assign-list {
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.assign-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
  cursor: pointer;
}
.assign-row:last-child {
  border-bottom: 0;
}
.assign-row:hover {
  background: var(--surface-2);
}
.assign-row:has(input:checked) {
  background: var(--brand-soft);
}
.assign-row img,
.assign-ph {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--soft);
}
.assign-info {
  display: grid;
  min-width: 0;
}
.assign-info strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.assign-info small {
  font-size: 12.5px;
  color: var(--muted);
}
.assign-model.mine {
  color: var(--brand-ink);
  font-weight: 650;
}
.assign-model.other {
  color: var(--warm-ink);
}
/* Publicación: quién la atiende */
.model-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 650;
  font-style: normal;
  padding: 3px 10px;
  border-radius: 99px;
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.model-tag .ic {
  width: 14px;
  height: 14px;
  flex: none;
}
.model-tag.on {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.model-tag.off {
  background: var(--warm-soft);
  color: var(--warm-ink);
}
.listing-ref-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.listing-ref-controls .listing-ref-bot {
  margin: 0;
}
.listing-ref-info .model-tag {
  margin-top: 2px;
}
@media (max-width: 860px) {
  .attention-summary {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .att-stat {
    padding: 12px 14px;
  }
  .att-stat strong {
    font-size: 24px;
  }
  .model-list {
    grid-template-columns: minmax(0, 1fr);
  }
  .models-tools input {
    max-width: none;
  }
  .listing-ref-controls,
  .listing-ref-controls .listing-ref-bot {
    width: 100%;
  }
  .listing-ref-controls .listing-ref-bot select {
    width: 100%;
  }
}
.inbox-search #listing-model-filter {
  max-width: 230px;
  margin: 0;
}
.inbox-search #listing-search {
  min-width: 180px;
}
@media (max-width: 860px) {
  .inbox-search #listing-model-filter {
    max-width: none;
  }
}
#engine-form .switch-row {
  margin: 14px 0;
}
/* Marketplace: bulk selection of publications */
.bulk-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.bulk-bar #market-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---- Generar publicaciones (borradores de un modelo) ---- */
#draft-box {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}
.draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.draft-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: 420px;
  overflow: auto;
}
.draft-item {
  border-bottom: 1px solid var(--line);
}
.draft-item:last-child {
  border-bottom: 0;
}
.draft-item > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.draft-item[open] > summary {
  background: var(--surface-2);
}
.draft-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.draft-price {
  color: var(--muted);
  white-space: nowrap;
}
.draft-body {
  display: grid;
  gap: 10px;
  padding: 10px 12px 14px;
}
.draft-thumbs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.draft-thumbs img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.draft-error {
  color: var(--danger);
}

/* ---------- Conversaciones a pantalla completa ----------
   La bandeja ocupa el resto de la ventana (fitInbox fija la altura): la lista
   y el chat tienen su propio scroll y el cuadro de respuesta queda siempre a
   la vista. Los filtros viven en la cabecera de la lista. */
body.chat-view .page {
  padding-top: 12px;
  padding-bottom: 12px;
}
body.chat-view .page-heading,
body.chat-view footer {
  display: none;
}
.inbox {
  min-height: 0;
  overflow: hidden;
}
.conv-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}
.inbox .conv-col .conversation-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  border-right: 0;
}
.conv-list-head {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.conv-list-head .inbox-search {
  min-width: 0;
  gap: 6px;
  justify-content: stretch;
}
.conv-list-head .inbox-search input {
  max-width: none;
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}
.conv-list-head .inbox-search select {
  width: auto;
  max-width: 130px;
  min-height: 36px;
  padding: 4px 8px;
  font-size: 13px;
  margin: 0;
}
.conv-tabs .chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  scrollbar-width: thin;
  padding-bottom: 2px;
}
.conv-tabs .chip {
  flex: none;
  min-height: 30px;
  padding: 3px 10px;
  font-size: 12.5px;
}
.conv-list-head .listing-filter {
  margin: 0;
  padding: 6px 8px;
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.conv-col .chat-import {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  font-size: 13px;
}
.conv-col .chat-import > summary {
  padding: 8px 12px;
}
.conv-col .chat-import[open] {
  max-height: 40%;
  overflow: auto;
}
.inbox .conversation-item {
  padding: 10px 12px;
  gap: 10px;
}
.inbox .conv-avatar {
  flex-basis: 38px;
  width: 38px;
  height: 38px;
}
.inbox .chat {
  min-height: 0;
  overflow: hidden;
}
.inbox .chat-head {
  padding: 8px 16px;
  flex: none;
}
.inbox .chat-head h3 {
  font-size: 15px;
}
.inbox .chat-head .conv-avatar.big {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  font-size: 12px;
}
.chat-context {
  display: flex;
  flex-wrap: wrap;
  flex: none;
  border-bottom: 1px solid var(--line);
}
.chat-context .listing-ref {
  flex: 1 1 300px;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 6px 16px;
  border-bottom: 0;
}
.chat-context .listing-ref img,
.chat-context .listing-ref-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.chat-context .listing-ref-info {
  min-width: 0;
  gap: 0;
}
.chat-context .listing-ref-info strong {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-context .listing-ref-info span {
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.chat-context .listing-ref-info .model-tag {
  margin: 0;
}
.chat-context .mode-bar {
  flex: 1 1 260px;
  min-width: 0;
  padding: 6px 16px;
  border-bottom: 0;
}
.chat-context .mode-bar > div {
  min-width: 0;
}
.chat-context .mode-bar small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}
.inbox .chat-details {
  flex: none;
}
.inbox .chat-details > summary {
  padding: 5px 16px;
  font-size: 12.5px;
}
.chat-details-body {
  max-height: 30vh;
  overflow: auto;
  padding: 8px 16px;
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.chat-details-body .fields-strip {
  padding: 0;
  border: 0;
}
.inbox .chat-history {
  flex: 1;
  min-height: 0;
  max-height: none;
  padding: 14px 16px;
}
.inbox .chat-compose {
  flex: none;
  gap: 6px;
  padding: 8px 16px 10px;
}
.inbox .compose-row textarea {
  min-height: 44px;
  max-height: 30vh;
  padding: 10px 12px;
}
.inbox .compose-tools {
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}
.inbox .compose-tools .mini,
.inbox .compose-tools .text-link {
  flex: none;
  min-height: 30px;
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 12.5px;
}
.inbox .compose-tools .hint {
  margin: 0 0 0 auto;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
@media (max-width: 860px) {
  body.chat-view .page {
    padding: 8px 8px 8px;
  }
  .inbox {
    grid-template-columns: minmax(0, 1fr);
  }
  .inbox .conv-col {
    border-right: 0;
  }
  .inbox .conv-col .conversation-list {
    max-height: none;
  }
  .inbox.show-chat .conv-col {
    display: none;
  }
  .inbox.show-chat .chat {
    min-height: 0;
  }
  .inbox .chat-head {
    padding: 6px 10px;
  }
  .chat-context .listing-ref,
  .chat-context .mode-bar {
    padding: 5px 10px;
    flex-basis: 100%;
  }
  .chat-context .mode-bar small {
    display: none;
  }
  .inbox .chat-compose {
    padding: 6px 10px 8px;
  }
  .inbox .compose-tools .hint {
    display: none;
  }
  .inbox .chat-history {
    padding: 10px;
  }
}
/* Vista de chat: solo queda la navegación de la app; la barra superior se
   oculta en escritorio (Actualizar vive en la cabecera de la lista). */
@media (min-width: 861px) {
  body.chat-view .topbar {
    display: none;
  }
}
.conv-list-head {
  grid-template-columns: minmax(0, 1fr);
}
.conv-list-head > * {
  min-width: 0;
}
.conv-col,
.inbox .chat {
  overflow: hidden;
}
.conv-toolbar {
  align-items: center;
}
.icon-tool {
  flex: none;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-tool:hover,
.icon-tool:focus-visible {
  color: var(--brand-ink);
  border-color: var(--brand);
}
.icon-tool .ic {
  width: 18px;
  height: 18px;
}
.chat-context .listing-ref {
  background: transparent;
}
.chat-context .mode-bar small {
  display: none;
}
.chat-context .mode-bar .mini,
.chat-context .mode-bar .secondary {
  min-height: 30px;
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 12.5px;
}
@media (max-width: 860px) {
  .inbox .chat-head {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .inbox .chat-title {
    flex: 1;
    gap: 8px;
  }
  .inbox .chat-title .conv-avatar,
  .inbox .chat-title p {
    display: none;
  }
  .inbox .chat-title h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .inbox .chat-title > div {
    min-width: 0;
  }
  .inbox .chat-back,
  .inbox .chat-actions .mini {
    min-height: 30px;
    padding: 3px 8px;
    font-size: 12px;
  }
  .inbox .chat-actions {
    flex-wrap: nowrap;
    gap: 4px;
  }
  .chat-context .listing-ref img,
  .chat-context .listing-ref-icon {
    width: 30px;
    height: 30px;
  }
}
@media (max-width: 860px) {
  .inbox .chat-title {
    flex: 1 0 40%;
  }
  .inbox .chat-actions {
    min-width: 0;
    overflow-x: auto;
  }
}
/* Agrupar con IA: banner at the top of «Modelos de atención». */
.grouping-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand-soft);
}
.grouping-banner-text {
  flex: 1 1 320px;
  min-width: 0;
}
.grouping-banner h3 {
  margin: 0 0 4px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.grouping-banner p {
  margin: 0;
  font-size: 14px;
}
.grouping-banner .meter {
  margin: 10px 0 0;
}
.grouping-banner > .hint {
  flex-basis: 100%;
  margin: 0;
}
/* Offering type and its data on each model card. */
.model-type-box {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.model-type-box .hint {
  margin: 0;
}
.model-type {
  font-size: 13px;
  font-weight: 650;
}
.model-type select {
  margin-top: 4px;
}
.model-progress {
  display: grid;
  gap: 4px;
  font-size: 13px;
}
.model-progress .meter {
  margin: 0;
}
.model-proposal {
  display: grid;
  gap: 8px;
}
.req {
  color: var(--warm-ink);
  font-weight: 600;
  font-size: 12px;
}
.model-rules {
  margin: 12px 0;
  font-size: 13px;
}
.model-rules summary {
  cursor: pointer;
  font-weight: 650;
}
.model-rules ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

/* =====================================================================
   Bandeja 2.0 · [menú] [bandejas] [lista] [chat + cajón de detalles]
   Todo bajo .nx-* para no chocar con las reglas anteriores de .inbox.
   ===================================================================== */
:root {
  --nx-rail-w: 240px;
  --nx-list-w: 320px;
  --nx-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
body.chat-view .page {
  padding: 0;
  max-width: none;
}
body.chat-view main {
  min-height: 0;
}

/* ---------- Menú de la app: indicador activo y modo compacto ---------- */
nav a {
  position: relative;
}
nav a.active::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand);
}
nav a .nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-group {
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 1px;
}
.nav-collapse {
  position: absolute;
  top: 26px;
  right: 12px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--soft);
  font-size: 18px;
  transition: background 0.15s, color 0.15s;
}
.nav-collapse:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--brand-ink);
}
.sidebar .logout {
  display: flex;
  gap: 6px;
  align-items: center;
}
@media (min-width: 861px) {
  body.nav-mini {
    --sidebar-w: 72px;
  }
  .sidebar,
  main {
    transition: width 0.2s var(--nx-ease), margin 0.2s var(--nx-ease);
  }
  body.nav-mini .sidebar {
    padding: 16px 10px 12px;
    align-items: stretch;
  }
  body.nav-mini .sidebar .brand {
    font-size: 0;
    padding: 0;
    justify-content: center;
  }
  body.nav-mini .brand-dot,
  body.nav-mini .workspace > div,
  body.nav-mini .nav-label,
  body.nav-mini #connection-label,
  body.nav-mini .sidebar-bottom small {
    display: none;
  }
  body.nav-mini .nav-collapse {
    position: static;
    margin: 10px auto 0;
    transform: scaleX(-1);
  }
  body.nav-mini .workspace {
    padding: 6px;
    justify-content: center;
    margin: 10px 0 4px;
  }
  body.nav-mini .nav-group {
    font-size: 0;
    height: 1px;
    padding: 0;
    margin: 10px 8px;
    background: var(--line);
  }
  body.nav-mini nav a {
    justify-content: center;
    padding: 9px 0;
  }
  body.nav-mini nav a .nav-count {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    font-size: 10px;
    box-shadow: 0 0 0 2px var(--surface);
  }
  body.nav-mini .sidebar-bottom {
    padding: 10px 0 0;
    display: grid;
    justify-items: center;
  }
  body.nav-mini .logout {
    font-size: 18px;
    padding: 8px 0 2px;
  }
}
@media (max-width: 860px) {
  .nav-collapse {
    display: none;
  }
}

/* ---------- Estructura de la bandeja ---------- */
.nx-inbox {
  display: grid;
  grid-template-columns: var(--nx-rail-w) var(--nx-list-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 380px;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.nx-welcome {
  margin: 32px;
}

/* ---------- Columna de bandejas ---------- */
.nx-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, var(--surface-2), #f1f6f3);
  border-right: 1px solid var(--line);
}
.nx-rail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 10px 10px;
  scrollbar-width: thin;
}
.nx-rail-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--soft);
  padding: 14px 10px 6px;
}
.nx-rail-main {
  padding-top: 2px;
}
.nx-folders,
.nx-rail-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}
.nx-folder,
.nx-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #3d5053;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s, transform 0.15s var(--nx-ease);
}
.nx-folder:hover,
.nx-filter:hover {
  background: #e9f0ec;
  color: var(--ink);
}
.nx-folder.active,
.nx-filter.active {
  background: var(--surface);
  color: var(--brand-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px #1c2b2e14, 0 0 0 1px var(--line);
}
.nx-folder:active,
.nx-filter:active {
  transform: scale(0.98);
}
.nx-folder-ic {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}
.nx-folder.active .nx-folder-ic {
  background: var(--brand);
  color: white;
}
.nx-folder-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nx-count {
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e1e9e5;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.nx-folder[data-value="reply"] .nx-count {
  background: var(--warm);
  color: white;
}
.nx-folder.active .nx-count {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.nx-count.bump {
  animation: nx-bump 0.6s var(--nx-ease);
}
@keyframes nx-bump {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.35);
    box-shadow: 0 0 0 4px #f59e2e33;
  }
  100% {
    transform: scale(1);
  }
}
.nx-filter {
  min-height: 34px;
  font-size: 13px;
  padding: 6px 10px;
}
.nx-filter small {
  color: var(--soft);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.nx-dot {
  width: 9px;
  height: 9px;
  flex: none;
  margin: 0 8px 0 8px;
  border-radius: 50%;
  background: var(--soft);
}
.nx-dot.direct,
.nx-dot.ai {
  background: #2bb673;
  box-shadow: 0 0 0 3px #2bb67326;
}
.nx-dot.browser {
  background: var(--warm);
  box-shadow: 0 0 0 3px #f59e2e26;
}
.nx-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px #c4483d22;
}
.nx-dot.off {
  background: #c3cecb;
}
.nx-dot.all {
  background: transparent;
  border: 2px solid #b8c6c1;
}
.nx-rail-foot {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.nx-rail-foot .icon-tool {
  width: 34px;
  height: 34px;
  min-height: 34px;
}

/* ---------- Lista de chats ---------- */
.nx-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.nx-list-head {
  display: grid;
  gap: 10px;
  padding: 16px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.nx-list-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.nx-list-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nx-list-title span {
  font-size: 12px;
  color: var(--soft);
  white-space: nowrap;
}
.nx-search {
  position: relative;
  display: block;
  margin: 0;
}
.nx-search > span {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--soft);
  font-size: 16px;
  pointer-events: none;
}
.nx-search input {
  width: 100%;
  margin: 0;
  min-height: 38px;
  padding: 7px 12px 7px 34px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13.5px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.nx-search input:focus {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px #12896b1f;
  outline: none;
}
.nx-list-head .listing-filter {
  margin: 0;
  padding: 7px 10px;
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.nx-list .conversation-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 6px;
  border: 0;
  scrollbar-width: thin;
}
.nx-inbox .conversation-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 10px;
  margin: 0 0 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  color: var(--ink);
  position: relative;
  transition: background 0.15s;
}
.nx-inbox .conversation-item:hover {
  background: var(--surface-2);
}
.nx-inbox .conversation-item.active {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}
.nx-av {
  position: relative;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.nx-av.big {
  width: 46px;
  height: 46px;
  font-size: 15px;
}
.av-0 { background: #dff3ea; color: #0b5c48; }
.av-1 { background: #e3ecfb; color: #2c5c9a; }
.av-2 { background: #fdebd8; color: #8a5a12; }
.av-3 { background: #f6e3f1; color: #8a2f6f; }
.av-4 { background: #e8e4fa; color: #4b3b9a; }
.av-5 { background: #dcf1f4; color: #1d6773; }
.av-6 { background: #fbe4e1; color: #9a3a30; }
.av-7 { background: #eef2d9; color: #5b6516; }
.nx-av-live {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
  animation: nx-pulse 1.6s ease-in-out infinite;
}
@keyframes nx-pulse {
  50% {
    box-shadow: 0 0 0 5px #12896b26;
  }
}
.nx-item-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.nx-item-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.nx-item-top strong {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation-item.unread .nx-item-top strong {
  font-weight: 750;
}
.nx-item-top time {
  flex: none;
  font-size: 11.5px;
  color: var(--soft);
}
.conversation-item.unread .nx-item-top time {
  color: var(--brand);
  font-weight: 650;
}
.nx-item-listing {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--warm-ink);
}
.nx-item-listing img,
.nx-item-listing .ic {
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 4px;
  object-fit: cover;
}
.nx-item-listing > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nx-item-last {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.nx-item-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation-item.unread .nx-item-text {
  color: var(--ink);
  font-weight: 550;
}
.nx-item-text.typing {
  color: var(--brand);
  font-style: italic;
}
.nx-unread {
  min-width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}
.nx-unread:not(:empty) {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
}
.nx-item-last .dot-warn {
  margin: 0;
  flex: none;
}
.nx-mode {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  letter-spacing: 0.2px;
}
.nx-mode-ai {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.nx-mode-bot {
  background: var(--sky-soft);
  color: var(--sky-ink);
}
.nx-mode-human {
  background: var(--warm-soft);
  color: var(--warm-ink);
}
.nx-empty-list {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 2px;
  padding: 44px 18px;
  color: var(--muted);
}
.nx-empty-list .list-empty {
  padding: 0;
  margin: 0;
  font-size: 13px;
}
.nx-empty-list small {
  font-size: 12.5px;
  color: var(--soft);
}
.nx-empty-art {
  width: 72px;
  height: 72px;
  margin-bottom: 10px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 32px;
  color: var(--brand);
  background: radial-gradient(circle at 30% 25%, #ffffff 0 18%, transparent 19%), linear-gradient(140deg, #e3f3ec, #fff3df);
  box-shadow: 0 10px 24px #12896b1f, inset 0 0 0 1px #12896b1a;
  transform: rotate(-4deg);
}
.nx-empty-list strong {
  font-size: 15px;
  color: var(--ink);
}
.nx-skeleton > div {
  display: flex;
  gap: 11px;
  padding: 12px 10px;
}
.nx-skeleton i,
.nx-skeleton b {
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, #edf2ef 25%, #f7faf8 50%, #edf2ef 75%);
  background-size: 200% 100%;
  animation: nx-shimmer 1.3s linear infinite;
}
.nx-skeleton i {
  width: 40px;
  height: 40px;
  flex: none;
}
.nx-skeleton span {
  flex: 1;
  display: grid;
  gap: 8px;
  padding-top: 5px;
}
.nx-skeleton b {
  height: 10px;
}
.nx-skeleton b + b {
  width: 70%;
}
@keyframes nx-shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- Chat ---------- */
.nx-chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}
.nx-chat-empty {
  justify-content: center;
}
.nx-chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 58px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.nx-chat-head .chat-back {
  display: none;
}
.nx-chat-title {
  flex: 1;
  min-width: 0;
}
.nx-chat-title h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nx-chat-title p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
}
.nx-chat-title .link-badge {
  font-size: 11px;
  padding: 1px 7px;
}
.nx-chat-head .chat-actions {
  display: flex;
  gap: 6px;
  flex: none;
}
.nx-chat-head .chat-actions .mini,
.nx-context .mini,
.nx-context .secondary {
  min-height: 30px;
  padding: 3px 11px;
  font-size: 12.5px;
  border-radius: 9px;
}
.nx-context {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.nx-context .listing-ref {
  flex: 0 1 auto;
  max-width: 46%;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid #f3dfbd;
  border-radius: 12px;
  background: var(--warm-soft);
}
.nx-context .listing-ref img,
.nx-context .listing-ref-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.nx-context .listing-ref-info {
  min-width: 0;
  gap: 0;
}
.nx-context .listing-ref-info strong {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nx-context .listing-ref-info span {
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
}
.nx-context .listing-ref-info .model-tag,
.nx-context .listing-ref-info .badge {
  margin: 0;
  font-size: 11px;
}
.nx-context .listing-ref-info .badge {
  display: none;
}
.nx-context .listing-ref .text-link {
  font-size: 12px;
  flex: none;
}
.nx-context .mode-bar {
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12.5px;
}
.nx-context .mode-bar.mode-ai {
  background: linear-gradient(90deg, var(--brand-soft), var(--surface-2));
  border-color: #cbe8dc;
}
.nx-context .mode-bar.mode-human {
  background: var(--warm-soft);
  border-color: #f3dfbd;
}
.nx-context .mode-bar > div {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nx-context .mode-bar small {
  display: none;
}
.mode-ai .mode-dot {
  animation: nx-pulse 2.4s ease-in-out infinite;
}
.nx-drawer {
  flex: none;
}
.nx-drawer > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.nx-drawer > summary {
  position: relative;
  z-index: 7;
}
.nx-drawer > summary::-webkit-details-marker {
  display: none;
}
.nx-drawer > summary .ic {
  font-size: 16px;
}
.nx-drawer > summary:hover,
.nx-drawer[open] > summary {
  border-color: var(--brand);
  color: var(--brand-ink);
  background: var(--brand-soft);
}
.nx-drawer > .chat-details-body {
  position: absolute;
  z-index: 6;
  top: var(--nx-top, 110px);
  right: 0;
  bottom: var(--nx-bottom, 0);
  width: min(360px, 100%);
  max-height: none;
  overflow-y: auto;
  display: block;
  padding: 0 0 18px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px #1c2b2e14;
}
.nx-drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.nx-drawer-head > div {
  flex: 1;
  min-width: 0;
  display: grid;
}
.nx-drawer-head small {
  color: var(--muted);
  font-size: 12px;
}
.nx-drawer-section {
  padding: 14px 16px 4px;
  display: grid;
  gap: 10px;
}
.nx-drawer-section h4 {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--soft);
}
.nx-drawer-mode {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--muted);
}
.nx-drawer-mode strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}
.nx-drawer-mode.mode-ai {
  background: var(--brand-soft);
}
.nx-drawer .listing-ref-controls,
.nx-drawer .fields-strip {
  display: grid;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
}
.nx-drawer .strip-source {
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.nx-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}
.nx-fields dt {
  color: var(--soft);
  text-transform: capitalize;
}
.nx-fields dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Mensajes */
.nx-chat .chat-history {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 16px clamp(14px, 3vw, 40px) 12px;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(#12896b12 1px, transparent 1.2px);
  background-size: 22px 22px;
  scrollbar-width: thin;
}
.nx-day {
  align-self: center;
  margin: 6px 0 14px;
}
.nx-day span {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: #ffffffd9;
  border: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  box-shadow: 0 1px 2px #1c2b2e0a;
}
.nx-chat .chat-history .summary-note {
  align-self: center;
  max-width: 520px;
  font-size: 13px;
  margin: 0 0 12px;
}
.nx-chat .bubble {
  position: relative;
  align-self: flex-start;
  max-width: min(72%, 560px);
  width: auto;
  margin: 0 0 3px;
  padding: 7px 12px 6px;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  white-space: normal;
  box-shadow: 0 1px 1.5px #1c2b2e14;
}
.nx-chat .bubble.tail {
  margin-bottom: 12px;
  border-bottom-left-radius: 5px;
}
.nx-chat .bubble.tail::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: -6px;
  width: 10px;
  height: 12px;
  background: inherit;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.nx-chat .bubble.assistant,
.nx-chat .bubble.team {
  align-self: flex-end;
  border: 0;
}
.nx-chat .bubble.assistant.tail,
.nx-chat .bubble.team.tail {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 5px;
}
.nx-chat .bubble.assistant.tail::before,
.nx-chat .bubble.team.tail::before {
  left: auto;
  right: -6px;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}
.nx-chat .bubble.assistant {
  background: #d9f0e6;
  color: #0f3f33;
}
.nx-chat .bubble.team {
  background: var(--brand);
  color: white;
}
.nx-chat .bubble small {
  display: block;
  margin-bottom: 1px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand-ink);
}
.nx-chat .bubble.assistant small {
  color: var(--brand-ink);
}
.nx-chat .bubble.team small {
  color: #d5f0e5;
}
.nx-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.nx-meta {
  float: right;
  margin: 6px 0 -2px 10px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--soft);
  white-space: nowrap;
}
.nx-chat .bubble.team .nx-meta {
  color: #cdeee1;
}
.nx-ai-tag {
  font-style: normal;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.2px;
}
.nx-chat .bubble.pending {
  opacity: 0.75;
  outline: 1.5px dashed #12896b66;
  outline-offset: -1.5px;
}
.nx-typing {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 8px;
  padding: 8px 14px;
  border-radius: 18px 18px 5px 18px;
  background: #d9f0e6;
  color: var(--brand-ink);
  font-size: 12.5px;
  font-weight: 600;
}
.nx-dots {
  display: inline-flex;
  gap: 3px;
}
.nx-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: nx-dot 1.2s ease-in-out infinite;
}
.nx-dots i:nth-child(2) {
  animation-delay: 0.15s;
}
.nx-dots i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes nx-dot {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Cuadro de respuesta */
.nx-chat .chat-compose {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px clamp(12px, 2vw, 24px) 10px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nx-chat .compose-row {
  align-items: flex-end;
  gap: 6px;
  padding: 5px 5px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.nx-chat .compose-row:focus-within {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px #12896b1f;
}
.nx-chat .compose-row textarea {
  height: 42px;
  min-height: 40px;
  max-height: 30vh;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
  outline: none;
}
.nx-chat .compose-row .primary {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 12px;
}
.nx-chat .compose-tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.nx-chat .compose-tools .mini,
.nx-chat .compose-tools .text-link {
  min-height: 30px;
  padding: 3px 11px;
  font-size: 12.5px;
  border-radius: 999px;
}
.nx-chat .compose-tools .mini {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nx-chat .compose-tools .mini:hover {
  background: var(--brand-soft);
  border-color: #cbe8dc;
  color: var(--brand-ink);
}
.nx-chat .quick-list {
  margin-bottom: 2px;
}
.nx-chat .chat-history > .empty,
.nx-chat-empty .empty {
  margin: auto;
}

/* ---------- Avisos (toast) ---------- */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border-radius: 14px;
  background: #1c2b2ef2;
  backdrop-filter: blur(6px);
  font-size: 14px;
  box-shadow: 0 18px 40px #1c2b2e40, 0 0 0 1px #ffffff14 inset;
  animation: nx-toast 0.28s var(--nx-ease);
}
.toast:before {
  content: "✓";
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #2bb673;
  color: white;
  font-size: 12px;
  font-weight: 800;
}
.toast.error {
  background: #a83b31f2;
}
.toast.error:before {
  content: "!";
  background: #ffffff33;
}
@keyframes nx-toast {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}
body.chat-view .toast {
  top: 16px;
}

/* ---------- Pantallas medianas ---------- */
@media (max-width: 1279px) and (min-width: 861px) {
  :root {
    --nx-rail-w: 64px;
    --nx-list-w: 300px;
  }
  .nx-rail-scroll {
    padding: 12px 8px;
  }
  .nx-rail-title {
    font-size: 0;
    height: 1px;
    padding: 0;
    margin: 10px 6px;
    background: var(--line);
  }
  .nx-rail-main {
    display: none;
  }
  .nx-folder,
  .nx-filter {
    position: relative;
    justify-content: center;
    padding: 6px 0;
  }
  .nx-folder .nx-folder-label,
  .nx-filter .nx-folder-label,
  .nx-filter small {
    display: none;
  }
  .nx-folder .nx-count {
    position: absolute;
    top: 0;
    right: 2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    font-size: 10px;
  }
  .nx-rail-foot {
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
  }
}

/* ---------- Móvil: bandejas en fila, lista → chat ---------- */
@media (max-width: 860px) {
  body.chat-view .page {
    padding: 0;
  }
  .nx-inbox {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    border-left: 0;
  }
  .nx-rail {
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
  }
  .nx-rail-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px;
    scrollbar-width: none;
  }
  .nx-rail-title {
    display: none;
  }
  .nx-folders,
  .nx-rail-section {
    display: flex;
    gap: 6px;
  }
  .nx-rail-section {
    padding-left: 6px;
    border-left: 1px solid var(--line);
  }
  .nx-folder,
  .nx-filter {
    width: auto;
    flex: none;
    min-height: 34px;
    padding: 4px 10px 4px 5px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 12.5px;
  }
  .nx-filter {
    padding-left: 2px;
  }
  .nx-folder-ic {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 14px;
  }
  .nx-folder.active,
  .nx-filter.active {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
  }
  .nx-folder.active .nx-folder-ic {
    background: #ffffff33;
  }
  .nx-folder.active .nx-count {
    background: #ffffff33;
    color: white;
  }
  .nx-filter.active small {
    color: #d5f0e5;
  }
  .nx-rail-foot {
    border-top: 0;
    border-left: 1px solid var(--line);
    padding: 0 8px;
  }
  .nx-inbox.show-chat .nx-rail,
  .nx-inbox.show-chat .nx-list,
  .nx-inbox:not(.show-chat) .nx-chat {
    display: none;
  }
  .nx-inbox.show-chat .nx-chat {
    grid-row: 1 / -1;
  }
  .nx-list {
    border-right: 0;
  }
  .nx-list-head {
    padding: 10px 12px 8px;
    gap: 8px;
  }
  .nx-list-title h2 {
    font-size: 16px;
  }
  .nx-chat-head {
    min-height: 52px;
    padding: 6px 10px;
    gap: 8px;
  }
  .nx-chat-head .chat-back {
    display: inline-flex;
    min-height: 32px;
    padding: 3px 9px;
    font-size: 12.5px;
  }
  .nx-chat-head > .nx-av {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }
  .nx-chat-title p .link-badge {
    display: none;
  }
  .nx-chat-head .chat-actions .mini {
    padding: 3px 8px;
  }
  .nx-context {
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 6px;
  }
  .nx-context .listing-ref {
    max-width: none;
    flex: 1 1 100%;
  }
  .nx-context .mode-bar {
    flex: 1 1 0;
  }
  .nx-drawer > summary span {
    display: none;
  }
  .nx-drawer > .chat-details-body {
    position: fixed;
    inset: 0;
    width: auto;
    z-index: 40;
    border: 0;
  }
  .nx-chat .bubble {
    max-width: 84%;
  }
  .nx-chat .chat-history {
    padding: 12px 12px 8px;
  }
  .nx-chat .chat-compose {
    padding: 6px 8px 8px;
  }
  .nx-chat .compose-tools {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nx-chat .compose-tools > * {
    flex: none;
  }
  body.chat-view .toast {
    top: auto;
    bottom: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .nx-count.bump,
  .nx-av-live,
  .nx-dots i,
  .mode-ai .mode-dot,
  .nx-skeleton i,
  .nx-skeleton b {
    animation: none;
  }
}

/* ---- Attention models as a table (modelRow in app.js) ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.models-table-wrap { overflow-x: auto; }
.models-table { width: 100%; font-size: 14px; }
.models-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.models-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.models-table tbody tr:hover { background: var(--surface-2); }
.models-table tr.model-row.on td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.models-table td > small, .models-table td strong + small { display: block; color: var(--muted); margin-top: 2px; }
.models-table .num { text-align: center; }
.models-table td:first-child { min-width: 190px; }
.models-table th, .models-table td { padding-left: 8px; padding-right: 8px; }
.models-table td:first-child strong { display: block; line-height: 1.3; }
.limits-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: none; border: 1px dashed transparent; border-radius: 8px; padding: 4px 6px; margin: -4px -6px; text-align: left; cursor: pointer; color: var(--ink); font: inherit; font-size: 13px; max-width: 200px; }
.limits-cell:hover, .limits-cell:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.limits-cell small { color: var(--brand-ink); font-weight: 600; }
.limits-cell.empty small { color: var(--muted); }
.models-table .row-select { max-width: 170px; width: 100%; padding: 4px 6px; font-size: 13px; }
.models-table .warn-text { color: var(--warm-ink); }
.models-table .link-button { background: none; border: 0; color: var(--brand-ink); font-weight: 700; text-decoration: underline; cursor: pointer; padding: 2px 6px; font-size: 14px; }
.models-table .switch-row.compact { padding: 0; border: 0; background: none; gap: 8px; margin: 0; }
.models-table .row-proposal { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; }
.models-table .row-actions { white-space: nowrap; text-align: right; }
.models-table .row-actions > * { margin-left: 4px; }
.row-menu { display: inline-block; position: relative; }
.row-menu > summary { list-style: none; cursor: pointer; display: inline-flex; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: flex; flex-direction: column; gap: 4px; min-width: 220px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.row-menu-list button { width: 100%; justify-content: flex-start; text-align: left; }
.offers-panel .offer-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.offers-panel .offer-item:last-child { border-bottom: 0; }
.offers-panel .offer-text { margin: 6px 0; padding: 8px 10px; border-left: 3px solid var(--warm); background: var(--warm-soft); border-radius: 6px; }
.offers-panel .offer-why { margin: 4px 0 8px 18px; color: var(--danger); font-size: 13px; }
.policy-line { margin-top: 6px; }
@media (max-width: 900px) {
  .models-table thead { display: none; }
  .models-table, .models-table tbody, .models-table tr, .models-table td { display: block; width: 100%; }
  .models-table tr.model-row { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 6px 10px; }
  .models-table tr.model-row.on { border-color: var(--brand); }
  .models-table tr.model-row.on td:first-child { box-shadow: none; }
  .models-table td { border-bottom: 0; padding: 6px 0; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
  .models-table td::before { content: attr(data-label); font-size: 12px; color: var(--muted); font-weight: 600; }
  .models-table td:first-child { display: block; }
  .models-table td:first-child::before { content: none; }
  .models-table .num { text-align: right; }
  .models-table .row-actions { justify-content: flex-start; text-align: left; white-space: normal; }
  .models-table .row-select { max-width: 60%; }
  .row-menu-list { left: 0; right: auto; }
}

/* ---- Coverage wizard ---- */
.cov-link { display: block; margin-top: 4px; font-size: 12px; text-align: left; padding: 0; }
.cov-table td, .cov-table th { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.cov-table td:first-child, .cov-table th:first-child { text-align: left; }
.cov-table .cov-yes { color: var(--brand-ink); font-weight: 700; }
.cov-table .cov-yes small { display: block; font-weight: 400; color: var(--muted); }
.cov-table .cov-no { color: var(--soft); }
.wizard-nav { margin-top: 12px; }

/* ---- Resizable inbox panes and table columns ---- */
.nx-inbox { position: relative; }
.nx-split { position: absolute; top: 0; bottom: 0; width: 9px; margin-left: -5px; cursor: col-resize; z-index: 5; touch-action: none; }
.nx-split[data-split="rail"] { left: var(--nx-rail-w); }
.nx-split[data-split="list"] { left: calc(var(--nx-rail-w) + var(--nx-list-w)); }
.nx-split:hover, .nx-split.dragging { background: linear-gradient(90deg, transparent 3px, var(--brand) 3px, var(--brand) 6px, transparent 6px); }
.table-wrap thead th { position: relative; }
.col-grip { position: absolute; top: 0; right: -4px; width: 9px; height: 100%; cursor: col-resize; z-index: 2; touch-action: none; }
.col-grip:hover { background: linear-gradient(90deg, transparent 3px, var(--brand) 3px, var(--brand) 5px, transparent 5px); }
table.sized { table-layout: fixed; max-width: none; }
.table-wrap:has(table.sized) { overflow-x: auto; }
table.sized td { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) { .nx-split, .col-grip { display: none; } }
.models-table.sized td.row-actions, table.sized td:has(.row-menu) { overflow: visible; }
.row-menu[open] .row-menu-list { position: fixed; }

/* ---- Send status on chat bubbles ---- */
.bubble.unsent { outline: 2px solid var(--danger); outline-offset: 1px; }
.nx-meta .send-fail { color: var(--danger); font-weight: 600; }
.nx-meta .send-ok { color: var(--brand-ink); }
.nx-meta .send-wait { color: var(--muted); }
.nx-meta .text-link { font-size: inherit; padding: 0; }

/* ---- Saved session: loading screen instead of the login form ---- */
body.booting #login { display: none; }
body.booting::before { content: "Cargando tu espacio…"; position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--muted); font-weight: 600; font-size: 16px; z-index: 50; }
.job-evidence { margin: 8px 0; }
.job-evidence .mono { font-family: ui-monospace, monospace; word-break: break-all; }
.evidence-shot { display: block; max-width: 100%; max-height: 360px; margin-top: 8px; border: 1px solid var(--line, #ddd); border-radius: 6px; object-fit: contain; object-position: top left; }

/* Un aviso en móvil debe conservar su altura natural entre las acciones. */
@media (max-width: 860px) {
  .toast { bottom: auto; }
  .system-page .panel-head { flex-wrap: wrap; gap: 12px; }
  .system-page td, .system-page th { white-space: normal; overflow-wrap: anywhere; }
  .system-page button { white-space: normal; }
}

@media (max-width: 600px) {
  .system-page table, .system-page tbody { display: block; width: 100%; }
  .system-page thead { display: none; }
  .system-page tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; padding: 14px; border-bottom: 1px solid var(--line); }
  .system-page td { display: block; border: 0; padding: 0; overflow-wrap: break-word; }
  .system-page td:nth-child(3) { grid-column: 1 / -1; }
}
