:root {
  --bg: #0a0a0a;
  --bg-sidebar: #0d0d0d;
  --card: #131313;
  --card-2: #1a1a1a;
  --card-3: #202020;
  --border: #232323;
  --border-soft: #1c1c1c;
  --text: #f2f2f2;
  --text-dim: #8c8c8c;
  --text-faint: #5f5f5f;
  --accent: #e4f24d;
  --accent-soft: rgba(228, 242, 77, 0.12);
  --accent-border: rgba(228, 242, 77, 0.35);
  --danger: #ff6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 26px 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover { background: var(--card); color: var(--text); }

.nav-item.active {
  background: var(--card-2);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-footer { margin-top: auto; }

.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #0a0a0a;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex: 0 0 auto;
}

.account-name { font-weight: 600; font-size: 13px; }
.account-role { color: var(--text-faint); font-size: 12px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 34px 44px 80px 44px;
  max-width: 1240px;
}

.page-title { font-size: 30px; font-weight: 700; margin: 0 0 6px 0; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-dim); margin: 0 0 26px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 22px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  row-gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.card-desc { color: var(--text-faint); font-size: 13px; margin: 0 0 22px 0; }

.section-title {
  font-size: 19px;
  font-weight: 700;
  margin: 30px 0 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  row-gap: 10px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.badge.muted { background: var(--card-3); color: var(--text-faint); }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.status-dot.off { background: var(--text-faint); }
.status-dot.live { animation: status-pulse-live 1.8s ease-in-out infinite; }
.status-dot.paused { background: #e5484d; animation: none; }

@keyframes status-pulse-live {
  0%, 100% { background: var(--accent); box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.55); }
  50% { background: #3dd68c; box-shadow: 0 0 0 5px rgba(61, 214, 140, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot.live { animation: none; background: #3dd68c; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  white-space: nowrap;
}

.btn:hover { border-color: #3a3a3a; background: var(--card-3); }
.btn-primary { background: var(--accent); color: #0a0a0a; border-color: var(--accent); }
.btn-primary:hover { background: #eef85f; border-color: #eef85f; }
.btn-outline-accent { border-color: var(--accent-border); color: var(--accent); background: transparent; }
.btn-outline-accent:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--card-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.3); background: transparent; }
.btn-danger:hover { background: rgba(255, 107, 107, 0.1); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.field-item, .field-block {
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.field-block:has(.field-value.quote) {
  background: none;
  border: none;
  padding: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 7px;
}

.field-label .badge { text-transform: none; letter-spacing: normal; }

.field-label.sentence {
  text-transform: none;
  letter-spacing: normal;
  font-size: 12.5px;
}

.field-value { color: var(--text); font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.field-value.empty { color: var(--text-faint); font-style: italic; font-weight: 400; }
.field-value.quote {
  font-style: italic;
  font-weight: 500;
  color: #cfcfcf;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent-border);
  padding: 12px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.field-block { margin-bottom: 22px; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}

.pill:hover { border-color: #3a3a3a; color: var(--text); }
.pill.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pill.static { cursor: default; }
.pill.static:hover { border-color: var(--border); color: var(--text-dim); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: #d2d2d2;
  font-size: 13px;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: none;
  background: var(--card-3);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6d6d6d;
  transition: transform 0.15s, background 0.15s;
}

.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(20px); background: #0a0a0a; }
.toggle-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.toggle-label { color: var(--text); font-size: 13px; }

.form-group { margin-bottom: 20px; }

label.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

label.form-label.sentence {
  text-transform: none;
  letter-spacing: normal;
  font-size: 12.5px;
}

.form-hint { color: var(--text-faint); font-size: 12px; margin-top: 7px; }

input[type="text"],
input[type="url"],
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.12s;
}

input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-border); }
textarea { resize: vertical; min-height: 92px; line-height: 1.6; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }

.steps { display: flex; flex-direction: column; gap: 13px; }
.step { display: flex; gap: 13px; align-items: flex-start; }

.step-num {
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.step-text { color: #dcdcdc; white-space: pre-wrap; }
.step-edit { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.step-edit textarea { min-height: 62px; }

.table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--card);
}

table { width: 100%; min-width: 560px; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--card);
}

tbody td { padding: 15px 18px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--card-2); }

.cell-strong { font-weight: 600; }
.cell-dim { color: var(--text-faint); }

.thumb {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--card-3);
  display: grid;
  place-items: center;
  color: var(--text-faint);
  overflow: hidden;
  flex: 0 0 auto;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }
.cell-product { display: flex; align-items: center; gap: 13px; }

.row-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 11px;
}

.row-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--card-3);
  display: grid;
  place-items: center;
  color: var(--text-dim);
  flex: 0 0 auto;
}

.row-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--card-3);
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-weight: 600;
  flex: 0 0 auto;
}

.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-title .handle { color: var(--text-faint); font-weight: 400; margin-left: 6px; }
.row-meta { color: var(--text-faint); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 12px; flex: 0 0 auto; }

.catalog-status-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 0;
  width: fit-content;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  margin-bottom: 22px;
}

.catalog-status-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  color: var(--text-faint);
  font-size: 12.5px;
  font-weight: 600;
}

.catalog-status-item.active { color: var(--text-dim); }
.catalog-status-item svg { flex: 0 0 auto; opacity: 0.85; }

.catalog-status-divider {
  width: 1px;
  height: 14px;
  background: var(--border-soft);
  flex: 0 0 auto;
}

.import-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.import-label { color: var(--text-dim); }

.tab-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
}

.tab:hover { color: var(--text); border-color: #333; }

.notice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: #e9e9c9;
  font-size: 13px;
  margin-bottom: 20px;
}

.notice.warn { background: rgba(255, 176, 32, 0.08); border-color: rgba(255, 176, 32, 0.3); color: #ffd79a; }
.notice.error { background: rgba(255, 107, 107, 0.09); border-color: rgba(255, 107, 107, 0.3); color: #ffc0c0; }

.flash {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 60;
  max-width: calc(100vw - 48px);
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 600;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
}

.flash.error { background: var(--danger); color: #fff; }

.empty-state {
  padding: 6px 0 18px 0;
  color: var(--text-faint);
  font-size: 13px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 6px;
  background: var(--card-3);
  overflow: hidden;
}

.progress-fill { height: 100%; background: var(--accent); border-radius: 6px; }

.progress-summary { margin-bottom: 22px; }
.progress-summary-text { font-size: 13px; color: var(--text-dim); display: block; margin-bottom: 8px; }
.progress-track-sm { height: 6px; }

.probar-conexion-resultado { font-size: 12.5px; }
.probar-conexion-resultado.ok { color: var(--accent); }
.probar-conexion-resultado.error { color: var(--danger); }

.detalle-tecnico { margin-top: 14px; }
.detalle-tecnico > summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  list-style: none;
}
.detalle-tecnico > summary::-webkit-details-marker { display: none; }
.detalle-tecnico > summary::before { content: "▸ "; color: var(--text-faint); }
.detalle-tecnico[open] > summary::before { content: "▾ "; }
.detalle-tecnico > summary:hover { color: var(--text); }
.detalle-tecnico-body { margin-top: 14px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 0; }

.stat-box {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.stat-box-wide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.stat-box-highlight { border-color: var(--accent-border); background: var(--accent-soft); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.stat-value { font-size: 19px; font-weight: 700; }

.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 385px; background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px; padding: 34px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 7px; }
.login-sub { color: var(--text-dim); margin-bottom: 26px; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.accent { color: var(--accent); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

.nav-toggle-input { display: none; }
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 14px;
  }
  .brand { padding: 0; white-space: nowrap; flex-shrink: 0; }

  .menu-toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-left: auto;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text);
    cursor: pointer;
  }
  .menu-toggle:hover { border-color: #3a3a3a; }
  .menu-toggle .icon-close { display: none; }
  .nav-toggle-input:checked ~ .menu-toggle .icon-burger { display: none; }
  .nav-toggle-input:checked ~ .menu-toggle .icon-close { display: block; }

  .nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    flex-basis: 100%;
    gap: 2px;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
  }
  .nav-toggle-input:checked ~ .nav { display: flex; }

  .sidebar-footer {
    display: none;
    flex-basis: 100%;
    margin-top: 0;
    margin-left: 0;
  }
  .nav-toggle-input:checked ~ .sidebar-footer { display: block; }

  .account-card { padding: 8px; }
  .main { padding: 22px 18px 60px 18px; }
}

@media (max-width: 600px) {
  .page-title { font-size: 22px; }
  .page-subtitle { font-size: 13px; }
  .card { padding: 16px 14px; }

  .brand { font-size: 14.5px; gap: 8px; }
  .nav-item { padding: 8px 10px; font-size: 12.5px; gap: 8px; }

  .btn { padding: 7px 12px; font-size: 12.5px; }
  .btn-sm { padding: 5px 10px; font-size: 11.5px; }

  .card-title { flex-wrap: wrap; row-gap: 6px; font-size: 16px; }
  .card-desc { font-size: 12.5px; }

  .tab-row { gap: 7px; }
  .tab { padding: 6px 11px; font-size: 12px; gap: 6px; }

  .field-grid { gap: 10px; }
  .field-item, .field-block { padding: 10px 12px; }
  .field-label { font-size: 10px; }
  .field-value { font-size: 13.5px; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid-3 { grid-template-columns: 1fr; }

  .row-actions { flex-basis: 100%; justify-content: flex-end; margin-top: 8px; }

  .card > .inline { flex-wrap: wrap; }
  .card > .inline > .row-body { flex-basis: 100%; }
  .card > .inline > .btn { width: 100%; justify-content: center; margin-top: 8px; }

  .variante-row input { max-width: 45% !important; }

  /* Tablas -> lista de tarjetas apiladas: header oculto, cada celda con su etiqueta */
  .table-wrap { overflow-x: visible; border: none; }
  .table-wrap table { min-width: 0; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr { display: block; border-bottom: 1px solid var(--border-soft); padding: 12px 0; }
  .table-wrap tbody tr:first-child { padding-top: 0; }
  .table-wrap tbody tr:last-child { border-bottom: none; padding-bottom: 0; }
  .table-wrap tbody td { display: block; padding: 5px 0; border: none; }
  .table-wrap tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 3px;
  }
  .table-wrap tbody td.cell-product { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
  .table-wrap tbody td.cell-actions { margin-top: 6px; }

  /* Respuestas largas: resumidas a 3 lineas, Editar para ver el resto */
  .cell-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* ---- "Probar chat": widget flotante fijo abajo a la derecha (Inicio y Configuracion) ---- */
.chat-toggle-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #0a0a0a;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  transition: background 0.12s, border-color 0.12s;
}
.chat-toggle-btn:hover { background: #eef85f; border-color: #eef85f; }
.chat-toggle-btn.open { background: var(--card-2); color: var(--text); border-color: var(--border); }

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 76px;
  z-index: 70;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 480px;
  max-height: calc(100vh - 140px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.chat-panel-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.chat-panel-sub {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-bubble {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.chat-bubble.cliente { align-self: flex-end; background: var(--accent); color: #0a0a0a; }
.chat-bubble.agente { align-self: flex-start; background: var(--card-2); color: var(--text); }
.chat-bubble.error {
  align-self: flex-start;
  background: rgba(255, 107, 107, 0.12);
  color: #ffc0c0;
  border: 1px solid rgba(255, 107, 107, 0.3);
}
.chat-bubble.pensando { align-self: flex-start; color: var(--text-faint); font-style: italic; }
.chat-bubble.aviso {
  align-self: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: #e9e9c9;
  font-size: 12px;
  text-align: center;
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.chat-form textarea {
  flex: 1;
  resize: none;
  min-height: 38px;
  max-height: 90px;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .chat-panel { left: 12px; right: 12px; width: auto; bottom: 72px; }
  .chat-toggle-btn { right: 12px; }
}
