/* ── Reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1b2a;
  --surface:   #1b263b;
  --border:    #2a3f58;
  --accent:    #778da9;
  --accent2:   #9db5cc;
  --text:      #e0e1dd;
  --muted:     #4e6d87;
  --user-bg:   #415a77;
  --maven-bg:  #1d2e42;
  --tool-bg:   #111c29;
  --radius:    16px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
}

.hidden { display: none !important; }

/* ── Login ───────────────────────────────────────────────────── */
#login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1b263b 0%, var(--bg) 70%);
}

.login-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  width: min(380px, 92vw);
}

.logo {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: #fff;
}

.login-box h2 { font-size: 22px; font-weight: 700; }
.login-box .subtitle { color: var(--muted); font-size: 13px; }

.login-box input {
  width: 100%; padding: 12px 16px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 15px;
  outline: none; letter-spacing: 2px;
}
.login-box input:focus { border-color: var(--accent); }

.login-box button {
  width: 100%; padding: 13px;
  background: var(--accent); border: none;
  border-radius: 12px; color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: opacity .15s;
}
.login-box button:hover { opacity: .9; }

.error { color: #f87171; font-size: 13px; }

/* ── App shell ───────────────────────────────────────────────── */
#app {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}

/* ── Dashboard ───────────────────────────────────────────────── */
#dashboard {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  overflow-y: auto;
  max-height: 42vh;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  #dashboard { padding: 8px 10px; max-height: 48vh; }
}

.dash-header {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; margin-bottom: 6px;
}
.dash-update-time {
  font-size: 10px; color: var(--muted);
}
#dash-refresh-btn {
  background: none; border: none;
  color: var(--muted); font-size: 15px;
  cursor: pointer; padding: 0 2px;
  line-height: 1; transition: color .15s;
}
#dash-refresh-btn:hover { color: var(--accent2); }
#dash-refresh-btn.spinning {
  animation: spin .7s linear infinite;
  pointer-events: none;
}

.dash-loading {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px;
  padding: 4px 0;
}

/* Stat cards — 4 col desktop, 2x2 mobile */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

@media (max-width: 600px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.stat-card.accent { border-color: #10b981; }

.stat-icon { font-size: 18px; flex-shrink: 0; }
.stat-body { min-width: 0; }
.stat-num  { font-size: 20px; font-weight: 800; line-height: 1; }
.stat-label {
  font-size: 10px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 380px) {
  .stat-icon { font-size: 15px; }
  .stat-num  { font-size: 18px; }
  .stat-label { font-size: 9px; }
}

/* Pipeline */
.pipeline-section, .followup-section { margin-bottom: 8px; }

.section-title {
  font-size: 10px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .6px; margin-bottom: 5px;
}

.pipe-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
.pipe-label {
  font-size: 11px; color: var(--text);
  width: 90px; flex-shrink: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pipe-track {
  flex: 1; height: 7px;
  background: var(--bg);
  border-radius: 99px; overflow: hidden;
  border: 1px solid var(--border);
  min-width: 0;
}
.pipe-fill {
  height: 100%; border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
  min-width: 5px;
}
.pipe-count {
  font-size: 11px; color: var(--muted);
  width: 14px; text-align: right; flex-shrink: 0;
}

@media (max-width: 380px) {
  .pipe-label { width: 75px; font-size: 10px; }
}

/* Follow-up list */
.fu-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 4px;
  gap: 6px;
  min-width: 0;
}
.fu-name {
  font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.fu-right { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.fu-date  { font-size: 11px; color: var(--muted); }
.fu-empty { color: var(--muted); font-size: 12px; padding: 3px 0; }

/* Badges */
.badge {
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .3px;
  white-space: nowrap;
}
.badge-purple { background: rgba(119,141,169,.2); color: #9db5cc; }
.badge-green  { background: rgba(16,185,129,.2); color: #34d399; }
.badge-yellow { background: rgba(245,158,11,.2); color: #fbbf24; }
.badge-orange { background: rgba(249,115,22,.2); color: #fb923c; }
.badge-blue   { background: rgba(59,130,246,.2); color: #60a5fa; }

/* ── Header ──────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative; /* needed for mobile dropdown */
}

.header-left {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; min-width: 0;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

.name   { font-weight: 700; font-size: 15px; white-space: nowrap; }
.status { font-size: 11px; color: var(--muted); }
.status.thinking { color: var(--accent2); }

/* ── Nav container ───────────────────────────────────────────── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 1;
  flex-wrap: nowrap;
  overflow: hidden;
}

/* ── Nav items ───────────────────────────────────────────────── */
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  border: 1.5px solid;
  cursor: pointer;
  white-space: nowrap;
  transition: filter .15s, background .15s;
  letter-spacing: .02em;
  line-height: 1;
  flex-shrink: 0;
  font-family: var(--font);
}
.nav-item:hover { filter: brightness(1.15); }

.ni-purple { background: rgba(108,99,255,.13); border-color: rgba(108,99,255,.4); color: #818cf8; }
.ni-green  { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.4); color: #6ee7b7; }
.ni-yellow { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.4); color: #fbbf24; }
.ni-red    { background: rgba(239,68,68,.1);   border-color: rgba(239,68,68,.35); color: #f87171; }

/* Icon-only utility buttons */
.nav-icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 9px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: 15px;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
  line-height: 1;
}
.nav-icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* Separator between groups */
.nav-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

/* ── Fixed right (live-btn + hamburger) ──────────────────────── */
.header-fixed {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 4px;
}

/* ── Live button ─────────────────────────────────────────────── */
.nav-live-btn {
  background: none; border: none; color: var(--accent);
  font-size: 20px; cursor: pointer; padding: 4px 6px;
  border-radius: 8px; transition: opacity .15s;
  animation: live-pulse-btn 2.5s ease-in-out infinite;
  display: flex; align-items: center;
}
.nav-live-btn:hover { opacity: .8; }

/* ── Hamburger button (mobile only) ──────────────────────────── */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color .15s;
}
.hamburger-btn span {
  display: block; width: 18px; height: 2px;
  background: var(--muted); border-radius: 2px;
  transition: all .22s;
}
.hamburger-btn:hover { border-color: var(--accent); }
.hamburger-btn:hover span { background: var(--text); }
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile nav dropdown ─────────────────────────────────────── */
@media (max-width: 768px) {
  header { padding: 10px 12px; }

  .header-nav {
    /* Hidden by default — opens as dropdown */
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    z-index: 200;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    box-shadow: 0 12px 32px rgba(0,0,0,.45);
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 14px 14px 16px;
  }
  .header-nav.open { display: flex; }

  /* Full-width nav items in dropdown */
  .header-nav .nav-item,
  .header-nav .nav-icon-btn {
    width: 100%;
    padding: 11px 14px;
    font-size: 13px;
    justify-content: flex-start;
    border-radius: 10px;
  }
  /* Override inline display:inline-flex so items fill the column */
  .header-nav .nav-item[style*="inline-flex"] { display: flex !important; }

  /* Separators become horizontal rules */
  .header-nav .nav-sep {
    width: 100%; height: 1px; margin: 2px 0;
  }

  /* Show hamburger, fix nav-live-btn alignment */
  .hamburger-btn { display: flex; }

  /* Keep logout full-width when JS sets display:inline-flex */
  #logout-btn { box-sizing: border-box; }
}

/* ── Compat: old #clear-btn / #dash-toggle ───────────────────── */
#clear-btn, #dash-toggle {
  background: none; border: 1px solid var(--border);
  color: var(--muted); border-radius: 9px;
  padding: 6px 9px; cursor: pointer; font-size: 15px;
  transition: color .15s, border-color .15s;
}
#clear-btn:hover, #dash-toggle:hover { color: var(--text); border-color: var(--accent); }

/* ── Messages ────────────────────────────────────────────────── */
#messages {
  flex: 1; overflow-y: auto;
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg {
  display: flex;
  max-width: 82%;
  animation: fadeUp .2s ease;
}
.msg.user  { align-self: flex-end; flex-direction: row-reverse; }
.msg.maven { align-self: flex-start; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user  .bubble { background: var(--user-bg); color: #fff; border-bottom-right-radius: 4px; }
.msg.maven .bubble { background: var(--maven-bg); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }

/* Markdown básico en respuestas de Maven */
.bubble strong { font-weight: 700; }
.bubble em { font-style: italic; color: var(--accent2); }
.bubble code {
  background: rgba(119,141,169,.18);
  padding: 1px 5px; border-radius: 5px;
  font-family: monospace; font-size: 13px;
}
.bubble pre {
  background: var(--tool-bg); border: 1px solid var(--border);
  padding: 10px 12px; border-radius: 10px; overflow-x: auto;
  margin: 6px 0; font-size: 12.5px;
}

/* Burbuja de "escribiendo..." */
.typing .bubble {
  display: flex; gap: 5px; align-items: center;
  padding: 12px 16px;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent2);
  animation: bounce 1.2s infinite;
}
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%,80%,100% { transform: scale(1); opacity: .5; }
  40%         { transform: scale(1.25); opacity: 1; }
}

/* ── Tool indicator ──────────────────────────────────────────── */
.tool-indicator {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px;
  background: var(--tool-bg);
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--accent2);
  flex-shrink: 0;
}
.tool-spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer / input ──────────────────────────────────────────── */
footer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.voice-btn {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 18px;
  transition: background .15s, border-color .15s;
  display: flex; align-items: center; justify-content: center;
}
.voice-btn.recording {
  background: #dc2626;
  border-color: #dc2626;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50%      { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

.input-wrap {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 12px;
  display: flex;
  transition: border-color .15s;
}
.input-wrap:focus-within { border-color: var(--accent); }

textarea {
  flex: 1; background: none; border: none;
  color: var(--text); font-size: 14.5px; font-family: var(--font);
  resize: none; outline: none;
  max-height: 120px; overflow-y: auto;
  line-height: 1.45;
}

#send-btn {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: 50%; border: none;
  background: var(--accent); color: #fff;
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, transform .1s;
}
#send-btn:hover  { opacity: .9; }
#send-btn:active { transform: scale(.93); }
#send-btn:disabled { opacity: .4; cursor: default; }

/* ── Live Mode Button ────────────────────────────────────────── */
#live-btn {
  background: none; border: none; color: var(--accent);
  font-size: 20px; cursor: pointer; padding: 4px 8px;
  border-radius: 8px; transition: opacity .15s;
  animation: live-pulse-btn 2.5s ease-in-out infinite;
}
#live-btn:hover { opacity: .8; }
@keyframes live-pulse-btn {
  0%,100% { text-shadow: 0 0 4px var(--accent); opacity:.65; }
  50%      { text-shadow: 0 0 16px var(--accent); opacity:1; }
}

/* ── Live Mode Overlay ───────────────────────────────────────── */
#live-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999;
  background: radial-gradient(ellipse 70% 55% at 50% 42%,
    rgba(119,141,169,.15) 0%, #080e1a 65%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#live-overlay.hidden { display: none !important; }

/* Close */
#live-close {
  position: absolute; top: 22px; right: 22px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.45);
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s, border-color .2s;
}
#live-close:hover {
  background: rgba(255,255,255,.13);
  color: #fff;
  border-color: rgba(255,255,255,.22);
}

/* ── Orb ─────────────────────────────────────────────────────── */
#live-orb-wrap {
  position: relative; width: 250px; height: 250px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 32px;
}
#live-orb {
  position: relative; width: 144px; height: 144px;
  display: flex; align-items: center; justify-content: center;
}

.orb-ring {
  position: absolute; border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
  animation: orb-breathe 3.4s ease-in-out infinite;
}
.r1 { width: 144px; height: 144px; animation-delay: 0s; }
.r2 { width: 196px; height: 196px; animation-delay: .8s; }
.r3 { width: 248px; height: 248px; animation-delay: 1.6s; }

@keyframes orb-breathe {
  0%   { opacity: 0;   transform: scale(.88); }
  40%  { opacity: .26; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.08); }
}

#live-orb-icon {
  width: 128px; height: 128px; border-radius: 50%;
  background: linear-gradient(145deg, #415a77, #5e7c96, #9db5cc);
  display: flex; align-items: center; justify-content: center;
  font-size: 54px; font-weight: 700; color: #fff;
  box-shadow:
    0 0 0 1px rgba(119,141,169,.3),
    0 0 55px rgba(119,141,169,.45),
    0 0 110px rgba(119,141,169,.15),
    inset 0 1px 0 rgba(255,255,255,.18);
  transition: box-shadow .4s ease, transform .35s ease, background .4s ease;
  z-index: 2;
}

/* Listening — red */
#live-overlay.state-listening #live-orb-icon {
  background: linear-gradient(145deg, #c81e1e, #ef4444, #f87171);
  box-shadow:
    0 0 0 1px rgba(239,68,68,.35),
    0 0 65px rgba(239,68,68,.6),
    0 0 130px rgba(239,68,68,.2),
    inset 0 1px 0 rgba(255,255,255,.18);
  transform: scale(1.06);
}
#live-overlay.state-listening .orb-ring {
  border-color: #ef4444;
  animation: orb-pulse-listen .8s ease-in-out infinite;
}
@keyframes orb-pulse-listen {
  0%,100% { opacity: .5; transform: scale(.95); }
  50%      { opacity: .12; transform: scale(1.06); }
}

/* Thinking — steel blue */
#live-overlay.state-thinking #live-orb-icon {
  background: linear-gradient(145deg, #1b263b, #415a77, #9db5cc);
  box-shadow:
    0 0 0 1px rgba(65,90,119,.35),
    0 0 65px rgba(65,90,119,.55),
    0 0 130px rgba(65,90,119,.18),
    inset 0 1px 0 rgba(255,255,255,.18);
  animation: orb-think 2s linear infinite;
}
@keyframes orb-think {
  from { filter: hue-rotate(0deg) brightness(1); }
  to   { filter: hue-rotate(35deg) brightness(1.1); }
}
#live-overlay.state-thinking .orb-ring {
  border-color: #778da9;
  animation: orb-pulse-think 1.3s ease-in-out infinite;
}
@keyframes orb-pulse-think {
  0%,100% { opacity: .28; transform: scale(.96); }
  50%      { opacity: .07; transform: scale(1.04); }
}

/* Speaking — green */
#live-overlay.state-speaking #live-orb-icon {
  background: linear-gradient(145deg, #047857, #10b981, #34d399);
  box-shadow:
    0 0 0 1px rgba(16,185,129,.35),
    0 0 65px rgba(16,185,129,.6),
    0 0 130px rgba(16,185,129,.2),
    inset 0 1px 0 rgba(255,255,255,.18);
}
#live-overlay.state-speaking .orb-ring {
  border-color: #10b981;
  animation: orb-wave-speak .7s ease-in-out infinite alternate;
}
.r2 { animation-delay: .2s !important; }
.r3 { animation-delay: .4s !important; }
@keyframes orb-wave-speak {
  from { opacity: .45; transform: scale(1); }
  to   { opacity: .08; transform: scale(1.1); }
}

/* ── Status pill ─────────────────────────────────────────────── */
#live-status {
  font-size: 13.5px; font-weight: 500;
  color: rgba(255,255,255,.42);
  letter-spacing: .05em; text-transform: uppercase;
  padding: 7px 20px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 99px;
  margin-bottom: 18px;
  transition: color .35s, border-color .35s, background .35s;
  min-width: 156px; text-align: center;
}
#live-overlay.state-listening #live-status {
  color: #f87171;
  border-color: rgba(239,68,68,.32);
  background: rgba(239,68,68,.08);
}
#live-overlay.state-thinking #live-status {
  color: #b0c8e0;
  border-color: rgba(65,90,119,.32);
  background: rgba(65,90,119,.08);
}
#live-overlay.state-speaking #live-status {
  color: #34d399;
  border-color: rgba(16,185,129,.32);
  background: rgba(16,185,129,.08);
}

/* ── Transcript ──────────────────────────────────────────────── */
#live-transcript {
  font-size: 13.5px; color: rgba(255,255,255,.28);
  max-width: 300px; text-align: center;
  min-height: 38px; line-height: 1.6;
  font-style: italic;
  padding: 0 24px;
  margin-bottom: 10px;
}

/* ── Wave bars ───────────────────────────────────────────────── */
#live-wave {
  display: flex; align-items: center; gap: 5px;
  height: 32px; margin-bottom: 44px;
  opacity: 0; transition: opacity .35s;
}
#live-wave span {
  display: block; width: 4px; height: 5px;
  border-radius: 99px; background: #10b981;
  animation: wave-bar 1.1s ease-in-out infinite;
}
#live-wave span:nth-child(1) { animation-delay: 0s; }
#live-wave span:nth-child(2) { animation-delay: .15s; }
#live-wave span:nth-child(3) { animation-delay: .3s; }
#live-wave span:nth-child(4) { animation-delay: .45s; }
#live-wave span:nth-child(5) { animation-delay: .6s; }
@keyframes wave-bar {
  0%,100% { height: 5px; opacity: .3; }
  50%     { height: 26px; opacity: 1; }
}
#live-wave { display: none !important; }
#live-transcript { margin-bottom: 80px; }

/* ── Mic button — oculto en modo automático ──────────────────── */
#live-mic-btn { display: none; }
#live-mic-btn {
  width: 76px; height: 76px; border-radius: 50%;
  border: 1.5px solid rgba(119,141,169,.32);
  background: rgba(119,141,169,.1);
  color: rgba(119,141,169,.9); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .25s, border-color .25s, transform .15s, box-shadow .25s;
  box-shadow: 0 0 0 0 rgba(119,141,169,0),
              inset 0 1px 0 rgba(255,255,255,.08);
}
#live-mic-btn:hover {
  background: rgba(119,141,169,.2);
  border-color: rgba(119,141,169,.58);
  box-shadow: 0 0 28px rgba(119,141,169,.28);
}
#live-mic-btn:active { transform: scale(.91); }
#live-mic-btn:disabled {
  opacity: .35; cursor: default;
  pointer-events: none;
}
#live-overlay.state-listening #live-mic-btn {
  background: rgba(239,68,68,.17);
  border-color: rgba(239,68,68,.52);
  color: #f87171;
  animation: mic-record-pulse .9s ease-in-out infinite;
}
@keyframes mic-record-pulse {
  0%,100% { box-shadow: 0 0 10px rgba(239,68,68,.18), 0 0 0 0 rgba(239,68,68,.12); }
  50%      { box-shadow: 0 0 30px rgba(239,68,68,.35), 0 0 18px rgba(239,68,68,.1); }
}

/* ── Live overlay — mobile ───────────────────────────────────── */
@media (max-height: 700px), (max-width: 480px) {
  #live-orb-wrap { width: 190px; height: 190px; margin-bottom: 22px; }
  #live-orb       { width: 110px; height: 110px; }
  .r1 { width: 110px; height: 110px; }
  .r2 { width: 152px; height: 152px; }
  .r3 { width: 190px; height: 190px; }
  #live-orb-icon  { width: 98px; height: 98px; font-size: 42px; }
  #live-status    { font-size: 12px; padding: 6px 16px; margin-bottom: 14px; }
  #live-transcript { font-size: 12.5px; min-height: 32px; }
  #live-mic-btn   { width: 64px; height: 64px; }
  #live-mic-btn svg { width: 24px; height: 24px; }
  #live-close     { top: 16px; right: 16px; }
}

/* ══════════════════════════════════════════════════════════════
   MORTGAGE CALCULATOR
   ══════════════════════════════════════════════════════════════ */

#calc-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(10, 11, 18, 0.96);
  backdrop-filter: blur(12px);
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  animation: calc-fade-in .22s ease;
}
@keyframes calc-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.calc-inner {
  width: 100%;
  max-width: 880px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  margin: auto;
}

/* ── Header ── */
.calc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #1b263b 0%, #1d2e42 100%);
}
.calc-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: var(--text);
}
.calc-title svg { color: var(--accent); }
#calc-close {
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  color: var(--muted); border-radius: 50%; width: 32px; height: 32px;
  cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
#calc-close:hover { background: rgba(255,255,255,.12); color: var(--text); }

/* ── Body (two columns) ── */
.calc-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

/* ── Inputs column ── */
.calc-inputs {
  padding: 24px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 16px;
}
.calc-field { display: flex; flex-direction: column; gap: 6px; }
.calc-field label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.calc-input-wrap {
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  transition: border-color .15s;
}
.calc-input-wrap:focus-within { border-color: var(--accent); }
.ci-prefix, .ci-suffix {
  padding: 0 10px; font-size: 14px; font-weight: 600;
  color: var(--accent); background: rgba(119,141,169,.08);
  height: 100%; display: flex; align-items: center;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.ci-suffix { border-right: none; border-left: 1px solid var(--border); }
.calc-input-wrap input {
  flex: 1; padding: 10px 12px;
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 15px; font-weight: 500;
  min-width: 0;
}
.calc-input-wrap input::-webkit-outer-spin-button,
.calc-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }
.calc-row-2 { display: grid; grid-template-columns: 1fr 90px; gap: 8px; }
.ci-pct-wrap .ci-prefix { display: none; }

.calc-terms { display: flex; gap: 6px; flex-wrap: wrap; }
.term-btn {
  flex: 1; min-width: 56px;
  padding: 9px 8px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.term-btn:hover { border-color: var(--accent); color: var(--accent); }
.term-btn.active {
  background: rgba(119,141,169,.18); border-color: var(--accent);
  color: var(--accent);
}

/* ── Results column ── */
.calc-results {
  padding: 24px;
  display: flex; flex-direction: column; gap: 20px; align-items: center;
}

.calc-monthly-card {
  width: 100%; padding: 20px 24px;
  background: linear-gradient(135deg, rgba(119,141,169,.15), rgba(157,181,204,.08));
  border: 1px solid rgba(119,141,169,.35);
  border-radius: 16px; text-align: center;
}
.cmc-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px;
}
.cmc-amount {
  font-size: 38px; font-weight: 800;
  background: linear-gradient(135deg, #778da9, #9db5cc);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}
.cmc-pmi {
  font-size: 11px; color: #ef4444; margin-top: 4px; min-height: 16px;
}

/* ── Donut chart ── */
.calc-chart-wrap {
  display: flex; align-items: center; gap: 20px;
  width: 100%;
}
#calc-donut { flex-shrink: 0; }
.calc-legend {
  flex: 1; display: flex; flex-direction: column; gap: 8px;
}
.cl-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.cl-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.cl-name { flex: 1; color: var(--muted); }
.cl-amt  { font-weight: 700; color: var(--text); }

/* ── Summary totals ── */
.calc-summary {
  width: 100%;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.cs-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.cs-row:last-child { border-bottom: none; }
.cs-total { background: rgba(119,141,169,.06); }
.cs-label { font-size: 13px; color: var(--muted); }
.cs-val   { font-size: 14px; font-weight: 700; color: var(--text); }
.accent-red { color: #f87171 !important; }

/* ── Amortization ── */
.calc-amort-btn {
  width: 100%; padding: 11px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 10px; color: var(--muted); font-size: 13px;
  cursor: pointer; transition: all .15s;
}
.calc-amort-btn:hover { border-color: var(--accent); color: var(--accent); }

#calc-amort-wrap {
  border-top: 1px solid var(--border);
  max-height: 340px;
}
.calc-amort-scroll { overflow-y: auto; max-height: 340px; }
.amort-table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px;
}
.amort-table th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px 14px; background: #0d1b2a;
  color: var(--muted); font-weight: 600; text-align: right;
  border-bottom: 1px solid var(--border);
}
.amort-table th:first-child { text-align: left; }
.amort-table td {
  padding: 8px 14px; text-align: right;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text);
}
.amort-table td:first-child { text-align: left; color: var(--muted); }
.amort-table tr:hover td { background: rgba(119,141,169,.05); }

/* ── Header calc button ── */
#calc-btn {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 6px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
#calc-btn:hover, #calc-btn.active { color: var(--accent); background: rgba(119,141,169,.12); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .calc-body { grid-template-columns: 1fr; }
  .calc-inputs { border-right: none; border-bottom: 1px solid var(--border); }
  .calc-chart-wrap { flex-direction: column; }
  #calc-donut { width: 150px; height: 150px; }
  .cmc-amount { font-size: 30px; }
}

/* ── PMI Panel ──────────────────────────────────────────────── */
.pmi-panel {
  background: #1b263b;
  border: 1px solid #ef444430;
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 14px;
}
.pmi-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #ef4444;
  margin-bottom: 12px;
}
.pmi-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}
.pmi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.pmi-cell {
  background: #1d2e42;
  border-radius: 8px;
  padding: 9px 12px;
}
.pmi-cell-wide { grid-column: span 1; }
.pmi-cell-label {
  font-size: 10px;
  color: #4e6d87;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 3px;
}
.pmi-cell-val {
  font-size: 14px;
  font-weight: 700;
  color: #e0e1dd;
}
.accent-red  { color: #ef4444 !important; }
.accent-green { color: #10b981 !important; }
.pmi-progress-wrap { margin-top: 4px; }
.pmi-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #4e6d87;
  margin-bottom: 5px;
}
.pmi-bar-bg {
  position: relative;
  height: 8px;
  background: #1d2e42;
  border-radius: 99px;
  overflow: visible;
  margin-bottom: 6px;
}
.pmi-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f87171);
  border-radius: 99px;
  transition: width .35s ease;
  max-width: 100%;
}
.pmi-bar-mark {
  position: absolute;
  top: -4px;
  left: 80%;
  width: 2px;
  height: 16px;
  background: #10b981;
  border-radius: 2px;
}
.pmi-bar-mark::after {
  content: "80%";
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #10b981;
  white-space: nowrap;
}

/* ── Leads / Nuevas Aplicaciones ────────────────────────────── */
.stat-card-leads { border: 1px solid transparent; transition: border-color .2s; }
.stat-card-leads-active { border-color: #f59e0b55 !important; background: #1b263b; }
.stat-card-leads-active .stat-num { color: #f59e0b; }

.leads-section { margin-bottom: 14px; }
.leads-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.leads-badge {
  background: #f59e0b;
  color: #000;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}
.lead-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #1b263b;
  margin-bottom: 6px;
  border: 1px solid #2a3f58;
  transition: border-color .15s;
}
.lead-pending { border-color: #f59e0b44; }
.lead-icon { font-size: 20px; flex-shrink: 0; }
.lead-info { flex: 1; min-width: 0; }
.lead-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-meta { font-size: 11px; color: #4e6d87; margin-top: 1px; }
.lead-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.lead-status { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.lbadge-pending { background: #f59e0b22; color: #f59e0b; }
.lbadge-done    { background: #10b98122; color: #10b981; }
.lead-date { font-size: 10px; color: #4e6d87; }
