*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 260px;
  --panel-w:   300px;
  --header-h:  56px;
  --topbar-h:  52px;

  --c-bg:          #f0f2f5;
  --c-surface:     #ffffff;
  --c-sidebar:     #111827;
  --c-sidebar-h:   #1f2937;
  --c-sidebar-act: #374151;
  --c-border:      #e5e7eb;
  --c-text:        #111827;
  --c-text-muted:  #6b7280;
  --c-accent:      #4f46e5;
  --c-accent-h:    #4338ca;

  --c-user-bubble: #4f46e5;
  --c-bot-bubble:  #ffffff;

  --radius: 12px;
  --radius-sm: 6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  height: 100vh;
  overflow: hidden;
}

/* ── Mobile top bar ── */
#mobile-topbar { display: none; }

/* ── Backdrop ── */
#drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 49; cursor: pointer;
}
#drawer-backdrop.active { display: block; }

/* ── App layout ── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  grid-template-rows: 100vh;
  height: 100vh;
}

/* ════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════ */

#sidebar {
  background: var(--c-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 48px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

#brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f9fafb;
  font-weight: 600;
  font-size: 14px;
}

.brand-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-accent);
}

.drawer-close {
  width: 28px; height: 28px;
  border-radius: 6px; border: none;
  background: transparent; color: #9ca3af;
  cursor: pointer; display: none;
  align-items: center; justify-content: center;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.drawer-close:hover { background: rgba(255,255,255,.1); color: #f9fafb; }

/* ── Agent selector bar ── */
#agent-selector-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  position: relative;
}

#agent-selector-wrap {
  flex: 1;
  position: relative;
}

.agent-select-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 10px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-sm);
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .12s, border-color .12s;
}
.agent-select-btn:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.15); }
.agent-select-btn svg { flex-shrink: 0; color: #6b7280; margin-left: auto; }

#agent-select-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #6b7280;
}

/* ── Agent dropdown ── */
.agent-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #1f2937;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  z-index: 60;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

.agent-dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: #d1d5db;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}
.agent-dropdown-item:hover { background: rgba(255,255,255,.07); }
.agent-dropdown-item.active { background: rgba(79,70,229,.25); color: #c7d2fe; }
.agent-dropdown-item svg { flex-shrink: 0; margin-left: auto; color: var(--c-accent); }

.agent-dropdown-info { flex: 1; min-width: 0; }
.agent-dropdown-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-dropdown-project { font-size: 11px; color: #6b7280; }

/* ── Sidebar icon button (gear) ── */
.sidebar-icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: #6b7280;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}
.sidebar-icon-btn:hover { background: rgba(255,255,255,.1); color: #e5e7eb; border-color: rgba(255,255,255,.15); }

/* ── Sidebar actions (new conversation button) ── */
#sidebar-actions {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

#btn-new {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 10px;
  background: var(--c-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
#btn-new:hover { background: var(--c-accent-h); }

/* ── Conv list ── */
#conv-list { flex: 1; overflow-y: auto; padding: 6px 0; }

#sidebar-nav-actions {
  display: flex;
  gap: 6px;
  padding: 8px 14px 4px;
  flex-shrink: 0;
}
.sidebar-nav-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04); color: #9ca3af;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background .12s, color .12s;
}
.sidebar-nav-btn:hover { background: rgba(255,255,255,.09); color: #e5e7eb; }
.sidebar-nav-btn.nav-active {
  background: rgba(99,102,241,.22);
  color: #c7d2fe !important;
  border-color: rgba(99,102,241,.45);
}
.sidebar-nav-btn.nav-active:hover { background: rgba(99,102,241,.30); }
.sidebar-nav-btn.nav-active span,
.sidebar-nav-btn.nav-active svg { color: #c7d2fe !important; }
.sidebar-nav-btn svg { flex-shrink: 0; }
.tab-count { font-size: 10px; font-weight: 700; opacity: .8; }
.tester-conv-btn-accept-all { background: rgba(16,185,129,.15); color: #10b981; border: 1px solid rgba(16,185,129,.3); }
.tester-conv-btn-accept-all:hover { background: rgba(16,185,129,.25); }

#sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.ver-badge {
  font-size: 10px; font-weight: 700;
  color: var(--c-accent);
  background: rgba(79,70,229,.18);
  padding: 2px 7px; border-radius: 4px; letter-spacing: .04em;
}
.ver-clickable {
  cursor: pointer; border: none; outline: none;
  transition: background .12s, color .12s;
}
.ver-clickable:hover { background: rgba(79,70,229,.32); color: #818cf8; }
.ver-date { font-size: 10px; color: #4b5563; }

.conv-item {
  padding: 10px 14px; cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 2px 6px; transition: background .12s;
}
.conv-item:hover  { background: var(--c-sidebar-h); }
.conv-item.active { background: var(--c-sidebar-act); }

.conv-item-name {
  color: #e5e7eb; font-weight: 500; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; min-width: 0; overflow: hidden;
}
.conv-item-name > *:first-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.conv-item-meta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 3px; flex-wrap: wrap;
}
.conv-item-time { color: #9ca3af; font-size: 11px; }

/* ════════════════════════════════════════════════════
   MAIN
   ════════════════════════════════════════════════════ */

#main { display: flex; flex-direction: column; overflow: hidden; background: var(--c-bg); }

#empty-state {
  display: flex; flex-direction: column;
  align-items: stretch; justify-content: flex-start;
  height: 100%; overflow-y: auto;
  padding: 36px 44px;
  box-sizing: border-box;
}

/* ── Dashboard ──────────────────────────────────────────────── */
#dashboard { width: 100%; max-width: 860px; margin: 0 auto; }

.dash-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.dash-title {
  font-size: 18px; font-weight: 600; color: var(--c-text); margin: 0;
}
.dash-new-btn {
  background: var(--c-accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: opacity .15s;
  white-space: nowrap;
}
.dash-new-btn:hover { opacity: .85; }

#dash-kpis {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.kpi-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 20px 22px;
  min-height: 120px;
}
.kpi-card-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--c-text-muted);
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.kpi-soon {
  font-size: 10px; font-weight: 500;
  background: rgba(99,102,241,.12); color: #818cf8;
  border-radius: 4px; padding: 2px 6px;
  text-transform: none; letter-spacing: 0;
}
.kpi-body { display: flex; flex-direction: column; gap: 10px; }
.kpi-row {
  display: grid;
  grid-template-columns: minmax(80px,130px) 1fr 38px 34px;
  align-items: center; gap: 8px;
}
.kpi-row-label {
  font-size: 13px; font-weight: 500; color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-bar-wrap {
  height: 5px; background: var(--c-border); border-radius: 3px; overflow: hidden;
}
.kpi-bar { height: 100%; border-radius: 3px; }
.kpi-row-count { font-size: 13px; font-weight: 600; color: var(--c-text); text-align: right; }
.kpi-row-pct   { font-size: 11px; color: var(--c-text-muted); text-align: right; }
.kpi-loading, .kpi-empty { font-size: 13px; color: var(--c-text-muted); }
.kpi-future .kpi-future-val {
  font-size: 32px; font-weight: 700; color: var(--c-border);
  line-height: 1; margin-top: 4px;
}

.btn-primary {
  padding: 10px 24px; background: var(--c-accent);
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--c-accent-h); }

.btn-secondary {
  padding: 8px 18px; background: transparent;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  font-size: 14px; cursor: pointer; color: var(--c-text-muted); transition: all .12s;
}
.btn-secondary:hover { border-color: #d1d5db; color: var(--c-text); }

.btn-danger {
  padding: 8px 18px; background: transparent;
  border: 1px solid #fca5a5; border-radius: var(--radius-sm);
  font-size: 14px; cursor: pointer; color: #dc2626; transition: all .12s;
}
.btn-danger:hover { background: #fef2f2; border-color: #f87171; }

#chat-view { display: flex; flex-direction: column; height: 100%; }

#chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: var(--header-h);
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
#chat-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
#chat-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-actions { display: flex; gap: 8px; flex-shrink: 0; }
#chat-actions button {
  padding: 5px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--c-border); background: var(--c-surface);
  color: var(--c-text-muted); font-size: 12px; cursor: pointer;
  transition: all .12s; white-space: nowrap;
}
#chat-actions button:hover { border-color: #d1d5db; color: var(--c-text); }
#btn-delete:hover { border-color: #fca5a5 !important; color: #dc2626 !important; }

#messages {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 12px;
}

.msg-row { display: flex; flex-direction: column; max-width: 72%; }
.msg-row.user { align-self: flex-end; align-items: flex-end; }
.msg-row.assistant { align-self: flex-start; }

.bubble {
  padding: 10px 14px; border-radius: var(--radius);
  line-height: 1.5; font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.user .bubble { background: var(--c-user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.assistant .bubble { background: var(--c-bot-bubble); color: var(--c-text); border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.msg-time { font-size: 11px; color: var(--c-text-muted); margin-top: 4px; padding: 0 2px; }
.msg-footer .msg-time { margin-top: 0; }

.typing-indicator .bubble { display: flex; gap: 4px; align-items: center; padding: 12px 16px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: blink 1.2s infinite; }
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity:.2 } 40% { opacity:1 } }

#input-form {
  display: flex; gap: 10px; padding: 14px 20px;
  background: var(--c-surface); border-top: 1px solid var(--c-border); flex-shrink: 0;
}
#msg-input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--c-border);
  border-radius: var(--radius); font-size: 14px; outline: none; transition: border-color .15s;
}
#msg-input:focus { border-color: var(--c-accent); }
#btn-send {
  padding: 10px 20px; background: var(--c-accent); color: #fff;
  border: none; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
#btn-send:hover { background: var(--c-accent-h); }
#btn-send:disabled { background: #c7d2fe; cursor: not-allowed; }

/* ════════════════════════════════════════════════════
   RIGHT PANEL
   ════════════════════════════════════════════════════ */

#panel {
  background: var(--c-surface); border-left: 1px solid var(--c-border);
  overflow-y: auto; display: flex; flex-direction: column;
}
#panel-header {
  display: none; align-items: center; justify-content: space-between;
  padding: 0 16px; height: var(--header-h);
  border-bottom: 1px solid var(--c-border); flex-shrink: 0;
}
.panel-header-title { font-weight: 600; font-size: 15px; }
#panel-header .drawer-close { color: var(--c-text-muted); }
#panel-header .drawer-close:hover { background: var(--c-bg); color: var(--c-text); }

.panel-section { padding: 18px 16px; border-bottom: 1px solid var(--c-border); }
.panel-section h3 {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--c-text-muted); margin-bottom: 12px;
}
.panel-hint { color: var(--c-text-muted); font-size: 13px; text-align: center; padding: 20px 0; }

/* Profile badge */
.profile-badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: #fff; letter-spacing: .03em;
}
.profile-large { font-size: 13px; padding: 4px 14px; }

/* Journey */
#stage-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.stage-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--c-text-muted);
}
.stage-item.done    { color: #059669; }
.stage-item.current { background: #eef2ff; color: var(--c-accent); font-weight: 600; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; border: 2px solid currentColor; flex-shrink: 0; }
.stage-item.done .stage-dot    { background: currentColor; }
.stage-item.current .stage-dot { background: currentColor; }

/* Data fields */
#data-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.data-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; font-size: 12px; }
.data-label  { color: var(--c-text-muted); flex-shrink: 0; }
.data-value  { color: var(--c-text); text-align: right; word-break: break-all; }
.data-value.empty { color: #d1d5db; }
.data-check  { flex-shrink: 0; font-size: 13px; }
#data-progress { font-weight: 400; color: var(--c-text-muted); }

/* Stats */
#stats-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; color: var(--c-text-muted); }
.stat-value { font-size: 16px; font-weight: 700; color: var(--c-text); }

/* Model badge */
.model-badge {
  display: inline-flex; align-items: center;
  padding: 1px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: .03em; color: #fff;
}
.model-claude { background: #7c3aed; }
.model-gemini { background: #1d4ed8; }
.model-openai { background: #065f46; }

/* Channel badge */
.ch-badge {
  display: inline-flex; align-items: center;
  padding: 1px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: .03em; color: #fff;
}

/* Agent stage badge */
.agent-badge {
  display: inline-flex; align-items: center;
  padding: 1px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: .03em; color: #fff;
}

/* ════════════════════════════════════════════════════
   MODAL: Nueva conversación
   ════════════════════════════════════════════════════ */

#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
#modal {
  background: var(--c-surface); border-radius: var(--radius);
  padding: 28px 32px; width: 380px;
  max-width: calc(100vw - 32px); max-height: calc(100dvh - 40px);
  overflow-y: auto; display: flex; flex-direction: column;
  gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
#modal h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
#modal label { font-size: 12px; font-weight: 600; color: var(--c-text-muted); margin-top: 4px; }
.optional { font-weight: 400; }
.modal-hint { font-size: 11px; color: var(--c-text-muted); line-height: 1.4; margin-top: -4px; }
#modal input, #modal select {
  padding: 9px 12px; border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); font-size: 14px; outline: none; transition: border-color .15s;
}
#modal input:focus, #modal select:focus { border-color: var(--c-accent); }

.flow-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.flow-option {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 8px; border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm); cursor: pointer; transition: border-color .12s, background .12s;
}
.flow-option:has(input:checked) { border-color: var(--c-accent); background: rgba(79,70,229,.06); }
.flow-option input[type="radio"] { display: none; }
.flow-label { font-size: 13px; font-weight: 600; color: var(--c-text); }
.flow-option:has(input:checked) .flow-label { color: var(--c-accent); }
.flow-desc { font-size: 11px; color: var(--c-text-muted); }

#modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ════════════════════════════════════════════════════
   LIGHTBOX
   ════════════════════════════════════════════════════ */

#lightbox { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
#lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.88); cursor: zoom-out; }
#lightbox-img { position: relative; z-index: 1; max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 24px 80px rgba(0,0,0,.5); object-fit: contain; }
#lightbox-close {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; backdrop-filter: blur(4px);
}
#lightbox-close:hover { background: rgba(255,255,255,.22); }

/* ════════════════════════════════════════════════════
   SHEET HANDLE (mobile only)
   ════════════════════════════════════════════════════ */

.sheet-handle { display: none; width: 40px; height: 4px; background: #d1d5db; border-radius: 2px; margin: 12px auto 0; flex-shrink: 0; }

/* ════════════════════════════════════════════════════
   MESSAGE FOOTER & COMMENT BUTTONS
   ════════════════════════════════════════════════════ */

.msg-footer { display: flex; align-items: center; gap: 6px; margin-top: 4px; align-self: flex-start; }
.user .msg-footer { align-self: flex-end; }

.btn-msg-comment {
  display: flex; align-items: center; gap: 3px; padding: 2px 5px;
  border: none; background: transparent; color: var(--c-text-muted);
  border-radius: 4px; cursor: pointer; font-size: 11px;
  opacity: 0.45; transition: opacity .15s, background .15s, color .15s; line-height: 1;
}
.btn-msg-comment:hover { opacity: 1; background: rgba(0,0,0,.06); }
.btn-msg-comment.has-comments { opacity: 1; color: var(--c-accent); }
.user .btn-msg-comment:hover { background: rgba(255,255,255,.15); }
.user .btn-msg-comment { color: rgba(255,255,255,.7); }
.user .btn-msg-comment.has-comments { color: #c7d2fe; }
.comment-count { font-size: 10px; font-weight: 700; }

.btn-comment-action { display: flex !important; align-items: center; gap: 5px; position: relative; }
.btn-comment-action.has-comments { color: var(--c-accent) !important; border-color: var(--c-accent) !important; }
.comment-count-badge {
  font-size: 10px; font-weight: 700;
  background: var(--c-accent); color: #fff; border-radius: 999px;
  padding: 0 5px; min-width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}

.btn-comments-sidebar {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; border: 1px solid rgba(255,255,255,.12);
  background: transparent; color: #9ca3af; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 11px; transition: background .12s, color .12s;
}
.btn-comments-sidebar:hover { background: rgba(255,255,255,.08); color: #e5e7eb; }
.comment-global-badge {
  font-size: 10px; font-weight: 700; background: var(--c-accent); color: #fff;
  border-radius: 999px; padding: 0 5px; min-width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.conv-item-comment-count { font-size: 10px; color: #9ca3af; margin-left: auto; }

/* ════════════════════════════════════════════════════
   TAG SYSTEM
   ════════════════════════════════════════════════════ */

.tag-chip {
  display: inline-flex; align-items: center;
  padding: 1px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600; color: #fff; letter-spacing: .02em;
}
.tag-chip-sm { font-size: 9px; padding: 1px 6px; }

.conv-item-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }

#panel-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 0; }

/* Tag picker popover */
#tag-picker {
  position: absolute; top: 100%; right: 0; z-index: 200;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,.2);
  width: 220px; padding: 8px 0;
  margin-top: 4px;
}
#tag-picker-list { display: flex; flex-direction: column; gap: 1px; max-height: 220px; overflow-y: auto; padding: 0 6px; }
.tag-picker-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  font-size: 13px;
}
.tag-picker-item:hover { background: var(--c-bg); }
.tag-picker-item input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--c-accent); flex-shrink: 0; cursor: pointer; }
.tag-picker-item .tag-chip { pointer-events: none; }
.tag-picker-empty { font-size: 12px; color: var(--c-text-muted); text-align: center; padding: 10px 0; }
#tag-picker-new {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px 4px; border-top: 1px solid var(--c-border); margin-top: 4px;
}
#tag-picker-input {
  flex: 1; border: 1px solid var(--c-border); border-radius: 6px;
  padding: 4px 8px; font-size: 12px; background: var(--c-bg); color: var(--c-text);
  outline: none;
}
#tag-picker-input:focus { border-color: var(--c-accent); }
#tag-picker-add {
  width: 24px; height: 24px; border: none; border-radius: 6px;
  background: var(--c-accent); color: #fff; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#tag-picker-add:hover { opacity: .85; }

/* ════════════════════════════════════════════════════
   COMMENT MODAL
   ════════════════════════════════════════════════════ */

#comment-modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 150; }
#comment-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); cursor: pointer; }
#comment-modal-box {
  position: relative; z-index: 1; background: var(--c-surface); border-radius: var(--radius);
  width: 420px; max-width: calc(100vw - 32px); max-height: 80vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column;
}
.comment-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--c-border); flex-shrink: 0;
}
.comment-modal-header span { font-weight: 600; font-size: 15px; }
.comment-modal-header button {
  width: 28px; height: 28px; border: none; background: transparent;
  color: var(--c-text-muted); cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; transition: background .12s;
}
.comment-modal-header button:hover { background: var(--c-bg); }
#comment-msg-preview {
  font-size: 12px; color: var(--c-text-muted); background: var(--c-bg);
  box-shadow: inset 3px 0 0 var(--c-border); padding: 8px 12px; margin: 12px 20px 0;
  border-radius: 4px; font-style: italic;
}
#comment-existing-list {
  padding: 12px 20px; display: flex; flex-direction: column; gap: 8px;
  max-height: 200px; overflow-y: auto;
}
.no-comments-hint { font-size: 12px; color: var(--c-text-muted); text-align: center; padding: 8px 0; }
.comment-item { background: var(--c-bg); border-radius: var(--radius-sm); padding: 8px 12px; }
.comment-item-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-item-author { font-size: 11px; font-weight: 600; color: var(--c-text); }
.comment-item-ts     { font-size: 11px; color: var(--c-text-muted); }
.comment-item-body   { font-size: 13px; color: var(--c-text); line-height: 1.4; margin: 0; }
.comment-form { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.comment-form input, .comment-form textarea {
  padding: 9px 12px; border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color .15s; resize: vertical;
}
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--c-accent); }
.comment-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ════════════════════════════════════════════════════
   GLOBAL COMMENTS MODAL
   ════════════════════════════════════════════════════ */

#global-comments-modal {
  position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center;
  z-index: 150; padding: 40px 20px;
}
#gc-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); cursor: pointer; }
#gc-box {
  position: relative; z-index: 1; background: var(--c-bg);
  border-radius: var(--radius); width: 700px; max-width: 100%;
  max-height: calc(100vh - 80px); overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
#gc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--c-surface);
  border-bottom: 1px solid var(--c-border); flex-shrink: 0;
}
#gc-header span { font-weight: 700; font-size: 16px; }
#gc-close {
  width: 32px; height: 32px; border: none; background: transparent;
  color: var(--c-text-muted); cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; transition: background .12s;
}
#gc-close:hover { background: var(--c-bg); }
#gc-content { overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.gc-empty { text-align: center; color: var(--c-text-muted); font-size: 14px; padding: 40px 0; }
.gc-conv-card { background: var(--c-surface); border-radius: var(--radius); border: 1px solid var(--c-border); overflow: hidden; }
.gc-conv-header {
  padding: 12px 16px; background: #f9fafb; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.gc-conv-name { font-weight: 600; font-size: 13px; color: var(--c-text); }
.gc-conv-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gc-conv-date { font-size: 11px; color: var(--c-text-muted); }
.gc-section { padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--c-border); }
.gc-section:last-child { border-bottom: none; }
.gc-msg-block { display: flex; flex-direction: column; gap: 6px; }
.gc-msg-preview {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: var(--c-text-muted); background: var(--c-bg);
  border-radius: var(--radius-sm); padding: 6px 10px;
}
.gc-msg-role { flex-shrink: 0; }
.gc-msg-text { line-height: 1.4; }
.gc-comment-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-sm); font-size: 13px;
}
.gc-comment-row.conv-comment { background: #eff6ff; color: #1d4ed8; }
.gc-comment-row.msg-comment  { background: #f0fdf4; color: #15803d; margin-left: 20px; }
.gc-comment-row svg { flex-shrink: 0; margin-top: 2px; }
.gc-comment-content { display: flex; flex-direction: column; gap: 2px; }
.gc-comment-body { font-size: 13px; color: var(--c-text); line-height: 1.4; }
.gc-comment-meta { font-size: 11px; color: var(--c-text-muted); }

/* ════════════════════════════════════════════════════
   AGENT MANAGER
   ════════════════════════════════════════════════════ */

#agent-manager {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 20px;
}
#am-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); cursor: pointer; }
#am-container {
  position: relative; z-index: 1; background: var(--c-surface);
  border-radius: var(--radius); width: 780px; max-width: 100%;
  max-height: calc(100vh - 64px); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 32px 100px rgba(0,0,0,.3);
}

#am-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--c-border);
  flex-shrink: 0; background: #f9fafb;
}
#am-header-left { display: flex; align-items: center; gap: 12px; }
#am-title { font-weight: 700; font-size: 16px; color: var(--c-text); }
#am-header-right { display: flex; align-items: center; gap: 8px; }

.am-back {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--c-border); background: transparent;
  color: var(--c-text-muted); font-size: 13px; cursor: pointer; transition: all .12s;
}
.am-back:hover { border-color: #d1d5db; color: var(--c-text); }

.am-new-btn { padding: 7px 16px; font-size: 13px; }

.am-close-btn {
  width: 32px; height: 32px; border: none; background: transparent;
  color: var(--c-text-muted); cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; transition: background .12s;
}
.am-close-btn:hover { background: var(--c-bg); color: var(--c-text); }

/* ── Agent list ── */
#am-list-view { overflow-y: auto; padding: 20px 24px; }
#am-agent-cards { display: flex; flex-direction: column; gap: 12px; }

.am-agent-card {
  display: flex; border: 1px solid var(--c-border);
  border-radius: var(--radius); overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.am-agent-card:hover { border-color: #d1d5db; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.am-agent-card.active { border-color: var(--agent-color, var(--c-accent)); }

.am-card-accent {
  width: 5px; flex-shrink: 0;
  background: var(--agent-color, var(--c-accent));
}
.am-card-body { flex: 1; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.am-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.am-agent-name { font-weight: 600; font-size: 14px; color: var(--c-text); }
.am-agent-project { font-size: 12px; color: var(--c-text-muted); margin-top: 2px; }
.am-card-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.am-active-badge {
  font-size: 10px; font-weight: 700; background: var(--agent-color, var(--c-accent));
  color: #fff; padding: 2px 8px; border-radius: 999px; letter-spacing: .04em;
}
.am-card-stats { font-size: 12px; color: var(--c-text-muted); display: flex; gap: 6px; }
.am-agent-url { font-size: 11px; color: #9ca3af; font-family: 'Menlo', monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-card-actions { display: flex; gap: 6px; margin-top: 4px; }
.am-card-actions button { font-size: 12px; padding: 4px 12px; }

/* ── Agent form ── */
#am-form-view { display: flex; flex-direction: column; overflow: hidden; }
#am-form-body  { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }
#am-form-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px; border-top: 1px solid var(--c-border);
  flex-shrink: 0; background: #f9fafb;
}

.am-section { display: flex; flex-direction: column; gap: 10px; }
.am-section-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.am-section-title { font-weight: 600; font-size: 14px; color: var(--c-text); }
.am-field-row { display: flex; flex-direction: column; gap: 5px; }
.am-field-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.am-label { font-size: 12px; font-weight: 600; color: var(--c-text-muted); }
.am-label .required { color: #dc2626; margin-left: 2px; }

.am-input {
  padding: 9px 12px; border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color .15s; width: 100%; background: var(--c-surface);
}
.am-input:focus { border-color: var(--c-accent); }
.am-input:disabled { background: var(--c-bg); color: var(--c-text-muted); cursor: not-allowed; }

.am-textarea {
  padding: 10px 12px; border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); font-size: 12px; font-family: 'Menlo', 'Consolas', monospace;
  outline: none; transition: border-color .15s; width: 100%; resize: vertical;
  background: #f9fafb; color: var(--c-text); line-height: 1.6;
}
.am-textarea:focus { border-color: var(--c-accent); background: #fff; }

.am-hint { font-size: 12px; color: var(--c-text-muted); line-height: 1.5; }
.am-link-btn {
  font-size: 12px; color: var(--c-accent); background: none; border: none;
  cursor: pointer; padding: 0; text-decoration: underline; flex-shrink: 0;
  transition: color .12s;
}
.am-link-btn:hover { color: var(--c-accent-h); }

.am-error {
  font-size: 12px; color: #dc2626; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: var(--radius-sm);
  padding: 8px 12px; line-height: 1.4;
}

/* Meta section (locked) */
.am-meta-section { opacity: 0.7; }
.am-coming-soon {
  font-size: 10px; font-weight: 700; background: #fef3c7; color: #92400e;
  padding: 2px 8px; border-radius: 999px; letter-spacing: .04em;
}
.am-meta-fields { display: flex; flex-direction: column; gap: 8px; }

/* ════════════════════════════════════════════════════
   IMAGE IN CHAT
   ════════════════════════════════════════════════════ */

.msg-image {
  display: block; max-width: 100%; width: 100%; border-radius: 8px;
  margin-top: 8px; cursor: zoom-in; transition: opacity .15s;
  border: 1px solid rgba(0,0,0,.08);
}
.msg-image:hover { opacity: .9; }

/* ════════════════════════════════════════════════════
   MARKDOWN IN BUBBLES
   ════════════════════════════════════════════════════ */

.assistant .bubble strong { font-weight: 700; }
.assistant .bubble em     { font-style: italic; }
.assistant .bubble del    { text-decoration: line-through; opacity: .65; }
.assistant .bubble code   { font-family: 'Menlo', 'Consolas', monospace; font-size: 12px; background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 3px; }

/* ════════════════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════════════════ */

.hidden { display: none !important; }

/* ════════════════════════════════════════════════════
   RESPONSIVE — Mobile (<768px)
   ════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  body { overflow: hidden; }

  #mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-h); background: var(--c-sidebar);
    z-index: 40; padding: 0 14px; gap: 8px;
  }
  #mobile-topbar button {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px;
    border: none; background: transparent; color: #e5e7eb; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: background .12s;
  }
  #mobile-topbar button:hover { background: rgba(255,255,255,.1); }
  #mobile-title {
    flex: 1; text-align: center; color: #f9fafb; font-weight: 600; font-size: 15px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px;
  }

  #app { display: block; }

  #main { position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0; }

  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(var(--sidebar-w), 85vw); z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1); box-shadow: none;
  }
  #sidebar.drawer-open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.28); }
  #btn-sidebar-close { display: flex; }

  #panel {
    position: fixed; bottom: 0; left: 0; right: 0; width: 100%;
    max-height: 82vh; z-index: 50;
    transform: translateY(110%);
    transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    border-radius: 20px 20px 0 0; border-left: none; border-top: none;
    box-shadow: 0 -4px 40px rgba(0,0,0,.18); overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  #panel.drawer-open { transform: translateY(0); }
  .sheet-handle { display: block; }
  #panel-header { display: flex; position: sticky; top: 0; background: var(--c-surface); z-index: 1; border-bottom: 1px solid var(--c-border); }
  #btn-panel-close { display: flex; }

  #chat-header { padding: 0 12px; height: 50px; }
  #chat-title { font-size: 14px; }
  #chat-actions button { padding: 4px 8px; font-size: 12px; }
  #messages { padding: 16px 12px; }
  .msg-row { max-width: 88%; }
  #input-form { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #btn-send { padding: 10px 16px; }
  #msg-input { font-size: 16px; }

  #agent-manager { padding: 0; align-items: flex-end; }
  #am-container { width: 100%; max-width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; }
  .am-field-grid2 { grid-template-columns: 1fr; }
}


/* ── Version footer group ── */
.ver-group { display: flex; align-items: center; gap: 5px; flex: 1; }
.ver-sep   { font-size: 10px; color: #4b5563; }
.ver-agent { background: rgba(8,145,178,.18); color: #0891b2; }

/* ── Conv ID badge in sidebar ── */
.conv-id-badge {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 9px; font-weight: 600;
  color: #6b7280;
  background: rgba(107,114,128,.10);
  padding: 1px 5px; border-radius: 3px;
  letter-spacing: .04em; flex-shrink: 0;
}

.conv-id-badge.ghl-badge {
  color: #818cf8;
  background: rgba(99,102,241,.15);
}

/* ── Gear auth dot ── */
.gear-auth-dot {
  position: absolute; bottom: 2px; right: 2px;
  width: 7px; height: 7px;
  border-radius: 50%; background: #10b981;
  border: 1.5px solid var(--c-sidebar);
  pointer-events: none;
}
.sidebar-icon-btn { position: relative; }

/* ── Login modal ── */
#login-modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
#login-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
}
#login-box {
  position: relative; z-index: 1;
  width: 320px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.login-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--c-border);
}
.login-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(79,70,229,.12);
  border-radius: 8px; color: var(--c-accent); flex-shrink: 0;
}
.login-title { font-size: 14px; font-weight: 600; flex: 1; }
.login-close {
  background: none; border: none; cursor: pointer;
  color: var(--c-text-muted); padding: 4px;
  border-radius: 6px; display: flex; align-items: center;
  transition: background .12s;
}
.login-close:hover { background: var(--c-hover); }
.login-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.login-label { font-size: 12px; font-weight: 500; color: var(--c-text-muted); margin-bottom: -4px; }
.login-input {
  width: 100%; padding: 8px 10px;
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: 8px; font-size: 13px; color: var(--c-text);
  outline: none; box-sizing: border-box; transition: border-color .15s;
}
.login-input:focus { border-color: var(--c-accent); }
.login-error {
  font-size: 12px; color: #dc2626;
  background: rgba(220,38,38,.08);
  border: 1px solid rgba(220,38,38,.2);
  border-radius: 6px; padding: 6px 10px;
}
.login-submit { width: 100%; margin-top: 4px; }

/* ── Agent manager auth row ── */
#am-auth-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.am-auth-badge {
  font-size: 11px; font-weight: 600;
  color: #10b981;
}


/* ════════════════════════════════════════════════════
   NEXUS TESTER — PANEL F3
   ════════════════════════════════════════════════════ */

/* Sidebar tester actions */
#tester-sidebar-actions {
  display: flex; gap: 6px; padding: 8px 14px 4px; flex-shrink: 0;
  flex-wrap: wrap;
}
.btn-close-tester {
  display: flex; align-items: center; gap: 5px; width: 100%;
  background: transparent; border: 1px solid rgba(255,255,255,.1);
  color: #9ca3af; border-radius: var(--radius-sm);
  padding: 5px 10px; font-size: 11px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-close-tester:hover { color: #e5e7eb; border-color: rgba(255,255,255,.25); }
.tester-filter-tabs {
  display: flex; width: 100%; gap: 2px;
  background: rgba(255,255,255,.05); border-radius: var(--radius-sm);
  padding: 2px; margin-top: 2px;
}
.tester-tab {
  flex: 1; padding: 4px 0; font-size: 11px; font-weight: 500; cursor: pointer;
  background: transparent; border: none; color: #9ca3af;
  border-radius: calc(var(--radius-sm) - 2px); transition: background .12s, color .12s;
}
.tester-tab:hover { color: #e5e7eb; }
.tester-tab.active { background: var(--c-accent); color: #fff; }

/* Tester scenario list in sidebar */
#tester-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.tester-scenario-item {
  padding: 10px 14px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s;
}
.tester-scenario-item:hover { background: var(--c-sidebar-h); }
.tester-scenario-item.active { background: var(--c-sidebar-act); border-left-color: var(--c-accent); }
.tester-scenario-name { font-size: 12px; color: #e5e7eb; font-weight: 500; line-height: 1.4; }
.tester-scenario-meta { display: flex; align-items: center; gap: 5px; margin-top: 4px; flex-wrap: wrap; }
.tester-agent-sep { color: #4b5563; font-size: 10px; }
.tester-scenario-header {
  display: flex; align-items: flex-start; gap: 6px;
}
.tester-scenario-header .tester-scenario-name { flex: 1; min-width: 0; }
.tester-run-btn {
  flex-shrink: 0; width: 20px; height: 20px;
  background: rgba(99,102,241,.2); border: none; border-radius: 4px;
  color: #818cf8; font-size: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s; line-height: 1;
}
.tester-run-btn:hover { background: var(--c-accent); color: #fff; }
.tester-run-btn:disabled { opacity: .4; cursor: not-allowed; }
.status-dot {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 7px; font-weight: 700; margin-top: 3px;
}
.dot-unrun   { background: #374151; }
.dot-running { background: #6366f1; animation: pulse-dot .8s infinite alternate; }
.dot-failed  { background: #ef4444; }
.dot-pending { background: #f59e0b; }
.dot-reviewed { background: #10b981; color: #fff; width: 10px; height: 10px; border-radius: 50%; font-size: 7px; }
@keyframes pulse-dot { from { opacity: .5; } to { opacity: 1; } }

/* Run status badge */
.run-status-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600; padding: 1px 7px;
  border-radius: 999px;
}
.status-complete   { background: rgba(16,185,129,.15); color: #10b981; }
.status-failed     { background: rgba(239,68,68,.15);  color: #ef4444; }
.status-running    { background: rgba(99,102,241,.15); color: #6366f1; }
.status-pending    { background: rgba(107,114,128,.15);color: #9ca3af; }
.status-none       { background: transparent; color: #4b5563; }

/* Tester main view */
#tester-view {
  flex: 1; display: flex; flex-direction: column;
  overflow-y: auto; background: var(--c-bg);
}
#tester-view-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
#tester-run-detail { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 24px; }

/* Run header */
#tester-run-header { background: var(--c-surface); border-radius: var(--radius); padding: 20px; }
.tester-run-title { font-size: 16px; font-weight: 700; color: var(--c-text); margin-bottom: 8px; }
.tester-run-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tester-run-date { font-size: 11px; color: var(--c-text-muted); }
.tester-score { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.score-item { font-size: 13px; font-weight: 600; }
.score-pass { color: #10b981; }
.score-fail { color: #ef4444; }
.score-review { color: #f59e0b; }

/* Tester sections */
.tester-section {
  background: var(--c-surface); border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.tester-section h3 { font-size: 13px; font-weight: 700; color: var(--c-text); }

/* Criteria list */
#tester-criteria-list { display: flex; flex-direction: column; gap: 8px; }
.criterion-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
}
.criterion-pass   { border-color: rgba(16,185,129,.3); background: rgba(16,185,129,.04); }
.criterion-fail   { border-color: rgba(239,68,68,.3);  background: rgba(239,68,68,.04); }
.criterion-pending_review { border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.04); }
.criterion-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.criterion-body { flex: 1; min-width: 0; }
.criterion-text   { font-size: 12px; font-weight: 500; color: var(--c-text); line-height: 1.4; }
.criterion-detail { font-size: 11px; color: var(--c-text-muted); margin-top: 2px; font-family: monospace; }
.criterion-auto-badge {
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 4px;
  background: var(--c-bg); color: var(--c-text-muted); flex-shrink: 0; margin-top: 2px;
}

/* Conversation link */
.tester-conv-btn-secondary {
  background: transparent !important;
  color: var(--c-text-muted) !important;
  border: 1px solid var(--c-border) !important;
}
.tester-conv-btn-secondary:hover { color: var(--c-text) !important; border-color: var(--c-text-muted) !important; }
.tester-conv-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--c-accent); border-radius: var(--radius-sm);
  background: transparent; color: var(--c-accent); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .12s;
}
.tester-conv-btn:hover { background: rgba(79,70,229,.06); }
.tester-conv-id { display: block; margin-top: 6px; font-size: 10px; font-family: monospace; color: var(--c-text-muted); user-select: all; }

/* Findings */
.findings-empty { text-align: center; padding: 16px 0; }
.findings-empty p { font-size: 13px; color: var(--c-text-muted); line-height: 1.6; }
.findings-empty code { font-size: 10px; font-family: monospace; user-select: all; }
.finding-dimension h4 { font-size: 12px; font-weight: 700; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.finding-card {
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px;
}
.finding-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.finding-status-badge { font-size: 11px; font-weight: 600; margin-left: auto; }
.finding-desc { font-size: 13px; color: var(--c-text); line-height: 1.5; }
.finding-suggestion { font-size: 12px; color: var(--c-text-muted); line-height: 1.5; }
.finding-section { font-size: 11px; color: var(--c-text-muted); }
.finding-carlos-comment { font-size: 12px; color: var(--c-accent); font-style: italic; }
.finding-actions { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.finding-comment-input {
  flex: 1; border: 1px solid var(--c-border); border-radius: 6px;
  padding: 5px 8px; font-size: 12px; background: var(--c-bg); color: var(--c-text); outline: none;
}
.btn-accept, .btn-reject {
  padding: 5px 10px; border: none; border-radius: 6px;
  font-size: 11px; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.btn-accept { background: rgba(16,185,129,.12); color: #10b981; }
.btn-accept:hover { background: rgba(16,185,129,.22); }
.btn-reject { background: rgba(239,68,68,.12); color: #ef4444; }
.btn-reject:hover { background: rgba(239,68,68,.22); }

/* Active tester mode in sidebar */
.tester-mode-active #btn-tester { color: var(--c-accent) !important; border-color: var(--c-accent) !important; }

/* ── Conv Lightbox ─────────────────────────────────────────── */
#conv-lightbox {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center;
}
#conv-lightbox.hidden { display: none; }
#conv-lightbox-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
}
#conv-lightbox-panel {
  position: relative; z-index: 1;
  width: min(680px, 94vw); max-height: 82vh;
  background: var(--c-surface); border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
  display: flex; flex-direction: column; overflow: hidden;
}
#conv-lightbox-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
#conv-lightbox-title {
  font-size: 14px; font-weight: 600; color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 48px);
}
#conv-lightbox-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: var(--c-bg); color: var(--c-text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#conv-lightbox-close:hover { background: var(--c-border); color: var(--c-text); }
#conv-lightbox-body {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

/* Turn blocks */
.lbox-turn { display: flex; flex-direction: column; gap: 8px; }
.lbox-turn-label {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  color: var(--c-text-muted); text-transform: uppercase;
}
.lbox-bubble-row { display: flex; gap: 8px; align-items: flex-end; }
.lbox-bubble-row.user { justify-content: flex-end; }
.lbox-bubble-row.agent { justify-content: flex-start; }
.lbox-bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 14px;
  font-size: 13px; line-height: 1.5; color: var(--c-text);
  white-space: pre-wrap; word-break: break-word;
}
.lbox-bubble.user {
  background: var(--c-accent); color: #fff; border-bottom-right-radius: 4px;
}
.lbox-bubble.agent {
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-bottom-left-radius: 4px;
}
.lbox-meta {
  font-size: 10px; color: var(--c-text-muted); padding: 0 4px;
  align-self: center;
}
.lbox-turn-divider {
  height: 1px; background: var(--c-border); margin: 4px 0; opacity: .5;
}

/* ── Push Notifications Panel ─────────────────────────────── */
.push-container {
  padding: 32px 28px; max-width: 560px;
}
.push-header h2 {
  color: var(--c-text); font-size: 20px; font-weight: 700; margin: 0 0 4px;
}
.push-subtitle {
  color: var(--c-text-muted); font-size: 14px; margin: 0 0 28px;
}
.push-form {
  display: flex; flex-direction: column; gap: 12px;
}
.push-target-row {
  display: flex; gap: 24px; flex-wrap: wrap;
}
.push-radio {
  display: flex; align-items: center; gap: 8px;
  color: var(--c-text-sub); font-size: 14px; cursor: pointer;
}
.push-radio input[type=radio] { accent-color: #3b82f6; }
#push-user-selector select {
  width: 100%;
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px;
}
.push-input,
.push-textarea {
  width: 100%; box-sizing: border-box;
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px;
  font-family: inherit;
}
.push-textarea { resize: vertical; }
.push-input:focus,
.push-textarea:focus {
  outline: none; border-color: #3b82f6;
}
.push-send-btn {
  background: #3b82f6; color: #fff; border: none;
  border-radius: 8px; padding: 12px 20px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: opacity .15s;
}
.push-send-btn:hover { opacity: .9; }
.push-send-btn:disabled { opacity: .55; cursor: default; }
.push-result {
  padding: 12px 14px; border-radius: 8px; font-size: 14px;
}
.push-result-ok    { background: rgba(16,185,129,.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,.25); }
.push-result-error { background: rgba(239,68,68,.10);  color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }

/* Run error box */
.run-error-box {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 10px; padding: 10px 12px;
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25);
  border-radius: 8px; font-size: 12px; color: #ef4444;
}
.run-error-box code {
  display: block; font-family: monospace; font-size: 11px;
  background: rgba(239,68,68,.06); padding: 6px 8px; border-radius: 4px;
  word-break: break-all; color: #dc2626;
}
.run-error-box span { color: var(--c-text-muted); font-size: 11px; }

/* ── Mejora Continua indicators ───────────────────────────── */
.mc-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(139,92,246,.15); color: #a78bfa;
  border: 1px solid rgba(139,92,246,.3);
}
.mc-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(139,92,246,.2); color: #a78bfa;
  font-size: 9px; font-weight: 700; flex-shrink: 0;
  title: "Procesado en mejora continua";
}
.tester-scenario-mc { border-left: 2px solid rgba(139,92,246,.4); }

/* ── MC Log Panel ─────────────────────────────────────────── */
#mc-log-lightbox {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: flex-start; justify-content: flex-end;
}
#mc-log-lightbox.hidden { display: none; }
#mc-log-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
}
#mc-log-panel {
  position: relative; z-index: 1;
  width: min(480px, 95vw); height: 100vh;
  background: var(--c-sidebar); display: flex; flex-direction: column;
  overflow: hidden; box-shadow: -4px 0 24px rgba(0,0,0,.4);
}
#mc-log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
#mc-log-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--c-text);
}
#mc-log-close {
  background: none; border: none; cursor: pointer;
  color: var(--c-text-muted); padding: 4px; border-radius: 4px;
  transition: color .12s;
}
#mc-log-close:hover { color: var(--c-text); }
#mc-log-body {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.mc-session-entry {
  background: var(--c-surface); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid rgba(139,92,246,.25);
}
.mc-session-date {
  font-size: 11px; font-weight: 700; color: #a78bfa;
  display: flex; align-items: center; gap: 6px;
}
.mc-session-agent {
  font-size: 11px; color: var(--c-text-muted);
  background: var(--c-bg); padding: 2px 8px; border-radius: 999px;
}
.mc-session-summary {
  font-size: 12px; color: var(--c-text); line-height: 1.6; white-space: pre-wrap;
}
.mc-session-runs {
  font-size: 10px; color: var(--c-text-muted); font-family: monospace;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.mc-session-run-tag {
  background: var(--c-bg); padding: 1px 6px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,.06);
}
.mc-log-empty {
  text-align: center; padding: 40px 0;
  font-size: 13px; color: var(--c-text-muted);
}

/* ── Version Log Panel ────────────────────────────────────── */
#ver-log-lightbox {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: flex-start; justify-content: flex-end;
}
#ver-log-lightbox.hidden { display: none; }
#ver-log-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
}
#ver-log-panel {
  position: relative; z-index: 1;
  width: min(480px, 95vw); height: 100vh;
  background: var(--c-sidebar); display: flex; flex-direction: column;
  overflow: hidden; box-shadow: -4px 0 24px rgba(0,0,0,.4);
}
#ver-log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
#ver-log-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--c-text);
}
#ver-log-close {
  background: none; border: none; cursor: pointer;
  color: var(--c-text-muted); padding: 4px; border-radius: 4px;
  transition: color .12s;
}
#ver-log-close:hover { color: var(--c-text); }
#ver-log-body {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.ver-entry {
  background: var(--c-surface); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid rgba(79,70,229,.25);
}
.ver-entry-header {
  display: flex; align-items: center; gap: 8px;
}
.ver-entry-num {
  font-size: 12px; font-weight: 800; color: #818cf8;
  background: rgba(79,70,229,.18); padding: 2px 8px; border-radius: 4px;
}
.ver-entry-date {
  font-size: 11px; color: var(--c-text-muted);
}
.ver-entry-changes {
  font-size: 12px; color: var(--c-text); line-height: 1.7;
  padding-left: 12px;
}
.ver-entry-changes li {
  margin-bottom: 2px; color: #d1d5db;
}

/* ── Toggle switch (Model Switch en modal) ──────────────────── */
.toggle-switch { position:relative; display:inline-block; width:40px; height:22px; cursor:pointer; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-thumb {
  position:absolute; top:0; left:0; right:0; bottom:0;
  background:var(--c-border); border-radius:22px; transition:.2s;
}
.toggle-thumb::before {
  content:''; position:absolute; height:16px; width:16px; left:3px; bottom:3px;
  background:#fff; border-radius:50%; transition:.2s;
}
.toggle-switch input:checked + .toggle-thumb { background:var(--c-accent); }
.toggle-switch input:checked + .toggle-thumb::before { transform:translateX(18px); }
