/* MyPortfolio: estilo app de iPhone, oscuro como el logo */
:root {
  --fondo: #0b0f14;
  --tarjeta: #141a22;
  --tarjeta-2: #1b232d;
  --borde: rgba(255, 255, 255, 0.07);
  --texto: #eef2f6;
  --suave: #8b98a7;
  --verde: #34d399;
  --rojo: #f87171;
  --acento: #3ee69a;
  --acento-oscuro: #0f8a5f;
  --valor: #3987e5;      /* paleta validada para el gráfico (modo oscuro) */
  --capital: #d95926;
  --radio: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.35; -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }

.contenido {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 96px);
}

/* Cabecera de cada pantalla */
.cabecera { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.cabecera h1 { font-size: 30px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.subtitulo { color: var(--suave); font-size: 14px; margin-top: 2px; }
.ojo { background: var(--tarjeta-2); border: 0; border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; }
.ojo svg { width: 22px; height: 22px; fill: none; stroke: var(--texto); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Tarjetas */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; margin-bottom: 12px; }
.tarjeta h2 { font-size: 17px; margin: 0 0 10px; }
.tarjeta p { margin: 0 0 12px; }
.destacada { background: linear-gradient(160deg, #13261d 0%, var(--tarjeta) 60%); }
.etiqueta { color: var(--suave); font-size: 14px; }
.cifra-grande { font-size: 38px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.cifra-media { font-size: 30px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.cifra { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.pie { color: var(--suave); font-size: 13px; margin-top: 8px; }
.suave { color: var(--suave); font-weight: 400; }
.fuerte { font-weight: 650; }
.pequeno { font-size: 13px; }
.derecha { text-align: right; }
.sube { color: var(--verde); }
.baja { color: var(--rojo); }
.aviso { color: #fbbf24; }
.nota { color: var(--suave); font-size: 12.5px; margin: 8px 4px 16px; }

/* Selector de periodo (estilo segmentado de iOS) */
.selector { display: flex; gap: 4px; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.selector button { flex: 1; border: 0; background: transparent; padding: 8px 0; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--suave); }
.selector button.activo { background: var(--tarjeta-2); color: var(--texto); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }

/* Gráfico */
.grafico { margin-top: 14px; min-height: 20px; }
.leyenda { color: var(--suave); font-size: 12.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.punto { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-left: 6px; }
.punto:first-child { margin-left: 0; }
.punto.valor { background: var(--valor); }
.punto.capital { background: var(--capital); }
.grafico svg { display: block; touch-action: pan-y; }
.grafico .linea { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.grafico .linea.valor { stroke: var(--valor); }
.grafico .linea.capital { stroke: var(--capital); }
.grafico .guia { stroke: rgba(255, 255, 255, 0.07); }
.grafico .eje { fill: var(--suave); font-size: 11px; }
.grafico .cursor { stroke: rgba(255, 255, 255, 0.4); }
.grafico .marca { stroke: var(--tarjeta); stroke-width: 2; }
.grafico .marca.valor { fill: var(--valor); }
.grafico .marca.capital { fill: var(--capital); }
.grafico .zona { fill: transparent; }
.detalle-grafico { font-size: 13px; color: var(--suave); margin-top: 6px; }

/* Filas (periodos, cuentas) */
.filas { display: flex; flex-direction: column; }
.fila { display: grid; grid-template-columns: 1fr auto 96px; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--borde); font-variant-numeric: tabular-nums; }
.fila:first-child { border-top: 0; }
.fila.cuenta { grid-template-columns: 1fr auto; }
.elegir { background: none; border: 0; text-align: left; display: flex; align-items: center; gap: 10px; padding: 0; font-weight: 600; }
.marca-radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--suave); flex: none; }
.fila.activa .marca-radio { border-color: var(--acento); background: radial-gradient(var(--acento) 45%, transparent 50%); }
.enlace { background: none; border: 0; color: var(--acento); font-weight: 600; }

/* Posiciones */
.rejilla { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.mini { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 14px; padding: 12px; }
.lista { display: flex; flex-direction: column; gap: 8px; }
.posicion { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 12px; }
.posicion .izquierda { min-width: 0; }
.posicion .ticker { font-weight: 700; }
.posicion .hoy { font-size: 12px; font-weight: 600; margin-left: 4px; }
.posicion .nombre { color: var(--suave); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.posicion .detalle { color: var(--suave); font-size: 12px; margin-top: 4px; }
.posicion .derecha { flex: none; font-variant-numeric: tabular-nums; }
.posicion .valor { font-weight: 600; }

/* Botones y formularios */
.boton { display: inline-block; text-align: center; text-decoration: none; border: 1px solid var(--borde); background: var(--tarjeta-2); border-radius: 12px; padding: 13px 16px; font-weight: 600; }
.boton.principal { background: linear-gradient(135deg, var(--acento), var(--acento-oscuro)); color: #04140d; border: 0; }
.boton.secundario { color: var(--acento); }
.boton.peligro { color: var(--rojo); }
.boton.ancho { display: block; width: 100%; margin-top: 8px; }
.boton:disabled { opacity: 0.6; }
.formulario { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.formulario label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--suave); }
.formulario input { background: var(--fondo); border: 1px solid var(--borde); border-radius: 10px; padding: 12px; font-size: 16px; color: var(--texto); }
.formulario .botones { display: flex; gap: 8px; }
.formulario .botones .boton { flex: 1; }

/* Barra de pestañas inferior */
.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: rgba(11, 15, 20, 0.88); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--borde); padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
}
.pestanas button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--suave); padding: 4px 18px; }
.pestanas button.activa { color: var(--acento); }
.pestanas svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Portada (iniciar sesión) */
.portada { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.portada .logo { width: 104px; height: 104px; border-radius: 24px; box-shadow: 0 0 40px rgba(62, 230, 154, 0.25); }
.portada h1 { font-size: 34px; margin: 20px 0 6px; }
.portada p { color: var(--suave); margin: 0 0 26px; }

/* Cargando */
.cargando { display: grid; place-items: center; padding: 60px 0; }
.estado-linea { font-size: 13px; color: var(--suave); display: flex; align-items: center; gap: 8px; margin: -6px 2px 12px; }
.girando { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--borde); border-top-color: var(--acento); animation: girar 0.8s linear infinite; display: inline-block; }
.cargando .girando { width: 28px; height: 28px; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Pestaña Mercado ---------- */
.pulsable { cursor: pointer; }
.pulsable:active { transform: scale(0.99); }
.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(62, 230, 154, 0.14); color: var(--acento); margin-right: 6px; vertical-align: 1px; white-space: nowrap; }
.avance { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.linea-avance { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ver-mas { color: var(--acento); font-weight: 600; font-size: 14px; margin-top: 10px; text-align: right; }

/* Noticias a pantalla completa */
body.sin-scroll { overflow: hidden; }
.hoja { position: fixed; inset: 0; background: var(--fondo); z-index: 20; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.hoja.entrando { animation: subir 0.22s ease-out; }
@keyframes subir { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.hoja-contenido { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px); }
.cerrar { background: var(--tarjeta-2); border: 0; border-radius: 50%; width: 36px; height: 36px; font-size: 16px; }
.chips-filtro { display: flex; gap: 8px; margin-bottom: 14px; }
.chips-filtro button { flex: 1; border: 1px solid var(--borde); background: var(--tarjeta); border-radius: 999px; padding: 9px 0; font-weight: 600; color: var(--suave); }
.chips-filtro button.activo { background: rgba(62, 230, 154, 0.14); border-color: var(--acento); color: var(--acento); }
.grupo { font-size: 17px; margin: 18px 2px 8px; }
.noticia { display: block; text-decoration: none; color: inherit; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.noticia .titular { font-weight: 600; font-size: 15px; }
.noticia .medio { display: block; color: var(--suave); font-size: 12.5px; margin-top: 6px; }

/* Calendario de resultados */
.cabecera-mes { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cabecera-mes h2 { margin: 0; font-size: 16px; text-transform: capitalize; }
.flecha { background: var(--tarjeta-2); border: 0; border-radius: 10px; width: 36px; height: 32px; font-size: 20px; line-height: 1; }
.semana, .rejilla-mes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.semana span { text-align: center; font-size: 11px; color: var(--suave); font-weight: 600; padding-bottom: 4px; }
.celda { min-width: 0; min-height: 62px; background: var(--fondo); border: 1px solid var(--borde); border-radius: 8px; padding: 3px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; overflow: hidden; }
.celda.vacia { background: transparent; border-color: transparent; }
.celda .num { font-size: 12px; color: var(--suave); }
.celda.hoy .num { background: var(--acento); color: #04140d; border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; font-weight: 700; }
.celda.con { border-color: rgba(62, 230, 154, 0.35); }
.celda.elegida { outline: 2px solid var(--acento); outline-offset: -1px; }
.tk { font-size: 9px; font-weight: 700; line-height: 1.25; padding: 0 3px; border-radius: 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk.sube { background: rgba(52, 211, 153, 0.18); color: var(--verde); }
.tk.baja { background: rgba(248, 113, 113, 0.18); color: var(--rojo); }
.tk.proxima { background: rgba(57, 135, 229, 0.22); color: #8fc0ff; }
.tk.estimada { border: 1px dashed var(--suave); color: var(--suave); }
.tk.mas { color: var(--suave); }
.leyenda-cal { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 11.5px; color: var(--suave); margin-top: 10px; }
.leyenda-cal .tk { font-size: 10px; }
.detalle-dia { margin-top: 14px; border-top: 1px solid var(--borde); padding-top: 12px; }
.detalle-dia h3 { margin: 0 0 8px; font-size: 15px; }
.evento { padding: 8px 0; border-top: 1px solid var(--borde); }
.evento:first-of-type { border-top: 0; }
.pestanas button { padding: 4px 10px; }
.enlace-informe { display: inline-block; margin-top: 6px; color: var(--acento); font-weight: 600; font-size: 14px; text-decoration: none; }
.acciones-informe { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 6px; }
.acciones-informe .enlace-informe { margin-top: 0; }
.boton.claude { padding: 8px 12px; font-size: 14px; background: rgba(217, 119, 87, 0.16); color: #f0a58a; border-color: rgba(217, 119, 87, 0.4); }
.nombre-empresa { background: none; border: 0; padding: 0; text-align: left; font-size: 15px; }
.nombre-empresa .ir { color: var(--acento); }
.tras-resultados { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.tras-resultados a { color: var(--texto); text-decoration: none; font-size: 13.5px; border-left: 2px solid var(--borde); padding-left: 8px; }
.widget { padding: 4px; overflow: hidden; }
.posicion.pulsable:active { transform: scale(0.99); }
