:root {
  --gc-navy: #0b2946;
  --gc-navy-deep: #040508;
  --gc-navy-glow: #0e4f84;
  --gc-ink: #1e293b;
  --gc-gold: #b08d57;
  --gc-sand: #e9e2d6;
  --gc-paper: #f0f4f8;
  --gc-white: #ffffff;
  --gc-border: #d5dce4;
  --nexo-cyan: #22d3ee;
  --nexo-indigo: #6366f1;
  --nexo-glass: rgba(12, 20, 32, 0.78);
  --nexo-glow: rgba(34, 211, 238, 0.35);
  --nexo-text: #e8f0fa;
  --nexo-muted: #8ba3be;
  --chat-bg: #0d0f14;
  --chat-surface: #141820;
  --chat-composer: #1e222c;
  --chat-composer-border: rgba(255, 255, 255, 0.1);
  --chat-user-bubble: #2a3140;
  --chat-text: #ececf1;
  --chat-muted: #8e8ea0;
  --font-ui: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--gc-ink);
  background: linear-gradient(180deg, #f8fafc, var(--gc-paper));
}

.topbar {
  background: linear-gradient(95deg, #040508 0%, var(--gc-navy) 52%, #0c3d5c 100%);
  color: var(--gc-white);
  padding: 14px 28px;
  border-bottom: 1px solid rgba(34, 211, 238, 0.35);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  position: relative;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--nexo-cyan), transparent);
  opacity: 0.6;
}

.primary-nav {
  background: linear-gradient(90deg, #081a2b 0%, #0c2740 100%);
  border-bottom: 1px solid #1d456b;
}

.primary-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 10px;
}

.nav-item {
  color: #c8ddef;
  text-decoration: none;
  padding: 12px 14px;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  cursor: pointer;
}

.nav-item:hover {
  color: var(--gc-white);
}

.nav-item-active {
  color: var(--gc-white);
  border-bottom-color: var(--nexo-cyan);
  text-shadow: 0 0 12px var(--nexo-glow);
}

.brand-wrap {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.brand-logo {
  width: 168px;
  max-width: 40vw;
  height: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 2px 10px rgba(34, 211, 238, 0.2));
}

.brand-text {
  display: grid;
  gap: 2px;
}

.session-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dceaf8;
  font-size: 0.85rem;
}

.logout-btn {
  background: #f3f6fb;
  color: #0f172a;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
}

.logout-btn:hover {
  background: #ffffff;
}

.brand-main {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand-sub {
  color: #b8e8f8;
  font-size: 0.95rem;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
}

.container {
  min-width: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
}

.single-view {
  max-width: none;
  margin: 0;
  padding: 0;
}

.presentation-shell {
  min-height: calc(100vh - 126px);
  padding: 28px 20px 36px;
}

.train-rag-shell {
  max-width: 980px;
  margin: 24px auto;
  padding: 0 20px 36px;
}

.train-docs-heading {
  margin: 1.25rem 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gc-ink, #1a2b3c);
}

.train-docs-hint {
  margin-bottom: 0.5rem;
}

.presentation-card {
  max-width: 1180px;
  margin: 0 auto;
  background: var(--gc-white);
  border: 1px solid var(--gc-border);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 5px 14px rgba(14, 27, 42, 0.06);
}

.presentation-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.presentation-block {
  border: 1px solid var(--gc-border);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 16px;
}

.presentation-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #33465e;
}

.presentation-list li {
  margin-bottom: 6px;
}

.presentation-image-wrap {
  margin-top: 14px;
  border: 1px solid #bfd0e3;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff, #f2f7fd);
  padding: 10px;
}

.presentation-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(14, 27, 42, 0.12);
}

.rag-doc-btn,
.rag-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #d4d4de;
  padding: 0;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.rag-doc-btn:hover,
.rag-tool-btn:hover {
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.45);
  color: var(--nexo-cyan);
}

.rag-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.rag-doc-confirm-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hidden-view {
  display: none !important;
}

.app-layout {
  max-width: 1280px;
  margin: 24px auto;
  padding: 0 20px 36px;
  display: grid;
  gap: 18px;
  grid-template-columns: 280px 1fr;
  align-items: start;
}

.sidebar {
  background: var(--gc-white);
  border: 1px solid var(--gc-border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 5px 14px rgba(14, 27, 42, 0.06);
  position: sticky;
  top: 20px;
}

.sidebar-client-selector {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gc-border);
}

.sidebar-client-selector label {
  display: block;
  font-size: 0.82rem;
  color: #60748a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.sidebar-client-selector select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--gc-border);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--gc-ink);
  font-size: 0.9rem;
  font-weight: 600;
}

.sidebar h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.process-search {
  width: 100%;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid var(--gc-border);
  border-radius: 6px;
  background: #fbfdff;
}

.process-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.process-item {
  padding: 10px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #f6f8fb;
  color: #33465e;
  font-size: 0.92rem;
}

.process-item-active {
  border-color: #bfd0e3;
  background: #e9f0f7;
  color: #17324f;
  font-weight: 600;
}

.card {
  background: var(--gc-white);
  border: 1px solid var(--gc-border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 5px 14px rgba(14, 27, 42, 0.06);
}

.stage3-card {
  border-left: 4px solid #b9c7d8;
}

.stage3-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.stage3-note {
  margin-bottom: 0;
}

.stage3-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage3-status {
  color: #60748a;
  font-weight: 600;
  font-size: 0.88rem;
}

.stage3-btn {
  margin-top: 14px;
  width: 100%;
  display: block;
  box-sizing: border-box;
  padding: 14px 18px;
  text-align: center;
  white-space: normal;
  line-height: 1.4;
  font-size: 0.95rem;
  font-weight: 600;
  color: #3d4f63;
  background: #eef2f7;
  border: 1px dashed #a8b8ca;
  border-radius: 8px;
  cursor: not-allowed;
  box-shadow: none;
}

.stage3-btn:hover,
.stage3-btn:disabled {
  background: #eef2f7;
  color: #3d4f63;
  opacity: 1;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #c4ced9;
  transition: 0.2s;
  border-radius: 999px;
}

.switch input:disabled + .slider {
  cursor: not-allowed;
  opacity: 0.88;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

h1,
h2 {
  margin: 0 0 10px;
  color: var(--gc-navy-deep);
}

.hint {
  margin: 0 0 16px;
  color: #526274;
}

.process-docs-intro {
  margin-bottom: 8px;
}

.process-io-block {
  margin: 16px 0 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  align-items: stretch;
}

.process-io-section {
  padding: 18px;
  border-radius: 10px;
  border: 1px solid var(--gc-border);
}

.process-io-input {
  background: linear-gradient(180deg, #f0f6fc 0%, #e8f0f9 100%);
  border-color: #b8d4ee;
}

.process-io-output {
  background: linear-gradient(180deg, #f0faf4 0%, #e3f5ea 100%);
  border-color: #a3d9b5;
}

.process-io-heading {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.process-io-heading--input {
  color: #1a4b7a;
}

.process-io-heading--output {
  color: #1a6b3a;
}

.process-io-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 800;
  flex-shrink: 0;
}

.process-io-heading--input .process-io-icon {
  background: #1a4b7a;
  color: #fff;
}

.process-io-heading--output .process-io-icon {
  background: #1a6b3a;
  color: #fff;
}

.process-io-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

.process-io-arrow {
  font-size: 1.6rem;
  color: #8a9bb0;
  font-weight: 800;
}

.process-doc-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 6px;
  background: #e2ecf5;
  color: #2a5080;
  border: 1px solid #bbd0e8;
}

.process-doc-badge--primary {
  background: #1a4b7a;
  color: #fff;
  border-color: #1a4b7a;
}

.process-doc-badge--output {
  background: #1a6b3a;
  color: #fff;
  border-color: #1a6b3a;
}

.process-doc-detail {
  display: block;
  margin-top: 4px;
  font-size: 0.84rem;
  color: #607080;
  line-height: 1.4;
}

.process-doc-list {
  margin: 0 0 18px;
  padding-left: 1.25rem;
  color: #526274;
  font-size: 0.92rem;
  line-height: 1.45;
}

.process-doc-list li {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.process-doc-list li:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.process-doc-list code {
  font-size: 0.84em;
  background: #f0f3f7;
  padding: 2px 6px;
  border-radius: 4px;
  color: #2a3d52;
  word-break: break-word;
}

@media (max-width: 800px) {
  .process-io-block {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .process-io-divider {
    padding: 4px 0;
    transform: rotate(90deg);
  }
}

/* --- RAG chat layout (ChatGPT-inspired, NEXO dark) --- */
body:has(#view-rag:not(.hidden-view)) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--chat-bg);
}

body:has(#view-rag:not(.hidden-view)) > .topbar {
  flex-shrink: 0;
  padding: 8px 20px;
}

body:has(#view-rag:not(.hidden-view)) .brand-logo {
  width: 132px;
}

body:has(#view-rag:not(.hidden-view)) .brand-sub {
  font-size: 0.82rem;
  line-height: 1.25;
}

body:has(#view-rag:not(.hidden-view)) > .tenant-banner,
body:has(#view-rag:not(.hidden-view)) > .primary-nav {
  flex-shrink: 0;
}

body:has(#view-rag:not(.hidden-view)) .primary-nav-inner {
  overflow-x: auto;
  scrollbar-width: thin;
}

body:has(#view-rag:not(.hidden-view)) #view-rag.rag-view {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
}

body:has(#view-rag:not(.hidden-view)) footer.app-footer {
  display: none;
}

.rag-view.single-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.rag-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(34, 211, 238, 0.05) 0%, transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(99, 102, 241, 0.07) 0%, transparent 38%),
    var(--chat-bg);
  padding: 0;
}

.rag-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 48rem;
  width: 100%;
  margin: 0 auto;
  padding: 6px 16px 0;
  min-height: 0;
  overflow: hidden;
}

.rag-header {
  flex: 0 0 auto;
  padding: 2px 0 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rag-title {
  display: none;
}

.rag-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.rag-control-field {
  flex: 1 1 140px;
  min-width: 0;
}

.rag-master-field {
  flex: 1 1 200px;
}

.rag-controls label {
  display: block;
  font-size: 0.72rem;
  color: var(--chat-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.rag-controls select {
  width: 100%;
  border: 1px solid var(--chat-composer-border);
  border-radius: 12px;
  padding: 8px 12px;
  background: var(--chat-composer);
  color: var(--chat-text);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.rag-controls select:hover,
.rag-controls select:focus {
  border-color: rgba(34, 211, 238, 0.35);
  outline: none;
}

.rag-chunk-info {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: #6b7f96;
  text-align: center;
  letter-spacing: 0.02em;
}

.rag-chat-wrap {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  margin: 0 -4px;
}

.rag-chat {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 12px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.rag-chat::-webkit-scrollbar {
  width: 8px;
}

.rag-chat::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.rag-chat::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.rag-msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 100%;
  width: 100%;
  padding: 0;
  animation: ragMsgIn 0.25s ease-out;
}

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

.rag-msg-body {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 0.95rem;
  color: var(--chat-text);
  word-break: break-word;
}

.rag-msg-user {
  flex-direction: row-reverse;
  padding-left: 12%;
}

.rag-msg-user .rag-msg-body {
  background: var(--chat-user-bubble);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px 20px 4px 20px;
  padding: 12px 16px;
  max-width: 85%;
}

.rag-msg-bot {
  padding-right: 8%;
}

.rag-msg-bot .rag-msg-body {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}

.rag-msg-images,
.rag-msg-videos {
  align-items: flex-start;
  padding-right: 8%;
}

.rag-msg-images .rag-image-gallery,
.rag-msg-videos .rag-video-gallery {
  flex: 1;
  min-width: 0;
  max-width: min(560px, 100%);
}

.rag-video-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
}

.rag-video-item {
  position: relative;
  margin: 0;
}

.rag-video-item--chapter .rag-chat-inline-video {
  max-height: 280px;
}

.rag-video-chapter-card {
  border-radius: 10px;
  border: 1px solid #36465d;
  background: rgba(11, 16, 24, 0.65);
  overflow: hidden;
}

.rag-chat-video-thumb {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  background: #000;
}

.rag-video-snippet {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #c8d2e0;
  border-top: 1px solid rgba(54, 70, 93, 0.6);
}

.rag-video-no-mp4-hint {
  margin: 0;
  padding: 8px 12px 12px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #8fa3bd;
  font-style: italic;
}

.rag-chat-inline-video {
  display: block;
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
  border: 1px solid #36465d;
  background: #000;
  object-fit: contain;
}

.rag-image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  width: 100%;
}

.rag-image-item {
  position: relative;
  margin: 0;
}

.rag-image-item img.rag-chat-thumb {
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border: 1px solid #36465d;
  border-radius: 8px;
  background: #0b1018;
  cursor: zoom-in;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rag-image-item img.rag-chat-thumb:hover {
  border-color: #63b7ff;
  box-shadow: 0 0 0 1px rgba(99, 183, 255, 0.35);
}

.rag-image-item img.rag-chat-thumb:focus {
  outline: none;
  border-color: #63b7ff;
  box-shadow: 0 0 0 2px rgba(99, 183, 255, 0.5);
}

.rag-media-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px;
  border-radius: 12px;
  background: rgba(5, 10, 18, 0.72);
  border: 1px solid rgba(99, 183, 255, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.rag-media-tool-btn {
  box-sizing: border-box;
  min-width: 42px;
  height: 42px;
  padding: 0 10px;
  margin: 0;
  border: 0;
  border-radius: 10px;
  background: #ffffff;
  color: #0b2946;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.rag-media-tool-btn:hover {
  background: #e8f2fc;
}

.rag-media-tool-btn:focus-visible {
  outline: 2px solid #63b7ff;
  outline-offset: 2px;
}

.rag-media-tool-glyph {
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1;
  font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif;
}

.rag-media-tool-link {
  color: #0b2946;
}

.rag-media-icon-btn {
  box-sizing: border-box;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #f3f6fb;
  color: #10131a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.rag-media-icon-btn:hover {
  background: #ffffff;
}

.rag-media-icon-btn:focus-visible {
  outline: 2px solid #63b7ff;
  outline-offset: 2px;
}

.rag-media-icon-link {
  color: #10131a;
}

.rag-media-icon-img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  pointer-events: none;
  flex-shrink: 0;
}

.rag-media-panel-icon {
  background: #1a2838;
  color: #e7edf7;
  border: 1px solid #36465d;
}

.rag-media-panel-icon:hover {
  background: #243447;
  color: #ffffff;
}

.rag-media-btn {
  border-radius: 999px;
  padding: 7px 12px;
  background: #f3f6fb;
  color: #10131a;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: none;
}

.rag-media-btn:hover {
  background: #ffffff;
}

.rag-media-link {
  display: inline-flex;
  align-items: center;
}

.rag-media-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  isolation: isolate;
}

/* Tutorial: scroll dentro del panel (clase rag-media-modal--tutorial desde JS) */
.rag-media-modal.rag-media-modal--tutorial {
  overflow-y: hidden;
  align-items: stretch;
  justify-content: center;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

.rag-media-modal.rag-media-modal--tutorial .rag-media-panel {
  margin-left: auto;
  margin-right: auto;
}

.rag-media-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(3, 6, 10, 0.82);
  cursor: pointer;
}

.rag-media-panel {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: min(960px, calc(100vw - 24px));
  max-width: 100%;
  max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  overflow: hidden;
  background: #0b1018;
  border: 1px solid #2f4761;
  border-radius: 16px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Modal tutorial: altura fija para que flex + overflow permitan scroll interno */
.rag-media-panel.rag-media-panel--tutorial {
  flex-shrink: 1;
  min-height: 0;
  /* Altura explicita: sin esto el panel crece con el texto y no aparece barra de scroll interna */
  height: min(
    88dvh,
    calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)),
    calc(100vh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
  );
  max-height: min(
    88dvh,
    calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)),
    calc(100vh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
  );
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

.rag-media-panel.rag-media-panel--tutorial .rag-media-body--tutorial,
.rag-media-panel.rag-media-panel--tutorial .rag-media-body--tutorial * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

.rag-media-floating-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  max-width: calc(100% - 24px);
  pointer-events: auto;
}

.rag-media-zoom-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-right: 2px;
}

.rag-media-zoom-label {
  min-width: 3.1em;
  text-align: center;
  font-weight: 800;
  font-size: 0.82rem;
  color: #e2ecf5;
  user-select: none;
  padding: 0 4px;
}

.rag-media-modal-btn-zoom {
  padding: 8px 11px;
  font-size: 0.85rem;
}

.rag-media-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  background: #0b2946;
  color: #ffffff;
}

.rag-media-modal-btn:hover {
  background: #123a5c;
}

.rag-media-modal-btn-download {
  background: #1a5f8f;
}

.rag-media-modal-btn-download:hover {
  background: #2470a8;
}

.rag-media-modal-btn-close {
  background: #3d1a1a;
  border-color: rgba(255, 180, 180, 0.45);
}

.rag-media-modal-btn-close:hover {
  background: #5c2424;
}

.rag-media-modal-glyph {
  font-size: 1.25rem;
  line-height: 1;
  font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif;
}

.rag-media-modal-hint {
  letter-spacing: 0.02em;
}

@media (max-width: 480px) {
  .rag-media-modal-hint {
    display: none;
  }

  .rag-media-modal-btn {
    padding: 10px 12px;
  }
}

.rag-media-body {
  padding: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.rag-media-zoom-stage {
  flex: 1;
  min-height: 160px;
  width: 100%;
  overflow: auto;
  padding: 4px;
  cursor: grab;
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.rag-media-zoom-stage.rag-media-zoom-stage--dragging {
  cursor: grabbing;
  user-select: none;
}

.rag-media-zoom-inner {
  display: inline-block;
  line-height: 0;
  vertical-align: top;
}

.rag-modal-main-img {
  display: block;
  max-width: none;
  height: auto;
  border-radius: 12px;
  border: 1px solid #36465d;
  background: #000;
  pointer-events: none;
  user-select: none;
}

.rag-media-body video {
  max-width: 100%;
  max-height: calc(100vh - 56px);
  border-radius: 12px;
  border: 1px solid #36465d;
  background: #000;
}

.rag-modal-main-video {
  width: 100%;
  max-height: min(78vh, 720px);
  margin: 0 auto;
  display: block;
}

.rag-image-item figcaption,
.rag-video-item figcaption {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #a7b9cd;
}

.rag-msg-typing {
  min-width: 90px;
}

.rag-msg-typing .typing-wrap {
  padding-top: 8px;
}

.typing-wrap {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 0;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--nexo-cyan);
  opacity: 0.7;
  animation: typingBounce 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.rag-bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(34, 211, 238, 0.35);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
  flex: 0 0 auto;
}

.rag-composer-zone {
  flex: 0 0 auto;
  padding-top: 6px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 10;
  background: var(--chat-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.rag-composer-zone::before {
  content: none;
}

.rag-composer {
  margin: 0;
}

.rag-composer-box {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 8px 10px 8px 6px;
  background: var(--chat-composer);
  border: 1px solid var(--chat-composer-border);
  border-radius: 26px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.2),
    0 8px 32px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rag-composer-box:focus-within {
  border-color: rgba(34, 211, 238, 0.35);
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.12),
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 24px rgba(34, 211, 238, 0.08);
}

.rag-composer-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding-bottom: 2px;
}

.rag-composer-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font-size: 1rem;
  line-height: 1.5;
  padding: 10px 8px;
  outline: none;
}

.rag-composer-input::placeholder {
  color: var(--chat-muted);
}

.rag-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--nexo-cyan) 0%, var(--nexo-indigo) 100%);
  color: #0a0c10;
  padding: 0;
  font-weight: 400;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.35);
  transition: transform 0.12s ease, opacity 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
  margin-bottom: 2px;
}

.rag-send-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: scale(1.04);
}

.rag-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.rag-send-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.rag-send-btn--loading .rag-send-icon {
  display: none;
}

.rag-send-btn--loading .rag-spinner {
  display: block;
}

.rag-composer-disclaimer {
  margin: 6px 0 0;
  text-align: center;
  font-size: 0.68rem;
  color: var(--chat-muted);
  line-height: 1.3;
}

.rag-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(10, 12, 16, 0.25);
  border-top-color: #0a0c10;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.hidden-spinner {
  display: none;
}

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

@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.train-table-wrap {
  margin-top: 14px;
}

.table-pager-wrap {
  margin-top: 14px;
}

.table-pager-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--gc-border);
  border-radius: 8px;
}

.table-pager-search-input {
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 380px;
  padding: 8px 10px;
  border: 1px solid var(--gc-border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--gc-white);
}

.table-pager-meta {
  font-size: 0.82rem;
  color: #5a6b7d;
  flex: 1 1 auto;
}

.table-pager-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-pager-page {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gc-navy-deep);
  min-width: 118px;
  text-align: center;
}

.table-pager-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--gc-border);
  background: var(--gc-white);
  color: var(--gc-navy-deep);
  cursor: pointer;
  font-size: 0.82rem;
}

.table-pager-btn:hover:not(:disabled) {
  background: #edf2f7;
}

.table-pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.users-form input,
.users-form select {
  min-width: 220px;
}

.users-role-select {
  width: 100%;
  min-width: 120px;
  padding: 6px 8px;
  border: 1px solid var(--gc-border);
  border-radius: 6px;
  background: #fbfdff;
}

.users-row-self {
  background: #f3f4f6;
}

.users-row-self td {
  color: #6b7280;
}

.users-feedback {
  margin-bottom: 12px;
  border-radius: 6px;
  padding: 9px 12px;
  font-weight: 600;
}

.users-feedback-hidden {
  display: none;
}

.users-feedback-ok {
  background: #eaf7ef;
  border: 1px solid #9cccad;
  color: #1f5130;
}

.users-feedback-error {
  background: #fcebec;
  border: 1px solid #ecb0b6;
  color: #7f1d1d;
}

.danger-btn {
  background: #7f1d1d;
}

.danger-btn:hover {
  background: #991b1b;
}

.users-row-self .danger-btn:disabled,
.users-row-self .users-role-select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.tutorial-output {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.saved-tutorials-wrap {
  margin-top: 0;
}

.saved-tutorials-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.saved-tutorials-table th,
.saved-tutorials-table td {
  border: 1px solid var(--gc-border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

.saved-tutorials-table thead th {
  background: #eef2f7;
  color: var(--gc-navy-deep);
  font-weight: 700;
}

.saved-tutorials-table tbody tr:nth-child(even) {
  background: #fafcfe;
}

.saved-tutorials-title-cell {
  max-width: 280px;
  word-break: break-word;
}

.saved-tutorials-col-actions,
.saved-tutorials-actions-cell {
  white-space: nowrap;
  width: 1%;
}

.saved-tutorials-actions-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tutorial-open-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #0e4f84;
  background: #fff;
  color: var(--gc-navy-deep);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.tutorial-open-btn:hover {
  background: #f0f7ff;
  border-color: #63b7ff;
}

/*
 * Tutorial: el panel tiene altura fija; el body sale del flujo flex (absolute)
 * y rellena el rectangulo debajo del boton Cerrar. El div .rag-media-tutorial-scroll
 * llena el body y es el unico elemento con overflow-y: scroll.
 */
.rag-media-panel.rag-media-panel--tutorial .rag-media-body.rag-media-body--tutorial {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: 50px !important;
  bottom: 0 !important;
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  display: block !important;
  flex: none !important;
  min-height: 0 !important;
  max-height: none !important;
  box-sizing: border-box !important;
}

.rag-media-panel.rag-media-panel--tutorial .rag-media-tutorial-wrap {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  bottom: 12px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.rag-media-panel.rag-media-panel--tutorial .rag-media-tutorial-scroll {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  padding: 4px 4px 28px;
  margin: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  outline: none;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.45) rgba(255, 255, 255, 0.08);
}

.rag-media-panel.rag-media-panel--tutorial .rag-media-tutorial-scroll::-webkit-scrollbar {
  width: 11px;
}

.rag-media-panel.rag-media-panel--tutorial .rag-media-tutorial-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.rag-media-panel.rag-media-panel--tutorial .rag-media-tutorial-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.rag-media-panel.rag-media-panel--tutorial .rag-media-tutorial-scroll:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(99, 183, 255, 0.45);
}

.rag-media-tutorial-title {
  margin: 0 48px 10px 4px;
  font-size: 1.22rem;
  font-weight: 800;
  color: #fff !important;
  line-height: 1.3;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.rag-media-tutorial-caption {
  font-size: 0.78rem;
  color: #fff !important;
  opacity: 0.92;
  margin: 0 4px 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2f4761;
  line-height: 1.4;
}

.rag-media-tutorial-prose {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 0.92rem;
  line-height: 1.58;
  color: #fff !important;
  padding: 0 4px;
  max-width: 72ch;
}

.rag-media-tutorial-prose h1,
.rag-media-tutorial-prose h2,
.rag-media-tutorial-prose h3,
.rag-media-tutorial-prose h4 {
  margin: 1.1em 0 0.4em;
  color: #fff !important;
  font-weight: 800;
  line-height: 1.28;
}

.rag-media-tutorial-prose h1:first-child,
.rag-media-tutorial-prose h2:first-child,
.rag-media-tutorial-prose h3:first-child {
  margin-top: 0;
}

.rag-media-tutorial-prose h1 {
  font-size: 1.2rem;
}

.rag-media-tutorial-prose h2 {
  font-size: 1.1rem;
}

.rag-media-tutorial-prose h3 {
  font-size: 1.02rem;
  color: #fff !important;
}

.rag-media-tutorial-prose h4 {
  font-size: 0.98rem;
  color: #fff !important;
}

.rag-media-tutorial-prose h5,
.rag-media-tutorial-prose h6 {
  margin: 0.95em 0 0.35em;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff !important;
}

.rag-media-tutorial-prose p {
  margin: 0 0 0.85em;
  color: #fff !important;
}

.rag-media-tutorial-prose ul {
  margin: 0 0 1em;
  padding-left: 1.35rem;
}

.rag-media-tutorial-prose li {
  margin-bottom: 0.35em;
  color: #fff !important;
}

.rag-media-tutorial-prose li::marker {
  color: #fff !important;
}

.rag-media-tutorial-prose code {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff !important;
}

.rag-media-tutorial-prose strong {
  font-weight: 700;
  color: #fff !important;
}

.rag-media-tutorial-prose em {
  font-style: italic;
  color: #fff !important;
  opacity: 0.95;
}

@media (max-width: 480px) {
  .rag-media-tutorial-title {
    margin-right: 4px;
    font-size: 1.05rem;
  }
}

.tutorial-block {
  border: 1px solid var(--gc-border);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
}

.tutorial-steps {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.tutorial-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.tutorial-media-card {
  margin: 0;
}

.tutorial-media-card img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #bfd0e3;
  background: #fff;
}

.tutorial-media-card figcaption {
  margin-top: 4px;
  font-size: 0.8rem;
  color: #526274;
}

.tutorial-links {
  display: grid;
  gap: 8px;
}

.tutorial-video-item video {
  width: min(480px, 100%);
  border-radius: 8px;
  border: 1px solid #bfd0e3;
  background: #000;
  display: block;
  margin-bottom: 6px;
}

.tutorial-inline-video {
  width: min(560px, 100%) !important;
  max-height: 320px;
}

.tutorial-video-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.tutorial-video-fs-btn {
  border: 1px solid #0e4f84;
  background: #0b2946;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.tutorial-video-fs-btn:hover {
  background: #123a5c;
}

.tutorial-link-item a,
.tutorial-video-item a {
  color: #0e4f84;
  text-decoration: none;
}

.tutorial-link-item a:hover,
.tutorial-video-item a:hover {
  text-decoration: underline;
}

.login-page {
  position: relative;
  overflow: hidden;
}

.login-grid-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(34, 211, 238, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
    linear-gradient(rgba(34, 211, 238, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.04) 1px, transparent 1px);
  background-size: auto, auto, 48px 48px, 48px 48px;
  pointer-events: none;
  z-index: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .login-grid-bg {
    animation: nexo-grid-drift 24s linear infinite;
  }
}

@keyframes nexo-grid-drift {
  0% { background-position: 0 0, 0 0, 0 0, 0 0; }
  100% { background-position: 0 0, 0 0, 48px 48px, 48px 48px; }
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 10%, #0d1520 0%, #060a10 55%, #040508 100%);
  position: relative;
  z-index: 1;
}

.login-card {
  width: min(440px, 100%);
  background: var(--nexo-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 16px;
  padding: 28px 26px;
  color: var(--nexo-text);
  box-shadow: 0 0 40px rgba(34, 211, 238, 0.08), 0 20px 50px rgba(0, 0, 0, 0.45);
}

.login-card-tech {
  position: relative;
}

.login-card-tech::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 17px;
  padding: 1px;
  background: linear-gradient(135deg, var(--nexo-cyan), transparent 40%, var(--nexo-indigo));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.login-brand {
  text-align: center;
  margin-bottom: 1rem;
}

.login-logo {
  width: min(240px, 100%);
  height: auto;
  margin: 0 auto 12px;
  display: block;
  filter: drop-shadow(0 0 16px rgba(34, 211, 238, 0.25));
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lang-switch-corner {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1200;
  padding: 5px 12px 5px 8px;
  background: rgba(6, 12, 22, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 999px;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.45),
    0 0 20px rgba(34, 211, 238, 0.12);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.lang-switch-corner:hover {
  border-color: rgba(34, 211, 238, 0.7);
  box-shadow:
    0 6px 28px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(34, 211, 238, 0.2);
  transform: translateY(-1px);
}

.lang-globe-icon {
  width: 18px;
  height: 18px;
  color: var(--nexo-cyan);
  flex-shrink: 0;
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--nexo-text);
  border: none;
  border-radius: 0;
  padding: 4px 22px 4px 2px;
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 88px;
  background-image: linear-gradient(45deg, transparent 50%, var(--nexo-cyan) 50%),
    linear-gradient(135deg, var(--nexo-cyan) 50%, transparent 50%);
  background-position: calc(100% - 10px) calc(50% - 2px), calc(100% - 5px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.lang-select:focus {
  outline: none;
}

.lang-switch-corner:focus-within {
  outline: 2px solid var(--nexo-cyan);
  outline-offset: 2px;
}

html[dir="rtl"] .lang-switch-corner {
  right: auto;
  left: 12px;
}

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

.nexo-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--nexo-cyan);
  border: 1px solid rgba(34, 211, 238, 0.4);
  border-radius: 4px;
  padding: 4px 10px;
  margin-bottom: 10px;
}

.login-card h1 {
  color: #f2f5fa;
  margin: 0 0 6px;
  font-size: 1.85rem;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}

.login-tagline {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--nexo-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 999px;
  padding: 5px 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
  animation: nexo-pulse 2s ease-in-out infinite;
}

@keyframes nexo-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.btn-nexo-primary {
  margin-top: 6px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  color: #041018;
  background: linear-gradient(135deg, var(--nexo-cyan) 0%, #38bdf8 50%, var(--nexo-indigo) 100%);
  box-shadow: 0 0 22px var(--nexo-glow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-nexo-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.5);
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 10px;
  background: rgba(6, 12, 20, 0.85);
  color: #e6edf6;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--nexo-cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

.login-error {
  background: #2b1114;
  color: #ffb4b4;
  border: 1px solid #66343a;
  border-radius: 8px;
  padding: 8px 10px;
}

#sector-select,
#client-select {
  border-radius: 999px;
  background: #0b0f15;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

input[type="file"] {
  padding: 8px;
  border: 1px solid var(--gc-border);
  border-radius: 6px;
  background: #fafcfe;
}

button,
.button-link {
  background: var(--gc-navy);
  color: var(--gc-white);
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}

button:hover,
.button-link:hover {
  background: var(--gc-navy-deep);
}

/* Chat composer: override global button styles */
.rag-composer-box .rag-tool-btn,
.rag-composer-box .rag-send-btn,
.rag-composer-box .rag-doc-btn {
  border-radius: 999px;
}

.rag-composer-box .rag-tool-btn,
.rag-composer-box .rag-doc-btn {
  background: rgba(255, 255, 255, 0.07);
  color: #d4d4de;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0;
  font-weight: 400;
}

.rag-composer-box .rag-tool-btn:hover,
.rag-composer-box .rag-doc-btn:hover {
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.45);
  color: var(--nexo-cyan);
}

.rag-composer-box .rag-send-btn {
  background: linear-gradient(135deg, var(--nexo-cyan) 0%, var(--nexo-indigo) 100%);
  color: #0a0c10;
  padding: 0;
  font-weight: 400;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.35);
}

.rag-composer-box .rag-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #3de8ff 0%, #7c7ff5 100%);
  filter: brightness(1.05);
}

.rag-quick-tab-btn {
  background: transparent;
  color: var(--chat-text);
  border: 1px solid var(--chat-composer-border);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 500;
}

.rag-quick-tab-btn:hover:not(:disabled) {
  background: rgba(34, 211, 238, 0.08);
  border-color: rgba(34, 211, 238, 0.4);
  color: var(--chat-text);
}

.convo-stop-btn {
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 600;
}

.convo-stop-btn:hover {
  background: #ef4444;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stats-grid div {
  background: #f9f7f3;
  border-left: 4px solid var(--gc-gold);
  padding: 10px 12px;
  border-radius: 4px;
}

.stats-grid strong {
  display: block;
  font-size: 0.9rem;
  color: #465b73;
}

.stats-grid span {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gc-navy);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  border: 1px solid var(--gc-border);
  padding: 8px;
  vertical-align: top;
}

th {
  text-align: left;
  background: #edf2f7;
  color: var(--gc-navy-deep);
}

.train-rag-features {
  margin: 0 0 20px;
  padding: 16px 18px;
  border: 1px solid var(--gc-border);
  border-radius: 10px;
  background: linear-gradient(180deg, #fbfcfe 0%, #f4f6fa 100%);
  box-shadow: 0 2px 10px rgba(14, 27, 42, 0.04);
}

.train-rag-features h2 {
  font-size: 1.05rem;
}

.train-feature-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.train-feature-block {
  padding: 18px 18px 16px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.train-feature-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.train-feature-tutorial {
  margin: 14px 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f7f9fc;
  border: 1px solid #e8edf4;
  font-size: 0.86rem;
  line-height: 1.45;
  color: #4a5a6e;
}

.train-feature-tutorial p {
  margin: 0 0 8px;
}

.train-feature-tutorial p:last-child {
  margin-bottom: 0;
}

.train-feature-formats code {
  font-size: 0.82rem;
  background: #edf2f7;
  padding: 1px 5px;
  border-radius: 4px;
}

.train-feature-need-files {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  color: #9b2c2c;
  font-size: 0.84rem;
  line-height: 1.4;
}

.train-feature-files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.train-feature-files-pager-wrap {
  margin-top: 12px;
}

.train-feature-files-pager-wrap .table-pager-bar {
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.train-feature-files-pager-wrap .train-feature-files {
  gap: 12px;
}

.train-feature-file-empty {
  font-size: 0.82rem;
  color: #718096;
  font-style: italic;
  padding: 6px 0;
}

.train-feature-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.84rem;
}

.train-feature-file-meta {
  word-break: break-word;
  color: #2d3748;
}

.train-feature-file-delete {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 0.78rem;
}

.train-feature-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.train-feature-text strong {
  font-size: 0.92rem;
  color: var(--gc-navy-deep);
}

.train-feature-desc {
  font-size: 0.8rem;
  color: #6b7c90;
  line-height: 1.35;
}

.train-rag-features .switch input:disabled + .slider {
  cursor: not-allowed;
}

.train-rag-features .switch input:checked + .slider {
  background-color: #2c5282;
}

.train-rag-features .switch input:checked + .slider:before {
  transform: translateX(20px);
}

.train-formatos-actions {
  margin-top: 4px;
}

.train-formatos-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: var(--gc-navy-deep, #1a365d);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(14, 27, 42, 0.12);
  transition: background 0.15s ease, transform 0.1s ease;
}

.train-formatos-btn:hover {
  background: #234876;
  color: #fff;
}

.rag-chat-quick-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 0 0 6px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid var(--chat-composer-border);
  background: rgba(30, 34, 44, 0.6);
}

.rag-chat-quick-label {
  font-size: 0.75rem;
  color: var(--chat-muted);
  font-weight: 600;
}

.rag-chat-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.rag-quick-tab-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--chat-composer-border);
  background: transparent;
  color: var(--chat-text);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.rag-save-tutorial-btn,
.rag-save-process-btn {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  line-height: 1.3;
  text-align: center;
  padding: 7px 10px;
}

.rag-quick-tab-btn:hover:not(:disabled) {
  border-color: rgba(34, 211, 238, 0.4);
  background: rgba(34, 211, 238, 0.08);
}

.rag-quick-tab-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.rag-video-time-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 3;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(11, 28, 48, 0.88);
  border: 1px solid rgba(99, 183, 255, 0.45);
  pointer-events: none;
}

.rag-video-playbar {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rag-video-playfrom-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #2c5282;
  background: #ebf4ff;
  color: #1a365d;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.rag-video-playfrom-btn:hover {
  background: #cfe4ff;
}

.formatos-rag-body .formatos-back-link {
  display: inline-block;
  margin-left: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gc-navy-deep);
  background: #edf2f7;
  border: 1px solid var(--gc-border);
}

.formatos-rag-main {
  padding-bottom: 40px;
}

.formatos-rag-card h2 {
  margin-top: 22px;
  font-size: 1.05rem;
}

.formatos-rag-list {
  margin: 8px 0 12px;
  padding-left: 1.25rem;
  line-height: 1.55;
  color: #3d4f63;
}

.formatos-rag-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--gc-border);
}

.primary-like-link {
  font-weight: 700;
  color: #2c5282;
  text-decoration: none;
}

.primary-like-link:hover {
  text-decoration: underline;
}

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

  .sidebar {
    position: static;
  }

  .presentation-grid {
    grid-template-columns: 1fr;
  }

  .stage3-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .session-box {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
}

/* --- Mapa 3D de la base vectorial --- */
.vm-shell {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.vm-title {
  margin: 0;
}

.vm-sub {
  margin: 0;
  color: var(--muted, #94a3b8);
  font-size: 0.9rem;
  max-width: 70ch;
}

.vm-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.vm-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.vm-field > label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #94a3b8);
}

.vm-field select,
.vm-search-row input {
  padding: 0.5rem 0.65rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.4);
  color: inherit;
  min-width: 12rem;
}

.vm-search {
  flex: 1 1 22rem;
}

.vm-search-row {
  display: flex;
  gap: 0.5rem;
}

.vm-search-row input {
  flex: 1 1 auto;
  min-width: 8rem;
}

.vm-btn {
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--accent, #6366f1);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.vm-btn:hover {
  filter: brightness(1.08);
}

.vm-btn-ghost {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: inherit;
}

.vm-plot {
  width: 100%;
  height: 68vh;
  min-height: 420px;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.35);
}

.vm-info {
  font-size: 0.85rem;
  color: var(--muted, #cbd5e1);
  line-height: 1.5;
}

.vm-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.vm-stat-cards {
  display: flex;
  gap: 0.75rem;
}

.vm-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 6rem;
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.08);
}

.vm-stat-num {
  font-size: 1.5rem;
  font-weight: 700;
}

.vm-stat-lbl {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #94a3b8);
}

.vm-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 16rem;
  font-size: 0.82rem;
}

.vm-doc-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.15rem 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.25);
}

.vm-doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vm-doc-chunks {
  color: var(--muted, #94a3b8);
  white-space: nowrap;
}

/* --- Preguntas sugeridas (chips) --- */
.rag-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
  margin: 0 0 8px;
  padding: 0 2px 2px;
  max-height: 4.8rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.rag-suggestion-chip {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--chat-composer-border);
  background: var(--chat-composer);
  color: var(--chat-text);
  font-size: 0.76rem;
  line-height: 1.25;
  cursor: pointer;
  white-space: normal;
  flex: 0 1 auto;
  max-width: 100%;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.rag-suggestion-chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.rag-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--chat-composer-border);
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  margin-left: auto;
}

.rag-export-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
  border-color: rgba(34, 211, 238, 0.3);
}

.rag-export-btn .rag-icon {
  width: 16px;
  height: 16px;
}

/* --- Boton de grabacion de voz en el chat --- */
.rag-mic-btn[disabled] {
  opacity: 0.7;
  cursor: progress;
}

.rag-mic-recording {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #f87171 !important;
  animation: rag-mic-pulse 1.1s ease-in-out infinite;
}

@keyframes rag-mic-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* --- Modo conversacion en tiempo real --- */
.rag-convo-active {
  background: rgba(34, 211, 238, 0.15) !important;
  color: var(--nexo-cyan) !important;
}

.convo-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 14px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: rgba(34, 211, 238, 0.06);
}

.convo-status {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--nexo-cyan);
  white-space: nowrap;
}

.convo-live {
  flex: 1 1 auto;
  color: var(--chat-muted);
  font-size: 0.82rem;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.convo-stop-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.convo-stop-btn:hover {
  background: #ef4444;
}

@media (max-height: 780px) {
  body:has(#view-rag:not(.hidden-view)) > .topbar {
    padding: 6px 14px;
  }

  body:has(#view-rag:not(.hidden-view)) .brand-logo {
    width: 108px;
  }

  .rag-header {
    padding: 0 0 4px;
  }

  .rag-controls {
    gap: 6px;
  }

  .rag-controls label {
    margin-bottom: 2px;
    font-size: 0.66rem;
  }

  .rag-controls select {
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  .rag-composer-disclaimer {
    margin-top: 4px;
    font-size: 0.62rem;
  }
}

@media (max-width: 640px) {
  .rag-card {
    padding: 4px 10px 0;
  }

  .rag-header {
    padding: 2px 0 6px;
  }

  .rag-msg-user {
    padding-left: 2%;
  }

  .rag-msg-bot,
  .rag-msg-images,
  .rag-msg-videos {
    padding-right: 2%;
  }

  .rag-msg-user .rag-msg-body {
    max-width: 92%;
    border-radius: 18px 18px 4px 18px;
    padding: 10px 14px;
  }

  .rag-composer-box {
    border-radius: 22px;
    padding: 6px 8px 6px 4px;
  }

  .rag-tool-btn,
  .rag-send-btn {
    width: 32px;
    height: 32px;
  }

  .rag-composer-input {
    font-size: 16px;
    padding: 8px 6px;
  }

  .rag-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .rag-export-btn {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

  .rag-suggestion-chip {
    font-size: 0.74rem;
    padding: 6px 10px;
  }

  .rag-save-tutorial-btn,
  .rag-save-process-btn {
    flex: 1 1 100%;
  }
}

.convo-listening .convo-status {
  color: #0f766e;
}

.convo-thinking .convo-status {
  color: #6d28d9;
}

.convo-speaking .convo-status {
  color: #2563eb;
}

.convo-listening {
  animation: rag-mic-pulse 1.4s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   Super Admin (SaaS multi-tenant)
   ---------------------------------------------------------------------------- */
.sa-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.sa-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.sa-title {
  margin: 0;
  font-size: 1.5rem;
}

.sa-sub {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.9rem;
}

.sa-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sa-badge {
  background: #eef2ff;
  color: #3730a3;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.sa-link {
  color: #2563eb;
  text-decoration: none;
  font-size: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
}

.sa-link:hover {
  text-decoration: underline;
}

.sa-logout {
  color: #b91c1c;
}

.sa-msg {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.sa-msg.ok {
  background: #ecfdf5;
  color: #065f46;
}

.sa-msg.err {
  background: #fef2f2;
  color: #b91c1c;
}

.sa-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.sa-card h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.sa-hint {
  color: #64748b;
  font-size: 0.85rem;
  margin: 0 0 12px;
}

.sa-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.sa-input {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  min-width: 220px;
}

.sa-btn {
  background: #4f46e5;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.sa-btn:hover {
  background: #4338ca;
}

.sa-btn-sm {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.sa-btn-sm:hover {
  background: #e2e8f0;
}

.sa-danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.sa-tenant {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.sa-tenant-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sa-tenant-name {
  font-size: 1rem;
}

.sa-tenant-state {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.sa-tenant-state.on {
  background: #dcfce7;
  color: #166534;
}

.sa-tenant-state.off {
  background: #fee2e2;
  color: #991b1b;
}

.sa-tenant-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sa-url {
  margin: 8px 0;
  font-size: 0.85rem;
  color: #475569;
}

.sa-features-title {
  font-size: 0.82rem;
  color: #475569;
  margin: 6px 0;
  font-weight: 600;
}

.sa-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 16px;
}

.sa-feature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #334155;
}

.sa-user-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sa-user-list li {
  font-size: 0.85rem;
}

.sa-role {
  background: #f1f5f9;
  color: #475569;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  margin-left: 6px;
}

.tenant-banner {
  background: #1e293b;
  color: #fff;
  padding: 8px 16px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.tenant-banner form {
  margin: 0;
}

.tenant-banner button {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.8rem;
}

/* ----------------------------------------------------------------------------
   Guia de uso (tutorial visual con maquetas animadas)
   ---------------------------------------------------------------------------- */
.guia-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.guia-header {
  margin-bottom: 20px;
}

.guia-title {
  margin: 0;
  font-size: 1.5rem;
  color: #0f172a;
}

.guia-sub {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 0.92rem;
}

.guia-sub a {
  color: #2563eb;
}

.guia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.guia-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.guia-card h3 {
  margin: 14px 0 8px;
  font-size: 1.05rem;
  color: #1e293b;
}

.guia-steps {
  margin: 0;
  padding-left: 18px;
  color: #475569;
  font-size: 0.88rem;
  line-height: 1.5;
}

.guia-steps li {
  margin-bottom: 4px;
}

/* --- Maqueta (mini pantalla tipo navegador) --- */
.mock {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
  height: 160px;
  display: flex;
  flex-direction: column;
}

.mock-bar {
  background: #e2e8f0;
  padding: 6px 8px;
  display: flex;
  gap: 5px;
}

.mock-bar span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.mock-bar span:first-child { background: #f87171; }
.mock-bar span:nth-child(2) { background: #fbbf24; }
.mock-bar span:nth-child(3) { background: #34d399; }

.mock-body {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  position: relative;
}

.mock-center {
  align-items: center;
  justify-content: center;
}

.mock-row {
  display: flex;
  gap: 6px;
}

.mock-pill {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.62rem;
  color: #64748b;
  padding: 2px 8px;
}

.mock-bubble {
  font-size: 0.64rem;
  padding: 5px 8px;
  border-radius: 8px;
  max-width: 80%;
}

.mock-bot {
  background: #eef2ff;
  color: #3730a3;
  align-self: flex-start;
}

.mock-user {
  background: #dcfce7;
  color: #166534;
  align-self: flex-end;
  min-height: 14px;
  display: flex;
  align-items: center;
}

.mock-text::after {
  content: "Como clasifico esta compra?";
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  animation: guia-type 4s steps(28) infinite;
  max-width: 100%;
}

.mock-caret {
  width: 1px;
  height: 10px;
  background: #166534;
  margin-left: 1px;
  animation: guia-blink 1s steps(1) infinite;
}

.mock-inputbar {
  margin-top: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.mock-input {
  flex: 1;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.62rem;
  color: #94a3b8;
  padding: 4px 8px;
}

.mock-send {
  background: #4f46e5;
  color: #fff;
  font-size: 0.62rem;
  padding: 4px 10px;
  border-radius: 6px;
}

.mock-send.mock-run {
  align-self: flex-start;
  margin-top: 4px;
  animation: guia-pulse 1.8s ease-in-out infinite;
}

/* Voz */
.mock-mic {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ef4444;
  position: relative;
  animation: guia-pulse 1.4s ease-in-out infinite;
}

.mock-mic::after {
  content: "";
  position: absolute;
  inset: 11px 14px 9px 14px;
  background: #fff;
  border-radius: 4px;
}

.mock-waves {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 24px;
}

.mock-waves i {
  width: 4px;
  background: #6366f1;
  border-radius: 2px;
  animation: guia-wave 1s ease-in-out infinite;
}

.mock-waves i:nth-child(2) { animation-delay: 0.15s; }
.mock-waves i:nth-child(3) { animation-delay: 0.3s; }
.mock-waves i:nth-child(4) { animation-delay: 0.45s; }
.mock-waves i:nth-child(5) { animation-delay: 0.6s; }

.mock-caption {
  font-size: 0.62rem;
  color: #64748b;
}

/* Documento */
.mock-file {
  width: 30px;
  height: 38px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  position: relative;
}

.mock-file::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-width: 0 8px 8px 0;
  border-style: solid;
  border-color: #cbd5e1 #f8fafc;
}

.mock-progress {
  width: 70%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.mock-progress span {
  display: block;
  height: 100%;
  background: #22c55e;
  animation: guia-progress 2.4s ease-in-out infinite;
}

/* Mapa 3D */
.mock-3d {
  position: relative;
  align-items: center;
  justify-content: center;
}

.mock-3d .dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2563eb;
  opacity: 0.85;
  animation: guia-float 3s ease-in-out infinite;
}

.mock-3d .d1 { top: 22%; left: 28%; background: #6366f1; }
.mock-3d .d2 { top: 40%; left: 55%; background: #22c55e; animation-delay: 0.4s; }
.mock-3d .d3 { top: 60%; left: 35%; background: #f59e0b; animation-delay: 0.8s; }
.mock-3d .d4 { top: 30%; left: 70%; background: #ef4444; animation-delay: 1.2s; }
.mock-3d .d5 { top: 65%; left: 65%; background: #06b6d4; animation-delay: 1.6s; }
.mock-3d .d6 { top: 50%; left: 20%; background: #a855f7; animation-delay: 2s; }

.mock-3d .mock-caption {
  position: absolute;
  bottom: 4px;
  right: 8px;
}

/* Procesos */
.mock-upload {
  background: #fff;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  font-size: 0.64rem;
  color: #64748b;
  padding: 8px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mock-cloud {
  width: 14px;
  height: 8px;
  background: #94a3b8;
  border-radius: 6px;
  display: inline-block;
}

.mock-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mock-rows span {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  animation: guia-fill 2.4s ease-in-out infinite;
}

.mock-rows span:nth-child(2) { animation-delay: 0.3s; width: 90%; }
.mock-rows span:nth-child(3) { animation-delay: 0.6s; width: 80%; }
.mock-rows span:nth-child(4) { animation-delay: 0.9s; width: 95%; }

/* Tutoriales */
.mock-save {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #6ee7b7;
  border-radius: 6px;
  font-size: 0.62rem;
  padding: 4px 8px;
  align-self: flex-start;
  animation: guia-pulse 1.8s ease-in-out infinite;
}

.mock-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mock-list span {
  height: 8px;
  background: #e2e8f0;
  border-radius: 3px;
}

.mock-list span:nth-child(2) { width: 75%; }

/* Admin */
.mock-tenant {
  font-size: 0.66rem;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mock-dot-on {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.mock-toggles {
  display: flex;
  gap: 8px;
}

.mock-toggles .tg {
  width: 26px;
  height: 14px;
  border-radius: 999px;
  position: relative;
  background: #cbd5e1;
}

.mock-toggles .tg::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
}

.mock-toggles .tg.on { background: #4f46e5; }
.mock-toggles .tg.on::after { left: 14px; }

@keyframes guia-type {
  0% { width: 0; }
  60% { width: 100%; }
  100% { width: 100%; }
}

@keyframes guia-blink {
  50% { opacity: 0; }
}

@keyframes guia-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.85; }
}

@keyframes guia-wave {
  0%, 100% { height: 6px; }
  50% { height: 22px; }
}

@keyframes guia-progress {
  0% { width: 5%; }
  90% { width: 100%; }
  100% { width: 100%; }
}

@keyframes guia-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes guia-fill {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  .mock-text::after,
  .mock-caret,
  .mock-send.mock-run,
  .mock-mic,
  .mock-waves i,
  .mock-progress span,
  .mock-3d .dot,
  .mock-rows span,
  .mock-save {
    animation: none !important;
  }
}

/* ----------------------------------------------------------------------------
   Remote / Slack
   ---------------------------------------------------------------------------- */
.remote-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.remote-header {
  margin-bottom: 18px;
}

.remote-title {
  margin: 0;
  font-size: 1.5rem;
  color: #0f172a;
}

.remote-sub {
  margin: 6px 0 12px;
  color: #64748b;
  font-size: 0.92rem;
}

.remote-status {
  display: inline-block;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #475569;
}

.remote-status.ok {
  background: #ecfdf5;
  color: #065f46;
}

.remote-status.warn {
  background: #fffbeb;
  color: #92400e;
}

.remote-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.remote-card h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
  color: #1e293b;
}

.remote-hint {
  color: #64748b;
  font-size: 0.85rem;
  margin: 0 0 12px;
}

.remote-url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.remote-url-label {
  font-size: 0.78rem;
  color: #475569;
  min-width: 200px;
  font-weight: 600;
}

.remote-url {
  flex: 1;
  min-width: 220px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  word-break: break-all;
}

.remote-copy {
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.remote-copy:hover {
  background: #4338ca;
}

.remote-steps {
  margin: 0;
  padding-left: 20px;
  color: #334155;
  font-size: 0.9rem;
  line-height: 1.6;
}

.remote-steps > li {
  margin-bottom: 10px;
}

.remote-steps ul {
  margin: 6px 0;
  padding-left: 18px;
  color: #475569;
}

.remote-steps code,
.remote-env code,
.remote-sub code {
  background: #f1f5f9;
  color: #0f172a;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.remote-env {
  margin: 0;
  padding-left: 18px;
  color: #334155;
  font-size: 0.88rem;
  line-height: 1.7;
}

.remote-mcp {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #fafaff 0%, #fff 48px);
}

.remote-mcp-badge {
  display: inline-block;
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #475569;
  margin: 8px 0 14px;
}

.remote-mcp-badge.ok {
  background: #eef2ff;
  color: #3730a3;
}

.remote-mcp-badge.warn {
  background: #fffbeb;
  color: #92400e;
}

.remote-subtitle {
  margin: 18px 0 8px;
  font-size: 0.98rem;
  color: #1e293b;
}

.remote-token-create {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.remote-token-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
}

.remote-token-btn {
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.9rem;
}

.remote-token-btn:hover {
  background: #4338ca;
}

.remote-token-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.remote-token-new {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.remote-token-alert {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: #92400e;
}

.remote-token-value {
  display: block;
  background: #0f172a;
  color: #fef08a;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  word-break: break-all;
  margin-bottom: 8px;
}

.remote-copy-token {
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.remote-features-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  margin: 0 0 8px;
}

.remote-token-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.remote-token-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.remote-token-meta {
  color: #94a3b8;
  font-size: 0.75rem;
  margin-left: 6px;
}

.remote-token-revoke {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
}

.remote-token-empty {
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 8px 0;
}

.remote-config {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  overflow-x: auto;
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.remote-copy-config {
  margin-bottom: 8px;
}

/* API docs (Swagger) en REMOTE */
.remote-api-docs {
  border-color: #a5b4fc;
}

.remote-api-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.remote-api-btn {
  display: inline-block;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
}

.remote-api-btn:hover {
  background: #4338ca;
  color: #fff;
}

.remote-api-btn.secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.remote-api-btn.secondary:hover {
  background: #e2e8f0;
}

.remote-swagger-wrap {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  min-height: 420px;
}

.remote-swagger-wrap .swagger-ui .topbar {
  display: none;
}

.remote-swagger-wrap .swagger-ui .info {
  margin: 12px 0;
}

.remote-swagger-wrap .swagger-ui .info .title {
  font-size: 1.25rem;
}
