:root {
  --bg: #0b0d11; --surface: #14171f; --surface2: #1e232d; --linea: #2a303c; --linea2: #384152;
  --texto: #f0f2f5; --suave: #9ea4b0; --tenue: #6c7385; --accent: #7aa2f7; --oro: #e0af68;
  --ok: #9ece6a; --alerta: #e0af68; --malo: #f7768e; --espera: #bb9af7; --cyan: #7dcfff; --purple: #c084fc;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--texto); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; overflow: hidden; }
.wrap { height: 100vh; display: flex; flex-direction: column; padding: 10px; }
.top-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--linea); padding-bottom: 8px; margin-bottom: 10px; flex-shrink: 0; }
.header-left { display: flex; align-items: center; gap: 20px; }
.header-left h1 { margin: 0; font-size: 18px; letter-spacing: -.02em; color: var(--cyan); }
.header-left-metrics { display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--suave); }
.header-right { display: flex; align-items: center; gap: 15px; font-size: 11px; color: var(--suave); }
.header-metric { display: flex; align-items: center; gap: 5px; }
.health-report-btn { background: var(--surface2); color: var(--suave); border: 1px solid var(--linea2); padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: all 0.2s; }
.health-report-btn:hover { background: var(--linea2); color: #fff; }
.health-report-btn.blinking-alert { background: var(--malo) !important; color: #fff !important; border-color: #fff !important; animation: blink-alert 1s infinite; }
@keyframes blink-alert { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
.main-layout { flex: 1; display: flex; gap: 10px; min-height: 0; position: relative; }
#svg-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 999; }
.panel { background: var(--surface); border: 1px solid var(--linea); border-radius: 8px; padding: 10px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; position: relative; transition: width 0.3s ease; }
.left-panel { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; }
.left-panel.collapsed { width: 65px; }
.left-panel.collapsed .file-tree-container, .left-panel.collapsed .left-panel-h3, .left-panel.collapsed #evo-slider-container { display: none !important; }
.left-panel-header { display: flex; justify-content: space-between; align-items: center; height: 45px; border-bottom: 1px solid var(--linea); margin-bottom: 8px; flex-shrink: 0; z-index: 50; isolation: isolate; background: var(--surface); position: relative; }
.sidebar-top-bar { display: flex; align-items: center; gap: 10px; }
.panel-icon-btn { background: var(--surface2); border: 1px solid var(--linea2); color: var(--cyan); width: 32px; height: 32px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; transition: all 0.2s; flex-shrink: 0; }
.panel-icon-btn:hover { background: var(--cyan); color: #000; }
.left-panel-actions { display: flex; gap: 6px; align-items: center; justify-content: center; }
.left-panel-h3 { margin: 0; font-size: 14px; color: var(--texto); display: flex; align-items: center; gap: 8px; font-weight: 600; }
.left-panel.collapsed .left-panel-header { flex-direction: column; align-items: center; gap: 8px; border-bottom: none; padding-top: 5px; height: auto; }
.left-panel.collapsed .sidebar-top-bar { justify-content: center; width: 100%; }
.left-panel.collapsed .left-panel-actions { display: none !important; }
#panel-center { flex: 1; min-width: 0; padding: 0; overflow: hidden; }
.right-panel {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 6px;
}
/* Salto 20: slots del panel derecho — AgentOS y news comparten sin taparse */
.rp-slot { flex-shrink: 0; }
.rp-slot-agentos { order: 1; }
.rp-slot-c2 { order: 2; }
.rp-slot-index { order: 3; flex: 0 1 auto; min-height: 80px; max-height: 32vh; overflow-y: auto; }
.rp-slot-media { order: 4; flex: 1 1 auto; min-height: 160px; }
.floating-bubbles { position: absolute; left: 8px; top: 110px; bottom: 15px; display: flex; flex-direction: column; gap: 18px; z-index: 10; overflow-y: auto; overflow-x: visible; padding-right: 12px; }
.chat-bubble { width: 48px; height: 48px; border-radius: 50%; background: var(--surface2); border: 2px solid var(--linea2); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s; position: relative; box-shadow: 0 4px 15px rgba(0,0,0,0.5); flex-shrink: 0; }
.chat-bubble.online { border-color: var(--cyan); }
.chat-bubble.user-bubble { border-color: var(--oro); }
.chat-bubble.offline { opacity: 0.3; filter: grayscale(1); border-color: var(--tenue); }
.chat-bubble:hover, .chat-bubble.hover-highlight { transform: scale(1.1) translateX(5px); z-index: 40; }
.chat-bubble img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.bubble-tooltip { position: absolute; left: 60px; top: 50%; transform: translateY(-50%); background: var(--surface); border: 1px solid var(--linea2); padding: 6px 10px; border-radius: 6px; font-size: 11px; white-space: nowrap; display: none; box-shadow: 0 4px 10px rgba(0,0,0,0.3); z-index: 50; }
.chat-bubble:hover .bubble-tooltip { display: block; }
.config-bubble { border-style: solid; border-color: var(--tenue); color: var(--tenue); font-size: 20px; }
.config-bubble:hover { border-color: var(--oro); color: var(--oro); }
.bubble-counter { position: absolute; top: -5px; right: -5px; background: var(--malo); color: #fff; font-size: 10px; font-weight: 700; border-radius: 10px; padding: 2px 5px; border: 1px solid var(--bg); box-shadow: 0 2px 4px rgba(0,0,0,0.5); cursor: pointer; }
.file-tree-container { font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-y: auto; overflow-x: hidden; flex: 1; text-align: left; padding-left: 65px; padding-right: 5px; }

.tree-top-bar { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--linea); padding-bottom: 8px; padding-left: 65px; }
.tree-top-btn { background: var(--surface2); border: 1px solid var(--linea2); color: var(--cyan); padding: 4px 8px; border-radius: 4px; font-size: 10px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.tree-top-btn:hover { background: var(--cyan); color: #000; }

.tree-node { margin-top: 2px; }
.tree-node.collapsed > .tree-children { display: none; }
.tree-item { display: flex; justify-content: flex-start; align-items: center; padding: 4px 6px; border-radius: 4px; cursor: pointer; gap: 8px; transition: background 0.2s; position: relative; }
.tree-item:hover { background: var(--surface2); }
.tree-item.file { color: var(--suave); }
.tree-item.dir { color: var(--cyan); font-weight: 600; }
.tree-icon { width: 14px; text-align: center; font-size: 12px; }
.tree-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-badges { display: flex; gap: 4px; flex-shrink: 0; }
.tree-badge { font-size: 9px; padding: 2px 5px; border-radius: 8px; font-weight: 700; }
.badge-lock { background: rgba(247,118,142,0.15); color: var(--malo); }
.badge-concurrency { background: rgba(224,175,104,0.15); color: var(--oro); animation: pulse 2s infinite; }
.badge-warn { background: rgba(224,175,104,0.15); color: var(--oro); border: 1px solid var(--oro); }
.badge-ok { background: rgba(158,206,106,0.15); color: var(--ok); border: 1px solid var(--ok); }
.root-item { font-weight: 700; text-transform: uppercase; font-size: 11px; }
.server-root .tree-icon { color: var(--suave); }
.public-root .tree-icon { color: var(--cyan); }
.private-root .tree-icon { color: var(--malo); }
.intranet-root .tree-icon { color: var(--oro); }
.local-root .tree-icon { color: var(--accent); }
.workspace-root .tree-icon { color: var(--cyan); }
.device-root .tree-icon { color: var(--accent); }
.sandbox-root .tree-icon { color: var(--purple); }
.temp-root .tree-icon { color: var(--tenue); }
.cloud-root .tree-icon { color: var(--purple); }
.storage-root .tree-icon { color: var(--ok); }
.gdrive-root .tree-icon { color: var(--ok); }
.onedrive-root .tree-icon { color: var(--ok); }
.otros-root .tree-icon { color: var(--ok); }
.tree-count { color: var(--tenue); font-size: 10px; margin-left: auto; margin-right: 5px; background: var(--bg); padding: 1px 5px; border-radius: 8px; }
.tree-node:not(.collapsed) > .tree-item .tree-count { display: none; }
.tree-checkbox { margin-left: auto; cursor: pointer; width: 14px; height: 14px; accent-color: var(--cyan); flex-shrink: 0; }
.gen-closed { border-color: var(--ok) !important; color: var(--ok) !important; animation: pulse-ok 2s infinite; }
@keyframes pulse-ok { 0% { box-shadow: 0 0 0 0 rgba(158, 206, 106, 0.4); } 70% { box-shadow: 0 0 0 8px rgba(158, 206, 106, 0); } 100% { box-shadow: 0 0 0 0 rgba(158, 206, 106, 0); } }
#evo-slider-container { padding: 15px; border-top: 1px solid var(--linea); background: var(--surface2); flex-shrink: 0; margin-left: 60px; margin-top: 10px; }
.evo-slider-range { width: 100%; accent-color: var(--purple); cursor: pointer; }
.evo-slider-header { display: flex; justify-content: space-between; font-size: 11px; color: var(--purple); margin-bottom: 8px; font-weight: 600; }
.read-only-mode .chat-input, .read-only-mode .chat-send-btn, .read-only-mode #evo-tree-btn { opacity: 0.5; pointer-events: none; }
.right-panel-h3 { margin: 0 0 10px; font-size: 14px; color: var(--texto); display: flex; align-items: center; gap: 8px; font-weight: 600; flex-shrink: 0; }
.aag-index-container { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; padding-right: 2px; }
.aag-index-item { background: var(--surface2); border: 1px solid var(--linea2); border-radius: 6px; padding: 10px; cursor: pointer; transition: all 0.2s; border-left: 3px solid var(--tenue); display: flex; align-items: center; gap: 10px; }
.aag-index-item:hover { border-color: var(--cyan); background: rgba(125, 207, 255, 0.08); transform: translateX(2px); }
.aag-index-item.state-active { border-left-color: var(--cyan); }
.aag-index-item.state-done { border-left-color: var(--ok); opacity: 0.7; }
.aag-index-item.state-pending { border-left-color: var(--oro); }
.highlight-pulse { animation: pulse-card 1.8s; border-color: var(--cyan) !important; box-shadow: 0 0 15px rgba(125, 207, 255, 0.4); }
@keyframes pulse-card { 0% { background: var(--surface2); } 50% { background: rgba(125, 207, 255, 0.15); } 100% { background: var(--surface); } }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface2); color: var(--cyan); padding: 10px 20px; border-radius: 6px; border: 1px solid var(--cyan); font-size: 12px; font-weight: 600; box-shadow: 0 4px 15px rgba(0,0,0,0.5); z-index: 10000; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast.show { opacity: 1; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--linea2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--tenue); }

/* Pipeline visual unificado del Setup (incluye LLM) */
.setup-pipeline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 8px;
  margin-bottom: 12px;
  background: var(--surface2);
  border: 1px solid var(--linea2);
  border-radius: 8px;
}
.pipe-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 52px;
  opacity: 0.35;
  transition: all 0.35s ease;
}
.pipe-stage i {
  font-size: 22px;
  color: var(--tenue);
  transition: all 0.35s ease;
}
.pipe-stage span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--tenue);
  letter-spacing: 0.03em;
}
.pipe-stage.active {
  opacity: 1;
}
.pipe-stage.active i {
  color: var(--cyan);
  transform: scale(1.25);
  filter: drop-shadow(0 0 6px rgba(125, 207, 255, 0.5));
}
.pipe-stage.active span {
  color: var(--cyan);
}
.pipe-stage.done {
  opacity: 1;
}
.pipe-stage.done i {
  color: var(--ok);
}
.pipe-stage.done span {
  color: var(--ok);
}
.pipe-stage.scanning i {
  animation: pipe-pulse 1.4s ease-in-out infinite;
}
@keyframes pipe-pulse {
  0%, 100% { transform: scale(1.15); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.7; }
}
.pipe-connector {
  font-size: 13px;
  font-weight: 700;
  color: var(--tenue);
  font-family: ui-monospace, Consolas, monospace;
  padding: 0 2px;
  user-select: none;
}