/* ============================================================
   Asesor Financiero de Élite — estilos (paleta validada, modo claro/oscuro)
   ============================================================ */
:root {
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --ink-1:       #0b0b0b;
  --ink-2:       #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --baseline:    #c3c2b7;
  --border:      rgba(11, 11, 11, 0.10);
  --chat-bg:     #f1f5f9;   /* fondo del hilo de chat */
  --s-income:    #2a78d6;   /* azul  — ingresos / progreso */
  --s-expense:   #e34948;   /* rojo  — gastos */
  --good:        #006300;
  --critical:    #d03b3b;
  --accent:      #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page:      #0d0d0d;
    --surface:   #1a1a19;
    --ink-1:     #ffffff;
    --ink-2:     #c3c2b7;
    --muted:     #898781;
    --grid:      #2c2c2a;
    --baseline:  #383835;
    --border:    rgba(255, 255, 255, 0.10);
    --chat-bg:   #131315;
    --s-income:  #3987e5;
    --s-expense: #e66767;
    --good:      #0ca30c;
    --critical:  #d03b3b;
    --accent:    #3987e5;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink-1);
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--critical); font-size: 0.9rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Botones ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-1);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 0.9rem;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7a5fd0);
  color: #fff; border-color: transparent; letter-spacing: 0.015em;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}
.btn-primary:hover {
  filter: brightness(1.07); transform: translateY(-1.5px);
  box-shadow: 0 7px 18px rgba(42, 120, 214, 0.38);
}
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 10px; font-size: 0.8rem; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; margin-top: 12px; font-size: 0.85rem; }
.btn-del { background: none; border: none; color: var(--muted); cursor: pointer; }
.btn-del:hover { color: var(--critical); }

/* ---------- Acceso ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px; width: 100%; max-width: 400px; text-align: center;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; }
.brand h1 { font-size: 1.3rem; margin: 0; }
.brand h1 span { color: var(--accent); }
.brand.small strong { font-size: 1rem; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.auth-sub { color: var(--ink-2); margin: 8px 0 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-form label { font-size: 0.8rem; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
input, select {
  background: var(--page); color: var(--ink-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: 0.9rem; font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* ---------- Estructura ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar-right { display: flex; gap: 12px; align-items: center; }
.layout {
  display: grid; grid-template-columns: 1fr 380px; gap: 20px;
  padding: 20px 24px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }
.col-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h2 { font-size: 1rem; margin: 0; }

/* ---------- Análisis de Sofía (burbuja de diálogo) ---------- */
.sofia-insight-card {
  display: flex; gap: 14px; align-items: flex-start;
  background: linear-gradient(135deg, rgba(122, 95, 208, 0.12), rgba(42, 120, 214, 0.08));
  border-color: rgba(122, 95, 208, 0.30);
}
.insight-avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  object-position: center 26%; border: 2px solid var(--accent); flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(42, 120, 214, 0.30);
}
.insight-bubble {
  position: relative; flex: 1; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px 12px;
}
.insight-bubble::before {
  content: ''; position: absolute; left: -7px; top: 20px;
  width: 12px; height: 12px; background: var(--surface);
  border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}
.insight-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
#insight-text { margin: 6px 0 0; font-size: 0.88rem; line-height: 1.5; color: var(--ink-2); }

/* ---------- Fichas KPI (rejilla asimétrica + micro-interacciones) ---------- */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
  position: relative; grid-column: span 2;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12); }
.tile-ico { position: absolute; top: 14px; right: 14px; color: var(--muted); opacity: 0.85; }
.hero-tile {
  grid-column: span 3;
  background: linear-gradient(135deg, rgba(42, 120, 214, 0.13), rgba(122, 95, 208, 0.10));
  border-color: rgba(42, 120, 214, 0.32);
}
.hero-tile .tile-value { font-size: 2rem; }
.hero-tile .tile-ico { color: var(--accent); }
.tile-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tile-value { font-size: 1.45rem; font-weight: 680; }
.tile-value.positive { color: var(--good); }
.tile-value.negative { color: var(--critical); }

/* ---------- Formularios embebidos ---------- */
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.inline-form input, .inline-form select { flex: 1 1 130px; }

/* ---------- Metas (anillos) ---------- */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.goal { text-align: center; padding: 10px 6px; border: 1px solid var(--border); border-radius: 12px; position: relative; }
.goal-name { font-size: 0.85rem; font-weight: 600; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-meta { font-size: 0.75rem; color: var(--ink-2); }
.goal-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 5px 10px;
  padding: 10px 12px 2px; text-align: left;
}
.goal-grid span {
  color: var(--muted); font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.06em; align-self: center;
}
.goal-grid b {
  text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 0.82rem; color: var(--ink-1);
}
.goal-grid b.neg { color: var(--critical); }
.goal-bar {
  height: 8px; border-radius: 5px; background: var(--grid);
  overflow: hidden; margin: 8px 10px 0;
}
.goal-bar > div { height: 100%; border-radius: 5px; min-width: 4px; transition: width 0.5s ease; }
.goal .btn-del { position: absolute; top: 6px; right: 8px; }
.goal-actions { margin-top: 10px; display: flex; gap: 6px; justify-content: center; align-items: stretch; }
.goal-actions input {
  width: 92px; padding: 7px 12px; font-size: 0.82rem;
  border-radius: 10px; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.goal-actions input:focus { box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.20); outline: none; border-color: var(--accent); }
.goal-actions .btn {
  min-width: 38px; border-radius: 10px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), #7a5fd0); border-color: transparent;
  box-shadow: 0 2px 8px rgba(42, 120, 214, 0.30);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.goal-actions .btn:hover { transform: translateY(-1.5px) scale(1.04); box-shadow: 0 6px 14px rgba(42, 120, 214, 0.42); }

/* ---------- Gráficos ---------- */
.chart-box { width: 100%; overflow-x: auto; }
.chart-box svg { display: block; }
.legend { display: flex; gap: 16px; margin: 4px 0 8px; font-size: 0.8rem; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.tooltip {
  position: fixed; pointer-events: none; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 0.78rem; color: var(--ink-1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18); max-width: 240px;
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }

/* ---------- FODA ---------- */
.foda-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .foda-grid { grid-template-columns: 1fr; } }
.foda-quad {
  border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.foda-quad:hover { transform: translateY(-1.5px); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08); }
.foda-fortaleza   { border-left-color: #10b981; }
.foda-oportunidad { border-left-color: var(--accent); }
.foda-debilidad   { border-left-color: #f59e0b; }
.foda-amenaza     { border-left-color: var(--critical); }
.foda-fortaleza h3   { color: #10b981; }
.foda-oportunidad h3 { color: var(--accent); }
.foda-debilidad h3   { color: #d97706; }
.foda-amenaza h3     { color: var(--critical); }
.foda-quad h3 { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.foda-quad ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.foda-quad li { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; }
.foda-param { color: var(--muted); font-size: 0.75rem; }

/* ---------- Libro contable: lista estilo neobanco ---------- */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tx-row:hover { transform: translateY(-1.5px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.09); }
.tx-ico {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
}
.ico-in      { background: rgba(12, 163, 12, 0.12);  color: var(--good); }
.ico-out     { background: rgba(227, 73, 72, 0.10);  color: var(--s-expense); }
.ico-inv     { background: rgba(42, 120, 214, 0.12); color: var(--accent); }
.ico-aho     { background: rgba(122, 95, 208, 0.14); color: #7a5fd0; }
.ico-neutral { background: rgba(137, 135, 129, 0.14); color: var(--muted); }
.tx-main { flex: 1; min-width: 0; }
.tx-desc {
  font-size: 0.88rem; font-weight: 620;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tx-sub { font-size: 0.72rem; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tx-cat { text-transform: capitalize; }
.pill {
  padding: 2px 9px; border-radius: 999px; font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.02em;
}
.pill-in   { background: rgba(12, 163, 12, 0.12);   color: var(--good); }
.pill-fijo { background: rgba(122, 95, 208, 0.14);  color: #8b7bd8; }
.pill-var  { background: rgba(237, 161, 0, 0.16);   color: #c98500; }
.pill-inv  { background: rgba(42, 120, 214, 0.13);  color: var(--accent); }
.pill-aho  { background: rgba(27, 175, 122, 0.14);  color: #1baf7a; }
.tx-amount {
  font-weight: 720; font-variant-numeric: tabular-nums; white-space: nowrap;
  font-size: 0.92rem; text-align: right;
}
.tx-amount.in { color: var(--good); }
.tx-approx { display: block; font-size: 0.68rem; color: var(--muted); font-weight: 500; }
.tx-del { opacity: 0.35; transition: opacity 0.15s; }
.tx-row:hover .tx-del { opacity: 1; }

/* ---------- Alertas ---------- */
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.alerts li { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; font-size: 0.85rem; }
.alerts li.tipo-limite_diario { border-left-color: var(--critical); }
.alerts li .alert-title { font-weight: 600; display: block; }
.alerts li .alert-msg { color: var(--ink-2); white-space: pre-line; }
.alerts li .alert-actions { margin-top: 6px; }

/* ---------- Chat de Sofía: cabecera fija compacta ---------- */
.col-avatar { display: flex; flex-direction: column; gap: 12px; align-self: start; position: sticky; top: 76px; max-height: calc(100vh - 96px); }
.chat-header {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: 4px 4px 10px; background: var(--surface);
  border-bottom: 1px solid var(--grid);
}
.chat-head-info { flex: 1; min-width: 0; text-align: left; }
.chat-head-info h2 { margin: 0; font-size: 1.06rem; font-weight: 700; letter-spacing: 0.01em; }
.chat-status {
  margin: 2px 0 0; font-size: 0.72rem; color: var(--muted);
  display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden;
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #10b981; flex-shrink: 0;
  animation: dot-pulse 2.4s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 2.5px rgba(16, 185, 129, 0.20); }
  50%      { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.06); }
}
.voice-btn {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; cursor: pointer;
  color: var(--muted); border: 1px solid var(--border);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.voice-btn:hover { color: var(--accent); border-color: var(--accent); }
.voice-btn .v-off { display: none; }
.voice-btn:has(input:not(:checked)) .v-on { display: none; }
.voice-btn:has(input:not(:checked)) .v-off { display: block; }
.voice-btn:has(input:not(:checked)) { color: var(--critical); }
.avatar-figure {
  width: 56px; height: 56px; position: relative; flex-shrink: 0;
  display: grid; place-items: center;
}
.avatar-core {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #7a5fd0);
  color: #fff; display: grid; place-items: center; z-index: 2;
  overflow: hidden; border: 2px solid var(--accent);
  box-shadow: 0 3px 12px rgba(42, 120, 214, 0.32);
}
.avatar-img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 26%;
  border-radius: 50%; display: block;
}
/* Al hablar: la imagen "habla" con un vaivén rítmico */
.speaking .avatar-img { animation: talk-bob 0.38s ease-in-out infinite alternate; }
@keyframes talk-bob {
  from { transform: scale(1.00) rotate(-0.8deg) translateY(0); }
  to   { transform: scale(1.05) rotate(1.0deg)  translateY(-1.5px); }
}
/* Ecualizador de voz bajo el avatar */
.voice-eq {
  display: flex; gap: 3px; justify-content: center; align-items: flex-end;
  height: 16px; margin: 0 2px; opacity: 0; transition: opacity 0.25s; flex-shrink: 0;
}
.chat-header:has(.avatar-figure.speaking) .voice-eq { opacity: 1; }
.voice-eq span {
  width: 4px; height: 100%; background: var(--accent); border-radius: 2px;
  transform-origin: bottom; animation: eq-bounce 0.7s ease-in-out infinite;
}
.voice-eq span:nth-child(1) { animation-delay: 0s; }
.voice-eq span:nth-child(2) { animation-delay: 0.15s; }
.voice-eq span:nth-child(3) { animation-delay: 0.3s; }
.voice-eq span:nth-child(4) { animation-delay: 0.1s; }
.voice-eq span:nth-child(5) { animation-delay: 0.25s; }
@keyframes eq-bounce {
  0%, 100% { transform: scaleY(0.25); }
  50%      { transform: scaleY(1); }
}
.ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0; z-index: 1;
}
.avatar-figure.speaking .ring { animation: pulse 1.8s ease-out infinite; }
.avatar-figure.speaking .r2 { animation-delay: 0.6s; }
.avatar-figure.speaking .r3 { animation-delay: 1.2s; }
@keyframes pulse {
  0%   { transform: scale(0.75); opacity: 0.7; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* ---- Sofía animada: respira, parpadea y mueve la boca al hablar ---- */
.avatar-core { animation: idle-sway 5s ease-in-out infinite; }
@keyframes idle-sway {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(2.5px) rotate(-1.2deg); }
}
.sofia-svg .lid { transform-origin: center 45px; transform: scaleY(0); animation: blink 4.6s infinite; }
.sofia-svg .eye:last-of-type .lid { animation-delay: 0.05s; }
@keyframes blink {
  0%, 93%, 100% { transform: scaleY(0); }
  95.5%, 97.5%  { transform: scaleY(1); }
}
.sofia-svg .mouth { transform-origin: 60px 73px; transform: scaleY(0.32); transition: transform 0.15s; }
.sofia-svg .smile { opacity: 1; }
.speaking .sofia-svg .mouth { animation: talk 0.26s ease-in-out infinite alternate; }
.speaking .sofia-svg .smile { opacity: 0; }
@keyframes talk {
  from { transform: scaleY(0.25) scaleX(0.9); }
  to   { transform: scaleY(1.1)  scaleX(1.05); }
}
.listening .sofia-svg { filter: drop-shadow(0 0 6px rgba(57, 135, 229, 0.8)); }
.listening .avatar-core {
  border-color: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.25), 0 0 22px rgba(52, 211, 153, 0.6);
}

/* ---- Adjuntar imagen y micrófono ---- */
.btn-icon { padding: 8px 10px; font-size: 1.05rem; line-height: 1; display: grid; place-items: center; cursor: pointer; }
.btn-icon.recording { background: var(--critical); border-color: transparent; animation: rec-pulse 1.2s ease-in-out infinite; }
@keyframes rec-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
.image-preview {
  display: flex; align-items: center; gap: 8px;
  border: 1px dashed var(--border); border-radius: 10px; padding: 6px 8px;
}
.image-preview img { height: 52px; border-radius: 6px; }
.msg .msg-img { max-width: 100%; border-radius: 8px; margin-top: 6px; display: block; }

.chat-log {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 11px;
  padding: 14px 10px; min-height: 220px;
  background: var(--chat-bg); border-radius: 14px;
}
.msg {
  max-width: 86%; padding: 11px 15px; border-radius: 18px;
  font-size: 0.87rem; line-height: 1.55; white-space: pre-wrap;
}
.msg.user {
  align-self: flex-end; margin-left: 14%;
  background: linear-gradient(135deg, var(--accent), #7a5fd0); color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 3px 10px rgba(42, 120, 214, 0.25);
}
.msg.assistant {
  align-self: flex-start; margin-right: 14%;
  background: var(--surface); border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.msg.action {
  align-self: center; background: transparent; border: 1px dashed var(--good);
  color: var(--good); font-size: 0.78rem; padding: 5px 10px; border-radius: 999px;
}
/* Caja de entrada minimalista (píldora con iconos integrados) */
.chat-form {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 6px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.07);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.chat-form:focus-within { border-color: var(--accent); box-shadow: 0 3px 16px rgba(42, 120, 214, 0.18); }
.chat-form input {
  flex: 1; border: none; background: transparent; box-shadow: none;
  min-height: 40px; padding: 6px 8px; min-width: 0;
}
.chat-form input:focus { outline: none; border: none; }
.chat-icon-btn {
  width: 38px; height: 38px; min-height: 38px; border-radius: 50%; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0; padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.chat-icon-btn:hover { background: rgba(42, 120, 214, 0.10); color: var(--accent); }
.chat-icon-btn.recording {
  background: var(--critical); color: #fff;
  animation: rec-pulse 1.2s ease-in-out infinite;
}
.chat-send {
  width: 40px; height: 40px; min-height: 40px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), #7a5fd0); color: #fff;
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0; padding: 0;
  box-shadow: 0 3px 10px rgba(42, 120, 214, 0.35);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}
.chat-send:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(42, 120, 214, 0.45); }
.chat-send:active { transform: scale(0.88); }
.chat-send:disabled { opacity: 0.55; transform: none; }

/* ---------- Meta Norte (hero) ---------- */
.hero-card {
  background: linear-gradient(135deg, var(--accent) 0%, #7a5fd0 100%);
  border: none; color: #fff;
}
.hero-card .muted { color: rgba(255,255,255,0.75); }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.hero-value { font-size: 1.6rem; font-weight: 750; margin: 8px 0 10px; }
.hero-bar {
  height: 10px; border-radius: 999px; background: rgba(255,255,255,0.25); overflow: hidden;
}
.hero-bar-fill {
  height: 100%; border-radius: 999px; background: #fff;
  transition: width 0.6s ease;
}
.hero-sub { margin-top: 8px; font-size: 0.82rem; }

/* ---------- Top categorías (barras de progreso) ---------- */
.cats-list { display: flex; flex-direction: column; gap: 12px; }
.cat-row { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.cat-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cat-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-2); text-transform: capitalize; font-weight: 550;
}
.cat-val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.cat-track { height: 10px; border-radius: 6px; background: var(--grid); overflow: hidden; }
.cat-fill {
  height: 100%; border-radius: 6px; min-width: 6px;
  background: linear-gradient(90deg, var(--accent), #7a5fd0);
  transition: width 0.5s ease;
}

/* ---------- Navegación inferior (app nativa) ---------- */
.bottom-nav { display: none; }

/* ---------- Móvil primero: la app vive en el teléfono ---------- */
@media (max-width: 1000px) {
  /* El avatar y el chat de Sofía van ARRIBA: es el corazón de la app */
  .layout { display: flex; flex-direction: column; padding: 12px; gap: 14px; }
  .col-avatar { order: -1; position: static; max-height: none; }
  .chat-log { min-height: 160px; }
  .chat-header { top: 56px; }

  /* Objetivos táctiles cómodos (≥44px) */
  .btn { min-height: 44px; }
  .chat-icon-btn, .chat-send { width: 42px; height: 42px; min-height: 42px; }
  .btn-small { min-height: 38px; }
  input, select { min-height: 44px; font-size: 16px; } /* 16px evita el auto-zoom de iOS */
  .inline-form input, .inline-form select { flex: 1 1 100%; }

  .card { padding: 14px; border-radius: 12px; }
  .tiles { gap: 8px; }
  .tile { padding: 12px; }
  .tile-value { font-size: 1.15rem; }
  .hero-tile .tile-value { font-size: 1.45rem; }
  .insight-avatar { width: 46px; height: 46px; }
  .goals-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .topbar { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}
@media (max-width: 420px) {
  .hero-tile { grid-column: span 6; }
  .tile:not(.hero-tile) { grid-column: span 3; }
  .tile:not(.hero-tile):last-child { grid-column: span 6; }
}

/* ---------- Pestañas móviles: una sección a la vez, como app de banco ---------- */
@media (max-width: 1000px) {
  .layout { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  [data-tabpane] { display: none !important; }
  [data-tabpane].tab-on { display: block !important; }
  .col-avatar[data-tabpane].tab-on { display: flex !important; }
  .col-avatar { min-height: calc(100vh - 190px); }
  .chat-log { max-height: none; flex: 1; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button {
    flex: 1; background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 0.64rem; color: #94a3b8; padding: 6px 0 8px; position: relative;
    min-height: 50px; font-family: inherit; letter-spacing: 0.01em;
    transition: color 0.18s ease;
  }
  .bottom-nav button .nav-ico { transition: transform 0.18s ease; }
  .bottom-nav button.active { color: var(--accent); font-weight: 650; }
  .bottom-nav button.active .nav-ico { transform: translateY(-1.5px); }
  .bottom-nav button.active::after {
    content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
    width: 18px; height: 3px; border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), #7a5fd0);
    box-shadow: 0 0 8px rgba(42, 120, 214, 0.55);
  }
  .nav-badge {
    position: absolute; top: 2px; right: 24%;
    background: var(--critical); color: #fff; font-size: 0.62rem; font-weight: 700;
    min-width: 16px; height: 16px; border-radius: 999px;
    display: grid; place-items: center; padding: 0 4px;
  }
}
