:root {
  color-scheme: light;
  --topbar-height: 66px;
  /* Navy profundo para CTAs principales y textos oscuros */
  --navy-950: #0a1020;
  --navy-900: #131d38;
  --navy-800: #1d294a;
  /* Acento primario CLARO: dorado/bronce (look juridico premium) */
  --blue-600: #a17b34;
  --blue-700: #82611f;
  --blue-500: #c09c52;
  --blue-100: #f2e8d5;
  --on-accent: #ffffff;
  /* Fin del gradiente y brillo del acento (se sobreescriben en dark) */
  --accent-2: #876224;
  --accent-glow: rgba(161, 123, 52, 0.28);
  /* Acentos secundarios (estados) */
  --cyan-500: #1391a6;
  --green-500: #2f7d4f;
  --green-100: #e9f1e2;
  --amber-500: #b9822f;
  --amber-100: #f7edd8;
  --violet-500: #6356e6;
  --violet-100: #ecebfb;
  --red-500: #c34b46;
  --red-100: #f7e6dd;
  /* Neutros CALIDOS: marfil/crema y tinta calida (clave del look premium) */
  --ink: #231c11;
  --muted: #7d7261;
  --line: #e9ddc8;
  --panel: #fffcf6;
  --surface-2: #f3ebda;
  --bg: #f6efe1;
  /* Sombras calidas y discretas */
  --shadow-soft: 0 10px 30px rgba(96, 72, 33, 0.07);
  --shadow-card: 0 2px 10px rgba(96, 72, 33, 0.05);
  --ring: 0 0 0 3px rgba(161, 123, 52, 0.25);
}

/* ====== MODO OSCURO ====== */
[data-theme="dark"] {
  color-scheme: dark;
  /* navy se mantiene OSCURO (es fondo del sidebar). Los pocos textos que lo
     usaban se cambiaron a --ink, que si se aclara en dark. */
  /* Acento mas luminoso para resaltar sobre fondo oscuro */
  --blue-600: #5a6ae6;
  --blue-700: #4853c9;
  --blue-500: #7d88ee;
  --blue-100: #1d2748;
  --on-accent: #ffffff;
  /* gradiente/brillo del acento: se mantienen AZULES en oscuro */
  --accent-2: #0755dc;
  --accent-glow: rgba(18, 105, 255, 0.22);
  --green-100: #14241d;
  --amber-100: #2a2113;
  --violet-100: #1d1b33;
  --red-500: #f06277;
  --red-100: #2c1820;
  /* Neutros oscuros */
  --ink: #e7eaf2;
  --muted: #9aa3b8;
  --line: #242a3a;
  --panel: #151a26;
  --surface-2: #1b2130;
  --bg: #0d111b;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(90, 106, 230, 0.35);
}

html,
body {
  background: var(--bg);
}
body {
  transition: background-color 0.2s ease, color 0.2s ease;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--blue-600);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Superficies translucidas que en dark deben oscurecerse */
[data-theme="dark"] .topbar {
  background: rgba(16, 21, 32, 0.9);
  border-bottom-color: var(--line);
}

/* Navegacion lateral tipo ChatGPT y composicion limpia */
.layout {
  display: block;
}

.sidebar {
  position: fixed;
  z-index: 100;
  top: 0;
  bottom: 0;
  left: 0;
  width: 292px;
  height: 100dvh;
  transform: translateX(-104%);
  transition: transform 180ms ease;
  box-shadow: 24px 0 60px rgba(5, 20, 48, 0.24);
}

body.sidebar-open {
  overflow: hidden;
}

body.sidebar-open .sidebar {
  transform: translateX(0);
}

.sidebar-close {
  display: grid;
  width: 38px;
  height: 38px;
  margin-left: auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-accent);
}

.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.sidebar-close svg {
  width: 19px;
  height: 19px;
}

.sidebar-backdrop {
  position: fixed;
  z-index: 90;
  inset: 0;
  visibility: hidden;
  border: 0;
  background: rgba(7, 20, 43, 0.42);
  opacity: 0;
  cursor: default;
  transition: opacity 180ms ease, visibility 180ms ease;
  backdrop-filter: blur(2px);
}

body.sidebar-open .sidebar-backdrop {
  visibility: visible;
  opacity: 1;
}

.workspace {
  width: 100%;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: var(--topbar-height);
  padding: 9px 24px;
  background: rgba(255, 255, 255, 0.96);
}

.topbar-navigation,
.topbar-brand {
  display: flex;
  min-width: 0;
  align-items: center;
}

.topbar-navigation {
  gap: 14px;
}

.sidebar-toggle {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #dbe3f0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.sidebar-toggle:hover,
.sidebar-toggle[aria-expanded="true"] {
  border-color: #b9cdf1;
  background: var(--blue-100);
  color: var(--blue-600);
}

.sidebar-toggle svg {
  width: 22px;
  height: 22px;
}

.topbar-brand {
  gap: 10px;
}

.topbar-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue-600);
  overflow: hidden;
  line-height: 0;
}

.topbar-brand strong,
.topbar-brand span {
  display: block;
}

.topbar-brand strong {
  font-size: 14px;
}

.topbar-brand > div > span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  gap: 12px;
}

.view {
  max-width: 1600px;
}

#ai-view {
  max-width: none;
}

#ai-view .ai-conversation-layout {
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(10, 31, 68, 0.06);
}

#ai-view .conversation-history {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
}

#ai-view .history-head,
#ai-view .history-note {
  background: var(--bg);
}

#ai-view .history-search input {
  background: var(--panel);
}

#ai-view .conversation-item {
  background: transparent;
}

#ai-view .conversation-item.active {
  border-color: #c9d9f7;
  background: var(--panel);
  box-shadow: inset 3px 0 0 var(--blue-600);
}

#ai-view .conversation-main {
  background: var(--panel);
}

#ai-view .conversation-titlebar {
  min-height: 68px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 18px;
  box-shadow: none;
}

#ai-view .enhanced-chat {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#ai-view .assistant-intro {
  min-height: 56px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

#ai-view .intro-mode-switch {
  width: min(440px, 100%);
}

#ai-view .intro-mode-switch button {
  min-height: 40px;
  box-shadow: none;
}

#ai-view .intro-mode-switch button.active {
  border-color: var(--blue-600);
  background: var(--blue-600);
  color: var(--on-accent);
  box-shadow: none;
}

/* Comandos como pills compactos (no una barra de 6 cajas grandes) */
#ai-view .command-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

#ai-view .command-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#ai-view .command-chip:hover {
  border-color: #cdd2e0;
  background: var(--surface-2);
  color: var(--ink);
  transform: none;
}

#ai-view .command-chip svg {
  width: 15px;
  height: 15px;
}

#ai-view .command-chip strong {
  color: inherit;
  font-size: 12.5px;
  font-weight: 600;
}

#ai-view .command-chip small {
  display: none;
}

#ai-view .command-chip.success {
  color: var(--green-500);
}

#ai-view .command-chip.danger {
  color: var(--red-500);
}

#ai-view .messages {
  gap: 26px;
  padding: 34px 44px;
  background: var(--panel);
}

#ai-view .message {
  max-width: min(1040px, 94%);
}

#ai-view .message.user {
  max-width: min(720px, 82%);
}

#ai-view .message .bubble {
  border-radius: 13px;
}

#ai-view .message.assistant .bubble {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: none;
}

#ai-view .message.user .bubble {
  border-color: transparent;
  background: var(--blue-100);
  color: var(--ink);
  box-shadow: none;
}

#ai-view .feedback-panel,
#ai-view .source-card {
  box-shadow: none;
}

#ai-view .chat-bottom {
  gap: 12px;
  padding: 14px 20px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

#ai-view .composer textarea {
  background: var(--panel);
  box-shadow: none;
}

#ai-view .prompt-actions button {
  min-height: 34px;
  background: var(--panel);
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    width: min(292px, calc(100vw - 44px));
    max-width: none;
    height: 100dvh;
  }

  .topbar {
    position: sticky;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    max-width: none;
    padding: 9px 14px;
  }

  .top-profile > div:last-child,
  .notification-dot {
    display: none;
  }

  #ai-view .ai-conversation-layout {
    display: block;
    border: 0;
    box-shadow: none;
  }

  #ai-view .conversation-history {
    max-height: 240px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  #ai-view .messages {
    padding: 24px 16px;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(18, 105, 255, 0.08), transparent 28rem),
    linear-gradient(180deg, var(--surface-2) 0%, var(--bg) 58%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

html,
body {
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, rgba(18, 105, 255, 0.12), transparent 24rem),
    linear-gradient(160deg, var(--navy-950), var(--navy-900) 55%, #05152d);
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  margin-bottom: 24px;
}

.brand-seal {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-accent);
  font-weight: 900;
}

.brand-seal svg {
  width: 28px;
  height: 28px;
}

.brand-copy strong,
.brand-copy span {
  display: block;
}

.brand-copy strong {
  font-size: 28px;
  line-height: 1;
}

.brand-copy span {
  margin-top: 2px;
  color: #b8c9e8;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 9px;
}

.nav-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 52px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d9e6ff;
  text-align: left;
  font-weight: 750;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--blue-600), var(--accent-2));
  color: white;
  box-shadow: 0 12px 28px var(--accent-glow);
}

.nav-item:not(.locked):hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.locked {
  color: rgba(217, 230, 255, 0.54);
  cursor: not-allowed;
}

.nav-glyph {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: currentColor;
  font-size: 11px;
  font-weight: 900;
}

.nav-glyph svg {
  width: 17px;
  height: 17px;
}

.nav-item small {
  display: grid;
  min-height: 22px;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #c4d4ee;
  font-size: 11px;
}

.sidebar-footer {
  display: grid;
  gap: 16px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.mini-status,
.sidebar-user,
.top-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

#sidebar-status-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--amber-500);
  box-shadow: 0 0 0 4px rgba(245, 154, 50, 0.14);
}

#sidebar-status-dot.ok {
  background: var(--green-500);
  box-shadow: 0 0 0 4px rgba(18, 166, 107, 0.15);
}

#sidebar-status-dot.bad {
  background: var(--red-500);
  box-shadow: 0 0 0 4px rgba(238, 75, 95, 0.15);
}

.mini-status strong,
.mini-status small,
.sidebar-user strong,
.sidebar-user span {
  display: block;
}

.mini-status strong,
.sidebar-user strong {
  font-size: 13px;
}

.mini-status small,
.sidebar-user span {
  color: #b8c9e8;
  font-size: 12px;
}

.user-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.user-avatar.compact {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #6d8cff, var(--blue-600));
  color: white;
}

.workspace {
  width: 100%;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 12px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.global-search {
  position: relative;
  display: flex;
  align-items: center;
}

.global-search input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px 0 46px;
  background: white;
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(16, 26, 52, 0.04);
}

.global-search input:focus,
.composer textarea:focus,
.login-row input:focus {
  border-color: var(--blue-600);
  outline: 3px solid rgba(18, 105, 255, 0.12);
}

.search-icon {
  position: absolute;
  left: 18px;
  width: 14px;
  height: 14px;
  border: 2px solid #667899;
  border-radius: 999px;
}

.search-icon::after {
  position: absolute;
  right: -7px;
  bottom: -5px;
  width: 8px;
  height: 2px;
  border-radius: 999px;
  background: #667899;
  content: "";
  transform: rotate(45deg);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.sync-button,
.primary-action,
.secondary-action,
.send-button,
.chat-actions button,
.segmented button,
.text-action,
.action-card,
.login-row button {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.sync-button,
.primary-action,
.send-button {
  min-height: 46px;
  padding: 0 18px;
  border-color: var(--blue-600);
  background: linear-gradient(135deg, var(--blue-600), var(--accent-2));
  color: white;
  box-shadow: 0 12px 26px var(--accent-glow);
}

.sync-button {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-button svg,
.primary-action svg,
.secondary-action svg,
.send-button svg,
.chat-actions svg,
.segmented svg {
  width: 18px;
  height: 18px;
}

.primary-action,
.secondary-action,
.send-button,
.chat-actions button,
.segmented button,
.text-action,
.login-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.secondary-action,
.chat-actions button,
.text-action {
  min-height: 40px;
  padding: 0 14px;
  background: white;
  color: var(--blue-600);
}

.top-profile strong,
.top-profile span {
  display: block;
}

.top-profile strong {
  font-size: 14px;
}

.top-profile span {
  color: var(--muted);
  font-size: 12px;
}

.notification-dot {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.notification-dot:hover {
  background: var(--panel);
  color: var(--blue-600);
}

.notification-dot.has-unread {
  color: var(--blue-600);
}

.notification-dot svg {
  width: 18px;
  height: 18px;
}

.notif-wrap {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--red-500);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: 320px;
  max-width: 84vw;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.notif-head strong {
  font-size: 14px;
  color: var(--ink);
}

.notif-head button {
  border: 0;
  background: transparent;
  color: var(--blue-600);
  font: 600 12px Inter, sans-serif;
  cursor: pointer;
}

.notif-list {
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
}

.notif-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.notif-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.notif-item:hover {
  background: var(--surface-2);
}

.notif-item.unread {
  background: var(--blue-100);
}

.notif-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--blue-600);
}

.notif-icon svg {
  width: 18px;
  height: 18px;
}

.notif-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.notif-copy strong {
  font-size: 13px;
  color: var(--ink);
}

.notif-copy small {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notif-time {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted);
}

.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--blue-600);
  vertical-align: middle;
}

.conversation-item.unread .conversation-copy strong {
  color: var(--ink);
  font-weight: 800;
}

.view {
  display: none;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 32px 36px 42px;
}

.view.active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 26px;
}

.home-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  width: 100vw;
  min-height: clamp(560px, calc(100vh - 92px), 780px);
  margin: -32px calc(50% - 50vw) 0;
  overflow: hidden;
  border-bottom: 1px solid rgba(176, 132, 44, 0.22);
  background: #15100a;
}

.home-hero-video {
  position: absolute;
  inset: 0;
  z-index: -3;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.96) contrast(1.05) brightness(0.82);
}

.home-hero-shade {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(12, 17, 31, 0.82) 0%, rgba(15, 20, 33, 0.66) 36%, rgba(74, 55, 28, 0.22) 70%, rgba(237, 222, 188, 0.2) 100%),
    linear-gradient(180deg, rgba(255, 251, 242, 0.18) 0%, rgba(12, 17, 31, 0.14) 42%, rgba(248, 239, 219, 0.58) 100%);
}

.home-hero::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  height: 34%;
  background: linear-gradient(180deg, transparent, var(--bg));
  content: "";
}

.home-hero-inner {
  display: flex;
  width: min(1500px, calc(100% - 72px));
  min-height: inherit;
  align-items: center;
  margin: 0 auto;
  padding: clamp(54px, 8vh, 90px) 0 clamp(110px, 15vh, 150px);
}

.home-hero-copy {
  display: flex;
  min-width: 0;
  max-width: 650px;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  color: white;
}

.home-hero-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(234, 209, 150, 0.42);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(8, 13, 25, 0.26);
  color: #f1d999;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
}

.home-hero-copy h1 {
  margin: 0;
  color: #fff7e6;
  font-size: clamp(38px, 5.6vw, 76px);
  line-height: 0.98;
  text-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  overflow-wrap: anywhere;
}

.home-hero-copy p {
  margin: 0;
  max-width: 54ch;
  color: rgba(255, 248, 231, 0.88);
  font-size: clamp(16px, 1.5vw, 20px);
  line-height: 1.55;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.home-drive-action {
  min-height: 46px;
  padding: 0 18px;
  border-color: rgba(232, 202, 135, 0.48);
  background: rgba(255, 246, 224, 0.14);
  color: #fff3d2;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
}

.home-drive-action:hover {
  border-color: rgba(248, 221, 158, 0.75);
  background: rgba(255, 246, 224, 0.2);
  color: white;
}

#home-view .flow-cards {
  position: relative;
  z-index: 2;
  margin-top: -76px;
}

@media (max-width: 920px) {
  .home-hero {
    min-height: calc(100vh - 82px);
  }

  .home-hero-inner {
    width: min(100% - 36px, 720px);
    padding: 58px 0 118px;
  }

  .home-hero-shade {
    background:
      linear-gradient(180deg, rgba(10, 16, 30, 0.84) 0%, rgba(11, 17, 31, 0.74) 48%, rgba(248, 239, 219, 0.54) 100%);
  }

  #home-view .flow-cards {
    margin-top: -58px;
  }
}

.page-heading > div {
  min-width: 0;
}

.page-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.page-heading p {
  max-width: 820px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.compact-heading h1 {
  font-size: clamp(28px, 3vw, 40px);
}

.ai-title-line {
  display: inline;
}

.ai-subtitle-line {
  display: inline;
}

.flow-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
  align-items: start;
}

.flow-card,
.summary-panel,
.status-panel,
.recommend-panel,
.documents-panel,
.activity-panel,
.chat-shell,
.help-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
}

.flow-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 22px;
  align-items: start;
  gap: 14px;
  padding: 18px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.flow-card:hover {
  border-color: var(--blue-600);
  box-shadow: var(--shadow-soft);
}

.step-visual {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--blue-600);
}

.step-visual svg {
  width: 20px;
  height: 20px;
}

.flow-card-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding-top: 2px;
}

.flow-kicker {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.flow-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.flow-detail {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.25s ease;
}

.flow-card.expanded .flow-detail {
  max-height: 320px;
  opacity: 1;
  margin-top: 6px;
}

.flow-desc {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.flow-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.flow-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--blue-600);
}

.flow-chevron {
  display: grid;
  place-items: center;
  padding-top: 4px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.flow-chevron svg {
  width: 18px;
  height: 18px;
}

.flow-card.expanded .flow-chevron {
  transform: rotate(180deg);
}

.panel-title h2,
.help-card h2 {
  margin: 0;
  font-size: 18px;
}

.panel-title h2 {
  display: flex;
  align-items: center;
  gap: 9px;
}

.panel-title h2 svg {
  width: 18px;
  height: 18px;
  color: var(--blue-600);
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 20px;
}

.summary-panel,
.status-panel,
.recommend-panel,
.documents-panel,
.activity-panel,
.help-card {
  padding: 22px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.action-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.action-card {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 10px;
  min-height: 130px;
  padding: 18px 14px;
  background: linear-gradient(180deg, var(--panel), var(--surface-2));
  color: var(--ink);
  text-align: left;
  align-items: center;
  align-content: start;
}

.action-card:hover,
.source-card:hover {
  border-color: #b7c9ef;
  transform: translateY(-1px);
}

.card-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--blue-600);
}

.card-icon svg {
  width: 20px;
  height: 20px;
}

.action-card strong {
  color: var(--blue-600);
}

.action-card small {
  display: block;
  grid-column: 1 / -1;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.status-metrics {
  display: grid;
  gap: 16px;
}

.status-metrics div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.status-metrics span,
.platform-ok small {
  color: var(--muted);
}

.status-metrics strong {
  font-size: 24px;
}

.platform-ok {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.platform-ok small {
  grid-column: 2;
  font-size: 12px;
}

.check {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--amber-500);
}

.check.ok {
  background: var(--green-500);
}

.check.bad {
  background: var(--red-500);
}

.recommend-panel ul {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.drive-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.drive-heading-actions a {
  text-decoration: none;
}

.drive-browser {
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
}

.drive-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(540px, 700px);
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.drive-toolbar-actions {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(300px, 1fr);
  gap: 10px;
  align-items: center;
}

.drive-sort {
  position: relative;
  min-width: 0;
}

.drive-sort > svg {
  position: absolute;
  z-index: 1;
  top: 13px;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.drive-sort select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 34px 0 38px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
}

.drive-sort select:focus {
  border-color: var(--blue-600);
  outline: none;
  box-shadow: var(--ring);
}

.drive-breadcrumb {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.drive-breadcrumb > svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.drive-breadcrumb button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.drive-breadcrumb button:hover {
  background: var(--surface-2);
  color: var(--blue-600);
}

.drive-breadcrumb button[aria-current="page"] {
  background: var(--blue-100);
  color: var(--blue-600);
}

.drive-breadcrumb button svg {
  width: 17px;
  height: 17px;
}

.drive-search {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  align-items: center;
}

.drive-search > svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.drive-search input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px 0 0 8px;
  padding: 0 14px 0 42px;
  color: var(--ink);
}

.drive-search input:focus {
  z-index: 1;
  border-color: var(--blue-600);
  outline: none;
  box-shadow: var(--ring);
}

.drive-search button {
  min-height: 44px;
  border: 1px solid var(--blue-600);
  border-radius: 0 8px 8px 0;
  background: var(--blue-600);
  color: var(--on-accent);
  font-weight: 700;
}

.drive-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.drive-statusbar > div:first-child {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 2px 9px;
  align-items: center;
}

.drive-statusbar small {
  grid-column: 2;
  color: var(--muted);
}

.drive-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--amber-500);
  box-shadow: 0 0 0 4px rgba(245, 154, 50, 0.12);
}

.drive-live-dot.live {
  background: var(--green-500);
  box-shadow: 0 0 0 4px rgba(18, 166, 107, 0.12);
}

.drive-status-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  color: var(--muted);
  font-size: 13px;
}

.drive-status-metrics strong {
  color: var(--ink);
}

.drive-list-head,
.drive-item {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 190px 140px 120px;
  gap: 14px;
  align-items: center;
}

/* Columna "Tipo" oculta: el icono ya indica que es carpeta/documento */
.drive-list-head span:nth-child(2),
.drive-item-type {
  display: none;
}

.drive-list-head {
  min-height: 42px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.drive-items {
  min-height: 340px;
  max-height: 620px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.drive-item {
  min-height: 72px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--surface-2);
  background: var(--panel);
}

.drive-item:last-child {
  border-bottom: 0;
}

.drive-item:hover {
  background: var(--surface-2);
}

.drive-item.folder {
  background: var(--panel);
}

.drive-item-main {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.drive-item-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
}

.drive-item-icon {
  border: 1px solid var(--line);
}

.drive-item-icon.folder {
  background: var(--surface-2);
  color: var(--blue-600);
}

.drive-item-icon.document {
  background: var(--surface-2);
  color: var(--muted);
}

.drive-item-icon svg {
  width: 22px;
  height: 22px;
}

.drive-item-name {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.drive-item-name strong,
.drive-item-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-item-name strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.drive-item-name small,
.drive-item-type,
.drive-item-date {
  color: var(--muted);
  font-size: 12px;
}

.drive-availability {
  display: inline-grid;
  min-height: 26px;
  place-items: center;
  border-radius: 999px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.drive-availability.live {
  background: var(--green-100);
  color: var(--green-500);
}

.drive-item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.drive-item-actions button,
.drive-item-actions a,
.drive-pagination button,
.drive-preview-head button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue-600);
  text-decoration: none;
}

.drive-item-actions button:hover,
.drive-item-actions a:hover,
.drive-pagination button:hover,
.drive-preview-head button:hover {
  border-color: var(--line);
  background: var(--blue-100);
}

.drive-item-actions svg,
.drive-pagination svg,
.drive-preview-head button svg {
  width: 17px;
  height: 17px;
}

.drive-loading,
.drive-empty {
  display: grid;
  min-height: 340px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.drive-loading svg {
  color: var(--blue-600);
  animation: drive-spin 900ms linear infinite;
}

.drive-empty svg {
  width: 38px;
  height: 38px;
  color: #7d8da8;
}

.drive-empty strong {
  color: var(--ink);
}

.drive-empty.error svg {
  color: var(--red-500);
}

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

.drive-pagination {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.drive-pagination > div {
  display: flex;
  gap: 8px;
}

.drive-pagination button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.drive-preview-dialog {
  width: min(1280px, calc(100vw - 54px));
  height: min(880px, calc(100vh - 54px));
  max-width: none;
  max-height: none;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(5, 20, 48, 0.28);
}

.drive-preview-dialog::backdrop {
  background: rgba(5, 20, 48, 0.58);
  backdrop-filter: blur(4px);
}

.drive-preview-head {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}

.drive-preview-head span,
.drive-preview-head strong {
  display: block;
}

.drive-preview-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.drive-preview-head strong {
  max-width: 780px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-preview-head > div:last-child {
  display: flex;
  align-items: center;
  gap: 9px;
}

.drive-preview-head a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--blue-600);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.drive-preview-head a svg {
  width: 17px;
  height: 17px;
}

.drive-preview-body {
  height: calc(100% - 72px);
  background: var(--surface-2);
}

.drive-preview-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--panel);
}

.documents-panel,
.activity-panel {
  margin-top: 20px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.source-card {
  display: grid;
  gap: 10px;
  min-height: 170px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  transition: transform 140ms ease, border-color 140ms ease;
}

.pdf-badge {
  display: grid;
  width: 42px;
  height: 48px;
  place-items: center;
  align-content: center;
  gap: 2px;
  border-radius: 6px;
  background: var(--red-100);
  color: var(--red-500);
  font-size: 11px;
  font-weight: 900;
}

.pdf-badge svg {
  width: 18px;
  height: 18px;
}

.source-card strong {
  line-height: 1.35;
}

.source-card small {
  color: var(--muted);
}

.source-card a {
  color: var(--blue-600);
  font-weight: 850;
  text-decoration: none;
}

.empty-state,
.empty-row {
  grid-column: 1 / -1;
  padding: 28px;
  border: 1px dashed #cbd6ea;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}

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

.table-head,
.table-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.7fr) 90px 90px 126px 112px;
  gap: 14px;
  align-items: center;
  min-width: 760px;
}

.table-head {
  padding-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.table-row {
  min-height: 50px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.table-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-grid;
  min-height: 26px;
  place-items: center;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-500);
  font-size: 12px;
  font-weight: 900;
}

.ai-view {
  max-width: none;
}

@media (min-width: 901px) {
  body.is-ai-view,
  body:has(#ai-view.active) {
    height: 100vh;
    overflow: hidden;
  }

  body.is-ai-view .layout,
  body:has(#ai-view.active) .layout {
    height: 100vh;
    overflow: hidden;
  }

  body.is-ai-view .workspace,
  body:has(#ai-view.active) .workspace {
    display: flex;
    height: 100vh;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  body.is-ai-view .topbar,
  body:has(#ai-view.active) .topbar {
    flex: 0 0 auto;
  }

  body.is-ai-view .ai-view.active,
  body:has(#ai-view.active) .ai-view.active {
    display: flex;
    width: 100%;
    height: calc(100vh - var(--topbar-height));
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    padding-top: 22px;
    padding-bottom: 16px;
    overflow: hidden;
  }
}

.ai-heading {
  align-items: center;
  flex: 0 0 auto;
  margin-bottom: 16px;
}

.ai-heading h1 {
  font-size: clamp(30px, 3.2vw, 42px);
}

.ai-heading p {
  margin-top: 8px;
}

.ai-conversation-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  flex: 1 1 auto;
  min-height: 0;
}

.conversation-history,
.conversation-main,
.conversation-titlebar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
}

.conversation-history {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.history-head strong,
.history-head span {
  display: block;
}

.history-head strong {
  font-size: 17px;
}

.history-head span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-head button,
.conversation-title-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue-600);
  font-size: 13px;
  font-weight: 900;
}

.history-head button {
  width: 38px;
  padding: 0;
  background: var(--blue-600);
  color: var(--on-accent);
}

.history-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 12px;
}

.history-search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: #667899;
}

.history-search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px 0 36px;
  color: var(--ink);
}

.conversation-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 0 14px 14px;
}

.conversation-list::-webkit-scrollbar {
  width: 10px;
}

.conversation-list::-webkit-scrollbar-thumb {
  border: 3px solid var(--panel);
  border-radius: 999px;
  background: #a7b8d2;
}

.conversation-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: start;
  width: 100%;
  min-height: 100px;
  padding: 7px;
  border: 1px solid #e1e8f5;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
}

.conversation-item.active {
  border-color: var(--line);
  background: var(--blue-100);
  box-shadow: inset 3px 0 0 var(--blue-600);
}

.conversation-open {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
  width: 100%;
  min-width: 0;
  padding: 7px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.conversation-delete {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid #f3d7dc;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--red-500);
}

.conversation-delete:hover {
  border-color: #ffd3d9;
  background: var(--red-100);
  color: var(--red-500);
}

.conversation-delete svg {
  width: 16px;
  height: 16px;
}

.conversation-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue-600);
}

.conversation-icon svg {
  width: 17px;
  height: 17px;
}

.conversation-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.conversation-copy strong,
.conversation-copy small,
.conversation-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-copy strong {
  white-space: nowrap;
  font-size: 13px;
}

.conversation-copy small {
  display: -webkit-box;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.conversation-copy em {
  color: var(--blue-600);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.history-empty {
  padding: 18px;
  border: 1px dashed #cbd6ea;
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.4;
}

.history-clear-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  margin: 4px 14px 12px;
  border: 1px solid #f2cbd1;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--red-500);
  font-size: 12px;
  font-weight: 900;
}

.history-clear-all:hover {
  border-color: #f2aeb8;
  background: var(--red-100);
}

.history-clear-all:disabled {
  border-color: #e3e9f5;
  background: var(--surface-2);
  color: #9aa8bd;
  cursor: not-allowed;
}

.history-clear-all svg {
  width: 16px;
  height: 16px;
}

.history-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: #435673;
  font-size: 12px;
  line-height: 1.35;
}

.history-note svg {
  width: 17px;
  height: 17px;
  color: var(--green-500);
}

.conversation-main {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.conversation-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 15px 18px;
  flex: 0 0 auto;
}

.conversation-titlebar span,
.conversation-titlebar strong,
.conversation-titlebar small {
  display: block;
}

.conversation-titlebar span {
  color: var(--blue-600);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.conversation-titlebar strong {
  max-width: 680px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.conversation-titlebar small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.conversation-title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.conversation-title-actions button {
  padding: 0 11px;
}

.conversation-title-actions button.danger {
  color: var(--red-500);
}

.conversation-title-actions button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.ai-mode-card {
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  min-width: 170px;
}

.ai-mode-card svg {
  grid-row: 1 / span 2;
  width: 25px;
  height: 25px;
  color: var(--blue-600);
}

.chat-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body.is-ai-view .chat-shell,
body:has(#ai-view.active) .chat-shell {
  flex: 1 1 auto;
  min-height: 0;
}

.enhanced-chat {
  border-color: var(--line);
  box-shadow: 0 24px 60px rgba(7, 26, 56, 0.09);
}

.assistant-intro {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 74px minmax(0, 1fr) 280px;
  gap: 22px;
  align-items: center;
  padding: 20px 26px;
  border-bottom: 1px solid #dce7f7;
  background:
    linear-gradient(135deg, rgba(18, 105, 255, 0.09), rgba(18, 183, 214, 0.05)),
    var(--panel);
  overflow: visible;
}

.assistant-orb {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--blue-100), #eff8ff);
  color: var(--blue-600);
  box-shadow: inset 0 0 0 1px #d2e2ff;
}

.assistant-orb svg {
  width: 31px;
  height: 31px;
}

.assistant-copy strong {
  display: block;
  font-size: 17px;
}

.assistant-copy p {
  max-width: 760px;
  margin: 5px 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.assistant-copy ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #314464;
}

.assistant-copy li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.assistant-copy li svg {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  color: var(--blue-600);
}

@media (min-width: 1501px) {
  .assistant-copy ul {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 12px;
  }

  .assistant-copy li {
    padding-right: 10px;
    border-right: 1px solid rgba(18, 105, 255, 0.14);
    line-height: 1.35;
  }

  .assistant-copy li:last-child {
    border-right: 0;
  }
}

.intro-mode-switch {
  display: grid;
  gap: 10px;
}

.intro-mode-switch button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 900;
  text-align: left;
}

.intro-mode-switch button svg {
  width: 20px;
  height: 20px;
}

.intro-mode-switch button.active {
  border-color: var(--blue-600);
  background: linear-gradient(135deg, var(--blue-600), #0b57d6);
  color: var(--on-accent);
  box-shadow: 0 14px 30px rgba(18, 105, 255, 0.23);
}

.command-bar {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  overflow: visible;
}

.command-chip {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  min-height: 54px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue-600);
  text-align: left;
  box-shadow: 0 8px 18px rgba(16, 26, 52, 0.04);
}

.command-chip:hover {
  border-color: var(--line);
  transform: translateY(-1px);
}

.command-chip svg {
  width: 19px;
  height: 19px;
}

.command-chip strong,
.command-chip small {
  display: block;
}

.command-chip strong {
  color: var(--ink);
  font-size: 13px;
}

.command-chip small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.command-chip.success {
  color: var(--green-500);
}

.command-chip.danger {
  color: var(--red-500);
}

.command-chip.ghost {
  color: #4e607d;
}

.login-box {
  display: grid;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
}

.login-row input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.login-row button {
  background: var(--blue-600);
  color: white;
}

.messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 32px;
  scrollbar-gutter: stable;
  background:
    radial-gradient(circle at top right, rgba(18, 105, 255, 0.06), transparent 24rem),
    linear-gradient(180deg, var(--surface-2), var(--surface-2));
}

.messages::-webkit-scrollbar {
  width: 12px;
}

.messages::-webkit-scrollbar-track {
  background: var(--surface-2);
}

.messages::-webkit-scrollbar-thumb {
  border: 3px solid var(--surface-2);
  border-radius: 999px;
  background: #9db2d1;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: #7389ac;
}

.message {
  display: flex;
  gap: 14px;
  max-width: min(1080px, 96%);
}

.message.user {
  align-self: end;
  flex-direction: row-reverse;
  max-width: min(760px, 86%);
}

.message.assistant {
  align-self: start;
}

.message-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--panel);
  color: var(--blue-600);
  font-size: 12px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px #dbe7f8;
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--blue-100), #e9fbff);
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #6d8cff, var(--blue-600));
  color: var(--on-accent);
}

.message-avatar svg {
  width: 20px;
  height: 20px;
}

.message-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.message .bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 21px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.62;
  box-shadow: 0 8px 22px rgba(16, 26, 52, 0.04);
}

.message.user .bubble {
  border-color: #d7e4ff;
  background: linear-gradient(135deg, var(--blue-100), #edf5ff);
}

.message.assistant .bubble {
  background: white;
}

.bubble a {
  color: var(--blue-600);
  font-weight: 850;
}

.message-time {
  color: var(--muted);
  font-size: 12px;
}

.message.user .message-time {
  justify-self: end;
  text-align: right;
}

.answer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.answer-meta span {
  display: inline-grid;
  min-height: 26px;
  place-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--blue-100);
  color: var(--blue-600);
  font-size: 12px;
  font-weight: 900;
}

.message-sources {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.message-sources .source-card {
  min-height: 126px;
  padding: 12px;
  font-size: 13px;
}

.feedback-panel {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding: 12px;
  border: 1px solid #dbe7f8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.feedback-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.feedback-row strong {
  margin-right: 6px;
  color: #30425f;
  font-size: 13px;
}

.feedback-panel button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue-600);
  font-size: 12px;
  font-weight: 900;
}

.feedback-panel button svg {
  width: 16px;
  height: 16px;
}

.feedback-panel button.good {
  color: var(--green-500);
}

.feedback-panel button.bad {
  color: var(--red-500);
}

.feedback-panel .feedback-saved {
  color: var(--green-500);
  font-size: 13px;
  font-weight: 900;
}

.correction-box {
  display: grid;
  gap: 9px;
}

.correction-box textarea {
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
}

.correction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-bottom {
  display: grid;
  flex: 0 0 auto;
  gap: 12px;
  padding: 16px 20px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 14px;
  align-items: end;
  padding: 0;
  border-top: 0;
  background: transparent;
}

.composer-input {
  position: relative;
}

.composer textarea {
  width: 100%;
  min-height: 58px;
  max-height: 140px;
  overflow-y: hidden;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 17px 18px;
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(16, 26, 52, 0.04);
}

.send-button {
  min-height: 58px;
  height: 58px;
  padding: 0 18px;
  border-radius: 8px;
  white-space: nowrap;
  align-self: end;
  box-shadow: 0 14px 30px rgba(18, 105, 255, 0.24);
}

.send-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  order: -1;
}

.prompt-actions button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  align-self: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue-600);
  font-size: 13px;
  font-weight: 900;
}

.prompt-actions button:hover {
  border-color: var(--line);
  background: var(--surface-2);
}

.prompt-actions svg {
  width: 17px;
  height: 17px;
}

.info-strip {
  flex: 0 0 auto;
  margin-top: 10px;
  padding: 11px 14px;
  border: 1px solid #d6e3ff;
  border-radius: 8px;
  background: var(--blue-100);
  color: #27446f;
  line-height: 1.4;
  font-size: 13px;
}

.mode-card {
  display: grid;
  gap: 4px;
  min-width: 150px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow-card);
}

.mode-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.mode-card strong {
  color: var(--blue-600);
  font-size: 18px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.help-card {
  min-height: 230px;
}

.help-card p {
  color: var(--muted);
  line-height: 1.55;
}

.hidden {
  display: none;
}

@media (max-width: 1200px) {
  .home-grid,
  .flow-cards,
  .help-grid,
  .source-grid {
    grid-template-columns: 1fr;
  }

  .ai-conversation-layout {
    grid-template-columns: 1fr;
  }

  .conversation-history {
    max-height: 260px;
  }

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

  .assistant-intro {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .intro-mode-switch {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .action-cards,
  .message-sources {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 901px) and (max-width: 1500px) {
  .ai-conversation-layout {
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 12px;
  }

  .conversation-titlebar {
    padding: 10px 12px;
  }

  .conversation-titlebar strong {
    max-width: 430px;
  }

  .conversation-title-actions button {
    min-height: 32px;
    padding: 0 9px;
  }

  .assistant-intro {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    padding: 12px 16px;
  }

  .assistant-orb {
    width: 42px;
    height: 42px;
  }

  .assistant-orb svg {
    width: 23px;
    height: 23px;
  }

  .assistant-copy strong {
    font-size: 15px;
  }

  .assistant-copy p {
    margin: 3px 0 6px;
    font-size: 13px;
    line-height: 1.35;
  }

  .assistant-copy ul {
    gap: 2px;
    font-size: 13px;
  }

  .intro-mode-switch {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intro-mode-switch button {
    min-height: 40px;
  }

  .command-bar {
    gap: 8px;
    padding: 8px 10px;
  }

  .command-chip {
    min-height: 44px;
    padding: 7px 8px;
  }

  .command-chip small {
    display: none;
  }
}

@media (min-width: 901px) and (max-height: 820px) {
  body.is-ai-view .ai-view.active,
  body:has(#ai-view.active) .ai-view.active {
    padding-top: 14px;
    padding-bottom: 12px;
  }

  .ai-heading {
    margin-bottom: 10px;
  }

  .ai-heading h1 {
    font-size: 32px;
    line-height: 1.05;
  }

  .ai-heading p {
    margin-top: 6px;
    font-size: 14px;
  }

  .ai-mode-card {
    min-width: 132px;
    padding: 10px 12px;
  }

  .assistant-intro {
    grid-template-columns: 54px minmax(0, 1fr) 274px;
    gap: 12px;
    padding: 10px 16px;
  }

  .assistant-orb {
    width: 44px;
    height: 44px;
  }

  .assistant-orb svg {
    width: 24px;
    height: 24px;
  }

  .assistant-copy strong {
    font-size: 15px;
  }

  .assistant-copy p {
    display: block;
    max-width: 720px;
    margin: 3px 0 5px;
    font-size: 13px;
    line-height: 1.3;
  }

  .assistant-copy ul {
    gap: 2px;
    margin-top: 3px;
    font-size: 13px;
  }

  .assistant-copy li:nth-child(3) {
    display: flex;
  }

  .intro-mode-switch {
    gap: 8px;
  }

  .intro-mode-switch button {
    min-height: 40px;
    padding: 0 12px;
  }

  .command-bar {
    gap: 8px;
    padding: 8px 14px;
  }

  .command-chip {
    min-height: 44px;
    padding: 7px 10px;
  }

  .command-chip small {
    display: none;
  }

  .messages {
    gap: 12px;
    padding: 14px 18px;
  }

  .message .bubble {
    padding: 13px 16px;
  }

  .prompt-actions button {
    min-height: 32px;
  }

  .composer textarea {
    padding: 12px 14px;
  }

  .chat-bottom {
    gap: 8px;
    padding: 9px 14px 10px;
  }

  .composer textarea,
  .send-button {
    min-height: 48px;
    height: 48px;
  }

  .info-strip {
    display: none;
  }
}

/* Estado definitivo: estas reglas deben permanecer al final del archivo. */
.layout {
  display: block;
  grid-template-columns: none;
}

.sidebar {
  position: fixed;
  z-index: 100;
  top: 0;
  right: auto;
  bottom: 0;
  left: 0;
  width: 292px;
  max-width: calc(100vw - 44px);
  height: 100dvh;
  transform: translateX(-104%);
  transition: transform 180ms ease;
  box-shadow: 24px 0 60px rgba(5, 20, 48, 0.24);
}

body.sidebar-open .sidebar {
  transform: translateX(0);
}

.workspace {
  width: 100%;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: var(--topbar-height);
  max-width: none;
  padding: 9px 24px;
}

#ai-view .ai-conversation-layout {
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(10, 31, 68, 0.06);
}

#ai-view .conversation-history {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
}

#ai-view .conversation-titlebar {
  min-height: 68px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 18px;
  box-shadow: none;
}

#ai-view .enhanced-chat {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#ai-view .assistant-intro,
#ai-view .command-bar,
#ai-view .chat-bottom {
  background: var(--panel);
}

#ai-view .assistant-intro {
  min-height: 56px;
  padding: 8px 18px;
}

#ai-view .command-bar {
  gap: 7px;
  padding: 8px 18px;
}

#ai-view .command-chip {
  min-height: 42px;
  padding: 6px 9px;
  background: var(--panel);
  box-shadow: none;
}

#ai-view .command-chip small {
  display: none;
}

#ai-view .messages {
  gap: 26px;
  padding: 34px 44px;
  background: var(--panel);
}

#ai-view .message.assistant .bubble {
  border-color: var(--line);
  background: var(--surface-2);
  box-shadow: none;
}

#ai-view .message.user .bubble {
  border-color: var(--line);
  background: var(--surface-2);
  box-shadow: none;
}

#ai-view .chat-bottom {
  padding: 14px 20px 16px;
}

@media (max-width: 900px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    width: min(292px, calc(100vw - 44px));
    max-width: calc(100vw - 44px);
    height: 100dvh;
  }

  .topbar {
    position: sticky;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    max-width: none;
    padding: 9px 14px;
  }

  #ai-view .ai-conversation-layout {
    display: block;
    border: 0;
    box-shadow: none;
  }

  #ai-view .conversation-history {
    max-height: 240px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  #ai-view .messages {
    padding: 24px 16px;
  }
}

/* Overrides finales del cajon lateral y la vista de consulta */
.layout {
  display: block;
  grid-template-columns: none;
}

.sidebar {
  position: fixed;
  z-index: 100;
  top: 0;
  bottom: 0;
  left: 0;
  width: 292px;
  max-width: calc(100vw - 44px);
  height: 100dvh;
  transform: translateX(-104%);
  transition: transform 180ms ease;
  box-shadow: 24px 0 60px rgba(5, 20, 48, 0.24);
}

body.sidebar-open .sidebar {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  z-index: 90;
  inset: 0;
}

.workspace {
  width: 100%;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: var(--topbar-height);
  max-width: none;
  padding: 9px 24px;
}

#ai-view .ai-conversation-layout {
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(10, 31, 68, 0.06);
}

#ai-view .conversation-history {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
}

#ai-view .conversation-titlebar {
  min-height: 68px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 18px;
  box-shadow: none;
}

#ai-view .enhanced-chat {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#ai-view .assistant-intro {
  min-height: 56px;
  padding: 8px 18px;
  background: var(--panel);
}

#ai-view .command-bar {
  gap: 7px;
  padding: 8px 18px;
  background: var(--panel);
}

#ai-view .command-chip {
  min-height: 42px;
  padding: 6px 9px;
  background: var(--panel);
  box-shadow: none;
}

#ai-view .command-chip small {
  display: none;
}

#ai-view .messages {
  gap: 26px;
  padding: 34px 44px;
  background: var(--panel);
}

#ai-view .message.assistant .bubble {
  border-color: var(--line);
  background: var(--surface-2);
  box-shadow: none;
}

#ai-view .message.user .bubble {
  border-color: var(--line);
  background: var(--surface-2);
  box-shadow: none;
}

#ai-view .chat-bottom {
  padding: 14px 20px 16px;
  background: var(--panel);
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    width: min(292px, calc(100vw - 44px));
    height: 100dvh;
  }

  .topbar {
    position: sticky;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 9px 14px;
  }

  #ai-view .ai-conversation-layout {
    display: block;
    border: 0;
    box-shadow: none;
  }

  #ai-view .conversation-history {
    max-height: 240px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  #ai-view .messages {
    padding: 24px 16px;
  }
}

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

  .sidebar {
    position: static;
    max-width: 100vw;
    height: auto;
  }

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

  .topbar {
    position: static;
    grid-template-columns: 1fr;
    max-width: 100vw;
    padding: 14px 18px;
  }

  .top-actions,
  .page-heading,
  .chat-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .view {
    width: 100vw;
    padding: 22px 18px 34px;
    max-width: 100vw;
    overflow: hidden;
  }

  .page-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .page-heading h1,
  .page-heading p {
    max-width: 260px;
  }

  .ai-title-line {
    display: block;
  }

  .ai-subtitle-line {
    display: block;
  }

  .flow-card {
    grid-template-columns: 1fr;
  }

  .global-search,
  .top-actions,
  .assistant-copy,
  .command-chip,
  .chat-shell {
    min-width: 0;
  }

  .assistant-copy p,
  .assistant-copy li,
  .command-chip strong,
  .command-chip small {
    overflow-wrap: anywhere;
  }

  .assistant-intro {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .conversation-history {
    max-height: none;
  }

  .conversation-list {
    grid-template-columns: 1fr;
  }

  .conversation-titlebar {
    align-items: stretch;
    flex-direction: column;
  }

  .assistant-orb {
    width: 64px;
    height: 64px;
  }

  .intro-mode-switch,
  .command-bar {
    grid-template-columns: 1fr;
  }

  .messages {
    padding: 20px 16px;
  }

  .message,
  .message.user {
    max-width: 100%;
  }

  .action-cards,
  .message-sources,
  .composer {
    grid-template-columns: 1fr;
  }

  .send-button {
    width: 100%;
  }

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

@media (max-width: 480px) {
  .page-heading > div,
  .page-heading h1,
  .page-heading p,
  .ai-mode-card,
  .chat-shell {
    width: 100%;
    max-width: 354px;
    max-width: calc(100dvw - 36px);
  }

  .page-heading h1 {
    font-size: 28px;
    line-height: 1.12;
  }
}

@media (max-width: 1380px) and (min-width: 901px) {
  .drive-list-head,
  .drive-item {
    grid-template-columns: minmax(320px, 1fr) 130px 120px;
  }

  .drive-list-head span:nth-child(3),
  .drive-item-date {
    display: none;
  }
}

@media (max-width: 1080px) and (min-width: 901px) {
  .drive-toolbar {
    grid-template-columns: 1fr;
  }

  .drive-list-head,
  .drive-item {
    grid-template-columns: minmax(300px, 1fr) 120px 132px;
  }

  .drive-list-head span:nth-child(2),
  .drive-item-type {
    display: none;
  }
}

@media (max-width: 900px) {
  .drive-heading-actions,
  .drive-statusbar {
    align-items: stretch;
    flex-direction: column;
  }

  .drive-heading-actions .primary-action,
  .drive-heading-actions .secondary-action {
    width: 100%;
  }

  .drive-toolbar {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .drive-toolbar-actions {
    grid-template-columns: 1fr;
  }

  .drive-search {
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .drive-statusbar {
    display: flex;
    padding: 14px;
  }

  .drive-status-metrics {
    display: grid;
  }

  .drive-list-head {
    display: none;
  }

  .drive-items {
    max-height: none;
    padding: 10px;
    background: var(--surface-2);
  }

  .drive-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }

  .drive-item-type,
  .drive-item-date,
  .drive-item-status {
    display: none;
  }

  .drive-item-actions {
    align-self: center;
  }

  .drive-item-actions button[data-drive-ask],
  .drive-item-actions button[data-drive-preview] {
    display: none;
  }

  .drive-preview-dialog {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
  }

  .drive-preview-head strong {
    max-width: 46vw;
  }

  .drive-preview-head a {
    width: 38px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }
}

@media (min-width: 901px) {
  body.is-ai-view .ai-view.active,
  body:has(#ai-view.active) .ai-view.active {
    padding-top: 14px;
    padding-right: 24px;
    padding-bottom: 14px;
    padding-left: 24px;
  }

  body.is-ai-view .ai-heading,
  body:has(#ai-view.active) .ai-heading {
    display: none;
  }

  .conversation-titlebar {
    min-height: 62px;
    margin-bottom: 10px;
    padding: 10px 16px;
  }

  .assistant-intro {
    display: flex;
    min-height: 60px;
    align-items: center;
    justify-content: flex-start;
    padding: 9px 16px;
    background: var(--surface-2);
  }

  .assistant-orb,
  .assistant-copy {
    display: none;
  }

  .intro-mode-switch {
    display: grid;
    width: min(470px, 100%);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .intro-mode-switch button {
    min-height: 42px;
    padding: 0 14px;
  }

  .command-bar {
    padding: 10px 16px;
  }

  .messages {
    gap: 24px;
    padding: 30px 38px;
  }

  .chat-bottom {
    padding: 14px 18px 16px;
  }

  .info-strip {
    display: none;
  }
}

@media (max-width: 900px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 100;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(292px, calc(100vw - 44px));
    max-width: calc(100vw - 44px);
    height: 100dvh;
    transform: translateX(-104%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .topbar {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    max-width: none;
    padding: 9px 14px;
  }

  #ai-view .ai-conversation-layout {
    display: block;
    border: 0;
    box-shadow: none;
  }

  #ai-view .conversation-history {
    max-height: 240px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  #ai-view .messages {
    padding: 24px 16px;
  }

  body.is-ai-view .ai-view.active,
  body:has(#ai-view.active) .ai-view.active {
    padding: 12px;
  }

  #ai-view .ai-heading {
    display: none;
  }

  #ai-view .assistant-intro {
    display: block;
    min-height: 0;
    padding: 10px;
  }

  #ai-view .assistant-orb,
  #ai-view .assistant-copy {
    display: none;
  }

  #ai-view .intro-mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  #ai-view .intro-mode-switch button {
    min-height: 42px;
  }

  #ai-view .command-bar {
    display: flex;
    overflow-x: auto;
    padding: 8px 10px;
    scrollbar-width: thin;
  }

  #ai-view .command-chip {
    min-width: 140px;
    flex: 0 0 auto;
  }
}

/* Panel tecnico */
.role-toggle {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--panel);
  color: var(--blue-600);
  font-size: 13px;
  font-weight: 900;
}

.role-toggle:hover,
body.is-admin-view .role-toggle {
  border-color: var(--blue-600);
  background: var(--blue-100);
}

.role-toggle svg {
  width: 17px;
  height: 17px;
}

.admin-nav-item {
  margin-top: 8px;
  border-top-color: rgba(255, 255, 255, 0.12);
}

.drive-monitor-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.drive-monitor-summary article {
  min-width: 0;
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.drive-monitor-summary article > div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.drive-monitor-summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.drive-monitor-summary strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-monitor-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #1769aa;
  background: #e8f3fb;
}

.drive-monitor-icon.green {
  color: #1e7a4b;
  background: #e5f4ea;
}

.drive-monitor-icon.amber {
  color: #9b6818;
  background: #f8eed8;
}

.drive-monitor-icon.violet {
  color: #6651aa;
  background: #eee9fb;
}

.drive-monitor-icon svg {
  width: 20px;
  height: 20px;
}

.drive-monitor-panel {
  min-height: 500px;
}

.drive-monitor-head {
  gap: 20px;
}

.drive-monitor-filter {
  width: min(380px, 42vw);
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.drive-monitor-filter svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.drive-monitor-filter input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.drive-monitor-table-wrap {
  overflow: auto;
}

.drive-monitor-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

.drive-monitor-table th,
.drive-monitor-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  vertical-align: middle;
}

.drive-monitor-table th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.drive-monitor-name {
  min-width: 310px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.drive-monitor-name > span {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #b74137;
  background: #f8e9e6;
}

.drive-monitor-name > span.folder {
  color: #9b6818;
  background: #f8eed8;
}

.drive-monitor-name svg {
  width: 17px;
  height: 17px;
}

.drive-monitor-name > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.drive-monitor-name strong {
  max-width: 410px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-monitor-name small {
  color: var(--muted);
}

.drive-monitor-path {
  display: block;
  max-width: 330px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-monitor-event {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #6f603e;
  background: #f3ead7;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.drive-monitor-event.created {
  color: #17623d;
  background: #e3f2e8;
}

.drive-monitor-event.modified {
  color: #315f8b;
  background: #e6f0f8;
}

.drive-monitor-actions {
  display: flex;
  gap: 7px;
}

.drive-monitor-actions button,
.drive-monitor-actions a {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--blue-600);
  background: var(--panel);
  cursor: pointer;
}

.drive-monitor-actions button:hover,
.drive-monitor-actions a:hover {
  border-color: var(--blue-600);
  background: var(--surface-2);
}

.drive-monitor-actions svg {
  width: 16px;
  height: 16px;
}

.drive-monitor-empty {
  height: 220px;
  color: var(--muted);
  text-align: center !important;
}

.drive-monitor-empty.error {
  color: var(--red-500);
}

[data-theme="dark"] .drive-monitor-icon {
  background: #182b3d;
}

[data-theme="dark"] .drive-monitor-icon.green {
  background: #183226;
}

[data-theme="dark"] .drive-monitor-icon.amber,
[data-theme="dark"] .drive-monitor-name > span.folder {
  background: #352a18;
}

[data-theme="dark"] .drive-monitor-icon.violet {
  background: #25213e;
}

[data-theme="dark"] .drive-monitor-name > span {
  background: #351e21;
}

@media (max-width: 1100px) {
  .drive-monitor-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drive-monitor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .drive-monitor-filter {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .drive-monitor-summary {
    grid-template-columns: 1fr;
  }

  .drive-monitor-summary article {
    min-height: 78px;
  }
}

.admin-view {
  max-width: 1680px;
  padding-top: 26px;
}

.admin-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.admin-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--blue-600);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-heading h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.admin-heading p {
  margin: 7px 0 0;
  color: var(--muted);
}

.admin-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.admin-environment,
.admin-refresh-control,
.admin-controls button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  border: 1px solid #dce4f1;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
}

.admin-environment select,
.admin-refresh-control select {
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font-weight: 800;
}

.admin-controls button {
  border-color: var(--blue-600);
  background: var(--blue-600);
  color: var(--on-accent);
  font-weight: 900;
}

.admin-controls svg {
  width: 17px;
  height: 17px;
}

.admin-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green-500);
  box-shadow: 0 0 0 4px rgba(18, 166, 107, 0.12);
}

.admin-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.admin-metric-card {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  min-height: 154px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(10, 31, 68, 0.045);
}

.admin-metric-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-100);
  color: var(--blue-600);
}

.admin-metric-card.green .admin-metric-icon {
  background: var(--green-100);
  color: var(--green-500);
}

.admin-metric-card.violet .admin-metric-icon {
  background: var(--violet-100);
  color: var(--violet-500);
}

.admin-metric-card.cyan .admin-metric-icon {
  background: var(--surface-2);
  color: var(--cyan-500);
}

.admin-metric-card.teal .admin-metric-icon {
  background: var(--green-100);
  color: var(--green-500);
}

.admin-metric-card.amber .admin-metric-icon {
  background: var(--amber-100);
  color: var(--amber-500);
}

.admin-metric-card.red .admin-metric-icon {
  background: var(--red-100);
  color: var(--red-500);
}

.admin-metric-card > div > span,
.admin-metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.admin-metric-card strong {
  display: block;
  margin: 7px 0 3px;
  font-size: 26px;
  line-height: 1;
}

.admin-metric-card canvas {
  position: absolute;
  right: 12px;
  bottom: 9px;
  left: 12px;
  width: calc(100% - 24px);
  height: 34px;
}

.admin-progress {
  position: absolute;
  right: 15px;
  bottom: 18px;
  left: 15px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.admin-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--cyan-500);
}

.admin-metric-card.teal .admin-progress span {
  background: var(--green-500);
}

.admin-health-label {
  position: absolute;
  right: 15px;
  bottom: 15px;
  left: 15px;
  display: grid;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: #52627f;
  font-size: 11px;
  font-weight: 900;
}

.admin-health-label.healthy {
  background: var(--green-100);
  color: var(--green-500);
}

.admin-health-label.warning {
  background: var(--amber-100);
  color: #b56805;
}

.admin-dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 1.25fr 0.9fr;
  gap: 14px;
}

.admin-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(10, 31, 68, 0.045);
}

.admin-panel-head {
  display: flex;
  min-height: 66px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}

.admin-panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.admin-panel-head p,
.admin-panel-head > span {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-panel-state {
  color: var(--green-500) !important;
  font-weight: 900;
}

.admin-pipeline-panel {
  grid-column: span 2;
}

.admin-health-panel {
  grid-column: span 1;
}

.admin-chart-panel {
  grid-column: span 2;
}

.admin-mode-panel {
  grid-column: span 1;
}

.admin-activity-panel {
  grid-column: span 2;
}

.admin-alerts-panel {
  grid-column: span 1;
}

.admin-pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 24px 16px;
}

.admin-pipeline-step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 0 8px;
  text-align: center;
}

.admin-pipeline-step:not(:last-child)::after {
  position: absolute;
  z-index: 0;
  top: 22px;
  right: -50%;
  width: 100%;
  border-top: 2px dashed #d2dbe9;
  content: "";
}

.admin-pipeline-icon {
  z-index: 1;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid #dbe4f1;
  border-radius: 999px;
  background: var(--panel);
  color: var(--blue-600);
}

.admin-pipeline-icon.healthy {
  border-color: #bde6d2;
  background: var(--green-100);
  color: var(--green-500);
}

.admin-pipeline-icon.unknown {
  background: #f2f4f8;
  color: #7f8ba1;
}

.admin-pipeline-step strong {
  font-size: 12px;
}

.admin-pipeline-step small {
  max-width: 150px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.admin-services {
  display: grid;
}

.admin-service-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 78px;
  gap: 9px;
  align-items: center;
  min-height: 48px;
  padding: 8px 15px;
  border-bottom: 1px solid var(--line);
}

.admin-service-row:last-child {
  border-bottom: 0;
}

.admin-service-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.admin-service-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--red-500);
}

.admin-service-dot.healthy {
  background: var(--green-500);
}

.admin-service-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.admin-service-row span,
.admin-service-row small {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.admin-chart-panel canvas {
  display: block;
  width: 100%;
  height: 290px;
  padding: 12px 15px 14px;
}

.admin-chart-legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.admin-chart-legend span::before {
  display: inline-block;
  width: 9px;
  height: 3px;
  margin-right: 5px;
  border-radius: 999px;
  background: var(--blue-600);
  content: "";
}

.admin-chart-legend .claw::before {
  background: var(--violet-500);
}

.admin-mode-content {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 270px;
  padding: 18px;
}

.admin-mode-content canvas {
  width: 190px;
  height: 190px;
}

.admin-mode-legend {
  display: grid;
  gap: 12px;
}

.admin-mode-legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.admin-mode-legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--blue-600);
}

.admin-mode-legend-row.claw i {
  background: var(--violet-500);
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
  text-align: left;
}

.admin-table th {
  background: #fafbfd;
  color: #64738d;
  font-size: 11px;
  text-transform: uppercase;
}

.admin-table td:first-child {
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.admin-mode-badge,
.admin-confidence-badge {
  display: inline-grid;
  min-height: 25px;
  place-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--blue-100);
  color: var(--blue-600);
  font-size: 10px;
  font-weight: 900;
}

.admin-mode-badge.claw {
  background: var(--violet-100);
  color: var(--violet-500);
}

.admin-confidence-badge.low {
  background: var(--red-100);
  color: var(--red-500);
}

.admin-alerts {
  display: grid;
}

.admin-alert {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  min-height: 66px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}

.admin-alert:last-child {
  border-bottom: 0;
}

.admin-alert-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--amber-100);
  color: #c87505;
}

.admin-alert.error .admin-alert-icon {
  background: var(--red-100);
  color: var(--red-500);
}

.admin-alert.success .admin-alert-icon {
  background: var(--green-100);
  color: var(--green-500);
}

.admin-alert strong,
.admin-alert span {
  display: block;
}

.admin-alert strong {
  font-size: 12px;
}

.admin-alert span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.admin-feedback-panel {
  grid-column: 1 / -1;
}

.admin-feedback-head {
  align-items: center;
}

.admin-feedback-filters {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.admin-feedback-filters button {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  padding: 0 12px;
  background: transparent;
  color: #65738a;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.admin-feedback-filters button.active {
  background: var(--panel);
  color: var(--blue-600);
  box-shadow: 0 2px 8px rgba(18, 62, 130, 0.1);
}

.admin-feedback-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.admin-feedback-summary > div {
  display: flex;
  min-height: 62px;
  align-items: center;
  gap: 10px;
  padding: 12px 17px;
  background: var(--panel);
  color: #4f5f78;
  font-size: 12px;
}

.admin-feedback-summary svg {
  width: 19px;
  height: 19px;
}

.admin-feedback-summary strong {
  margin-right: 3px;
  color: var(--ink);
  font-size: 20px;
}

.admin-feedback-summary .good svg {
  color: var(--green-500);
}

.admin-feedback-summary .bad svg {
  color: var(--red-500);
}

.admin-feedback-summary .correction svg {
  color: var(--blue-600);
}

.admin-feedback-summary .learned-summary svg {
  color: var(--green-500);
}

.admin-feedback-summary .pending-summary svg {
  color: var(--amber-500);
}

.admin-feedback-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
}

.admin-feedback-learning-state {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px 17px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.admin-feedback-learning-state strong {
  color: var(--ink);
}

.admin-feedback-learning-state svg {
  width: 16px;
  height: 16px;
  color: var(--amber-600);
}

.admin-feedback-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red-500);
  border-radius: 7px;
  padding: 14px;
  background: var(--panel);
}

.admin-feedback-item.bien {
  border-left-color: var(--green-500);
}

.admin-feedback-item.correccion {
  border-left-color: var(--blue-600);
}

.admin-feedback-item-top,
.admin-feedback-item footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.admin-feedback-type,
.admin-feedback-item footer span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-feedback-type {
  color: var(--red-500);
  font-weight: 900;
}

.admin-feedback-item.bien .admin-feedback-type {
  color: var(--green-500);
}

.admin-feedback-item.correccion .admin-feedback-type {
  color: var(--blue-600);
}

.admin-feedback-type svg,
.admin-feedback-item footer svg {
  width: 15px;
  height: 15px;
}

.admin-feedback-item h3 {
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.4;
}

.admin-feedback-correction {
  border: 1px solid #cfe0ff;
  border-radius: 6px;
  padding: 10px 12px;
  background: #f3f7ff;
}

.admin-feedback-correction strong {
  color: var(--blue-600);
  font-size: 11px;
  text-transform: uppercase;
}

.admin-feedback-correction p,
.admin-feedback-item details p {
  margin: 7px 0 0;
  color: #34445d;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.admin-feedback-learning-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  border: 1px solid #cfe8dc;
  border-radius: 6px;
  padding: 9px 11px;
  background: #f0fbf5;
  color: var(--green-700);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.admin-feedback-learning-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.admin-feedback-item details {
  margin: 11px 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.admin-feedback-item summary {
  color: var(--blue-600);
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.admin-feedback-item footer {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  flex-wrap: wrap;
}

.admin-feedback-item footer .learned {
  color: var(--green-500);
  font-weight: 800;
}

.admin-feedback-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 150px;
  place-items: center;
  align-content: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}

.admin-feedback-empty svg {
  width: 30px;
  height: 30px;
  color: #8ca0be;
}

.admin-feedback-empty strong {
  color: var(--ink);
}

@media (max-width: 1380px) {
  .admin-metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1050px) {
  .admin-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .admin-pipeline-panel,
  .admin-health-panel,
  .admin-chart-panel,
  .admin-mode-panel,
  .admin-activity-panel,
  .admin-alerts-panel {
    grid-column: span 1;
  }

  .admin-feedback-panel {
    grid-column: span 1;
  }
}

@media (max-width: 700px) {
  .role-toggle span {
    display: none;
  }

  .role-toggle {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .admin-view {
    padding: 18px 12px 30px;
  }

  .admin-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .admin-metric-grid {
    grid-template-columns: 1fr;
  }

  .admin-feedback-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-feedback-filters {
    overflow-x: auto;
  }

  .admin-feedback-summary,
  .admin-feedback-list {
    grid-template-columns: 1fr;
  }

  .admin-pipeline {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .admin-pipeline-step {
    grid-template-columns: 46px minmax(0, 1fr);
    justify-items: start;
    text-align: left;
  }

  .admin-pipeline-step:not(:last-child)::after {
    display: none;
  }

  .admin-mode-content {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

/* El modo se cambia por comandos (/rag, /claw) y se muestra en el encabezado.
   Ocultamos el toggle e intro para una UI mas limpia. */
#ai-view .assistant-intro { display: none; }

/* ============================================================
   MINIMALISTA estilo ChatGPT (limpieza del chat)
   ============================================================ */

/* Selector de modo junto al input */
.mode-select {
  align-self: center;
  height: 36px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236a7080' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>")
    no-repeat right 10px center;
  color: var(--ink);
  font: 600 13px Inter, sans-serif;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.mode-select:focus { outline: none; box-shadow: var(--ring); }

/* Barra de comandos del top y acciones: fuera (ChatGPT no las tiene arriba) */
#ai-view .command-bar { display: none; }
#ai-view .prompt-actions { display: none; }

/* Encabezado del chat mas liviano */
#ai-view .conversation-titlebar { border-bottom: 0; }

/* Mensajes: asistente sin caja (texto plano), usuario burbuja sutil.
   Ocupan TODO el ancho disponible (no columna angosta). */
#ai-view .messages { padding: 28px 48px; gap: 30px; }
#ai-view .message { max-width: 100%; width: auto; margin: 0; }
#ai-view .message.assistant { max-width: 100%; }
#ai-view .message.user { max-width: min(760px, 76%); margin: 0; }
#ai-view .message.assistant .bubble {
  border: 0;
  background: transparent;
  padding: 2px 0;
  box-shadow: none;
}
#ai-view .message.user .bubble {
  border: 0;
  background: var(--surface-2);
  border-radius: 18px;
  padding: 12px 16px;
}
#ai-view .message-avatar { width: 30px; height: 30px; box-shadow: inset 0 0 0 1px var(--line); }
#ai-view .answer-meta {
  font-size: 11.5px;
  color: var(--muted);
  opacity: 0.8;
}

/* Input estilo ChatGPT: barra redondeada que ocupa el ancho disponible */
#ai-view .chat-bottom { border-top: 0; padding: 8px 48px 18px; background: transparent; }
#ai-view .composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 7px 7px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
}
#ai-view .composer:focus-within { border-color: var(--blue-600); box-shadow: var(--ring); }
#ai-view .composer-input { flex: 1 1 auto; }
#ai-view .composer textarea {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 9px 6px;
  resize: none;
  max-height: 200px;
}
#ai-view .send-button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  background: var(--blue-600);
  color: var(--on-accent);
}
#ai-view .send-button .button-label { display: none; }
#ai-view .send-button svg { width: 18px; height: 18px; }

/* Seleccion multiple del historial */
.history-actions { display: grid; gap: 8px; }
.selection-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.select-cancel,
.select-confirm {
  height: 38px;
  border-radius: 10px;
  font: 600 13px Inter, sans-serif;
  cursor: pointer;
  border: 1px solid var(--line);
}
.select-cancel { background: var(--panel); color: var(--ink); }
.select-cancel:hover { background: var(--surface-2); }
.select-confirm { background: var(--red-500); color: #fff; border-color: transparent; }
.select-confirm:disabled { opacity: 0.5; cursor: not-allowed; }
.conversation-check { display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); margin-right: 2px; }
.conversation-check svg { width: 18px; height: 18px; }
.conversation-item.selected { outline: 2px solid var(--blue-600); outline-offset: -2px; border-radius: 12px; }
.conversation-item.selected .conversation-check { color: var(--blue-600); }
/* En modo seleccion el checkbox reemplaza al icono (mas espacio para el texto) */
.conversation-item.selectable .conversation-icon { display: none; }

/* Menu de tres puntos por conversacion (estilo ChatGPT) */
.conversation-item { position: relative; display: flex; align-items: stretch; }
.conversation-item .conversation-open { flex: 1 1 auto; min-width: 0; }
.conversation-menu-wrap { position: relative; display: flex; align-items: center; }
.conversation-menu-button {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  color: var(--muted); border-radius: 8px;
  opacity: 0; cursor: pointer;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.conversation-item:hover .conversation-menu-button,
.conversation-menu-button:focus-visible { opacity: 1; }
.conversation-menu-button:hover { background: var(--surface-2); color: var(--ink); }
.conversation-menu-button svg { width: 17px; height: 17px; }

.conversation-menu {
  position: absolute;
  top: calc(100% - 4px);
  right: 4px;
  z-index: 40;
  min-width: 168px;
  padding: 6px;
  display: grid;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}
.conversation-menu button {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 500 13px Inter, sans-serif;
  text-align: left; cursor: pointer;
}
.conversation-menu button:hover { background: var(--surface-2); }
.conversation-menu button svg { width: 15px; height: 15px; color: var(--muted); }
.conversation-menu button.danger { color: var(--red-500); }
.conversation-menu button.danger svg { color: var(--red-500); }

/* Toggle "ver archivadas" minimalista */
.archived-toggle {
  display: flex; align-items: center; gap: 7px;
  width: 100%;
  padding: 8px 10px;
  border: 0; background: transparent;
  color: var(--muted);
  font: 600 12.5px Inter, sans-serif;
  border-radius: 8px; cursor: pointer;
}
.archived-toggle:hover { background: var(--surface-2); color: var(--ink); }
.archived-toggle.active { color: var(--blue-600); }
.archived-toggle svg { width: 15px; height: 15px; }

.conversation-menu.hidden { display: none; }

/* ====== AYUDA: comentarios de usuarios ====== */
.help-comment-section {
  margin-top: 18px;
}
.help-comment-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.help-comment-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.help-comment-card h2 i {
  width: 20px;
  height: 20px;
  color: var(--blue-600);
}
.help-comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.help-comment-form input,
.help-comment-form textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  resize: vertical;
}
.help-comment-form input::placeholder,
.help-comment-form textarea::placeholder {
  color: var(--muted);
}
.help-comment-form input:focus,
.help-comment-form textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: var(--ring);
}
.help-comment-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.help-comment-status {
  font-size: 0.9rem;
  color: var(--muted);
}
.help-comment-status.ok {
  color: var(--green-500);
}
.help-comment-status.error {
  color: var(--red-500);
}

/* ====== ADMIN: panel de comentarios ====== */
.admin-comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
}
.admin-comment-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}
.admin-comment-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}
.admin-comment-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
}
.admin-comment-author i {
  width: 15px;
  height: 15px;
}
.admin-comment-item p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* "Panel tecnico" solo visible en vista administrador */
/* "Panel tecnico" en el sidebar: visible siempre que haya sesion admin
   (el admin navega por toda la app con su rol elevado). */
body:not(.is-admin) .admin-nav-item { display: none; }
body.is-admin .reviewer-nav-item { display: none; }
body.is-reviewer-mode .admin-nav-item,
body.is-reviewer-mode .admin-profile-action { display: none !important; }
body.is-reviewer-mode .reviewer-nav-item { display: flex !important; }

/* Modal de acceso administrador */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 11, 20, 0.55);
  backdrop-filter: blur(3px);
}
.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--blue-100);
  color: var(--blue-600);
}
.modal-icon svg { width: 19px; height: 19px; }
.modal-head > div { flex: 1 1 auto; min-width: 0; }
.modal-head strong { display: block; font-size: 15px; color: var(--ink); }
.modal-head small { color: var(--muted); font-size: 12.5px; }
.modal-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-close svg { width: 17px; height: 17px; }
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px 20px;
}
.modal-form label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 6px;
}
.modal-form input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font: 400 14px Inter, sans-serif;
}
.modal-form input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: var(--ring);
}
.modal-error {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--red-100);
  color: var(--red-500);
  font-size: 12.5px;
  font-weight: 600;
}
.modal-submit {
  justify-content: center;
  margin-top: 14px;
  width: 100%;
}

/* El cierre de sesion forma parte del encabezado mientras exista una sesion. */
.role-toggle { display: none !important; }
body.is-authed .role-toggle { display: inline-flex !important; }

/* FIX CRITICO: el overlay del modal debe ocultarse con .hidden (gana a display:grid) */
.modal-overlay.hidden { display: none !important; }

/* ===== Panel admin dinamico: KPIs y servicios clickeables + popup de detalle ===== */
.admin-metric-card[data-metric] {
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.admin-metric-card[data-metric]:hover {
  transform: translateY(-2px);
  border-color: var(--blue-600);
  box-shadow: var(--shadow-soft);
}
.admin-metric-card[data-metric]:focus-visible {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: var(--ring);
}
.admin-metric-card[data-metric]::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 14px;
  height: 14px;
  opacity: 0.35;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M7 17 17 7M9 7h8v8'/></svg>") center/contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M7 17 17 7M9 7h8v8'/></svg>") center/contain no-repeat;
  color: var(--muted);
  transition: opacity 0.12s ease;
}
.admin-metric-card[data-metric]:hover::after { opacity: 0.8; color: var(--blue-600); }

.admin-service-row[data-service] {
  cursor: pointer;
  transition: background 0.12s ease;
}
.admin-service-row[data-service]:hover { background: var(--surface-2); }
.admin-service-row[data-service]:focus-visible { outline: none; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--blue-600); }

/* Popup de detalle */
.detail-card { max-width: 470px; }
.detail-body {
  padding: 14px 18px 20px;
  max-height: 68vh;
  overflow-y: auto;
}
.detail-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.detail-stat:last-child { border-bottom: 0; }
.detail-stat-label { color: var(--muted); }
.detail-stat-value { color: var(--ink); font-weight: 600; text-align: right; }
.detail-stat-value em { color: var(--muted); font-weight: 400; font-style: normal; }
.detail-section-title {
  margin: 16px 0 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail-history-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 14px 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font: 600 13px Inter, sans-serif;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.detail-history-button:hover {
  border-color: var(--blue-600);
  background: var(--panel);
}
.detail-history-button i { width: 15px; height: 15px; }
.detail-bar { margin-bottom: 10px; }
.detail-bar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 12px;
}
.detail-bar-top span { color: var(--muted); }
.detail-bar-top strong { color: var(--ink); }
.detail-bar-track {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.detail-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--blue-600);
}
.detail-alert {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.detail-alert strong { font-size: 13px; color: var(--ink); }
.detail-alert small { font-size: 12px; color: var(--muted); }
.detail-alert.error { border-color: var(--red-500); }
.detail-alert.error strong { color: var(--red-500); }
.detail-alert.warning strong { color: #c07d12; }
.detail-alert.success strong { color: var(--green-500); }
.detail-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

/* ===== Revision juridica (sesion de abogado) ===== */
.review-view {
  max-width: 1320px;
  margin: 0 auto;
}
.review-heading {
  align-items: end;
}
.review-heading-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}
.review-heading-actions label {
  display: grid;
  gap: 6px;
}
.review-heading-actions label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.review-heading-actions select {
  width: 230px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: 700 13px Inter, sans-serif;
}
.review-auto-action {
  border-color: var(--blue-600) !important;
  color: var(--blue-700) !important;
}
.review-auto-action:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}
.review-summary {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(520px, 1.7fr);
  gap: 28px;
  align-items: center;
  margin-bottom: 18px;
  padding: 20px 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.review-summary-main > span,
.review-proposal > span,
.review-reason > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.review-summary-main h2 {
  margin: 0;
  color: var(--ink);
  font: 700 26px/1.15 Georgia, serif;
  letter-spacing: 0;
}
.review-summary-main p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.review-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
}
.review-metrics > div {
  min-width: 0;
  padding: 4px 18px;
  border-left: 1px solid var(--line);
}
.review-metrics span,
.review-metrics strong {
  display: block;
  letter-spacing: 0;
}
.review-metrics span {
  min-height: 30px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.review-metrics strong {
  color: var(--ink);
  font-size: 25px;
}
.review-complete-notice {
  margin-bottom: 14px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.review-complete-notice.success {
  border-color: var(--green-500);
  background: var(--green-100);
  color: var(--green-500);
}
.review-complete-notice.warning {
  border-color: var(--amber-500);
  background: var(--amber-100);
}
.review-complete-notice.error {
  border-color: var(--red-500);
  background: var(--red-100);
  color: var(--red-500);
}
.review-workspace {
  border-top: 1px solid var(--line);
}
.review-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.review-filters {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.review-filters button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font: 700 12px Inter, sans-serif;
  cursor: pointer;
}
.review-filters button span {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: center;
}
.review-filters button.active {
  border-color: var(--blue-600);
  background: var(--blue-600);
  color: var(--on-accent);
}
.review-filters button.active span {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.review-items {
  display: grid;
}
.review-item {
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
}
.review-item-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}
.review-order {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}
.review-item-head > div > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.review-item-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.review-status {
  min-height: 26px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--amber-100);
  color: var(--amber-500);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.review-status.approved {
  background: var(--green-100);
  color: var(--green-500);
}
.review-status.rejected {
  background: var(--red-100);
  color: var(--red-500);
}
.review-item-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(320px, 1.3fr);
  gap: 22px;
  margin: 14px 0 14px 48px;
}
.review-proposal,
.review-reason {
  min-width: 0;
  padding-left: 12px;
  border-left: 3px solid var(--line);
}
.review-proposal {
  border-left-color: var(--blue-600);
}
.review-proposal strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.review-proposal small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.review-reason p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.review-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 48px;
  flex-wrap: wrap;
}
.review-actions button,
.review-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: 700 12px Inter, sans-serif;
  text-decoration: none;
  cursor: pointer;
}
.review-actions svg,
.review-correction svg {
  width: 15px;
  height: 15px;
}
.review-open {
  color: var(--blue-700);
}
.review-open.disabled {
  color: var(--muted);
  cursor: default;
}
.review-approve {
  border-color: var(--green-500) !important;
  color: var(--green-500) !important;
}
.review-correct {
  border-color: var(--amber-500) !important;
  color: var(--amber-500) !important;
}
.review-reject {
  border-color: var(--red-500) !important;
  color: var(--red-500) !important;
}
.review-correction {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
  margin: 14px 0 14px 48px;
  padding: 12px;
  border: 1px solid var(--amber-500);
  border-radius: 8px;
  background: var(--amber-100);
}
.review-correction.hidden {
  display: none;
}
.review-correction label {
  display: grid;
  gap: 5px;
}
.review-correction label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.review-correction select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
.review-finish-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 -8px 24px rgba(35, 28, 17, 0.08);
  backdrop-filter: blur(8px);
}
.review-finish-bar > div {
  display: grid;
  gap: 3px;
}
.review-finish-bar strong {
  color: var(--ink);
  font-size: 14px;
}
.review-finish-bar span {
  color: var(--muted);
  font-size: 12px;
}
.review-finish-bar .primary-action span {
  color: inherit;
}
.review-finish-bar button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* ===== Vista Web scraping (panel admin) ===== */
.scraping-review-ready {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 13px 15px;
  border: 1px solid var(--green-500);
  border-radius: 8px;
  background: var(--green-100);
}
.scraping-review-ready-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--green-500);
}
.scraping-review-ready-icon svg {
  width: 18px;
  height: 18px;
}
.scraping-review-ready > div:nth-child(2) {
  display: grid;
  gap: 3px;
}
.scraping-review-ready span {
  color: var(--green-500);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}
.scraping-review-ready strong {
  color: var(--ink);
  font-size: 14px;
}
.scraping-review-ready p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.scraping-review-ready-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel);
  white-space: nowrap;
}

.scraping-apply-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid var(--green-500);
  border-radius: 8px;
  background: var(--green-100);
}
.scraping-apply-summary.warning {
  border-color: var(--amber-500);
  background: var(--amber-100);
}
.scraping-apply-summary.success {
  box-shadow: 0 10px 26px rgba(43, 130, 86, 0.08);
}
.scraping-apply-summary-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.scraping-apply-summary-head > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--green-500);
  flex: 0 0 auto;
}
.scraping-apply-summary.warning .scraping-apply-summary-head > span {
  color: var(--amber-500);
}
.scraping-apply-summary-head svg {
  width: 17px;
  height: 17px;
}
.scraping-apply-summary-head div {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.scraping-apply-summary-head strong,
.scraping-apply-summary-head small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scraping-apply-summary-head strong {
  color: var(--ink);
  font-size: 13px;
}
.scraping-apply-summary-head small {
  color: var(--muted);
  font-size: 11px;
}
.scraping-apply-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue-600);
  font: 800 12px Inter, sans-serif;
  cursor: pointer;
}
.scraping-apply-toggle svg {
  width: 14px;
  height: 14px;
}
.scraping-apply-summary-details {
  display: grid;
  gap: 8px;
}
.scraping-apply-summary.collapsed .scraping-apply-summary-details {
  display: none;
}
.scraping-apply-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 8px;
}
.scraping-apply-summary-grid span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}
.scraping-apply-summary-grid strong {
  color: var(--ink);
}
.scraping-apply-next-step {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(43, 130, 86, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--green-700);
  font-size: 12px;
  font-weight: 700;
}
.scraping-apply-summary ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.scraping-control-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(300px, 1.4fr) repeat(3, minmax(130px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(180, 125, 34, 0.10), rgba(255,255,255,0.58));
}
.scraping-control-panel label,
.scraping-status-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scraping-control-panel label span,
.scraping-status-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.scraping-control-panel input[type="number"],
.scraping-reprocess-wrap select {
  height: 38px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font: 700 13px Inter, sans-serif;
}
.scraping-portal-live input[readonly] {
  border-color: #75a978;
  background: #eef8ef;
  color: #27653b;
  cursor: default;
}
.scraping-portal-live small {
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}
.scraping-portal-live small.has-updates { color: var(--blue-600); font-weight: 700; }
.scraping-portal-live small.is-current { color: #2e7d46; font-weight: 700; }
.scraping-portal-live small.has-error { color: var(--red-500); font-weight: 700; }
.drive-heading-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.scraping-control-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: end;
  gap: 8px;
  margin-top: 8px;
}
.scraping-control-edit button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--blue-600);
  cursor: pointer;
}
.scraping-control-edit button:hover {
  border-color: var(--blue-600);
  background: var(--blue-100);
}
.scraping-control-edit svg {
  width: 16px;
  height: 16px;
}
.scraping-mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.scraping-mode-options button {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.scraping-mode-options button.active {
  border-color: var(--blue-600);
  background: var(--blue-100);
  box-shadow: var(--ring);
}
.scraping-mode-options svg {
  width: 18px;
  height: 18px;
  color: var(--blue-600);
  flex: 0 0 auto;
}
.scraping-mode-options span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.scraping-mode-options strong {
  font-size: 13px;
  color: var(--ink);
}
.scraping-mode-options small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.25;
}
.scraping-plan {
  grid-column: 1 / -1;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.scraping-ai-status {
  grid-column: 1 / -1;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.scraping-ai-status.ready {
  border-color: #75a978;
  background: #eef8ef;
}
.scraping-ai-status.error {
  border-color: var(--red-500);
  background: #fff3f1;
}
.scraping-ai-status svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--blue-600);
}
.scraping-ai-status.error svg {
  color: var(--red-500);
}
.scraping-ai-status span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.scraping-ai-status strong {
  color: var(--ink);
  font-size: 13px;
}
.scraping-ai-status small {
  color: var(--muted);
  font-size: 11.5px;
}
.scraping-status-card strong {
  color: var(--ink);
  font-size: 15px;
}
.scraping-status-card small {
  color: var(--muted);
  line-height: 1.35;
}
.scraping-check {
  min-height: 38px;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.scraping-check input {
  width: 16px;
  height: 16px;
}
.scraping-check {
  flex-direction: row !important;
  align-items: center;
}
.scraping-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.scraping-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.scraping-filters button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--muted);
  font: 600 12.5px Inter, sans-serif; cursor: pointer;
}
.scraping-filters button span {
  background: var(--surface-2); color: var(--ink);
  border-radius: 999px; padding: 0 7px; font-size: 11px;
}
.scraping-filters button.active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.scraping-filters button.active span { background: rgba(255,255,255,0.25); color: #fff; }
.scraping-search { position: relative; display: flex; align-items: center; }
.scraping-search svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); }
.scraping-search input {
  height: 38px; min-width: 220px; padding: 0 12px 0 34px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--ink);
}
.scraping-search input:focus { outline: none; border-color: var(--blue-600); box-shadow: var(--ring); }

.drive-list-head.scraping-head,
.scraping-row {
  grid-template-columns: minmax(280px, 1fr) 190px 92px 110px 116px;
}
.scraping-doc { display: flex; align-items: center; gap: 11px; min-width: 0; }
.scraping-doc .conversation-copy { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.scraping-doc strong { font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scraping-doc small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scraping-group {
  height: 34px; max-width: 100%; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--ink);
  font: 500 12.5px Inter, sans-serif;
}
.scraping-conf { font-weight: 700; color: var(--ink); font-size: 13px; }
.scrap-badge {
  display: inline-grid; place-items: center; min-height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.scrap-badge.approved { color: var(--green-500); border-color: transparent; background: var(--green-100); }
.scrap-badge.rejected { color: var(--red-500); border-color: transparent; background: var(--red-100); }
.scraping-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.scraping-actions a,
.scraping-actions button {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--muted); cursor: pointer; text-decoration: none;
}
.scraping-actions svg { width: 16px; height: 16px; }
.scraping-actions .scrap-approve:hover { border-color: var(--green-500); color: var(--green-500); background: var(--green-100); }
.scraping-actions .scrap-reject:hover { border-color: var(--red-500); color: var(--red-500); background: var(--red-100); }
.scraping-actions a:hover { border-color: var(--blue-600); color: var(--blue-600); background: var(--blue-100); }

.scraping-findings {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--blue-600);
  border-radius: 14px;
  background: var(--blue-100);
}
.scraping-findings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.scraping-findings-head span {
  color: var(--blue-600);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.scraping-findings-head strong {
  color: var(--ink);
  font-size: 14px;
}
.scraping-findings p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.scraping-findings-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
}
.scraping-findings-list article {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.scraping-findings-list strong,
.scraping-findings-list small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scraping-findings-list strong {
  color: var(--ink);
  font-size: 13px;
}
.scraping-findings-list small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.scraping-job { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.scraping-job.error { border-color: var(--red-500); }
.scraping-job pre {
  margin: 0; padding: 12px 14px; max-height: min(420px, 45vh); overflow-y: auto; overflow-x: hidden;
  font: 12px ui-monospace, Menlo, Consolas, monospace; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; overscroll-behavior: contain; scroll-behavior: auto;
}

/* kicker reutilizable (por si no existe) */
.admin-kicker { display: inline-block; margin-bottom: 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--blue-600); }

.scraping-estado-wrap { display: flex; align-items: center; gap: 8px; }
.scraping-estado-wrap span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.scraping-estado-wrap select {
  height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--ink); font: 600 13px Inter, sans-serif; cursor: pointer;
}
.scraping-estado-wrap select:focus { outline: none; border-color: var(--blue-600); box-shadow: var(--ring); }

@media (max-width: 1100px) {
  .review-summary {
    grid-template-columns: 1fr;
  }
  .scraping-control-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .scraping-status-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .review-heading,
  .review-heading-actions,
  .review-toolbar,
  .review-finish-bar {
    align-items: stretch;
  }
  .review-heading-actions,
  .review-toolbar,
  .review-finish-bar {
    flex-direction: column;
  }
  .review-heading-actions label,
  .review-heading-actions select,
  .review-search,
  .review-search input {
    width: 100%;
  }
  .review-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 0;
  }
  .review-item-head {
    grid-template-columns: 36px minmax(0, 1fr);
  }
  .review-status {
    grid-column: 2;
    justify-self: start;
  }
  .review-item-body,
  .review-correction {
    grid-template-columns: 1fr;
    margin-left: 0;
  }
  .review-actions {
    margin-left: 0;
  }
  .review-actions button,
  .review-open {
    flex: 1 1 140px;
  }
  .scraping-review-ready {
    grid-template-columns: 36px minmax(0, 1fr);
  }
  .scraping-review-ready-badge {
    grid-column: 2;
    justify-self: start;
  }
  .scraping-apply-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .scraping-apply-summary-head strong,
  .scraping-apply-summary-head small {
    white-space: normal;
  }
}

/* ===== Vista Indexacion y entrenamiento ===== */
.index-summary { margin-bottom: 14px; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.index-summary svg { width: 17px; height: 17px; color: #2f855a; }
.index-summary strong { color: var(--ink); }
.index-state-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.index-state-toolbar label { flex: 1 1 360px; max-width: 520px; display: grid; gap: 6px; }
.index-state-toolbar label > span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.index-state-toolbar select { width: 100%; min-height: 42px; padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); font: inherit; }
.index-state-actions { display: flex; align-items: center; gap: 8px; }
.index-state-actions button:disabled { opacity: .48; cursor: not-allowed; }
.index-telemetry { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.index-metric { min-width: 0; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.index-metric.healthy { border-bottom-color: #3a8b62; }
.index-metric.warning { border-bottom-color: #b18129; }
.index-metric.error { border-bottom-color: #c94a4a; }
.index-metric-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); color: var(--blue-600); }
.index-metric-icon svg { width: 19px; height: 19px; }
.index-metric div { min-width: 0; display: grid; gap: 2px; }
.index-metric small { color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 700; }
.index-metric strong { color: var(--ink); font-size: 20px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.index-metric span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.index-items { padding: 10px; display: grid; gap: 10px; }
.index-group { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.index-group-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.index-group-icon { display: grid; place-items: center; color: var(--blue-600); }
.index-group-icon svg { width: 18px; height: 18px; }
.index-group-head strong { flex: 1 1 auto; min-width: 0; color: var(--ink); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.index-group-count { flex: 0 0 auto; background: var(--blue-100); color: var(--blue-600); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.index-document-list { display: grid; }
.index-document-row { display: grid; grid-template-columns: 32px minmax(280px, 1fr) 130px 146px; gap: 10px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.index-document-row:last-child { border-bottom: 0; }
.index-document-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-2); color: var(--blue-600); }
.index-document-icon svg { width: 16px; height: 16px; }
.index-document-main { min-width: 0; display: grid; gap: 3px; }
.index-document-main strong { color: var(--ink); font-size: 13px; overflow-wrap: anywhere; line-height: 1.35; }
.index-document-main > span { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.index-document-main b { color: var(--ink); font-weight: 600; }
.index-document-main small { margin-left: 5px; color: var(--muted); }
.index-document-main .index-document-error { color: var(--red-600); white-space: normal; }
.index-approval-badge { justify-self: start; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.index-approval-badge.approved { background: #e7f4e9; color: #2f855a; }
.index-approval-badge.held { background: #fff3d7; color: #9a681c; }
.index-approval-badge.excluded { background: #fde9e7; color: #c94a4a; }
.index-document-actions { display: flex; justify-content: end; gap: 5px; }
.index-document-actions button { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--blue-600); cursor: pointer; }
.index-document-actions button:hover:not(:disabled) { border-color: var(--blue-600); background: var(--blue-100); }
.index-document-actions button:disabled { opacity: .38; cursor: not-allowed; }
.index-document-actions svg { width: 15px; height: 15px; }
.index-correction-form { grid-column: 2 / -1; display: flex; align-items: end; gap: 8px; padding-top: 8px; }
.index-correction-form.hidden { display: none; }
.index-correction-form label { flex: 1 1 auto; display: grid; gap: 5px; }
.index-correction-form label > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.index-correction-form select { min-height: 40px; padding: 0 34px 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); }
.index-correction-form button { min-height: 40px; }
.index-group-files { list-style: none; margin: 0; padding: 8px 14px; display: grid; gap: 6px; }
.index-group-files li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.index-group-files li svg { width: 15px; height: 15px; flex: 0 0 auto; }
.index-group-files li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.index-group-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--blue-600); font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s; }
.index-group-btn:hover { background: var(--blue-100); border-color: var(--blue-600); }
.index-group-btn:disabled { opacity: .42; cursor: not-allowed; }
.index-group-btn:disabled:hover { background: var(--surface); border-color: var(--line); }
.index-group-btn svg { width: 14px; height: 14px; }
.index-history-panel { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.index-history-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.index-history-head h2 { margin: 2px 0 0; color: var(--ink); font-size: 17px; letter-spacing: 0; }
.index-history-head > span { color: var(--muted); font-size: 12px; }
.index-history { display: grid; }
.index-history-row { display: grid; grid-template-columns: 30px minmax(180px, 1fr) 100px 110px 72px; gap: 12px; align-items: center; min-height: 54px; padding: 9px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.index-history-row:last-child { border-bottom: 0; }
.index-history-row > div { min-width: 0; display: grid; gap: 2px; }
.index-history-row strong { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.index-history-row span { color: var(--muted); }
.index-history-row b { color: var(--ink); font-size: 12px; }
.index-history-state { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); }
.index-history-state svg { width: 16px; height: 16px; }
.index-history-state.healthy { color: #2f855a; }
.index-history-state.error { color: #c94a4a; }

@media (max-width: 1050px) {
  .index-telemetry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .index-document-row { grid-template-columns: 32px minmax(0, 1fr) 126px; }
  .index-document-actions { grid-column: 2 / -1; justify-content: start; }
  .index-correction-form { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .index-telemetry { grid-template-columns: 1fr; }
  .index-state-toolbar { align-items: stretch; flex-direction: column; }
  .index-state-toolbar label { flex-basis: auto; max-width: none; }
  .index-state-actions { display: grid; grid-template-columns: 1fr; }
  .index-state-actions button { width: 100%; justify-content: center; }
  .index-document-row { grid-template-columns: 30px minmax(0, 1fr); }
  .index-approval-badge { grid-column: 2; }
  .index-document-actions { grid-column: 2; }
  .index-correction-form { flex-direction: column; align-items: stretch; }
  .index-history-row { grid-template-columns: 30px minmax(0, 1fr) 74px; }
  .index-history-row > span:nth-of-type(2),
  .index-history-row > b { display: none; }
}

/* ============================================================
   MODO CLARO PREMIUM — crema + dorado + serif
   (refs de Inicio, Providencias y Consultas IA).
   Solo aplica en claro; el modo oscuro queda intacto.
   ============================================================ */
html:not([data-theme="dark"]) body {
  background:
    radial-gradient(1100px 560px at 88% -12%, rgba(193, 158, 90, 0.12), transparent 62%),
    radial-gradient(900px 500px at 0% 0%, rgba(193, 158, 90, 0.06), transparent 55%),
    var(--bg);
}

/* Titulos display en serif elegante (como las referencias) */
html:not([data-theme="dark"]) .home-hero-copy h1,
html:not([data-theme="dark"]) .page-heading h1,
html:not([data-theme="dark"]) .compact-heading h1,
html:not([data-theme="dark"]) .topbar-brand strong {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: -0.005em;
}
html:not([data-theme="dark"]) .home-hero-copy h1 {
  color: #fff7e6;
  font-size: clamp(38px, 5.6vw, 76px);
  line-height: 0.98;
}

/* CTA principal del hero en NAVY, como la referencia de Inicio */
html:not([data-theme="dark"]) .home-hero-copy .primary-action {
  border-color: rgba(246, 220, 160, 0.44);
  background: linear-gradient(135deg, rgba(19, 28, 52, 0.96), rgba(5, 10, 25, 0.98));
  box-shadow: 0 18px 38px rgba(6, 10, 22, 0.36);
}
html:not([data-theme="dark"]) .home-hero-copy .primary-action:hover {
  border-color: rgba(248, 221, 158, 0.72);
  box-shadow: 0 20px 42px rgba(6, 10, 22, 0.42);
}

/* Tarjetas y paneles con esquinas mas suaves y calidas */
html:not([data-theme="dark"]) .flow-card,
html:not([data-theme="dark"]) .summary-panel,
html:not([data-theme="dark"]) .status-panel,
html:not([data-theme="dark"]) .recommend-panel,
html:not([data-theme="dark"]) .documents-panel,
html:not([data-theme="dark"]) .activity-panel,
html:not([data-theme="dark"]) .chat-shell,
html:not([data-theme="dark"]) .help-card,
html:not([data-theme="dark"]) .home-hero-art {
  border-radius: 16px;
}

/* Iconos de paso/marca con leve halo dorado */
html:not([data-theme="dark"]) .step-visual {
  background: var(--blue-100);
  border-color: #e7d6b0;
}

/* ============================================================
   NAVEGACION SUPERIOR (top-nav) estilo referencia
   logo izquierda · secciones centro · acciones derecha
   ============================================================ */
.topbar-nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  min-width: 0;
  padding-left: 16px;
  flex-wrap: nowrap;
}
.topnav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: color 0.15s ease, background 0.15s ease;
}
.topnav-item:hover {
  color: var(--ink);
  background: var(--surface-2);
}
.topnav-item.active {
  color: var(--ink);
  font-weight: 760;
}
.topnav-item.active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--blue-600);
}

/* Marca "AI JPD Providencias" en linea, mas presente */
.topbar-brand > div {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.topbar-brand strong,
.topbar-brand span {
  display: inline;
}
.topbar-brand strong {
  font-size: 20px;
  line-height: 1;
}
.topbar-brand > div > span {
  margin-top: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}
html:not([data-theme="dark"]) .topbar-brand strong {
  font-family: "Playfair Display", Georgia, serif;
  letter-spacing: -0.01em;
}
/* Logo: aro dorado con la balanza centrada (como la referencia) */
.topbar-brand-mark {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--blue-600);
  border-radius: 999px;
  background: transparent;
  color: var(--blue-600);
  overflow: visible;
}
/* Hamburguesa: se CONSERVA para abrir el panel lateral izquierdo */
.topbar .sidebar-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}
.topbar .sidebar-toggle:hover,
.topbar .sidebar-toggle[aria-expanded="true"] {
  border-color: var(--blue-600);
  background: var(--surface-2);
  color: var(--blue-600);
}
/* Movil/tablet: se oculta el top-nav y vuelve el hamburguesa */
@media (max-width: 900px) {
  .topbar-nav {
    display: none;
  }
  .topbar-brand > div > span {
    font-size: 14px;
  }
  .topbar-brand strong {
    font-size: 17px;
  }
}
/* Pantallas medianas: nav un poco mas compacta */
@media (min-width: 901px) and (max-width: 1180px) {
  .topnav-item {
    font-size: 14px;
    padding: 7px 10px;
  }
  .topbar {
    padding: 12px 18px;
    gap: 12px;
  }
}

/* Perfil con chevron + boton Cerrar sesion estilo referencia */
.profile-chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--muted);
}
.top-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
html:not([data-theme="dark"]) .role-toggle {
  color: var(--ink);
  font-weight: 700;
}
html:not([data-theme="dark"]) .role-toggle svg {
  color: var(--ink);
}

/* ============================================================
   ENCABEZADO INSTITUCIONAL
   Marca, navegacion, acciones y perfil en una sola composicion.
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: auto minmax(380px, 1fr) auto;
  gap: 22px;
  min-height: 76px;
  padding: 10px clamp(18px, 2.2vw, 38px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 88%, var(--blue-600));
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: 0 6px 24px rgba(74, 53, 20, 0.055);
  backdrop-filter: blur(18px) saturate(1.15);
}

.topbar::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 4%, rgba(161, 123, 52, 0.38) 50%, transparent 96%);
  content: "";
  pointer-events: none;
}

.topbar-navigation {
  gap: 12px;
  padding-right: 22px;
  border-right: 1px solid var(--line);
}

.topbar-brand {
  gap: 11px;
  min-width: 218px;
}

.topbar-brand-mark {
  flex-basis: 48px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  align-self: center;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  line-height: 0;
}

.topbar-brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.topbar-navigation,
.topbar-brand {
  align-items: center;
}

.topbar-brand {
  min-height: 48px;
}

.sidebar-toggle {
  align-self: center;
}

.topbar-brand > div {
  gap: 6px;
}

.topbar-brand strong {
  color: var(--ink);
  font-size: 21px;
}

.topbar-brand > div > span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.topbar-nav {
  justify-content: center;
  gap: 5px;
  padding: 0;
}

.topnav-item {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 650;
}

.topnav-item:hover {
  background: color-mix(in srgb, var(--surface-2) 76%, transparent);
}

.topnav-item.active {
  background: color-mix(in srgb, var(--blue-100) 52%, transparent);
  color: var(--ink);
}

.topnav-item.active::after {
  right: 15px;
  bottom: 3px;
  left: 15px;
  height: 2px;
}

.top-actions {
  justify-content: flex-end;
  gap: 8px;
  min-width: max-content;
}

.theme-toggle,
.notification-dot {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 3px 10px rgba(77, 55, 22, 0.035);
}

.theme-toggle:hover,
.notification-dot:hover {
  border-color: color-mix(in srgb, var(--blue-600) 58%, var(--line));
  background: var(--surface-2);
  color: var(--blue-700);
}

.role-toggle {
  min-height: 42px;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 3px 10px rgba(77, 55, 22, 0.035);
  color: var(--ink);
  font: 700 12px Inter, sans-serif;
}

.role-toggle:hover {
  border-color: color-mix(in srgb, var(--blue-600) 58%, var(--line));
  background: var(--surface-2);
}

.role-toggle svg {
  width: 17px;
  height: 17px;
  color: currentColor;
}

@media (min-width: 901px) {
  body.is-home-view .topbar-brand {
    min-width: 230px;
  }
}

.profile-wrap {
  position: relative;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.top-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 0;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.top-profile:hover,
.top-profile[aria-expanded="true"] {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

.top-profile[aria-expanded="true"] .profile-chevron {
  transform: rotate(180deg);
}

.top-profile .user-avatar.compact {
  width: 40px;
  height: 40px;
  background:
    linear-gradient(145deg, #8198dc 0%, #6579b5 42%, #9b7636 100%);
  box-shadow: 0 4px 12px rgba(36, 43, 72, 0.18);
  color: #fff;
  font-size: 12px;
}

.top-user-meta {
  gap: 2px;
  max-width: 154px;
}

.top-user-meta strong,
.top-user-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-user-meta strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.top-user-meta span {
  color: var(--muted);
  font-size: 11px;
}

.profile-chevron {
  transition: transform 0.16s ease;
}

.profile-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 90;
  width: 238px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 22px 50px rgba(61, 43, 16, 0.16);
}

.profile-panel-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 5px;
  padding: 9px 10px 12px;
  border-bottom: 1px solid var(--line);
}

.profile-panel-head > div {
  display: grid;
  gap: 2px;
}

.profile-panel-head strong {
  color: var(--ink);
  font-size: 12px;
}

.profile-panel-head small {
  color: var(--muted);
  font-size: 11px;
}

.profile-panel-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green-500);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green-100) 84%, transparent);
}

.profile-panel button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: 650 12px Inter, sans-serif;
  text-align: left;
  cursor: pointer;
}

.profile-panel button:hover {
  background: var(--surface-2);
}

.profile-panel button svg {
  width: 16px;
  height: 16px;
  color: var(--blue-600);
}

.profile-panel-logout {
  color: var(--red-500) !important;
}

.profile-panel-logout svg {
  color: currentColor !important;
}

body:not(.is-admin) .admin-profile-action {
  display: none;
}

[data-theme="dark"] .topbar {
  background: color-mix(in srgb, var(--panel) 91%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

[data-theme="dark"] .topbar-brand-mark {
  background: var(--surface-2);
}

@media (max-width: 1320px) {
  .topbar {
    grid-template-columns: auto minmax(330px, 1fr) auto;
    gap: 14px;
    padding-inline: 18px;
  }

  .topbar-navigation {
    padding-right: 14px;
  }

  .topbar-brand {
    min-width: auto;
  }

  .topbar-brand > div > span,
  .top-user-meta span {
    display: none;
  }

  .topnav-item {
    padding-inline: 11px;
  }
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: auto minmax(280px, 1fr) auto;
  }

  .topbar-brand strong {
    font-size: 18px;
  }

  .top-user-meta {
    display: none;
  }

  .role-toggle span {
    display: none;
  }

  .role-toggle {
    width: 42px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 68px;
    gap: 10px;
    padding: 8px 14px;
  }

  .topbar-navigation {
    min-width: 0;
    padding-right: 0;
    border-right: 0;
  }

  .top-actions {
    flex-direction: row;
    align-items: center;
    min-width: 0;
  }

  .topbar-brand-mark {
    flex-basis: 39px;
    width: 39px;
    height: 39px;
  }

  .profile-wrap {
    padding-left: 8px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-inline: 10px;
  }

  .topbar-navigation {
    gap: 8px;
  }

  .topbar-brand {
    gap: 8px;
  }

  .topbar-brand strong {
    font-size: 16px;
  }

  .top-actions {
    gap: 5px;
  }

  .role-toggle,
  .theme-toggle {
    display: none !important;
  }

  .profile-wrap {
    margin-left: 0;
    border-left: 0;
  }

  .top-profile {
    padding-right: 4px;
  }

  .profile-chevron {
    display: none;
  }

  .notification-dot,
  .top-profile .user-avatar.compact {
    width: 38px;
    height: 38px;
  }
}

/* ====== Chat history + PDF cards polish ====== */
#ai-view .history-head {
  padding: 14px 14px 10px;
}

#ai-view .history-head strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}

#ai-view .history-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

#ai-view .history-head .new-chat-button {
  width: auto;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
}

#ai-view .history-head .new-chat-button span {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: 12px;
}

#ai-view .conversation-list {
  gap: 3px;
  padding: 4px 8px 10px;
}

#ai-view .conversation-item {
  display: flex;
  align-items: center;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
}

#ai-view .conversation-item:hover {
  background: rgba(40, 36, 29, 0.055);
}

#ai-view .conversation-item.active {
  border-color: transparent;
  background: rgba(178, 124, 35, 0.14);
  box-shadow: none;
}

#ai-view .conversation-open {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px 8px 12px;
}

#ai-view .conversation-copy-compact {
  display: block;
  min-width: 0;
  width: 100%;
}

#ai-view .conversation-copy-compact strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ai-view .conversation-copy-compact small,
#ai-view .conversation-copy-compact em {
  display: none;
}

#ai-view .conversation-menu-wrap {
  padding-right: 5px;
}

#ai-view .conversation-menu-button {
  opacity: 0.35;
}

#ai-view .conversation-item:hover .conversation-menu-button,
#ai-view .conversation-item.active .conversation-menu-button,
#ai-view .conversation-menu-button:focus-visible {
  opacity: 1;
}

#ai-view .history-note {
  margin: 6px 10px 10px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 11px;
}

#ai-view .source-grid {
  gap: 12px;
}

#ai-view .source-card {
  align-content: start;
  min-height: 154px;
  padding: 16px;
  border-radius: 14px;
}

#ai-view .source-card strong {
  display: -webkit-box;
  overflow: hidden;
  min-height: 2.55em;
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.28;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#ai-view .source-card small {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ====== Consultas: historial plegable y citas limpias ====== */
#ai-view .ai-conversation-layout.history-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

#ai-view .ai-conversation-layout.history-collapsed .conversation-history {
  display: none;
}

#ai-view .history-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

#ai-view .history-head .history-collapse-button,
#ai-view .show-history-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
}

#ai-view .history-head .history-collapse-button:hover,
#ai-view .show-history-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

#ai-view .show-history-button {
  margin-right: 8px;
  flex: 0 0 auto;
}

#ai-view .show-history-button.hidden {
  display: none;
}

#ai-view .conversation-menu-button {
  opacity: 0.72;
}

#ai-view .conversation-item:hover .conversation-menu-button,
#ai-view .conversation-item.active .conversation-menu-button,
#ai-view .conversation-menu-button:focus-visible {
  opacity: 1;
}

#ai-view .conversation-menu {
  right: 8px;
}

#ai-view .message .bubble a[href^="/pdf-viewer.html"] {
  display: inline;
  color: var(--gold-700);
  font-weight: 800;
  overflow-wrap: anywhere;
}

/* ====== Consultas: sin scroll horizontal en historial ====== */
#ai-view .conversation-history,
#ai-view .conversation-list,
#ai-view .history-search,
#ai-view .history-head,
#ai-view .archived-toggle,
#ai-view .history-note {
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

#ai-view .conversation-list {
  scrollbar-gutter: stable;
}

#ai-view .conversation-item,
#ai-view .conversation-open,
#ai-view .conversation-copy-compact {
  min-width: 0;
  max-width: 100%;
}

#ai-view .conversation-copy-compact strong {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#ai-view .history-head .new-chat-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

#ai-view .history-search input {
  min-width: 0;
  text-overflow: ellipsis;
}

/* ====== Feedback juridico guiado ====== */
.correction-guided-head {
  display: grid;
  gap: 3px;
}

.correction-guided-head strong {
  color: var(--ink);
  font-size: 14px;
}

.correction-guided-head span,
.correction-reason-group > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.correction-reason-group {
  display: grid;
  gap: 7px;
}

.correction-reason-group > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.correction-reason-group button {
  min-height: 31px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 11.5px;
}

.correction-reason-group button.active {
  border-color: var(--gold-700);
  background: rgba(178, 124, 35, 0.14);
  color: var(--gold-700);
}
