/* Oscuro azul marino, acento esmeralda/cielo, cifras monoespaciadas.
   Mobile-first: la base es el teléfono; los @media amplían a escritorio. */

@font-face { font-family: "Jakarta"; font-weight: 400; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Jakarta"; font-weight: 500; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Jakarta"; font-weight: 600; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Jakarta"; font-weight: 700; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Jakarta"; font-weight: 800; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family: "JBMono"; font-weight: 400; font-display: swap; src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "JBMono"; font-weight: 600; font-display: swap; src: url(fonts/jetbrains-mono-latin-600-normal.woff2) format("woff2"); }

:root {
  --bg: #0b0f17;
  --card: #111827;
  --card-2: #0f1522;
  --border: #1f2937;
  --border-2: #374151;
  --text: #e5e7eb;
  --strong: #f9fafb;
  --muted: #94a3b8;
  --brand: #10b981;
  --brand-600: #059669;
  --sky: #38bdf8;
  --up: #34d399;
  --down: #f87171;
  --amber: #f59e0b;
  --violet: #a78bfa;
  --radius: 16px;
  --nav-h: 66px;
  --mono: "JBMono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

/* Toda columna de cuadrícula puede encogerse: una columna `auto` o `1fr` crece hasta el
   texto más ancho que no se parte (un nombre largo de ETF, una tabla) y ensancha la página
   del teléfono. Pasó tres veces; tests/test_css.py lo vigila. */
* { box-sizing: border-box; grid-auto-columns: minmax(0, 1fr); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 "Jakarta", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
a { color: var(--sky); }
h1, h2 { line-height: 1.2; margin: 0 0 .4rem; color: var(--strong); font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; font-weight: 700; }
code { font-family: var(--mono); font-size: .85em; background: var(--card-2); border: 1px solid var(--border); padding: .05em .35em; border-radius: 6px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.container { max-width: 1240px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }

/* ---- Barra superior + navegación ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1rem; padding-top: calc(.8rem + env(safe-area-inset-top));
  /* Sin backdrop-filter: crearía un bloque contenedor y la .nav "fixed" de
     abajo quedaría atrapada dentro de esta barra en el teléfono. */
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #04130d;
}
.brand .logo svg { width: 22px; height: 22px; }
.brand .title { color: var(--brand); font-weight: 800; font-size: 1.08rem; line-height: 1.1; }
.brand .title span { color: var(--strong); }
.brand small { display: none; color: var(--muted); font-size: .75rem; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(17, 24, 39, .97); border-top: 1px solid var(--border);
}
.nav a, .nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: inherit; font-size: .72rem; font-weight: 600; color: var(--muted); text-decoration: none;
  background: none; border: 0; cursor: pointer; min-height: 48px; border-radius: 10px;
}
.nav form { flex: 1; display: flex; min-width: 0; }
/* min-width/padding 0: con 4 pestañas, el relleno heredado de "button" hacía la barra más
   ancha que un teléfono de 375 px y eso ensanchaba toda la página. */
.nav a, .nav button { min-width: 0; padding: 0; }
.nav svg, .icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav .active { color: var(--brand); }

/* ---- Tarjetas ---- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; display: block; color: inherit;
}
.card.narrow { max-width: 430px; width: 100%; margin: 1.5rem auto; }
.card.empty { text-align: center; color: var(--muted); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .6rem; }
.card-head p { margin: 0; }
.count { font-family: var(--mono); font-size: .75rem; background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: .05rem .5rem; color: var(--muted); vertical-align: middle; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .84rem; margin: .5rem 0 0; }
.center { text-align: center; }
.up { color: var(--up); }
.down { color: var(--down); }
.label {
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}

/* KPI: tarjetas de resumen con ícono a la derecha */
.kpis { display: grid; gap: .8rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { position: relative; padding: 1rem; display: grid; gap: .25rem; align-content: start; transition: transform .25s, border-color .25s; }
.kpi:hover { transform: translateY(-2px); border-color: rgba(16, 185, 129, .35); }
.kpi .value { font-family: var(--mono); font-weight: 600; font-size: 1.15rem; color: var(--strong); line-height: 1.25; word-break: break-word; }
.kpi .sub { font-size: .78rem; color: var(--muted); }
.kpi .sub .num { color: var(--text); }
.kpi .tile {
  position: absolute; top: .9rem; right: .9rem; width: 38px; height: 38px; border-radius: 11px;
  display: none; place-items: center; border: 1px solid var(--border);
}
.tile.green { background: rgba(16, 185, 129, .1); color: var(--brand); border-color: rgba(16, 185, 129, .3); }
.tile.sky { background: rgba(56, 189, 248, .1); color: var(--sky); border-color: rgba(56, 189, 248, .3); }
.tile.violet { background: rgba(167, 139, 250, .1); color: var(--violet); border-color: rgba(167, 139, 250, .3); }
.tile.amber { background: rgba(245, 158, 11, .1); color: var(--amber); border-color: rgba(245, 158, 11, .3); }
.kpi .label.amber { color: var(--amber); }

/* Chips de subidas/caídas del día */
.movers { display: grid; gap: .8rem; }
.movers .card { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; padding: .85rem 1.1rem; }
.chip-num {
  font-family: var(--mono); font-size: .76rem; padding: .2rem .5rem; border-radius: 6px; text-decoration: none;
  border: 1px solid; white-space: nowrap;
}
.chip-num.up { color: var(--up); background: rgba(52, 211, 153, .08); border-color: rgba(52, 211, 153, .3); }
.chip-num.down { color: var(--down); background: rgba(248, 113, 113, .08); border-color: rgba(248, 113, 113, .3); }

/* Badges */
.badge { font-family: var(--mono); font-size: .76rem; padding: .15rem .45rem; border-radius: 6px; white-space: nowrap; }
.badge.amber { color: var(--amber); background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .45); }
.badge.down { background: rgba(248, 113, 113, .1); }
.badge.up { background: rgba(52, 211, 153, .1); }
.tag { font-size: .66rem; font-weight: 700; color: var(--sky); background: rgba(56, 189, 248, .12); border-radius: 5px; padding: .05rem .35rem; margin-left: .35rem; }

/* ---- Formularios: 16px para que iOS no haga zoom; botones de 48px para el dedo ---- */
input, select, button, .button { font: inherit; font-size: 16px; min-height: 48px; border-radius: 11px; }
input, select {
  width: 100%; padding: .6rem .85rem; border: 1px solid var(--border);
  background: var(--card-2); color: var(--strong);
}
input::placeholder { color: #64748b; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: 0 1.2rem; border: 0; background: var(--brand); color: #03140d;
  font-weight: 700; cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { background: #34d399; }
.button.secondary { background: transparent; color: var(--brand); border: 1px solid rgba(16, 185, 129, .5); }
button.link { background: none; color: var(--sky); padding: 0; min-height: 44px; font-weight: 600; font-size: .85rem; }
button.link.danger { color: var(--down); }
label { display: grid; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.stack { display: grid; gap: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.form-grid .wide { grid-column: 1 / -1; }

.flash { padding: .8rem 1rem; border-radius: 12px; border: 1px solid rgba(16, 185, 129, .35); background: rgba(16, 185, 129, .08); color: var(--strong); }
.flash.warn { border-color: rgba(245, 158, 11, .4); background: rgba(245, 158, 11, .08); }
.flash.error { border-color: rgba(248, 113, 113, .45); background: rgba(248, 113, 113, .08); }

/* ---- Portada ---- */
.hero { text-align: center; padding: 1.5rem .5rem .5rem; }
.hero h1 { font-size: 2.1rem; }
.hero h1 em { font-style: normal; color: var(--brand); }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 1.3rem; }
.actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.features { display: grid; gap: .8rem; }
.features .card { display: grid; gap: .3rem; }
.features p { color: var(--muted); margin: 0; }
.features .tile { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; border: 1px solid; }

/* ---- Buscar / valuación ---- */
.search { display: flex; gap: .5rem; }
.search input { flex: 1; text-transform: uppercase; font-family: var(--mono); }
.search input::placeholder { text-transform: none; font-family: "Jakarta", sans-serif; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .9rem; }
.chip {
  font-family: var(--mono); font-size: .85rem; padding: .35rem .8rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  text-decoration: none; min-height: 40px; display: inline-flex; align-items: center;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.quote-head { display: flex; justify-content: space-between; gap: .8rem 1.5rem; flex-wrap: wrap; }
.quote-head h1 { font-family: var(--mono); font-size: 1.7rem; margin: 0; }
.quote-head p { margin: 0; }
.price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .4rem; }
.price strong { font-family: var(--mono); font-size: 1.7rem; color: var(--strong); }
.price small { flex-basis: 100%; }
.mine { margin: .9rem 0 0; padding-top: .9rem; border-top: 1px solid var(--border); font-size: .9rem; }
.score-head { display: flex; justify-content: space-between; align-items: baseline; }
.score { font-family: var(--mono); font-size: 1.9rem; color: var(--brand); }
.score small { font-size: .85rem; color: var(--muted); }
.bar { height: 8px; background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: .35rem 0; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--sky)); border-radius: 999px; }
.grid3 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-top: 1rem; }
.metric { background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: .65rem .85rem; display: grid; gap: .1rem; }
.metric strong { font-family: var(--mono); color: var(--strong); font-weight: 600; }
details { margin-top: 1rem; }
summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; color: var(--strong); }
.checks { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .35rem; }
.checks li::before { margin-right: .55rem; font-weight: 800; }
.checks .ok::before { content: "✓"; color: var(--up); }
.checks .no { color: var(--muted); }
.checks .no::before { content: "✗"; color: var(--down); }

/* Tablas */
.table-wrap { overflow-x: auto; margin: 0 -1.2rem -1.1rem; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th {
  text-align: left; font-family: var(--mono); font-size: .68rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted); padding: .75rem 1.2rem; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--card-2);
}
td { padding: .8rem 1.2rem; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
td.num, th.num { text-align: right; }
td.num { font-family: var(--mono); white-space: nowrap; }
.fundamentals td:first-child { font-weight: 600; color: var(--strong); }
.fundamentals th, .fundamentals td { padding: .6rem .45rem; }
.fundamentals th:first-child, .fundamentals td:first-child { padding-left: 1.2rem; }
.fundamentals th:last-child, .fundamentals td:last-child { padding-right: 1.2rem; }

.news { list-style: none; padding: 0; margin: 0; display: grid; }
.news li { padding: .75rem 0; border-bottom: 1px solid var(--border); display: grid; gap: .2rem; }
.news li:last-child { border-bottom: 0; }
.news a { text-decoration: none; font-weight: 600; color: var(--strong); }
.news a:hover { color: var(--sky); }

/* ---- Portafolio ---- */
.positions-table { display: none; }
.positions-cards { display: grid; gap: .6rem; }
.position { text-decoration: none; display: grid; gap: .3rem; padding: .95rem 1rem; }
.position .row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.position .row .num { font-family: var(--mono); }
.position .row.muted { font-size: .82rem; }
.ticker { font-weight: 800; color: var(--strong); }
.company { display: block; font-size: .75rem; color: var(--muted); }
.weight { display: grid; gap: .3rem; justify-items: center; min-width: 90px; }
.weight .bar { width: 90px; height: 6px; margin: 0; }
.weight .bar span { background: var(--sky); }
.two-col { display: grid; gap: 1rem; }
.txns { list-style: none; padding: 0; margin: .5rem 0 0; }
.txns li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.txns .num { font-family: var(--mono); }

/* Verde/rojo ganan sobre los colores base de cifras y etiquetas (van al final a propósito). */
.kpi .value.up, .kpi .sub .up, .label.up, .position .up, .metric .up, td.up, td .up { color: var(--up); }
.kpi .value.down, .kpi .sub .down, .label.down, .position .down, .metric .down, td.down, td .down { color: var(--down); }
.ccy { font-size: .62em; color: var(--muted); font-weight: 400; }

.disclaimer { text-align: center; color: var(--muted); font-size: .76rem; padding: 1rem 1rem 2rem; }

/* ---- Pantallas grandes: navegación de píldoras arriba, tabla completa ---- */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .container { padding: 1.5rem; gap: 1.2rem; }
  .brand small { display: block; }
  .nav {
    position: static; height: auto; padding: .3rem; gap: .25rem;
    background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  }
  .nav a, .nav button { flex-direction: row; font-size: .86rem; padding: 0 .95rem; gap: .45rem; min-height: 38px; white-space: nowrap; }
  .nav form { flex: 0 0 auto; }
  .nav .active { background: var(--brand); color: #03140d; }
  .nav svg { width: 17px; height: 17px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
  .kpi { padding: 1.3rem 1.3rem 1.2rem; min-height: 150px; }
  .kpi .tile { display: grid; }
  /* Fluida: entre 900 y ~1100 px cuatro tarjetas no caben a 1.55rem y "$108,657.38" se partía. */
  .kpi .value { font-size: clamp(1.15rem, 2vw, 1.55rem); padding-right: 2.6rem; }
  .movers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .features { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .positions-table { display: block; }
  .positions-cards { display: none; }
  .price { justify-content: flex-end; text-align: right; }
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; align-items: start; }
}
.position .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.position .row > :last-child { flex-shrink: 0; }

/* Tableta / teléfono horizontal: dos columnas antes de pasar a la tabla completa */
@media (min-width: 600px) and (max-width: 899px) {
  .positions-cards, .movers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .tile { display: grid; }
  .kpi .value { padding-right: 2.6rem; }
}

#resultado { display: grid; gap: 1rem; }
.fundamentals td:not(:first-child), .fundamentals th:not(:first-child) { text-align: right; }
.fundamentals td:not(:first-child) { font-family: var(--mono); white-space: nowrap; }

/* Botones de acción en la ficha de una empresa: apilados en teléfono, en fila en pantallas anchas */
.quote-actions { display: grid; gap: .5rem; margin-top: .9rem; }
.quote-actions form { display: contents; }
.quote-actions .button, .quote-actions button { width: 100%; }
@media (min-width: 600px) {
  .quote-actions { display: flex; flex-wrap: wrap; }
  .quote-actions .button, .quote-actions button { width: auto; }
}

/* Ningún contenido puede ensanchar la página: la columna de la cuadrícula no crece
   más que la pantalla (sin minmax(0,1fr) la tabla de fundamentales la estiraba). */
.container, #resultado { grid-template-columns: minmax(0, 1fr); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 599px) {
  .fundamentals { font-size: .8rem; }
  .fundamentals th, .fundamentals td { padding: .5rem .3rem; }
  .fundamentals th:first-child, .fundamentals td:first-child { padding-left: 0; }
  .fundamentals th:last-child, .fundamentals td:last-child { padding-right: 0; }
  .fundamentals td:last-child { white-space: normal; }
}

/* Todas las cuadrículas con minmax(0, …): una columna "1fr" normal se estira a su contenido
   más largo que no se parte (p. ej. un nombre recortado con "…") y desborda el teléfono. */
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.positions-cards, .movers, .two-col { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) and (max-width: 899px) {
  .positions-cards, .movers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .movers, .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Fundamentales en el teléfono: 3 columnas; el año anterior va como renglón chico bajo el actual. */
.prior-inline { display: none; }
@media (max-width: 599px) {
  .fundamentals .col-prior { display: none; }
  .prior-inline { display: block; font-size: .72rem; color: var(--muted); margin-top: .1rem; }
}

/* ---- Estrategias (Indizado, Renta Fija, Patrimonial, Trading…) ---- */
.strategies { display: grid; gap: .7rem; grid-template-columns: minmax(0, 1fr); }
.strategy { display: grid; gap: .45rem; text-decoration: none; padding: 1rem 1.1rem; background: var(--card-2); transition: border-color .2s, transform .2s; }
.strategy:hover { border-color: rgba(16, 185, 129, .45); transform: translateY(-1px); }
.strategy .row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.strategy .row.muted { font-size: .8rem; flex-wrap: wrap; }
.strategy-name { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.strategy-name strong { display: block; color: var(--strong); font-size: 1rem; }
.strategy-name small { display: block; font-size: .75rem; }
.strategy-name .tile { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; border: 1px solid; flex-shrink: 0; }
.strategy-name .tile .icon { width: 19px; height: 19px; }
.strategy .chevron { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.strategy-value { font-size: 1.25rem; font-weight: 600; color: var(--strong); }
.strategy .bar { margin: 0; height: 6px; }

.crumbs a { display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; font-weight: 600; min-height: 40px; }
.crumbs .icon { width: 18px; height: 18px; }
.strategy-head { display: flex; justify-content: space-between; align-items: flex-end; gap: .8rem 1rem; flex-wrap: wrap; }
.strategy-head h1 { margin: 0; }
.strategy-head p { margin: .2rem 0 0; }
.strategy-head .button { width: 100%; }
.strategy-tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; -webkit-overflow-scrolling: touch; }
.strategy-tabs a {
  flex-shrink: 0; padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); text-decoration: none; font-weight: 600; font-size: .85rem;
  min-height: 40px; display: inline-flex; align-items: center;
}
.strategy-tabs a.active { background: var(--brand); color: #03140d; border-color: var(--brand); }

@media (min-width: 600px) {
  .strategies { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strategy-head .button { width: auto; }
}
@media (min-width: 1100px) {
  .strategies { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Cada dato de la tarjeta se mueve entero al siguiente renglón en vez de partirse. */
.strategy .row { flex-wrap: wrap; row-gap: .2rem; }
.strategy .row > span { white-space: nowrap; }
.strategy .row > .strategy-name { white-space: normal; }

/* Editar / Quitar de cada posición */
td.actions { white-space: nowrap; text-align: right; }
td.actions, .row.actions { display: table-cell; }
.row.actions { display: flex; justify-content: flex-end; gap: 1.2rem; border-top: 1px solid var(--border); padding-top: .3rem; margin-top: .2rem; }
td.actions form, .row.actions form { display: inline; }
td.actions .link-action { margin-right: .9rem; }
.link-action { color: var(--sky); text-decoration: none; font-weight: 600; font-size: .85rem; min-height: 44px; display: inline-flex; align-items: center; }
textarea { width: 100%; font: inherit; font-family: var(--mono); font-size: 14px; padding: .6rem .8rem; border-radius: 11px;
           border: 1px solid var(--border); background: var(--card-2); color: var(--strong); resize: vertical; }
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
label.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 500; color: var(--text); font-size: .85rem; }
label.check input { width: 20px; min-height: 20px; height: 20px; margin-top: .1rem; flex-shrink: 0; accent-color: var(--brand); }

/* ---- Asistente ---- */
.chat-head { display: flex; justify-content: space-between; align-items: flex-end; gap: .8rem 1rem; flex-wrap: wrap; }
.chat-head h1 { margin: 0; }
.chat-head p { margin: .2rem 0 0; max-width: 640px; }
.chat { display: grid; gap: .8rem; }
.conversation { display: grid; gap: .8rem; }
.chat-empty .chips { justify-content: flex-start; }
.chat-empty .chip { font-family: inherit; font-size: .85rem; font-weight: 500; text-align: left; min-height: 40px; height: auto; padding: .45rem .9rem; white-space: normal; }
.msg { max-width: 100%; border-radius: 14px; padding: .75rem .95rem; overflow-wrap: anywhere; }
.msg p { margin: 0; white-space: pre-wrap; }
.msg.user { justify-self: end; max-width: 85%; background: rgba(16, 185, 129, .14); border: 1px solid rgba(16, 185, 129, .35); color: var(--strong); }
.msg.assistant { justify-self: stretch; background: var(--card-2); border: 1px solid var(--border); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol { margin: .5rem 0; }
.md h1, .md h2, .md h3 { font-size: 1rem; margin: .9rem 0 .4rem; color: var(--sky); }
.md table { display: block; overflow-x: auto; max-width: 100%; font-size: .82rem; margin: .5rem 0; }
.md th, .md td { padding: .4rem .6rem; }
.md td { font-family: var(--mono); white-space: nowrap; }
.md td:first-child { font-family: inherit; white-space: normal; }
.md code { font-size: .8rem; }
.md blockquote { margin: .5rem 0; padding-left: .75rem; border-left: 3px solid var(--brand); color: var(--muted); }
.thinking { color: var(--sky); font-size: .85rem; }
.chat-form { display: flex; gap: .5rem; align-items: flex-end; }
.chat-form textarea { flex: 1; font-family: inherit; font-size: 16px; min-height: 52px; max-height: 40vh; }
.chat-form button { min-width: 52px; min-height: 52px; padding: 0; }
.chat-form button .icon { width: 22px; height: 22px; }
.chat-form textarea:disabled, .chat-form button:disabled { opacity: .55; }
/* Con 5 pestañas abajo en el teléfono, letras un poco más chicas para que quepan. */
@media (max-width: 899px) { .nav a, .nav button { font-size: .66rem; } }
/* Una tabla ancha en la respuesta se desplaza dentro de su mensaje; nunca ensancha la página
   (sin minmax(0,1fr) la cuadrícula crece al ancho de la tabla — misma trampa que en Mi cartera). */
.chat, .conversation { grid-template-columns: minmax(0, 1fr); }
.msg.assistant { min-width: 0; }
/* Las etiquetas de la tabla no se parten a media palabra ("Ganan-cia"). */
.md th, .md td { overflow-wrap: normal; word-break: normal; }
.md td:first-child { min-width: 7.5rem; }
