/* ===== Ari · Design System 2.0 (Modern & Sophisticated) ===== */
:root {
  /* ARI by Ariwell — paleta digital (ari.tokens.json v1.0) */
  --ari-mint: #76CFB5;
  --ari-gray: #A7A9A6;
  --ari-ink: #2F3435;
  --ari-surface: #F7FAF8;
  --ari-greenText: #143C32;
  --ari-warning: #F4BA59;

  --surface: #F7FAF8;
  --surface-subtle: #EDF3EF;
  --surface-card: #ffffff;
  --surface-low: #F0F6F2;
  --surface-container-lowest: #ffffff;
  --surface-variant: #F7FAF8;
  --surface-container-highest: #DDE7E1;
  --outline-variant: #DDE7E1;
  --border-subtle: rgba(20, 60, 50, 0.12);
  --border-strong: rgba(20, 60, 50, 0.22);

  --on-surface: #2F3435;
  --on-surface-variant: #143C32;
  --text-muted: #5F6A67;

  --primary: #143C32;
  --primary-container: #76CFB5;
  --ai-grad-start: #76CFB5;
  --ai-grad-end: #143C32;
  --ai-grad-glow: rgba(118, 207, 181, 0.25);

  --secondary: #76CFB5;
  --error: #e11d48;
  --stop-red: #e11d48;
  --stop-red-hover: #be123c;
  --warning: #F4BA59;

  /* Component Tokens */
  --input-height: 44px;
  --input-radius: 10px;
  --focus-ring: 0 0 0 3px rgba(118, 207, 181, 0.30);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
  --shadow-elevated: 0 20px 50px -10px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.04);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);

  --font-ui: Arial, Helvetica, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

:root[data-theme="dark"] {
  --surface: #1A211F;
  --surface-subtle: #222C29;
  --surface-card: #232C29;
  --surface-low: #1D2522;
  --surface-container-lowest: #232C29;
  --surface-variant: #222C29;
  --surface-container-highest: #2E3A35;
  --outline-variant: #2E3A35;
  --border-subtle: rgba(118, 207, 181, 0.18);
  --border-strong: rgba(118, 207, 181, 0.32);

  --on-surface: #F1F5F2;
  --on-surface-variant: #B9C6BF;
  --text-muted: #7D8A84;

  --primary: #76CFB5;
  --primary-container: #143C32;
  --ai-grad-start: #76CFB5;
  --ai-grad-end: #2F3435;
  --ai-grad-glow: rgba(118, 207, 181, 0.28);

  --secondary: #76CFB5;
  --error: #f43f5e;
  --stop-red: #f43f5e;
  --stop-red-hover: #e11d48;
  --focus-ring: 0 0 0 3px rgba(118, 207, 181, 0.32);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.35);
  --shadow-elevated: 0 20px 50px -10px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background-color: var(--surface);
  background-image: 
    radial-gradient(1200px 500px at 50% -50px, rgba(0, 72, 141, 0.06), transparent 75%),
    radial-gradient(800px 400px at 85% 150px, rgba(0, 104, 200, 0.04), transparent 60%);
  background-attachment: fixed;
  color: var(--on-surface);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 24px;
  letter-spacing: -0.011em;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(203, 213, 225, 0.6); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.8); }

.ms {
  font-family: "Material Symbols Outlined";
  font-weight: 400;
  font-size: 20px;
  line-height: 1;
  user-select: none;
  text-transform: none;
  font-variant-ligatures: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Topbar Header ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(248, 250, 252, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  transition: border-color 0.2s;
}

.bar-inner {
  height: 62px;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--on-surface);
}

.conn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  margin-top: 1px;
}

.conn .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--secondary);
  animation: pulse-emerald 2.2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.conn-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--on-surface-variant);
}

.health-fail .dot {
  background: var(--error);
  animation: none;
}
.health-fail .conn-text {
  color: var(--error);
}

@keyframes pulse-emerald {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

.ai-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-avatar .ari-head {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ai-avatar .ms {
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.ai-glow-pulse {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-grad-start), var(--ai-grad-end));
  opacity: 0.25;
  filter: blur(4px);
  z-index: -1;
  animation: auraPulse 3s ease-in-out infinite;
}

@keyframes auraPulse {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.1); }
}

.ai-avatar.lg {
  width: 54px;
  height: 54px;
  box-shadow: 0 8px 24px rgba(118, 207, 181, 0.28);
}

.ai-avatar.lg .ms {
  font-size: 28px;
}

.ai-avatar-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.ai-avatar-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid var(--surface-card);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.ai-avatar-badge .ms {
  font-size: 13px;
  color: var(--primary-container);
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-card);
  border-color: var(--border-subtle);
  color: var(--on-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.icon-btn:active {
  transform: scale(0.95);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-subtle);
  border: 1.5px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 6px;
}

.user-avatar .ms {
  font-size: 18px;
  color: var(--on-surface-variant);
}

/* ---------- Layout & Main Thread ---------- */
.main {
  position: relative;
  padding-top: 86px;
  padding-bottom: 210px;
  min-height: 100vh;
}

.thread {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---------- Empty Hero & Prompt Grid ---------- */
.empty {
  text-align: center;
  margin-top: 2.5vh;
  margin-bottom: 3vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: heroFade 0.4s ease-out;
}

@keyframes heroFade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-hero {
  max-width: 580px;
  margin: 0 auto 32px;
  /* min-width:0 para que un hijo con contenido nowrap (el chip del paquete
     sectorial) no ensanche el hero ni provoque scroll horizontal. */
  min-width: 0;
}

.empty-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  color: var(--on-surface);
  line-height: 1.25;
}

.hint {
  font-size: 15px;
  color: var(--on-surface-variant);
  line-height: 1.5;
  margin: 0;
  max-width: 520px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 720px;
  text-align: left;
}

.prompt-card {
  min-width: 0;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
  text-align: left;
  font-family: inherit;
  color: inherit;
}

.prompt-card:hover {
  background: #ffffff;
  border-color: rgba(0, 72, 141, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(0, 72, 141, 0.1), 0 2px 6px rgba(0, 0, 0, 0.03);
}

.prompt-card:active {
  transform: scale(0.98);
}

.prompt-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-container);
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}

.prompt-card:hover .prompt-icon {
  background: #eef4fb;
  transform: scale(1.05);
}

.prompt-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.prompt-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-container);
}

.prompt-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--on-surface);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-arrow {
  font-size: 16px;
  color: var(--text-muted);
  transition: transform 0.2s, color 0.2s;
  flex-shrink: 0;
}

.prompt-card:hover .prompt-arrow {
  transform: translate(2px, -2px);
  color: var(--primary-container);
}

/* ---------- #007: hero dinámico (paquete sectorial activo) ---------- */
/* Una sola línea para no empujar la parrilla de preguntas bajo el compositor. */
.hero-sector {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 14px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  text-align: left;
  animation: heroFade 0.4s ease-out;
}

:root[data-theme="dark"] .hero-sector { background: var(--surface-card); }

.hero-sector-icon {
  font-size: 18px;
  color: var(--primary-container);
  flex-shrink: 0;
}

.hero-sector-name {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-container);
  white-space: nowrap;
  flex-shrink: 0;
}

.hero-sector-desc {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
  /* Clamp de una línea (en vez de nowrap): un texto nowrap aporta un
     min-content enorme y ensancha el hero en pantallas estrechas. */
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding-left: 6px;
  border-left: 1px solid var(--border-subtle);
}

.hero-sector-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  color: var(--on-surface-variant);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.hero-sector-change .ms { font-size: 15px; }
.hero-sector-change:hover {
  border-color: var(--primary-container);
  color: var(--primary-container);
  background: var(--surface-subtle);
}
.hero-sector-change:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---------- Chat Messages ---------- */
#chat {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.row {
  display: flex;
  width: 100%;
  animation: msgSlide 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes msgSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* User Message */
.row.user {
  justify-content: flex-end;
}

.row.user .wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 82%;
}

.row.user .bubble {
  background: var(--primary-container);
  color: #ffffff;
  border-radius: 20px 20px 4px 20px;
  padding: 12px 18px;
  box-shadow: 0 4px 14px -2px rgba(0, 72, 141, 0.3);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

.row.user .bubble p {
  margin: 0;
}

.row.user .user-avatar {
  background: #003a75;
  border-color: rgba(255, 255, 255, 0.15);
  margin: 0;
}

.row.user .user-avatar .ms {
  color: #ffffff;
}

/* Bot Message */
.row.bot {
  justify-content: flex-start;
}

.row.bot .wrap {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: 95%;
  width: 100%;
}

.row.bot .content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* El estado Pensando es una burbuja compacta, jamas full-width */
.row.bot .content .think {
  align-self: flex-start;
}

.row.bot .bubble {
  color: var(--on-surface);
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
}

.row.bot .bubble.error {
  color: var(--error);
  background: #fee2e2;
  border: 1px solid #fecaca;
  padding: 12px 16px;
  border-radius: 14px;
}

/* Thinking Indicator */
.think {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 2px 0;
}

.think .think-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.think .tdot {
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
  background: var(--primary-container);
  animation: blink 1.2s infinite;
}

.think .tdot:nth-child(2) { animation-delay: 0.2s; }
.think .tdot:nth-child(3) { animation-delay: 0.4s; }
.think.writing .tdot { animation-duration: 0.7s; }

.think-label {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--on-surface-variant);
}

@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.9); }
  40% { opacity: 1; transform: scale(1.15); }
}

/* Tool execution chips */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--on-surface-variant);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  padding: 4px 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.chip.done {
  color: var(--primary-container);
  border-color: rgba(0, 72, 141, 0.25);
  background: #edf4fc;
}

/* Message Meta & Action Toolbar */
.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.meta .ms {
  font-size: 14px;
}

.timestamp, .tok {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--on-surface-variant);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.copy-btn {
  position: relative;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--on-surface-variant);
  padding: 4px 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  transition: all 0.15s ease;
}

.copy-btn .ms {
  font-size: 15px;
}

.copy-btn:hover {
  background: var(--surface-card);
  border-color: var(--border-subtle);
  color: var(--on-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.copy-btn.copied {
  color: var(--secondary);
  border-color: rgba(5, 150, 105, 0.3);
  background: #ecfdf5;
}

/* ---------- Rich Markdown Typography ---------- */
.md {
  white-space: normal;
  word-break: break-word;
}

.md p {
  margin: 8px 0;
}
.md p:first-child { margin-top: 0; }
.md p:last-child { margin-bottom: 0; }

.md h1, .md h2, .md h3 {
  margin: 18px 0 8px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--on-surface);
  line-height: 1.3;
}
.md h1 { font-size: 22px; }
.md h2 { font-size: 18px; }
.md h3 { font-size: 16px; }

.md ul, .md ol {
  margin: 8px 0;
  padding-left: 24px;
}
.md li { margin: 4px 0; }
.md strong { font-weight: 700; color: #001d3f; }

.md code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  color: #00488d;
  border-radius: 6px;
  padding: 2px 6px;
}

.md pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  overflow-x: auto;
  border: 1px solid #1e293b;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  margin: 12px 0;
}
.md pre code {
  background: transparent;
  color: inherit;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.55;
  font-family: var(--font-mono);
}

.md blockquote {
  border-left: 3.5px solid var(--primary-container);
  margin: 12px 0;
  padding: 6px 16px;
  background: var(--surface-subtle);
  border-radius: 0 10px 10px 0;
  color: var(--on-surface-variant);
  font-size: 14px;
}

/* Modern Card-Style Data Tables */
.md table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: 14px 0;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.md th {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  background: var(--surface-subtle);
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.md td {
  font-size: 13.5px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--on-surface);
  line-height: 1.5;
}

.md tr:last-child td {
  border-bottom: none;
}

/* Alineación de columnas: marked traduce la sintaxis GFM (:---: centro, ---:
   derecha) a align="..." en th/td, y la heurística de app.js (alinearTablas)
   la aplica también a tablas sin marcadores (CANTIDAD al centro, montos a la
   derecha). Sin align, todo queda a la izquierda por defecto. */
.md th[align="center"], .md td[align="center"] { text-align: center; }
.md th[align="right"], .md td[align="right"] { text-align: right; font-variant-numeric: tabular-nums; }
.md th[align="left"], .md td[align="left"] { text-align: left; }

.md tr:hover td {
  background: rgba(0, 72, 141, 0.03);
}

:root[data-theme="dark"] .md tr:hover td {
  background: rgba(0, 104, 200, 0.08);
}

.md a {
  color: var(--primary-container);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
}
.md a:hover {
  text-decoration: underline;
}

/* ---------- Charts Container ---------- */
.chart-card {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 18px 20px 16px;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
  margin-top: 10px;
  animation: fade 0.25s ease;
}

.chart-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--on-surface);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-wrap {
  position: relative;
  height: 320px;
  width: 100%;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Fuentes consultadas (origen de datos en Odoo) ---------- */
.fuentes-card {
  width: 100%;
  /* Integrado con el fondo del chat: sin tarjeta blanca (petición UI). */
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 6px 0 0;
  margin-top: 6px;
  animation: fade 0.25s ease;
}

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

.fuentes-head .ms {
  font-size: 13px;
  color: var(--primary-container);
}

.fuentes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fuente-item {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 7px;
  padding: 4px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}

.fuente-modelo {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--on-surface);
}

.fuente-total {
  font-size: 11px;
  color: var(--on-surface-variant);
  white-space: nowrap;
}

.fuente-total::before {
  content: "·";
  margin-right: 7px;
  color: var(--border-strong);
}

.fuente-links {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.fuente-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-container);
  padding: 2px 6px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.fuente-link:hover {
  background: rgba(0, 72, 141, 0.09);
  text-decoration: underline;
}

.fuente-link .ms {
  font-size: 12px;
}

:root[data-theme="dark"] .fuente-link {
  color: #9cc3ee;
}

:root[data-theme="dark"] .fuente-link:hover {
  background: rgba(0, 104, 200, 0.2);
}

/* ---------- Command bar Dock & Floating Island ---------- */
/* ---------- Command bar Dock & Inline Dark Voice Note Bar ---------- */
.dock {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, rgba(248, 250, 252, 0.96) 24%, var(--surface) 100%);
  padding: 24px 20px 20px;
}

.dock-inner {
  position: relative;
  max-width: 768px;
  margin: 0 auto;
}

/* ---------- Quick Context Chips ---------- */
.quick-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.quick-chips::-webkit-scrollbar {
  display: none;
}

.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.quick-chip .ms {
  font-size: 15px;
  color: var(--primary-container);
}

.quick-chip:hover {
  background: #ffffff;
  border-color: rgba(0, 72, 141, 0.35);
  color: var(--primary-container);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 72, 141, 0.08);
}

.quick-chip:active {
  transform: scale(0.97);
}

/* ---------- AI Modern Chatbox Card (Two-Tier Composer) ---------- */
.commandbar.ai-chatbox-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(203, 213, 225, 0.85);
  border-radius: 20px;
  box-shadow: 
    0 16px 36px -6px rgba(15, 23, 42, 0.08),
    0 2px 6px -1px rgba(15, 23, 42, 0.02);
  padding: 12px 14px 10px 16px;
  min-height: 96px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.commandbar.ai-chatbox-card:focus-within:not(.is-recording) {
  background: #ffffff;
  border-color: rgba(0, 72, 141, 0.45);
  box-shadow: 
    0 20px 40px -8px rgba(0, 72, 141, 0.12),
    0 0 0 3px rgba(0, 72, 141, 0.06);
}

.commandbar.ai-chatbox-card.is-recording {
  min-height: 52px;
  border-radius: 28px;
  padding: 6px 8px 6px 14px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
}

/* Modo Normal: Compositor */
.chatbox-normal-mode {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.chatbox-input-area {
  width: 100%;
}

.chatbox-input-area textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--on-surface);
  padding: 2px 0;
  max-height: 140px;
  line-height: 22px;
  box-sizing: border-box;
}

.chatbox-input-area textarea::placeholder {
  color: #94a3b8;
}

/* Action Shelf Inferior */
.chatbox-action-shelf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-top: 6px;
  border-top: 1px solid rgba(241, 245, 249, 0.9);
}

.shelf-left,
.shelf-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shelf-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.shelf-btn .ms {
  font-size: 19px;
}

.shelf-btn:hover {
  background: var(--surface-subtle);
  color: var(--primary-container);
}

.context-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #059669;
  background: #ecfdf5;
  border: 1px solid #d1fae5;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  user-select: none;
}

.dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #059669;
  animation: pulse-emerald 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.shelf-mic-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--surface-subtle);
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s ease;
  flex-shrink: 0;
  padding: 0;
}

.shelf-mic-btn .ms {
  font-size: 19px;
}

.shelf-mic-btn:hover {
  background: #eef4fb;
  color: var(--primary-container);
  transform: scale(1.06);
}

.shelf-mic-btn:active {
  transform: scale(0.94);
}

.shelf-mic-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.shelf-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--ai-grad-start), var(--ai-grad-end));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 72, 141, 0.28);
  transition: all 0.16s ease;
  flex-shrink: 0;
  padding: 0;
}

.shelf-send-btn .ms {
  font-size: 18px;
  font-weight: 700;
}

.shelf-send-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 72, 141, 0.4);
  transform: scale(1.06);
}

.shelf-send-btn:active {
  transform: scale(0.94);
}

.shelf-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  background: var(--surface-container-highest);
  color: var(--text-muted);
}

.shelf-send-btn.is-stop {
  background: var(--stop-red);
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.35);
}
.shelf-send-btn.is-stop:hover {
  background: var(--stop-red-hover);
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.45);
}

.shelf-send-btn.is-stop .stop-glyph {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #ffffff;
}

/* ==========================================================================
   Stitch Modern Smooth Audio Waveform Capsule
   ========================================================================== */

.commandbar.is-recording {
  background: rgba(255, 255, 255, 0.88) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.85) !important;
  border-radius: 9999px !important;
  box-shadow: 0 12px 30px -4px rgba(37, 99, 235, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.05) !important;
  padding: 8px 12px !important;
  min-height: 60px !important;
  flex-direction: row !important;
  align-items: center !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.commandbar.is-recording:hover {
  border-color: #cbd5e1 !important;
}

.stitch-voice-capsule {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  animation: stitchCapsuleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes stitchCapsuleIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* 1. Botón Descartar (Papelera) */
.stitch-btn-trash {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.stitch-btn-trash svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.stitch-btn-trash:hover {
  color: #e11d48;
  background: rgba(254, 226, 226, 0.8);
}

.stitch-btn-trash:hover svg {
  transform: rotate(6deg);
}

.stitch-btn-trash:active {
  transform: scale(0.95);
}

/* 2. Live Timer Badge Pill */
.stitch-rec-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.8);
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.stitch-rec-radar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 8px;
  height: 8px;
}

.stitch-radar-ping {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #60a5fa;
  opacity: 0.75;
  animation: stitchRadarPing 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes stitchRadarPing {
  75%, 100% { transform: scale(2.2); opacity: 0; }
}

.stitch-radar-dot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.4);
}

.stitch-rec-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.stitch-rec-timer {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #334155;
  line-height: 1;
}

/* 3. Waveform Center Container (Inner Slot) */
.stitch-waveform-slot {
  flex: 1;
  height: 42px;
  background: linear-gradient(180deg, rgba(241, 245, 249, 0.75) 0%, rgba(248, 250, 252, 0.9) 100%);
  border: 1px solid rgba(226, 232, 240, 0.7);
  border-radius: 9999px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
}

.stitch-waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Transcribing Overlay */
.stitch-transcribing-overlay {
  position: absolute;
  inset: 0;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 9999px;
  z-index: 10;
}

.stitch-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(37, 99, 235, 0.2);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: stitchSpin 0.75s linear infinite;
}

@keyframes stitchSpin {
  to { transform: rotate(360deg); }
}

.stitch-transcribing-text {
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
}

/* 4. Pause / Stop Button */
.stitch-btn-stop {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  padding: 0;
}

.stitch-stop-square {
  width: 13px;
  height: 13px;
  background: #334155;
  border-radius: 3px;
  transition: transform 0.2s ease;
}

.stitch-btn-stop:hover {
  background: rgba(241, 245, 249, 0.9);
}

.stitch-btn-stop:hover .stitch-stop-square {
  transform: scale(0.9);
}

.stitch-btn-stop:active {
  transform: scale(0.95);
}

/* 5. Primary Action / Send Button */
.stitch-btn-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px -3px rgba(37, 99, 235, 0.4), 0 2px 6px -1px rgba(37, 99, 235, 0.2);
  transition: all 0.2s ease;
  padding: 0;
}

.stitch-btn-send svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.stitch-btn-send:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  box-shadow: 0 10px 24px -2px rgba(37, 99, 235, 0.55);
  transform: scale(1.04);
}

.stitch-btn-send:hover svg {
  transform: translateY(-1px);
}

.stitch-btn-send:active {
  transform: scale(0.95);
}

.stitch-btn-trash:disabled,
.stitch-btn-stop:disabled,
.stitch-btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.disclaimer {
  text-align: center;
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

/* Toast notification */
.vn-toast {
  position: fixed;
  bottom: 86px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  color: #f8fafc;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  font-family: var(--font-ui);
}

.vn-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.vn-toast .ms {
  font-size: 18px;
  color: #10b981;
}

.vn-toast.error .ms {
  color: #f87171;
}

/* Responsive Mobile Adjustments */
@media (max-width: 640px) {
  .bar-inner { padding: 0 14px; }
  .thread { padding: 0 14px; gap: 20px; }
  .main { padding-bottom: 245px; }
  
  .empty { margin-top: 1.5vh; margin-bottom: 1.5vh; }
  .empty-title { font-size: 22px; }
  .hint { font-size: 14px; }
  
  .prompt-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* #007: el chip del paquete sectorial no debe robar espacio al hero. */
  .hero-sector { gap: 10px; padding: 9px 10px; margin-top: 14px; }
  .hero-sector-change { padding: 0 9px; }
  .hero-sector-change span:last-child { display: none; }

  .prompt-card {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    min-height: 96px;
  }

  .prompt-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .prompt-icon .ms {
    font-size: 16px;
  }

  .prompt-tag {
    font-size: 9px;
  }

  .prompt-text {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.35;
  }

  .prompt-arrow {
    display: none;
  }
  
  .row.user .wrap { max-width: 90%; }
  .row.bot .wrap { max-width: 100%; gap: 10px; }
  .row.bot .bubble { font-size: 14.5px; }
  
  .dock { padding: 14px 12px 14px; }
  
  .commandbar.ai-chatbox-card {
    padding: 10px 12px 8px 14px;
    min-height: 90px;
  }
  
  .commandbar.ai-chatbox-card.is-recording {
    padding: 6px 8px 6px 10px;
  }
  
  .vn-voice-waveform { gap: 2px; }
  .vn-voice-bar-item { flex: 0 0 2px; width: 2px; }
  .vn-voice-timer { font-size: 13px; }
}

/* ===== Sidebar (sesiones / integraciones / perfil) ===== */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: 280px; z-index: 80;
  background: var(--surface-card); border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar.open { transform: translateX(0); box-shadow: 8px 0 32px rgba(15, 23, 42, 0.1); }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 75;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); }
.sidebar-brand-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; color: var(--on-surface); }
.sidebar-brand .conn { margin-top: 1px; }
.sidebar-brand .conn .conn-text { font-size: 10.5px; }
.sidebar-close { margin-left: auto; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 20px; }

.sidebar-new-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 10px 12px; border: none; border-radius: 12px;
  background: var(--primary-container); color: #fff;
  font-family: var(--font-ui); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.sidebar-new-btn:hover { background: #003a75; }
.sidebar-new-btn .ms { font-size: 18px; }

.sidebar-section { display: flex; flex-direction: column; gap: 6px; }
.sidebar-section-title {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); padding: 0 8px;
}
.sidebar-section-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 7px 8px; background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); border-radius: 8px;
}
.sidebar-section-head:hover { background: var(--surface-subtle); color: var(--on-surface-variant); }
.sidebar-caret { font-size: 16px; transition: transform 0.2s; }
.sidebar-section-head.collapsed .sidebar-caret { transform: rotate(-90deg); }

.session-list { display: flex; flex-direction: column; gap: 2px; }
.session-item {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: 9px 12px; border: none; background: none; border-radius: 10px;
  cursor: pointer; font-family: var(--font-ui);
}
.session-item:hover { background: var(--surface-subtle); }
.session-item.active { background: #eaf2fb; }
.session-item .session-title {
  font-size: 13.5px; font-weight: 600; color: var(--on-surface);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-item .session-sub { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.session-list .session-item { position: relative; padding-right: 30px; }
.session-del {
  position: absolute; top: 7px; right: 7px; display: none; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 8px; color: var(--text-muted); cursor: pointer;
}
.session-del:hover { background: rgba(225, 29, 72, 0.12); color: var(--error); }
.session-item:hover .session-del { display: flex; }
.session-del .ms { font-size: 15px; }

.integration-list { display: flex; flex-direction: column; gap: 2px; }
.integration-list.collapsed { display: none; }
.integration-item { display: flex; align-items: center; gap: 9px; padding: 8px 8px 8px 12px; border-radius: 10px; }
.integration-item:hover { background: var(--surface-subtle); }
.integration-item.active { background: #eaf2fb; cursor: default; }
.integration-info { flex: 1; }
.integration-actions {
  display: flex; gap: 1px; margin-left: auto; flex-shrink: 0;
  opacity: 0.55; transition: opacity 0.15s;
}
.integration-item:hover .integration-actions,
.integration-item:focus-within .integration-actions { opacity: 1; }
.ia-btn {
  width: 25px; height: 25px; border: none; background: none; border-radius: 7px;
  cursor: pointer; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.ia-btn:hover { background: rgba(15, 23, 42, 0.07); color: var(--on-surface-variant); }
.ia-btn.delete:hover { background: #fef2f2; color: var(--error); }
.ia-btn .ms { font-size: 15px; }

#intContextBackdrop { position: fixed; inset: 0; z-index: 85; background: transparent; }
#intContextMenu {
  position: fixed; z-index: 90; min-width: 195px;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: 14px; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 5px; font-family: var(--font-ui);
}
.int-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: none; background: none; border-radius: 9px;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--on-surface);
  cursor: pointer; text-align: left; transition: background 0.12s;
}
.int-menu-item:hover { background: var(--surface-subtle); }
.int-menu-item .ms { font-size: 16px; color: var(--on-surface-variant); }
.int-menu-item.danger { color: var(--error); }
.int-menu-item.danger .ms { color: var(--error); }
.int-menu-item.danger:hover { background: #fef2f2; }
.modal-result {
  margin: 0; font-size: 12.5px; font-weight: 500; border-radius: 12px;
  padding: 9px 12px; line-height: 1.45; word-break: break-word;
  display: flex; align-items: flex-start; gap: 8px;
}
.modal-result .ms { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.modal-result.success { color: #065f46; background: #ecfdf5; border: 1px solid #a7f3d0; }
.modal-result.error { color: var(--error); background: #fef2f2; border: 1px solid #fecaca; }
.modal-spacer { flex: 1; }
.integration-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--secondary); flex-shrink: 0; }
.integration-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.integration-name { font-size: 13px; font-weight: 600; color: var(--on-surface); }
.integration-url {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border-subtle); }

/* ===== Boton flotante de Ari (movil) + encabezado de sesion ===== */
.chat-fab {
  position: fixed; top: 12px; left: 12px; z-index: 55;
  display: none; border: none; background: none; cursor: pointer; padding: 0;
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.22);
  transition: transform 0.15s;
}
.chat-fab:active { transform: scale(0.94); }

.chat-heading { text-align: center; margin: 2px 0 10px; }
.chat-heading .chat-context-title {
  font-size: 15px; font-weight: 600; color: var(--on-surface);
  letter-spacing: -0.01em;
}

@media (min-width: 641px) {
  .sidebar { transform: none; }
  .sidebar-backdrop { display: none; }
  .sidebar-close { display: none; }
  .dock { left: 280px; }
  .main { margin-left: 280px; }
}

/* ===== Seccion integraciones: fila + boton agregar ===== */
.sidebar-section-row { display: flex; align-items: center; gap: 2px; }
.sidebar-section-row .sidebar-section-head { flex: 1; }
.sidebar-add-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: none; background: none; border-radius: 8px;
  cursor: pointer; color: var(--text-muted); flex-shrink: 0;
}
.sidebar-add-btn:hover { background: var(--surface-subtle); color: var(--primary-container); }
.sidebar-add-btn .ms { font-size: 17px; }

/* ===== Modal nueva integracion (rediseñado) ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(11, 17, 32, 0.65);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--surface-card); border-radius: 20px; width: 100%; max-width: 460px;
  box-shadow: var(--shadow-elevated); border: 1px solid var(--border-strong);
  padding: 24px; display: flex; flex-direction: column; gap: 16px;
  max-height: 92vh; overflow-y: auto;
  animation: modalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header { display: flex; align-items: center; gap: 12px; }
.modal-head-icon {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ai-grad-start), var(--ai-grad-end));
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 72, 141, 0.28);
}
.modal-head-icon .ms { font-size: 22px; }
.modal-head-text { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--on-surface); letter-spacing: -0.01em; }
.modal-subtitle { font-size: 12.5px; color: var(--text-muted); line-height: 1.35; }
.modal-form { display: flex; flex-direction: column; gap: 14px; }

.int-field { display: flex; flex-direction: column; gap: 6px; }
.int-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--on-surface-variant);
  line-height: 1;
}
.int-input-wrap {
  position: relative; display: flex; align-items: center;
  height: var(--input-height, 44px); min-height: 44px;
}
.int-input-icon {
  position: absolute; left: 14px; font-size: 18px; color: var(--text-muted);
  pointer-events: none; transition: color 0.15s;
}
.int-input-wrap:focus-within .int-input-icon { color: var(--primary-container); }
.int-input-wrap input {
  width: 100%; height: 100%; border: 1.5px solid var(--border-strong); border-radius: var(--input-radius, 10px);
  padding: 10px 14px 10px 42px; font: inherit; font-size: 14px;
  color: var(--on-surface); background: var(--surface-card); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.int-input-wrap:focus-within input,
.int-input-wrap input:focus {
  border-color: var(--primary-container);
  box-shadow: var(--focus-ring);
}
.int-input-wrap input::placeholder { color: #9aa7b8; }
.int-input-wrap input.pw-in { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: none; border-radius: 8px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.pw-toggle:hover { color: var(--primary-container); background: rgba(0, 72, 141, 0.08); }
.pw-toggle .ms { font-size: 19px; }
.int-row { display: flex; gap: 12px; }
.int-row .int-field { flex: 1; min-width: 0; }

.int-test-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  height: var(--input-height, 44px); padding: 0 14px; margin-top: 4px;
  border-radius: var(--input-radius, 10px); border: 1.5px solid rgba(0, 72, 141, 0.4);
  background: #f2f7fd; color: var(--primary-container);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
:root[data-theme="dark"] .int-test-btn {
  background: rgba(0, 72, 141, 0.2); border-color: rgba(0, 104, 200, 0.5); color: #9cc3ee;
}
.int-test-btn:hover { background: #e6f0fa; border-color: var(--primary-container); }
:root[data-theme="dark"] .int-test-btn:hover { background: rgba(0, 72, 141, 0.35); }
.int-test-btn:active { transform: scale(0.98); }
.int-test-btn:disabled { opacity: 0.6; cursor: default; }
.int-test-btn .ms { font-size: 18px; }

/* #24: variante destructiva (revocar credencial) */
.int-test-btn.danger {
  background: #fef2f2; border-color: rgba(220, 38, 38, 0.45); color: #b91c1c;
}
:root[data-theme="dark"] .int-test-btn.danger {
  background: rgba(220, 38, 38, 0.15); border-color: rgba(248, 113, 113, 0.5); color: #fca5a5;
}
.int-test-btn.danger:hover { background: #fde8e8; border-color: #dc2626; }
:root[data-theme="dark"] .int-test-btn.danger:hover { background: rgba(220, 38, 38, 0.28); }

.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 4px; }
.modal-btn-ghost {
  padding: 10px 18px; height: var(--input-height, 44px); border-radius: var(--input-radius, 10px);
  border: 1px solid var(--border-strong);
  background: var(--surface-card); font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--on-surface-variant); cursor: pointer; transition: var(--transition-fast);
}
.modal-btn-ghost:hover { background: var(--surface-subtle); color: var(--on-surface); }
.modal-btn-ghost:active { transform: scale(0.98); }
.modal-btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; height: var(--input-height, 44px); border-radius: var(--input-radius, 10px); border: none;
  background: var(--primary-container); color: #fff;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 72, 141, 0.25);
  transition: var(--transition-fast);
}
.modal-btn-primary:hover:not(:disabled) { background: #003a75; box-shadow: 0 4px 14px rgba(0, 72, 141, 0.35); }
.modal-btn-primary:active:not(:disabled) { transform: scale(0.98); }
.modal-btn-primary .ms { font-size: 17px; }
.modal-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== Ayuda contextual en integraciones (spec 032) ===== */
.help-tip {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  background-color: transparent;
  box-shadow: none;
  outline: none;
  cursor: help;
  color: #9ca3af;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
  transition: color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.help-tip:hover,
.help-tip:focus-visible {
  color: #4b5563;
  background: transparent;
  background-color: transparent;
  outline: none;
}
:root[data-theme="dark"] .help-tip {
  color: #9ca3af;
}
:root[data-theme="dark"] .help-tip:hover,
:root[data-theme="dark"] .help-tip:focus-visible {
  color: #e2e8f0;
  background: transparent;
  background-color: transparent;
}
.help-icon {
  width: 15px;
  height: 15px;
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

.help-popover {
  position: fixed;
  z-index: 120;
  width: max-content;
  max-width: 300px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.28);
  padding: 10px 12px;
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 12px;
  line-height: 1.45;
  box-sizing: border-box;
  animation: helpPopIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}
@keyframes helpPopIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.help-popover-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
}
.help-popover-section {
  margin-top: 4px;
  color: #cbd5e1;
  font-size: 11.5px;
  line-height: 1.4;
}
.help-popover-section strong {
  color: #ffffff;
  font-weight: 600;
}
.help-popover-section em {
  font-style: normal;
  color: #e2e8f0;
}
.help-popover-section ul {
  margin: 3px 0 2px 0;
  padding-left: 14px;
}
.help-popover-section li {
  margin-bottom: 2px;
}
.help-popover-section code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 4px;
  border-radius: 4px;
  color: #93c5fd;
}
.help-popover-alert {
  margin-top: 6px;
  background: rgba(234, 138, 0, 0.18);
  border-left: 2px solid #f59e0b;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: #fef3c7;
}
@media (max-width: 480px) {
  .help-popover {
    max-width: calc(100vw - 32px);
  }
}

@media (max-width: 640px) {
  .chat-fab { display: block; }
  .main { padding-top: 64px; }
}

.main { padding-top: 28px; }

/* ===== Vista de autenticacion (login / primer acceso) ===== */
.auth-view {
  position: fixed; inset: 0; z-index: 300;
  background:
    radial-gradient(900px 500px at 20% -100px, rgba(0, 72, 141, 0.16), transparent 70%),
    radial-gradient(700px 400px at 90% 110%, rgba(0, 104, 200, 0.12), transparent 65%),
    var(--surface);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  overflow-y: auto;
}
.auth-card {
  background: var(--surface-card); border-radius: 24px; width: 100%; max-width: 400px;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.18); padding: 30px 28px 26px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.auth-logo { margin-bottom: 10px; }
.auth-title { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; margin: 0; color: var(--on-surface); }
.auth-sub { font-size: 13.5px; color: var(--text-muted); margin: 2px 0 18px; }
.auth-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.auth-first-hint {
  margin: 0 0 2px; font-size: 12.5px; color: var(--on-surface-variant);
  background: #eef4fb; border: 1px solid rgba(0, 72, 141, 0.18);
  border-radius: 12px; padding: 9px 12px; line-height: 1.4;
}
.auth-submit {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 12px 14px; margin-top: 4px; border: none; border-radius: 12px;
  background: var(--primary-container); color: #fff; cursor: pointer;
  font: inherit; font-size: 14.5px; font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.auth-submit:hover { background: #003a75; }

/* ===== Estado de arranque (anti-flash: el chat no existe hasta validar sesión) ===== */
.boot-screen {
  position: fixed; inset: 0; z-index: 310;
  background:
    radial-gradient(900px 500px at 20% -100px, rgba(0, 72, 141, 0.16), transparent 70%),
    radial-gradient(700px 400px at 90% 110%, rgba(0, 104, 200, 0.12), transparent 65%),
    var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.boot-spinner {
  margin-top: 20px; width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgba(0, 72, 141, 0.15); border-top-color: var(--primary-container);
  animation: bootSpin 0.7s linear infinite;
}
@keyframes bootSpin { to { transform: rotate(360deg); } }

/* Sin sesión confirmada aún: nada de la app se pinta (ni un frame). */
body:not(.state-app) #sidebar,
body:not(.state-app) #sidebarBackdrop,
body:not(.state-app) main.main,
body:not(.state-app) .chat-fab,
body:not(.state-app) .commandbar { display: none !important; }

/* Estado resuelto (app o auth): fuera pantalla de arranque. */
body.state-app .boot-screen,
body.state-auth .boot-screen { display: none; }
.auth-submit:active { transform: scale(0.99); }
.auth-submit:disabled { opacity: 0.6; cursor: default; }
.auth-submit .ms { font-size: 18px; }

/* ===== Pagina dedicada de usuarios (Enterprise Minimalist & Compact) ===== */
.users-view {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.users-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
}
.users-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 500;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: var(--transition-fast);
}
.users-back:hover {
  background: var(--surface-subtle);
  color: var(--on-surface);
}
.users-back .ms {
  font-size: 16px;
}
.users-head-text {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.users-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--on-surface);
}
.users-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.users-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}

/* ===== Tabla de usuarios limpia y compacta ===== */
.users-list {
  display: block;
  width: 100%;
}
.users-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  font-size: 13px;
}
.users-table thead th {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on-surface-variant);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}
.users-table thead th.ut-acciones {
  text-align: right;
}

.users-table tbody tr {
  transition: background 0.12s ease;
  border-bottom: 1px solid var(--border-subtle);
}
.users-table tbody tr:last-child {
  border-bottom: none;
}
.users-table tbody tr:hover {
  background: var(--surface-subtle);
}
.users-table tbody td {
  padding: 10px 14px;
  vertical-align: middle;
}

/* Columna Usuario */
.ut-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ut-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--primary-container);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}
.ut-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ut-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ut-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Columna Rol */
.users-table td.ut-rol {
  white-space: nowrap;
}
.user-badge-rol {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 2px 7px;
  white-space: nowrap;
}
.user-badge-rol.owner {
  background: #eef4fc;
  color: #00488d;
}
.user-badge-rol.admin {
  background: #ecfdf5;
  color: #047857;
}
.user-badge-rol.member {
  background: var(--surface-subtle);
  color: var(--on-surface-variant);
}
:root[data-theme="dark"] .user-badge-rol.owner {
  background: rgba(0, 104, 200, 0.2);
  color: #93c5fd;
}
:root[data-theme="dark"] .user-badge-rol.admin {
  background: rgba(5, 150, 105, 0.2);
  color: #6ee7b7;
}

/* Columna Acceso Odoo */
.users-table td.ut-acceso {
  white-space: nowrap;
}
.user-odoo {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--on-surface-variant);
  background: var(--surface-subtle);
  border-radius: 6px;
  padding: 2px 7px;
  display: inline-block;
}
.user-odoo.none {
  color: var(--text-muted);
  background: transparent;
  padding: 0;
}

/* Columna Acciones */
.users-table td.ut-acciones {
  text-align: right;
  white-space: nowrap;
}
.user-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.user-act-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}
.user-act-btn .ms {
  font-size: 16px;
}
.user-act-btn:hover {
  background: var(--surface-subtle);
  color: var(--on-surface);
}
.user-act-btn.delete:hover {
  background: #fee2e2;
  color: #dc2626;
}
:root[data-theme="dark"] .user-act-btn.delete:hover {
  background: rgba(225, 29, 72, 0.2);
  color: #fda4af;
}

/* ===== #25: registro de consultas (auditoría) en /usuarios ===== */
.users-tabs {
  display: flex;
  gap: 4px;
  margin: 14px 0 10px;
  padding: 4px;
  background: var(--surface-subtle);
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
}
.users-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--on-surface-variant);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.users-tab .ms { font-size: 15px; }
.users-tab:hover { color: var(--on-surface); }
.users-tab.on {
  background: var(--surface-card);
  color: var(--primary-container);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.06));
}
.audit-view { width: 100%; }
.audit-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}
.af-select,
.af-input {
  height: 38px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--input-radius, 10px);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  color: var(--on-surface);
  background: var(--surface-card);
  outline: none;
  min-width: 0;
}
.af-select {
  padding-right: 26px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.af-select:focus,
.af-input:focus { border-color: var(--primary-container); }
.af-input { flex: 1 1 160px; }
.af-input.af-date { flex: 0 0 auto; width: 150px; }
.af-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 38px;
  padding: 0 14px;
  border: 1.5px solid rgba(0, 72, 141, 0.4);
  border-radius: var(--input-radius, 10px);
  background: #f2f7fd;
  color: var(--primary-container);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
:root[data-theme="dark"] .af-btn {
  background: rgba(0, 72, 141, 0.2);
  border-color: rgba(0, 104, 200, 0.5);
  color: #9cc3ee;
}
.af-btn:hover { background: #e6f0fa; }
:root[data-theme="dark"] .af-btn:hover { background: rgba(0, 72, 141, 0.35); }
.af-btn.ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--on-surface-variant);
}
.af-btn.ghost:hover { background: var(--surface-subtle); color: var(--on-surface); }
.af-btn .ms { font-size: 17px; }
.af-btn:disabled { opacity: 0.45; cursor: default; }

.audit-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.audit-count { font-size: 12.5px; color: var(--text-muted); }
.audit-pager { display: inline-flex; gap: 6px; }
.audit-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 2px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.audit-note .ms { font-size: 14px; }

/* Tabla de auditoría (reusa .users-table con su propio envoltorio) */
.audit-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}
.audit-table-wrap .users-table { min-width: 860px; }
.at-click { cursor: pointer; }
.at-click:hover { background: var(--surface-subtle); }
.at-fecha { white-space: nowrap; font-variant-numeric: tabular-nums; }
.at-fecha small { display: block; font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); }
.at-usuario { white-space: nowrap; font-weight: 500; }
.at-consulta small {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 1px;
}
.at-total { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.at-estado { white-space: nowrap; }
.audit-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.audit-pill.ok { background: #ecfdf5; color: #047857; }
.audit-pill.err { background: #fee2e2; color: #dc2626; }
:root[data-theme="dark"] .audit-pill.ok { background: rgba(5, 150, 105, 0.2); color: #6ee7b7; }
:root[data-theme="dark"] .audit-pill.err { background: rgba(225, 29, 72, 0.2); color: #fda4af; }
.audit-int { font-size: 11px; color: var(--text-muted); }
.at-expand {
  text-align: right;
  white-space: nowrap;
  color: var(--on-surface-variant);
}
.at-expand .ms { font-size: 16px; vertical-align: middle; }

/* Fila de detalle desplegable */
.audit-detail-row { display: none; }
.audit-detail-row.abierto { display: table-row; }
.audit-detail-row td {
  background: var(--surface-subtle);
  padding: 0 !important;
}
.audit-detail-inner {
  padding: 10px 16px 12px 40px;
  font-size: 12px;
  color: var(--on-surface-variant);
}
.audit-detail-inner .ad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 18px;
  margin-top: 6px;
}
.audit-detail-inner .ad-k {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.audit-detail-inner pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--on-surface);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
.audit-detail-inner .ad-err {
  background: rgba(225, 29, 72, 0.08);
  border-color: rgba(225, 29, 72, 0.3);
  color: var(--error);
}

/* ===== Extras de formularios (select, separadores) ===== */
.int-select {
  width: 100%; height: var(--input-height, 44px); border: 1.5px solid var(--border-strong); border-radius: var(--input-radius, 10px);
  padding: 10px 36px 10px 14px; font: inherit; font-size: 14px;
  color: var(--on-surface); background: var(--surface-card); outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.int-select:focus {
  border-color: var(--primary-container); box-shadow: var(--focus-ring);
}
:root[data-theme="dark"] .int-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.int-sep {
  display: flex; align-items: center; gap: 10px; margin: 6px 0 2px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
}
.int-sep::before, .int-sep::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }
.int-sep-note { margin: -2px 0 2px; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

@media (max-width: 640px) {
  .users-view { padding: 0 14px; }
  .users-head { gap: 10px; }
}

/* ===== Footer del sidebar: chip de perfil + dropdown de configuracion ===== */
.profile-chip {
  display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1;
  padding: 6px 8px; border: none; border-radius: 12px; background: transparent;
  cursor: pointer; color: inherit; font: inherit; text-align: left;
  transition: background 0.15s, transform 0.1s;
}
.profile-chip:hover { background: var(--surface-subtle); }
.profile-chip:active { transform: scale(0.98); }
.user-avatar-mini {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ai-grad-start), var(--ai-grad-end));
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.user-avatar-mini .ms { font-size: 16px; }
.profile-chip-name {
  font-size: 13px; font-weight: 600; color: var(--on-surface);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.sf-settings { position: relative; margin-left: 6px; flex-shrink: 0; }
.settings-menu {
  position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 90;
  min-width: 215px; background: var(--surface-card);
  border: 1px solid var(--border-subtle); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.settings-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: none; border-radius: 10px; background: transparent;
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--on-surface);
  cursor: pointer; text-align: left;
  transition: background 0.15s;
}
.settings-item:hover { background: var(--surface-subtle); }
.settings-item:active { transform: scale(0.98); }
.settings-item .ms { font-size: 17px; color: var(--on-surface-variant); }

/* ===== Pagina de perfil ===== */
.profile-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: 18px; padding: 22px 24px; box-shadow: var(--shadow-card);
}
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ai-grad-start), var(--ai-grad-end));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; text-transform: uppercase;
}
.profile-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.profile-name { font-size: 18px; font-weight: 700; color: var(--on-surface); }
.profile-email { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-details {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: 16px; padding: 6px 20px; display: flex; flex-direction: column;
  box-shadow: var(--shadow-card);
}
.profile-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px; color: var(--on-surface-variant);
}
.profile-row:last-child { border-bottom: none; }
.profile-row .ms { font-size: 19px; color: var(--text-muted); width: 24px; }
.profile-row strong {
  margin-left: auto; font-weight: 600; color: var(--on-surface);
  font-size: 13.5px; text-align: right; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 60%;
}
.profile-logout {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: 1px solid rgba(225, 29, 72, 0.25); border-radius: 12px;
  background: rgba(225, 29, 72, 0.06); color: var(--error); font: inherit;
  font-size: 14px; font-weight: 600; cursor: pointer; align-self: flex-start;
  transition: background 0.15s, transform 0.1s;
}
.profile-logout:hover { background: rgba(225, 29, 72, 0.14); }
.profile-logout:active { transform: scale(0.98); }

/* ===== Resultado de invitacion (password generada, se muestra una vez) ===== */
.invite-result {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 4px;
}
.invite-result-icon {
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--ai-grad-start), var(--ai-grad-end));
  color: #fff; margin-bottom: 4px;
}
.invite-result-icon .ms { font-size: 22px; }
.invite-result-title { font-size: 16px; font-weight: 700; color: var(--on-surface); }
.invite-result-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }
.invite-result-pass {
  width: 100%; background: var(--surface-subtle); border: 1px dashed var(--border-strong);
  border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.invite-result-pass-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
}
.invite-result-pass-row { display: flex; align-items: center; gap: 10px; }
.invite-result-pass-row code {
  flex: 1; font-family: var(--font-mono); font-size: 17px; font-weight: 700;
  letter-spacing: 0.04em; color: var(--primary-container); word-break: break-all;
}
:root[data-theme="dark"] .invite-result-pass-row code { color: #9cc3ee; }
.invite-result-note {
  font-size: 11.5px; color: var(--text-muted); text-align: center;
  margin: 2px 0 12px; line-height: 1.45;
}
#userCreatedOk { width: 100%; }

/* ===== Tema oscuro (data-theme="dark" en <html>) ===== */
:root { --chart-text: #43474f; }
:root[data-theme="dark"] {
  --surface: #0b1120;
  --surface-subtle: #151f36;
  --surface-card: #101a2e;
  --surface-low: #151f36;
  --surface-container-lowest: #101a2e;
  --surface-variant: #0b1120;
  --surface-container-highest: #1e2b47;
  --outline-variant: #24334f;
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);
  --on-surface: #e8eef7;
  --on-surface-variant: #b6c2d6;
  --text-muted: #8493ad;
  --chart-text: #c9d4e3;
  color-scheme: dark;
}
:root[data-theme="dark"] .int-input-wrap input,
:root[data-theme="dark"] .int-select { background: #0e1729; color: var(--on-surface); }
:root[data-theme="dark"] .auth-first-hint {
  background: rgba(0, 72, 141, 0.2); border-color: rgba(0, 104, 200, 0.35);
  color: var(--on-surface-variant);
}
:root[data-theme="dark"] .user-odoo { background: rgba(0, 72, 141, 0.25); color: #9cc3ee; }
:root[data-theme="dark"] .user-odoo.none { background: var(--surface-subtle); color: var(--text-muted); }
:root[data-theme="dark"] .session-item.active,
:root[data-theme="dark"] .integration-item.active { background: rgba(0, 88, 173, 0.25); }
:root[data-theme="dark"] .session-item:hover { background: var(--surface-subtle); }
:root[data-theme="dark"] .prompt-card,
:root[data-theme="dark"] .chart-card,
:root[data-theme="dark"] .modal-card,
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .profile-card,
:root[data-theme="dark"] .profile-details,
:root[data-theme="dark"] .user-row { background: var(--surface-card); }

/* ===== Pagina de preferencias ===== */
.prefs-card {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: 18px; padding: 6px 20px; display: flex; flex-direction: column;
  box-shadow: var(--shadow-card);
}
.prefs-row {
  display: flex; align-items: center; gap: 14px; padding: 15px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.prefs-row:last-child { border-bottom: none; }
.prefs-row > .ms { font-size: 22px; color: var(--text-muted); flex-shrink: 0; width: 24px; }
.prefs-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.prefs-label { font-size: 14px; font-weight: 600; color: var(--on-surface); }
.prefs-hint { font-size: 12px; color: var(--text-muted); }
.prefs-row select {
  height: 38px; border: 1.5px solid var(--border-strong); border-radius: 10px;
  background: var(--surface-card); color: var(--on-surface);
  font: inherit; font-size: 13.5px; font-weight: 500; padding: 6px 32px 6px 12px;
  outline: none; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
:root[data-theme="dark"] .prefs-row select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.prefs-row select:focus { border-color: var(--primary-container); box-shadow: var(--focus-ring); }
.prefs-note {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted); margin: 6px 4px 0;
}
.prefs-note .ms { font-size: 16px; color: var(--primary-container); }

/* ===== Modal generico de confirmacion ===== */
.confirm-card { max-width: 400px; }
.modal-head-icon.danger {
  background: rgba(225, 29, 72, 0.1); color: var(--error);
}
.modal-btn-primary.danger { background: var(--error); box-shadow: 0 2px 8px rgba(225, 29, 72, 0.25); }
.modal-btn-primary.danger:hover { background: var(--stop-red-hover); box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35); }

/* ===== Chips de acceso a integraciones (invitar/editar usuario) ===== */
.int-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.int-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; border: 1.5px solid var(--border-strong);
  background: var(--surface-card); color: var(--on-surface-variant);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.15s ease;
}
.int-chip .ms { font-size: 15px; }
.int-chip:hover { border-color: var(--primary-container); color: var(--primary-container); }
.int-chip:active { transform: scale(0.97); }
.int-chip.on {
  background: rgba(0, 72, 141, 0.12); border-color: var(--primary-container);
  color: var(--primary-container);
}
/* ===== Tema oscuro: zona del input de chat nunca más blanca ===== */
:root[data-theme="dark"] .commandbar.ai-chatbox-card,
:root[data-theme="dark"] .commandbar.is-recording {
  background: rgba(13, 23, 43, 0.95) !important;
  border-color: rgba(148, 163, 184, 0.28) !important;
  box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.6) !important;
}
:root[data-theme="dark"] .commandbar.ai-chatbox-card:focus-within:not(.is-recording) {
  background: #0d1729 !important;
  border-color: rgba(0, 104, 200, 0.55) !important;
  box-shadow:
    0 20px 40px -8px rgba(0, 0, 0, 0.6),
    0 0 0 3px rgba(0, 104, 200, 0.14) !important;
}
:root[data-theme="dark"] .commandbar textarea,
:root[data-theme="dark"] .commandbar input,
:root[data-theme="dark"] .commandbar .chat-input {
  color: var(--on-surface) !important;
  caret-color: var(--primary-container) !important;
}
:root[data-theme="dark"] .quick-chip {
  background: rgba(13, 23, 43, 0.82);
  border-color: rgba(148, 163, 184, 0.22);
  color: var(--on-surface-variant);
}
:root[data-theme="dark"] .quick-chip:hover {
  background: #101a2e;
  border-color: rgba(0, 104, 200, 0.5);
  color: var(--on-surface);
}
:root[data-theme="dark"] .int-chip.on { background: rgba(0, 104, 200, 0.22); color: #9cc3ee; }

/* ===== Tema oscuro: tablas markdown de Ari (el "parche blanco") ===== */
:root[data-theme="dark"] .md table {
  background: #0f1a2e;
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: none;
}
:root[data-theme="dark"] .md th {
  background: #16223c;
  border-bottom-color: rgba(148, 163, 184, 0.16);
}
:root[data-theme="dark"] .md td {
  border-bottom-color: rgba(148, 163, 184, 0.08);
}
:root[data-theme="dark"] .md tr:nth-child(even) td { background: #0c1526; }
:root[data-theme="dark"] .md blockquote {
  background: rgba(0, 104, 200, 0.12);
  border-left-color: var(--primary-container);
}

/* ===== Registro por invitación: tarjeta grande, todo en una pantalla ===== */
.auth-card-xl {
  width: min(94vw, 560px); max-width: 560px;
  padding: 40px 44px 34px; gap: 2px;
}
.auth-card-xl .auth-title { font-size: 30px; }
.auth-card-xl .auth-sub { margin: 2px 0 16px; font-size: 14px; max-width: 420px; text-align: center; }
.auth-card-xl .auth-form { width: 100%; gap: 16px; margin-top: 6px; }
.auth-card-xl .auth-first-hint { font-size: 13px; padding: 11px 14px; }
.auth-card-xl .int-field { gap: 7px; }
.auth-card-xl .int-label { font-size: 12px; }
.auth-card-xl .int-input-wrap input {
  padding: 13px 14px 13px 46px; font-size: 15px;
}
.auth-card-xl .auth-submit { padding: 13px 18px; font-size: 14.5px; }

/* ===== Switch Login / Registro ===== */
.auth-switch-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--text-muted, #64748b);
}
.auth-switch-link {
  color: var(--primary, #0068c8);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
}
.auth-switch-link:hover {
  text-decoration: underline;
  color: var(--primary-hover, #0052a3);
}

/* ===== Demo Guidance Banner ===== */
.demo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  margin: 12px auto 0;
  width: min(94vw, 900px);
  background: rgba(0, 104, 200, 0.08);
  border: 1px solid rgba(0, 104, 200, 0.22);
  border-radius: 12px;
  font-size: 13.5px;
  color: var(--text-main, #1e293b);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  animation: fadeInBanner 0.25s ease-out;
  z-index: 10;
}
@keyframes fadeInBanner {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.demo-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.demo-banner-icon {
  color: var(--primary, #0068c8);
  font-size: 20px;
  flex-shrink: 0;
}
.demo-banner-text {
  font-weight: 500;
  line-height: 1.4;
}
.demo-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.demo-banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--primary, #0068c8);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.demo-banner-btn:hover {
  background: var(--primary-hover, #0052a3);
}
.demo-banner-btn .ms {
  font-size: 16px;
}
.demo-banner-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.demo-banner-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-main, #1e293b);
}
.demo-banner-close .ms {
  font-size: 18px;
}

:root[data-theme="dark"] .demo-banner {
  background: rgba(0, 104, 200, 0.16);
  border-color: rgba(0, 104, 200, 0.35);
  color: #e2e8f0;
}
:root[data-theme="dark"] .demo-banner-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

/* ==========================================================================
   Voice Note Studio & Real-Time Waveform Capsule
   ========================================================================== */
.stitch-voice-capsule {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 14px;
  background: var(--surface-card, #ffffff);
  border-radius: 20px;
  min-height: 52px;
  box-sizing: border-box;
  animation: slideUpCapsule 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpCapsule {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

:root[data-theme="dark"] .stitch-voice-capsule {
  background: var(--surface-elevated, #161f30);
  border-color: rgba(255, 255, 255, 0.08);
}

/* Discard / Trash Button */
.stitch-btn-trash {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.stitch-btn-trash:hover {
  background: rgba(239, 68, 68, 0.18);
  transform: scale(1.05);
}

.stitch-btn-trash:active {
  transform: scale(0.95);
}

.stitch-btn-trash svg {
  width: 18px;
  height: 18px;
}

/* Recording Badge Pill */
.stitch-rec-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  flex-shrink: 0;
}

.stitch-rec-radar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 8px;
  height: 8px;
}

.stitch-radar-dot {
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  border-radius: 50%;
}

.stitch-radar-ping {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #ef4444;
  opacity: 0.75;
  animation: radarPing 1.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes radarPing {
  75%, 100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

.stitch-rec-label {
  font-size: 11px;
  font-weight: 700;
  color: #ef4444;
  letter-spacing: 0.06em;
}

.stitch-rec-timer {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface, #0f172a);
  min-width: 32px;
}

:root[data-theme="dark"] .stitch-rec-timer {
  color: #f8fafc;
}

/* Waveform Slot & Canvas */
.stitch-waveform-slot {
  position: relative;
  flex: 1;
  min-width: 100px;
  height: 36px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
  padding: 0 8px;
  overflow: hidden;
}

:root[data-theme="dark"] .stitch-waveform-slot {
  background: rgba(0, 0, 0, 0.2);
}

.stitch-waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Transcribing Overlay */
.stitch-transcribing-overlay {
  position: absolute;
  inset: 0;
  background: var(--surface-card, #ffffff);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  z-index: 5;
}

:root[data-theme="dark"] .stitch-transcribing-overlay {
  background: var(--surface-elevated, #161f30);
}

.stitch-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0, 104, 200, 0.2);
  border-top-color: var(--primary, #0068c8);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stitch-transcribing-text {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--primary, #0068c8);
}

/* Stop Button */
.stitch-btn-stop {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: var(--on-surface-variant, #475569);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

:root[data-theme="dark"] .stitch-btn-stop {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.stitch-btn-stop:hover {
  background: rgba(0, 0, 0, 0.12);
}

:root[data-theme="dark"] .stitch-btn-stop:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.stitch-stop-square {
  width: 12px;
  height: 12px;
  border-radius: 2.5px;
  background: currentColor;
}

/* Send Voice Note Button */
.stitch-btn-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--primary-container, #00488d);
  color: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 72, 141, 0.3);
  transition: background 0.15s ease, transform 0.1s ease;
}

.stitch-btn-send:hover {
  background: var(--primary, #0068c8);
  transform: scale(1.04);
}

.stitch-btn-send:active {
  transform: scale(0.96);
}

.stitch-btn-send svg {
  width: 18px;
  height: 18px;
}

/* ============================================================
   Experiencia móvil / PWA (spec 008 · T004)
   ------------------------------------------------------------
   Ajustes que solo aplican a pantallas pequeñas y al modo app
   instalada. Van al final para no alterar el orden de la cascada
   existente: en escritorio nada de esto cambia.
   ============================================================ */

/* 1. Alto real del viewport. 100vh incluye la barra del navegador móvil
      (que se oculta al hacer scroll) y el final del chat queda tapado.
      100dvh sigue el viewport visible; sin soporte se queda el 100vh. */
@supports (height: 100dvh) {
  .main { min-height: 100dvh; }
}

/* 2. Zonas seguras: notch/isla (arriba), barra de gestos (abajo). */
.dock { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.chat-fab {
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
}
.sidebar { padding-top: env(safe-area-inset-top, 0px); }
.vn-toast { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
.auth-view {
  padding: calc(20px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px))
           calc(20px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
}
.modal-overlay {
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px
           calc(20px + env(safe-area-inset-bottom, 0px));
}

/* 3. Modo app instalada: no hay barra de navegador, la shell arranca
      pegada al borde superior del dispositivo. */
@media (display-mode: standalone), (display-mode: fullscreen) {
  .main { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
}

/* 4. Móvil (<=640px). */
@media (max-width: 640px) {
  /* iOS hace zoom automático al enfocar campos con texto < 16px. */
  input, textarea, select { font-size: 16px; }
  .chatbox-input-area textarea { line-height: 22px; }

  /* Objetivos táctiles cómodos (los botones del compositor eran de 32-34px). */
  .shelf-btn { width: 38px; height: 38px; }
  .shelf-mic-btn, .shelf-send-btn { width: 40px; height: 40px; }
  .quick-chip { min-height: 34px; padding: 6px 13px; }

  /* Modales que caben con el teclado abierto y sin desbordar a los lados. */
  .modal-card { padding: 20px 18px; border-radius: 18px; max-height: calc(100dvh - 28px); }
  .auth-card { padding: 26px 20px 22px; }

  /* Gráficos: 320px de alto ocupan media pantalla en un móvil. */
  .chart-wrap { height: 240px; max-width: 100%; }

  /* Tablas: el ancho mínimo se reduce para que el scroll horizontal sea corto. */
  .users-table { min-width: 520px; }
}

/* ===== Selector de empresa (spec 019) ===== */
/* El picker vive dentro del modo normal del composer. El select nativo es
   invisible (se mantiene por compatibilidad); el control visible es un chip
   con un menú desplegable hacia arriba. */
.company-picker {
  position: relative;
  display: flex; align-items: flex-start;
  min-width: 0; margin: 0 0 2px;
}

.company-chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; max-width: 100%; min-width: 0;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(var(--empresa-rgb, 148, 163, 184), 0.35);
  background: rgba(var(--empresa-rgb, 148, 163, 184), 0.10);
  color: var(--on-surface);
  font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.company-chip-btn:hover {
  background: rgba(var(--empresa-rgb, 148, 163, 184), 0.14);
  border-color: rgba(var(--empresa-rgb, 148, 163, 184), 0.45);
}

.company-chip-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--empresa-color, var(--primary-container));
}

.company-chip-label {
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.company-chip-btn .ms {
  font-size: 16px; color: var(--on-surface-variant); flex-shrink: 0;
}

.company-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: rgb(var(--dot-rgb, var(--empresa-rgb, 148, 163, 184)));
  box-shadow: 0 0 0 3px rgba(var(--dot-rgb, var(--empresa-rgb, 148, 163, 184)), 0.18);
}

.company-select-native {
  position: absolute; width: 1px; height: 1px;
  opacity: 0; pointer-events: none; overflow: hidden;
  border: 0; padding: 0; margin: 0;
}

.company-menu {
  position: absolute;
  bottom: calc(100% + 6px); left: 0;
  z-index: 100;
  width: max-content;
  max-width: min(300px, calc(100vw - 32px));
  min-width: 180px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.18);
  padding: 6px;
}

.company-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  border-radius: 8px; border: none;
  background: transparent; color: var(--on-surface);
  font: inherit; font-size: 13px; text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.company-menu-item:hover,
.company-menu-item:focus-visible {
  background: var(--surface-subtle);
  outline: none;
}

.company-menu-item[aria-selected="true"] {
  background: rgba(0, 72, 141, 0.08);
  color: var(--primary-container);
}

.company-menu-name {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.company-menu-item .ms.check {
  font-size: 16px; color: var(--primary-container); flex-shrink: 0;
}

/* Acento sutil del composer con la empresa activa. Se usa un pseudo-elemento
   porque el tema oscuro pisaría cualquier border-color/box-shadow con
   !important sobre .commandbar.ai-chatbox-card. */
.commandbar.ai-chatbox-card[data-empresa="1"]::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: 6px;
  height: 2px; border-radius: 999px;
  background: var(--empresa-color);
  opacity: 0.4;
  pointer-events: none;
}

:root[data-theme="dark"] .company-chip-btn {
  background: rgba(var(--empresa-rgb, 148, 163, 184), 0.18);
  border-color: rgba(var(--empresa-rgb, 148, 163, 184), 0.45);
}

:root[data-theme="dark"] .company-dot {
  box-shadow: 0 0 0 3px rgba(var(--dot-rgb, var(--empresa-rgb, 148, 163, 184)), 0.28);
}

:root[data-theme="dark"] .company-menu {
  background: rgba(13, 23, 43, 0.98);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
}

:root[data-theme="dark"] .company-menu-item[aria-selected="true"] {
  background: rgba(0, 104, 200, 0.16);
}

@media (max-width: 640px) {
  .company-chip-btn { font-size: 12px; height: 28px; }
}

/* ===== Backoffice · Consumo (spec 025) ===== */
/* Dashboard de solo lectura (ruta /backoffice, solo Owner/Admin) sobre la
   telemetría de la spec 023. Reglas de marca: NINGÚN color HEX en este bloque;
   solo var(--...) o rgba() derivados de la paleta ARI ya definida arriba. */
:root {
  /* Solo variables nuevas del dashboard; NINGÚN HEX suelto en las reglas */
  --bo-track: rgba(20, 60, 50, 0.10);
  --bo-hint: var(--text-muted);
  --bo-barra: var(--primary-container);
  --bo-barra-hover: var(--ari-greenText);
}
:root[data-theme="dark"] {
  --bo-track: rgba(118, 207, 181, 0.16);
  --bo-barra: var(--ari-mint);
  --bo-barra-hover: var(--ari-surface);
}

/* La vista reusa .users-view (padding/ancho base); aquí solo se amplía el
   ancho máximo porque el grid de tarjetas necesita más aire que /usuarios. */
.bo-view {
  max-width: 1080px;
}

/* Estado centrado: cargando, "sin datos aún" (válido, no es error) y error
   real (solo el detalle de un tenant usa la variante roja). */
.bo-estado {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
}
.bo-estado-titulo {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
}
.bo-estado-hint {
  font-size: 12px;
  color: var(--bo-hint);
  max-width: 420px;
}
.bo-estado-error .bo-estado-titulo {
  color: var(--error);
}

/* Grid de tarjetas: minmax(min(100%, 320px), 1fr) evita el scroll horizontal
   en pantallas estrechas (la tarjeta nunca fuerza más del 100% del ancho). */
.bo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

/* Tarjeta de tenant */
.bo-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}
.bo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.bo-card-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
  overflow-wrap: anywhere;
}
.bo-card-id {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px 8px;
}

/* Métricas: etiqueta pequeña + número grande tabular */
.bo-metric {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bo-metric-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.bo-metric-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.bo-metric-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--on-surface);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.bo-metric-hint {
  font-size: 11px;
  color: var(--bo-hint);
}

/* Barra de progreso de la cuota (mes/día). El relleno es mint por defecto y
   cambia a warning/error solo por clase (nada de HEX en JS). */
.bo-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bo-track);
  overflow: hidden;
}
.bo-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--bo-barra);
  transition: width 0.3s ease;
}
.bo-bar-fill.bo-cuota-alto {
  background: var(--warning);
}
.bo-bar-fill.bo-cuota-excedida {
  background: var(--error);
}

/* Sparkline de la tarjeta y gráfico grande del detalle (SVG inline) */
.bo-spark {
  width: 100%;
  height: auto;
  display: block;
}
.bo-chart {
  width: 100%;
  height: auto;
  display: block;
}
.bo-bar {
  fill: var(--bo-barra);
}
.bo-bar:hover {
  fill: var(--bo-barra-hover);
}
.bo-axis {
  stroke: var(--border-subtle);
  stroke-width: 1;
}
.bo-axis-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-ui);
}

/* Filas de "tokens por modelo": nombre mono, barra proporcional y valor */
.bo-model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.bo-model-name {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--on-surface);
  overflow-wrap: anywhere;
}
.bo-model-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bo-track);
  overflow: hidden;
}
.bo-model-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}
.bo-model-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Botones del dashboard */
.bo-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: var(--surface-card);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.bo-btn:hover {
  opacity: 0.9;
}
.bo-btn:active {
  transform: scale(0.98);
}
.bo-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--on-surface-variant);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}
.bo-btn-ghost:hover {
  background: var(--surface-subtle);
  color: var(--on-surface);
}

/* Panel de detalle del tenant (se abre encima del grid de tarjetas) */
.bo-detalle {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
}
.bo-detalle-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bo-detalle-title {
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--on-surface);
  overflow-wrap: anywhere;
}
.bo-detalle-sec {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bo-detalle-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
}

/* Responsive: a <=640px el grid pasa a 1 columna, paddings menores y el SVG
   sigue sin desbordar (width:100% + height:auto ya lo garantizan). */
@media (max-width: 640px) {
  .bo-view { padding: 0 14px 80px; }
  .bo-grid { grid-template-columns: 1fr; gap: 12px; }
  .bo-card { padding: 14px; border-radius: 16px; }
  .bo-detalle { padding: 14px; border-radius: 16px; }
  .bo-model-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 6px; }
}


