:root {
  --gc-navy: #0b2946;
  --gc-navy-deep: #071a2f;
  --gc-navy-glow: #0e4f84;
  --gc-ink: #223041;
  --gc-gold: #b08d57;
  --gc-sand: #e9e2d6;
  --gc-paper: #f7f5f1;
  --gc-white: #ffffff;
  --gc-border: #d5dce4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--gc-ink);
  background: linear-gradient(180deg, #fbfaf8, var(--gc-paper));
}

.topbar {
  background: linear-gradient(95deg, #071a2f 0%, var(--gc-navy) 58%, var(--gc-navy-glow) 100%);
  color: var(--gc-white);
  padding: 14px 28px;
  border-bottom: 2px solid #1f5f97;
}

.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: #63b7ff;
}

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

.brand-logo {
  width: 200px;
  max-width: 44vw;
  height: auto;
  border-radius: 6px;
  border: 1px solid rgba(144, 194, 240, 0.35);
  box-shadow: 0 4px 14px rgba(6, 16, 29, 0.42);
}

.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: #dceaf8;
  font-size: 0.95rem;
}

.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);
}

.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-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.rag-controls label {
  display: block;
  font-size: 0.86rem;
  color: #9ea8b7;
  margin-bottom: 5px;
}

.rag-controls select,
.rag-form input {
  width: 100%;
  border: 1px solid #2a2d36;
  border-radius: 10px;
  padding: 11px 12px;
  background: #0f1218;
  color: #e8edf4;
}

.rag-shell {
  min-height: calc(100vh - 126px);
  background: radial-gradient(circle at 20% 10%, #111722 0%, #080a0f 55%, #040507 100%);
  padding: 28px 20px 32px;
}

.rag-card {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
}

.rag-title {
  text-align: center;
  color: #f2f5fa;
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 8px 0 20px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

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

.rag-chat {
  height: 360px;
  overflow-y: auto;
  border: 1px solid #242833;
  border-radius: 16px;
  background: linear-gradient(180deg, #0c1118, #0a0d13);
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.rag-msg {
  max-width: 90%;
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.92rem;
  width: fit-content;
}

.rag-msg-user {
  justify-self: end;
  background: #172637;
  border: 1px solid #2f4761;
  color: #dbe6f1;
}

.rag-msg-bot {
  justify-self: start;
  background: #151a23;
  border: 1px solid #303a4b;
  color: #e7edf7;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.rag-msg-images {
  align-items: flex-start;
  width: 100%;
  max-width: min(560px, 100%);
}

.rag-msg-videos {
  align-items: flex-start;
  width: 100%;
  max-width: min(640px, 100%);
  flex-direction: column;
}

.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;
  white-space: normal;
  padding: 8px 10px;
}

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

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #8ea9c7;
  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: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #4f8cc5;
  box-shadow: 0 2px 8px rgba(7, 28, 49, 0.45);
  flex: 0 0 auto;
}

.rag-form {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.rag-form input {
  border-radius: 999px;
  padding: 14px 18px;
  font-size: 1rem;
}

.rag-form button {
  border-radius: 999px;
  padding: 12px 20px;
  background: #f3f6fb;
  color: #10131a;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rag-form button:hover {
  background: #ffffff;
}

.rag-form button:disabled {
  opacity: 0.85;
  cursor: wait;
}

.rag-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #9ca3af;
  border-top-color: #111827;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.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-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 10%, #111722 0%, #080a0f 55%, #040507 100%);
}

.login-card {
  width: min(420px, 100%);
  background: #101722;
  border: 1px solid #2b3b4f;
  border-radius: 12px;
  padding: 22px;
  color: #dceaf8;
}

.login-card h1 {
  color: #f2f5fa;
}

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

.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #2b3b4f;
  border-radius: 8px;
  background: #0c121a;
  color: #e6edf6;
}

.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);
}

.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-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px dashed #a8b8cc;
  background: rgba(248, 250, 252, 0.9);
}

.rag-chat-quick-label {
  font-size: 0.82rem;
  color: #5a6b7d;
  font-weight: 600;
}

.rag-chat-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 280px;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
}

.rag-quick-tab-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e0;
  background: #fff;
  color: var(--gc-navy-deep);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.rag-save-tutorial-btn,
.rag-save-process-btn {
  flex: 1 1 200px;
  min-width: 140px;
  max-width: 100%;
  white-space: normal;
  line-height: 1.3;
  text-align: center;
  padding: 8px 12px;
}

.rag-quick-tab-btn:hover:not(:disabled) {
  border-color: #63b7ff;
  background: #f0f7ff;
}

.rag-quick-tab-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  border-color: #d1dae4;
  background: #f1f4f8;
  color: #7a8a9a;
}

.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;
  }
}
