:root {
  /* Main background and text colors */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-soft: #f9fafb;
  --border-soft: #e5e7eb;
  --text-main: #111827;
  --text-soft: #6b7280;

  /* MK brand colors */
  --mk-blue: #004b91;
  --mk-orange: #ff9f23;
  --mk-green: #10b981;
  --mk-gray: #6b7280;

  /* Token colors */
  --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 backgrounds */
  --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 75%, #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);
  /* Intentionally using a lighter gray for --token-q10 in dark mode for better contrast with background */
  --token-q10: rgba(148, 163, 184, 0.35);
}
body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
} 

.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
  color: var(--text-main);
}

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

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

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

.footer-meta {
  font-size: 0.75rem;
  color: var(--text-soft);
}

/* footer legal minimalista */
.legal-footer {
  font-size: 0.3rem;
  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;
}

/* Layout 3 columnas */
.layout-3col {
  display: flex;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.col-dialog,
.col-matches,
.col-questions {
  flex: 0 0 100%;
  max-width: 100%;
  margin-bottom: 0.75rem;
}

@media (min-width: 992px) {
  .col-dialog {
    flex: 0 0 38%;
     padding-right: 0.5rem;
    border-right: 1px solid var(--border-soft);
  }

  .col-matches {
    flex: 0 0 30%;
     padding: 0 0.5rem;
    border-right: 1px solid var(--border-soft);
  }

  .col-questions {
    flex: 0 0 32%;
    max-width: 32%;
    padding-left: 0.5rem;
  }
}

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

/* Toggle tema */
.theme-toggle {
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-soft);
  color: var(--text-soft);
  cursor: pointer;
}

/* 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: #6b7280;
}
.api-status-pill.busy {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}
.api-status-pill.ok {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
}
.api-status-pill.error {
  background: rgba(220, 38, 38, 0.16);
  color: #b91c1c;
}
.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 solid var(--border-soft);
  padding: 0.6rem 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.q-row:last-child {
  border-bottom: none;
}

.q-header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.q-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

.q-meta {
  font-size: 0.68rem;
  color: var(--text-soft);
}

.q-ans {
  font-size: 0.76rem;
  color: var(--text-main);
  line-height: 1.35;
  word-break: break-word;
}

.q-ans.empty {
  color: var(--text-soft);
  font-style: italic;
  font-size: 0.73rem;
}

.q-badge-score {
  font-size: 0.65rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 48px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.q-badge-score.low {
  border-color: #f97316;
  color: #9a3412;
  background: rgba(249, 115, 22, 0.1);
}

.q-badge-score.mid {
  border-color: #eab308;
  color: #854d0e;
  background: rgba(234, 179, 8, 0.12);
}

.q-badge-score.high {
  border-color: #22c55e;
  color: #14532d;
  background: rgba(34, 197, 94, 0.12);
}

.q-badge-score.zero {
  border-color: var(--border-soft);
  color: var(--text-soft);
  background: transparent;
}

.q-badge-score .check {
  font-size: 0.7rem;
}

/* Diálogo */
.dialogue-box {
  border-radius: 0.6rem;
  padding: 0.75rem;
  background: var(--panel-dialog-bg);
  border: 1px solid var(--border-soft);
  height: 15vh;
  min-height: 120px;
  max-height: 25vh;
  overflow-y: auto;
  will-change: scroll-position;
}
.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: 90%;
  word-wrap: break-word;
}
.msg-bubble.asesor {
  background-color: var(--mk-blue);
  color: #ffffff;
  border-bottom-right-radius: 0.3rem;
  float: right;
}
.msg-bubble.cliente {
  background-color: #ffffff;
  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;
  margin-right: 6px;
}
.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 central: etiquetas */
.match-list-box {
  border-radius: 0.6rem;
  border: 1px solid var(--border-soft);
  background: var(--panel-match-bg);
  max-height: 65vh;
  overflow-y: auto;
  padding: 0.5rem;
}
.match-item {
  border-radius: 0.6rem;
  border: 1px solid var(--border-soft);
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.5rem;
  background: var(--bg-soft);
}
.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);
}

/* Drag & drop audio */
.audio-dropzone {
  border: 1px dashed var(--border-soft);
  border-radius: 0.5rem;
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
  margin-top: 0.4rem;
  color: var(--text-soft);
  cursor: pointer;
  background: rgba(148, 163, 184, 0.05);
}
.audio-dropzone.active {
  background: rgba(148, 163, 184, 0.16);
}
