/* ============================================================
   Analizador Monkey Money — estilos del módulo "Pro"
   (escenarios, sensibilidad, indicadores avanzados, cartera, copia de seguridad, impresión)
   Funciona en modo claro y oscuro, computador y celular.
   ============================================================ */

/* Texto en español / inglés para el HTML estático nuevo */
.l-en { display: none; }
html[lang="en"] .l-es { display: none !important; }
html[lang="en"] .l-en { display: inline !important; }
html:not([lang="en"]) .l-en { display: none !important; }

/* Lo avanzado solo se ve en modo Avanzado */
body:not(.mode-adv) .adv-only { display: none !important; }
body.no-ai-lookup .field-lookup-btn { display: none !important; }

/* ---------- Escenarios ---------- */
.scenario-card { margin-top: 12px; }
.scenario-card:empty { display: none; }
.scn-lead { margin: 4px 0 12px; font-size: 13px; line-height: 1.5; color: #4a5b55; }
.scn-foot { margin: 12px 0 0; font-size: 11.5px; color: #55665f; }
.scn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.scn-item { border: 1px solid #d9e2d5; border-top: 4px solid #94a3b8; border-radius: 10px; padding: 10px 12px; background: #f7fbf4; text-align: center; }
.scn-item.bad { border-top-color: #dc3545; }
.scn-item.good { border-top-color: #15803d; }
.scn-item.base { border-top-color: #176d67; background: #fff; }
.scn-head { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; }
.scn-big { font-size: 26px; font-weight: 800; line-height: 1.2; margin-top: 6px; color: #11693a; }
.scn-big.neg { color: #b4232f; }
.scn-sub { font-size: 11px; color: #55665f; }
.scn-final { font-size: 14px; font-weight: 700; margin-top: 6px; }
.scn-chip { margin-top: 8px; display: flex; justify-content: center; }
.scn-note { margin-top: 8px; font-size: 11px; line-height: 1.4; color: #55665f; }
.scn-chip .eval { display: inline-flex; align-items: center; gap: 6px; }
.scn-chip .eval img, .indicator-row .eval img { width: 18px; height: 18px; object-fit: contain; }

/* ---------- Tabla de sensibilidad ---------- */
.sens-scroll { overflow-x: auto; }
.sens-table { border-collapse: separate; border-spacing: 4px; width: 100%; font-size: 13px; text-align: center; }
.sens-table th { font-weight: 700; padding: 6px 8px; font-size: 12px; color: #34463f; white-space: nowrap; }
.sens-table th small { display: block; font-weight: 500; opacity: .75; }
.sens-table thead th:first-child { text-align: left; font-size: 11px; white-space: normal; max-width: 150px; }
.sens-table td { padding: 8px 6px; border-radius: 8px; font-weight: 700; min-width: 64px; }
.sens-neg { background: #fde5e8; color: #8f1d2c; }
.sens-low { background: #ffe7b0; color: #6a4100; }
.sens-mid { background: #eaf0ea; color: #2c3b37; }
.sens-high { background: #d4f0d4; color: #0e5b30; }
.sens-na { background: #eef1ee; color: #55665f; }
.sens-base { outline: 3px solid #176d67; outline-offset: -1px; }
.sens-base-h { color: #176d67 !important; text-decoration: underline; text-underline-offset: 3px; }
.sens-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin: 0 4px 0 10px; vertical-align: -1px; }
.sens-key.neg { background: #fbc9d0; } .sens-key.low { background: #ffd98a; } .sens-key.mid { background: #d5dfd5; } .sens-key.high { background: #aee3ae; }

/* ---------- Cartera ---------- */
.port-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.port-kpis .kpi { padding: 12px; text-align: center; }
.port-kpis .kpi small { display: block; font-size: 12px; color: #4a5b55; }
.port-kpis .kpi b { display: block; font-size: 22px; margin-top: 4px; }
.port-msg { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: #e7f3ec; color: #14402d; font-size: 14px; line-height: 1.5; }
.port-note { margin: 10px 0 0; font-size: 12px; color: #55665f; line-height: 1.5; }
.port-empty { text-align: center; padding: 28px 18px; }
.port-empty-icon { font-size: 40px; color: #176d67; }
.port-empty p { max-width: 52ch; margin: 8px auto 0; color: #4a5b55; font-size: 14px; line-height: 1.5; }
.port-bar { margin: 10px 0 14px; }
.port-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.port-bar-track { height: 12px; border-radius: 99px; background: #e4ece4; overflow: hidden; }
.port-bar-track i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #176d67, #38a169); }
.port-bar small { font-size: 11.5px; color: #55665f; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.port-list { display: flex; flex-direction: column; gap: 6px; }
.port-row { display: grid; grid-template-columns: 22px 28px minmax(0, 1fr) auto 46px auto; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid #d9e2d5; border-radius: 10px; background: #fff; cursor: pointer; font-size: 13px; }
.port-row.off { opacity: .55; }
.port-name { display: flex; flex-direction: column; min-width: 0; }
.port-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port-name small { color: #55665f; font-size: 11.5px; }
.port-amt, .port-w { text-align: right; font-weight: 700; white-space: nowrap; }
.port-v { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.port-v.good { background: #d4f0d4; color: #0e5b30; }
.port-v.neutral { background: #ffe7b0; color: #6a4100; }
.port-v.bad { background: #fbd6db; color: #8f1d2c; }
.port-adv { margin-top: 12px; }

/* ---------- Copia de seguridad / botones ---------- */
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.backup-btn { cursor: pointer; border: 1px solid #176d67; background: #fff; color: #176d67; border-radius: 99px; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 700; }
.backup-btn:hover { background: #176d67; color: #fff; }
.backup-msg { min-height: 1.2em; margin: 6px 4px 12px; font-size: 13px; color: #0e5b30; }
.backup-msg.bad { color: #b4232f; }
.print-btn { cursor: pointer; border: 1px solid #176d67; background: #fff; color: #176d67; border-radius: 99px; padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 700; margin-left: 8px; }
.print-btn:hover { background: #176d67; color: #fff; }

/* ---------- Datos sugeridos por IA ---------- */
.from-ai { border-color: #d97706 !important; background-image: repeating-linear-gradient(135deg, rgba(217,119,6,.10) 0 6px, transparent 6px 12px) !important; }
.ai-note { margin: 10px 4px 0; font-size: 12px; line-height: 1.5; color: #55665f; }
.lookup-warn { margin: 6px 0; font-size: 12px; color: #8a5600; }

/* ---------- Modo oscuro ---------- */
body.dark .scn-lead, body.dark .scn-foot, body.dark .scn-sub, body.dark .scn-note, body.dark .port-note, body.dark .ai-note, body.dark .port-name small, body.dark .port-bar small, body.dark .port-empty p, body.dark .port-kpis .kpi small { color: #a9c0b9; }
body.dark .scn-item { background: #17313b; border-color: #2d4a55; }
body.dark .scn-item.base { background: #1b3944; }
body.dark .scn-item.bad { border-top-color: #ef6f7c; } body.dark .scn-item.good { border-top-color: #4ade80; } body.dark .scn-item.base { border-top-color: #5eead4; }
body.dark .scn-big { color: #6ee7a0; } body.dark .scn-big.neg { color: #ff9aa5; }
body.dark .scn-final, body.dark .scn-head { color: #dbe9e4; }
body.dark .sens-table th { color: #cfe4d8; }
body.dark .sens-neg { background: #46202a; color: #ffb4bd; } body.dark .sens-low { background: #43330f; color: #f5c96a; }
body.dark .sens-mid { background: #1f3338; color: #cfe4d8; } body.dark .sens-high { background: #17402a; color: #7ee2a3; }
body.dark .sens-na { background: #1f3338; color: #a9c0b9; }
body.dark .sens-base { outline-color: #5eead4; } body.dark .sens-base-h { color: #5eead4 !important; }
body.dark .port-msg { background: #17402a; color: #cdeedd; }
body.dark .port-bar-track { background: #24373a; }
body.dark .port-row { background: #17313b; border-color: #2d4a55; color: #dbe9e4; }
body.dark .port-v.good { background: #17402a; color: #7ee2a3; } body.dark .port-v.neutral { background: #43330f; color: #f5c96a; } body.dark .port-v.bad { background: #46202a; color: #ffb4bd; }
body.dark .backup-btn, body.dark .print-btn { background: transparent; color: #7be0cf; border-color: #4aa99b; }
body.dark .backup-btn:hover, body.dark .print-btn:hover { background: #1f7a70; color: #fff; }
body.dark .backup-msg { color: #7ee2a3; } body.dark .backup-msg.bad { color: #ff9aa5; }
body.dark .lookup-warn { color: #f5c96a; }
body.dark .from-ai { border-color: #f5b84a !important; }

/* ---------- Celular ---------- */
@media (max-width: 760px) {
  .port-kpis { grid-template-columns: 1fr; }
  .port-row { grid-template-columns: 22px 24px minmax(0, 1fr) auto; }
  .port-w { display: none; }
  .port-v { grid-column: 3 / -1; justify-self: start; }
  .sens-table td { min-width: 54px; padding: 7px 4px; font-size: 12px; }
  .print-btn { margin: 8px 0 0; }
}

/* ---------- Imprimir / guardar como PDF ---------- */
.print-header { display: none; }
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; color: #111 !important; }
  header.site-header, footer, .topbar, .sidebar, .mobile-menu-btn, .mode-switch, .toggle-details-btn, .save-analysis-btn, .print-btn,
  #aiNote, .field-lookup-btn, .print-skip, .loan-card, .mm-share-float, .mm-chat-btn, .mm-chat-panel, #mm-player, body:after, .page-head .mode-switch { display: none !important; }
  .app { min-width: 0 !important; background: #fff !important; display: block !important; }
  .main { padding: 0 !important; width: 100% !important; }
  .columns { display: block !important; }
  .rightcol { display: block !important; margin-top: 10px; }
  .card, .scn-item, .kpi-card, .verdict, .return { box-shadow: none !important; break-inside: avoid; border: 1px solid #bbb !important; background: #fff !important; color: #111 !important; }
  .page:not(.active-page) { display: none !important; }
  .print-header { display: block; margin-bottom: 12px; }
  .print-brand { display: flex; justify-content: space-between; font-size: 12px; color: #444; border-bottom: 2px solid #176d67; padding-bottom: 4px; }
  .print-header h1 { font-size: 20px; margin: 10px 0 6px; color: #111 !important; }
  .print-table { border-collapse: collapse; width: 100%; font-size: 11px; margin-bottom: 8px; }
  .print-table td { border: 1px solid #ccc; padding: 3px 6px; }
  .print-disc { font-size: 10px; color: #555; margin: 6px 0 0; }
  .eval, .verdict-pill, .port-v, .sens-table td, .scn-item { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  * { text-shadow: none !important; }
  .scn-lead, .scn-foot, .scn-note, .scn-sub, .port-note { color: #333 !important; }
}

.port-mode { margin: 0 0 12px; display: inline-flex; }
@media print { .port-mode { display: none !important; } }

/* ---------- Escenarios: se adaptan al ancho de su propia tarjeta (columna central o celular) ---------- */
.scenario-card { container-type: inline-size; }
.scn-head { flex-direction: column; gap: 2px; }
.scn-head span { font-size: 18px; line-height: 1; }
.scn-chip .eval, .indicator-row .eval { white-space: nowrap; flex: none; margin: 0; }
.scn-chip .eval { font-size: 11.5px; }
@container (max-width: 560px) {
  .scn-grid { grid-template-columns: 1fr; }
  .scn-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "head big" "note sub" "final chip"; gap: 4px 12px; text-align: left; align-items: center; }
  .scn-head { grid-area: head; flex-direction: row; justify-content: flex-start; gap: 8px; }
  .scn-big { grid-area: big; font-size: 22px; margin: 0; text-align: right; }
  .scn-sub { grid-area: sub; text-align: right; }
  .scn-note { grid-area: note; margin: 0; text-align: left; }
  .scn-final { grid-area: final; margin: 0; }
  .scn-chip { grid-area: chip; justify-content: flex-end; margin: 0; }
}

/* Tabla de sensibilidad más compacta (cabe en la columna central) */
.sens-axes { margin: 0 0 8px; font-size: 12px; color: #34463f; }
body.dark .sens-axes { color: #cfe4d8; }
.sens-table { border-spacing: 3px; }
.sens-table th { padding: 5px 3px; font-size: 11.5px; }
.sens-table td { min-width: 0; padding: 7px 2px; font-size: 12.5px; }
.sens-corner { width: 44px; font-size: 11px !important; color: #55665f; }
body.dark .sens-corner { color: #a9c0b9; }

/* Espacio interno de los bloques nuevos dentro de sus tarjetas */
.scn-lead, .scn-foot, .sens-axes, .ai-note { padding-left: 14px; padding-right: 14px; }
.scn-grid, .port-bar, .port-list { margin-left: 14px; margin-right: 14px; }
.port-list { margin-bottom: 14px; }
.sens-scroll { padding: 0 10px 4px; }
.port-adv .port-note, .card .port-note { padding: 0 14px 14px; }
.scn-foot { padding-bottom: 12px; }
