:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-soft: #f9fafb;
  --border-soft: #e5e7eb;
  --text-main: #111827;
  --text-soft: #6b7280;

  --mk-blue: #004b91;
  --mk-orange: #ff9f23;
  --mk-green: #10b981;
  --mk-gray: #6b7280;

  --token-q1: rgba(37, 99, 235, 0.18);
  --token-q2: rgba(16, 185, 129, 0.20);
  --token-q3: rgba(245, 158, 11, 0.20);
  --token-q4: rgba(239, 68, 68, 0.20);
  --token-q5: rgba(59, 130, 246, 0.18);
  --token-q6: rgba(34, 197, 94, 0.20);
  --token-q7: rgba(14, 165, 233, 0.20);
  --token-q8: rgba(168, 85, 247, 0.20);
  --token-q9: rgba(239, 68, 68, 0.20);
  --token-q10: rgba(107, 114, 128, 0.20);

  --panel-match-bg: #ffffff;
  --panel-dialog-bg: #f9fafb;
  --panel-questions-bg: transparent;
}

body.theme-dark {
  --bg-main: #020617;
  --bg-card: radial-gradient(circle at top left, #0f172a 0, #020617 55%, #000 100%);
  --bg-soft: #020617;
  --border-soft: rgba(148, 163, 184, 0.45);
  --text-main: #e5e7eb;
  --text-soft: #9ca3af;

  --panel-match-bg: radial-gradient(circle at top, #020617 0, #020617 75%, #000 100%);
  --panel-dialog-bg: radial-gradient(circle at top left, #020617 0, #020617 10%, #000 100%);
  --panel-questions-bg: transparent;

  --token-q1: rgba(37, 99, 235, 0.33);
  --token-q2: rgba(16, 185, 129, 0.35);
  --token-q3: rgba(245, 158, 11, 0.32);
  --token-q4: rgba(239, 68, 68, 0.35);
  --token-q5: rgba(59, 130, 246, 0.28);
  --token-q6: rgba(34, 197, 94, 0.33);
  --token-q7: rgba(14, 165, 233, 0.33);
  --token-q8: rgba(168, 85, 247, 0.32);
  --token-q9: rgba(239, 68, 68, 0.35);
  --token-q10: rgba(148, 163, 184, 0.35);
}

body {
  background: var(--bg-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
}

/* Topbar */
.bg-blue { background: var(--mk-blue) !important; }
.app-navbar { backdrop-filter: blur(6px); }
.navbar-tools-right{ display:flex; align-items:center; gap:6px; }

.btn-pill { border-radius: 999px; }

/* Shell */
.app-shell{ padding-top: 70px; }
.app-main{
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 6.5rem;
}
.questions-card, .dialogue-card{
  border-radius: 0.75rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  padding: 0.85rem;
}

/* Titles */
.panel-title-small {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-subtitle { font-size: 0.7rem; color: var(--text-soft); }

.status-msg {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
}

.footer-meta-inline{
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin-top:8px;
  font-size:.75rem;
  color: var(--text-soft);
}

/* footer legal minimalista */
.legal-footer {
  font-size: 0.7rem;
  color: var(--text-soft);
  text-align: center;
  margin-top: 0.6rem;
  padding: 0.35rem 0 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}
.legal-footer span { display:block; }

/* Estado global API */
.api-status-pill {
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.api-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #9ca3af;
}
.api-status-pill.idle { background: rgba(148, 163, 184, 0.12); color: #cbd5e1; }
.api-status-pill.busy { background: rgba(59, 130, 246, 0.16); color: #93c5fd; }
.api-status-pill.ok { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.api-status-pill.error { background: rgba(220, 38, 38, 0.20); color: #fca5a5; }
.api-status-pill.busy .api-dot { background: #3b82f6; animation: apiPulse 1s infinite; }
.api-status-pill.ok .api-dot { background: #22c55e; }
.api-status-pill.error .api-dot { background: #ef4444; }
@keyframes apiPulse { 0%{transform:scale(1)} 50%{transform:scale(1.3)} 100%{transform:scale(1)} }

/* Preguntas */
.q-row { border-bottom: 1px dashed var(--border-soft); padding: 0.45rem 0; }
.q-header { display:flex; justify-content:space-between; align-items:center; margin-bottom: 0.15rem; }
.q-label { font-size: 0.82rem; font-weight: 600; color: var(--text-main); }
.q-meta { font-size: 0.7rem; color: var(--text-soft); }
.q-ans { font-size: 0.78rem; padding-top: 0.1rem; min-height: 1.2rem; color: var(--text-main); }
.q-ans.empty { color: var(--text-soft); font-style: italic; }
.q-badge-score {
  font-size: 0.65rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 52px;
  justify-content: center;
}
.q-badge-score.low { border-color:#f97316; color:#fdba74; background: rgba(248, 113, 113, 0.06); }
.q-badge-score.mid { border-color:#eab308; color:#fde68a; background: rgba(234, 179, 8, 0.09); }
.q-badge-score.high { border-color:#22c55e; color:#bbf7d0; background: rgba(34, 197, 94, 0.16); }
.q-badge-score.zero { border-color: var(--border-soft); color: var(--text-soft); background: transparent; }
.q-badge-score .check { font-size: 0.75rem; }

/* Diálogo */
.dialogue-box {
  border-radius: 0.6rem;
  padding: 0.75rem;
  background: var(--panel-dialog-bg);
  border: 1px solid var(--border-soft);
  height: 55vh;
  min-height: 260px;
  max-height: 55vh;
  overflow-y: auto;
}

/* Mensajes */
.msg-row { margin-bottom: 0.4rem; clear: both; }
.msg-bubble {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
  max-width: 92%;
  word-wrap: break-word;
}
.msg-bubble.asesor { background-color: var(--mk-blue); color:#fff; border-bottom-right-radius: 0.3rem; float:right; }
.msg-bubble.cliente { background-color:#fff; color:#111827; border: 1px solid var(--border-soft); border-bottom-left-radius: 0.3rem; float:left; }
body.theme-dark .msg-bubble.cliente { background:#020617; color:#e5e7eb; border: 1px solid rgba(148, 163, 184, 0.64); }
.msg-row.live .msg-bubble { font-style: italic; opacity: 0.85; }

/* tokens */
.token-hit { padding: 0 2px; border-radius: 0.2rem; }
.token-hit-q1 { background: var(--token-q1); }
.token-hit-q2 { background: var(--token-q2); }
.token-hit-q3 { background: var(--token-q3); }
.token-hit-q4 { background: var(--token-q4); }
.token-hit-q5 { background: var(--token-q5); }
.token-hit-q6 { background: var(--token-q6); }
.token-hit-q7 { background: var(--token-q7); }
.token-hit-q8 { background: var(--token-q8); }
.token-hit-q9 { background: var(--token-q9); }
.token-hit-q10 { background: var(--token-q10); }

/* Indicador voz */
.rec-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #9ca3af;
  display: inline-block;
}
.rec-indicator.active {
  background-color: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.9);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Panel flotante de etiquetas */
.matches-panel{
  position: fixed;
  top: 74px;
  right: 10px;
  width: min(360px, 92vw);
  z-index: 1001;
}
.matches-inner{
  border-radius: 0.75rem;
  border: 1px solid var(--border-soft);
  background: var(--panel-match-bg);
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
  padding: 0.6rem;
}
.match-list-box {
  border-radius: 0.6rem;
  border: 1px solid var(--border-soft);
  background: rgba(2,6,23,0.25);
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.5rem;
  margin-top: 0.5rem;
}
.match-item {
  border-radius: 0.6rem;
  border: 1px solid var(--border-soft);
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.5rem;
  background: rgba(2,6,23,0.35);
}
.match-header { display:flex; align-items:flex-start; justify-content:space-between; gap:0.2rem; }
.match-color-dot { width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; margin-top: 3px; flex-shrink:0; }
.match-color-q1 { background:#2563eb; }
.match-color-q2 { background:#10b981; }
.match-color-q3 { background:#f59e0b; }
.match-color-q4 { background:#ef4444; }
.match-color-q5 { background:#3b82f6; }
.match-color-q6 { background:#22c55e; }
.match-color-q7 { background:#0ea5e9; }
.match-color-q8 { background:#a855f7; }
.match-color-q9 { background:#ef4444; }
.match-color-q10 { background:#6b7280; }
.match-title { font-size:0.78rem; font-weight:600; color: var(--text-main); }
.match-score { font-size:0.72rem; font-weight:700; color: var(--mk-green); }
.match-score.low { color:#fb923c; }
.match-score.zero { color:#9ca3af; }
.match-snippet { font-size:0.73rem; color: var(--text-main); margin-top:0.2rem; }
.match-qid { font-size:0.68rem; color: var(--text-soft); }
.match-suggestions { margin-top:0.25rem; padding-top:0.25rem; border-top:1px dashed var(--border-soft); }
.match-suggestions-title { font-size:0.7rem; font-weight:600; text-transform:uppercase; color: var(--text-soft); margin-bottom:0.1rem; }
.match-suggestions-body { font-size:0.72rem; color: var(--text-main); }

/* Barra inferior */
.live-bar{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1002;
  padding: 8px 10px;
  background: rgba(2,6,23,0.85);
  border-top: 1px solid rgba(148,163,184,0.25);
  backdrop-filter: blur(6px);
}
.live-bar-inner{
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.live-preview-wrap{ flex: 1 1 auto; min-width: 0; }
.live-status-wrap{ flex: 0 0 260px; text-align: right; }

/* FAB */
.rec-fab{
  position: fixed;
  bottom: 70px;
  z-index: 1003;
}
.rec-fab-right{ right: 12px; }
.rec-fab-left{ left: 12px; }

/* Modal PWA */
.pwa-modal-backdrop{
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
}
.pwa-modal{
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.pwa-modal-header{ display:flex; gap:12px; align-items:center; }
.pwa-modal-header img{ width: 54px; height: 54px; border-radius: 12px; }
.pwa-modal-title{ font-weight:700; }
.pwa-modal-body{ margin: 10px 0 12px; font-size: .9rem; color:#374151; }
.pwa-modal-actions{ display:flex; justify-content:flex-end; gap:10px; }
.d-none{ display:none !important; }
