/* Campo · Tracker · lista de portafolios + detalle (T2). Prefijo tkl-. Tokens de _dev_proto-campo.css. */
#tkList { container: tkl / inline-size; }
.tkl-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tkl-num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.tkl .gain, .tkl-detail .gain { color: var(--gain); }
.tkl .loss, .tkl-detail .loss { color: var(--loss); }
.tkl-ic { width: 18px; height: 18px; flex: none; display: block; }
html.tkl-lock { overflow: hidden; scrollbar-gutter: stable; }

/* ---------- panel + columnas ---------- */
.tkl { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1), var(--inset); overflow: clip; }
.tkl-cols, .tkl-row { display: grid; grid-template-columns: 24px 10px minmax(120px, 1.5fr) 104px 112px 100px 112px 64px 84px 36px 12px; column-gap: 10px; align-items: center; padding: 0 8px; }
.tkl-cols { min-height: 38px; font-size: 12.5px; color: var(--text-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tkl-cols .r { text-align: right; }
.tkl-list { list-style: none; margin: 0; padding: 0; }
.tkl-row { position: relative; min-height: 68px; border-bottom: 1px solid var(--line); background: var(--s1); transition: background-color 180ms var(--ease-out), opacity 180ms var(--ease-out); }
.tkl-row > * { min-width: 0; }
.tkl-row[data-edit] { z-index: 2; }

/* resaltado cruzado con la gráfica */
.tkl[data-hl] .tkl-row:not([data-hl]) { opacity: 0.55; }
.tkl-row[data-hl] { background: var(--s2); }
.tkl-row[data-hl] .tkl-sw { box-shadow: 0 0 0 3px color-mix(in oklch, var(--pc) 28%, transparent); }

.tkl-grip { width: 24px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); border-radius: 6px; cursor: grab; touch-action: none; position: relative; z-index: 3; opacity: 0.6; transition: opacity 180ms var(--ease-out), color 180ms var(--ease-out); }
.tkl-grip:disabled { opacity: 0.2; cursor: default; }
.tkl-grip .tkl-ic { width: 16px; height: 16px; }
.tkl-grip:focus-visible, .tkl-more:focus-visible, .tkl-open:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.tkl-sw { width: 10px; height: 34px; border-radius: 5px; background: var(--pc); transition: box-shadow 180ms var(--ease-out); }

.tkl-nm { display: grid; gap: 2px; min-width: 0; }
.tkl-open { all: unset; box-sizing: border-box; cursor: pointer; min-width: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.tkl-open::after { content: ''; position: absolute; inset: 0; z-index: 1; }
.tkl-open:focus-visible::after { outline: 2px solid var(--accent-ink); outline-offset: -2px; border-radius: 2px; }
.tkl-nmt { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tkl-sub { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tkl-rename { min-height: 38px; height: 38px; padding: 0 10px; font-size: 16px; font-weight: 600; border-radius: var(--r-sm); position: relative; z-index: 4; }

.tkl-val { text-align: right; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.tkl-share { display: flex; align-items: center; gap: 8px; }
.tkl-share[hidden] { display: none; }
.tkl-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--s3); overflow: hidden; }
.tkl-bar i { display: block; height: 100%; width: var(--w); background: var(--pc); border-radius: 3px; transform-origin: left; }
.tkl-shp { font-size: 13px; color: var(--text-2); min-width: 34px; text-align: right; }
.tkl-day { display: grid; text-align: right; font-size: 13.5px; line-height: 1.3; }
.tkl-day span:first-child { font-weight: 500; }
.tkl-ct { position: relative; height: 10px; border-radius: 2px; background: linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat; }
.tkl-ct i { position: absolute; top: 1px; bottom: 1px; width: var(--w); border-radius: 2px; }
.tkl-ct i.gain { left: 50%; background: var(--gain); }
.tkl-ct i.loss { right: 50%; background: var(--loss); }
.tkl-ct i:not(.gain):not(.loss) { display: none; }
.tkl-ret { text-align: right; font-size: 14px; font-weight: 500; }
.tkl-spk { height: 28px; }
.tkl-sp { width: 100%; height: 28px; display: block; overflow: visible; }
.tkl-spl { fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }
.tkl-spd.gain { fill: var(--gain); } .tkl-spd.loss { fill: var(--loss); }
.tkl-more { position: relative; z-index: 3; width: 36px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--text-2); border-radius: var(--r-sm); cursor: pointer; transition: background-color 150ms var(--ease-out), transform 120ms var(--ease-out); }
.tkl-more:active { transform: scale(0.97); }
.tkl-chev { color: var(--text-3); display: grid; transition: transform 220ms var(--ease-out), color 180ms var(--ease-out); }
.tkl-chev .tkl-ic { width: 14px; height: 14px; }

/* una sola fila: destacada, sin barras de parte */
.tkl[data-single] .tkl-row[data-id] { background: var(--s2); box-shadow: inset 3px 0 0 var(--accent); }

/* arrastre */
.tkl[data-drag] { user-select: none; -webkit-user-select: none; }
.tkl[data-drag] .tkl-row { transition: none; }
.tkl[data-drag] .tkl-grip { cursor: grabbing; }
.tkl-row.tkl-lift { z-index: 5; background: var(--s2); box-shadow: var(--sh-2); border-radius: var(--r-md); will-change: transform; }

/* entrada */
.tkl[data-pre] .tkl-row { opacity: 0; }
.tkl[data-enter] .tkl-bar i { animation: tkl-grow 700ms var(--ease-expo) both; }
.tkl[data-enter] .tkl-spl { animation: tkl-draw 900ms var(--ease-expo) both; }
.tkl[data-enter] .tkl-spd { animation: tkl-pop 300ms var(--ease-out) 650ms both; }
@keyframes tkl-grow { from { transform: scaleX(0); } }
@keyframes tkl-draw { from { stroke-dashoffset: 1; } }
@keyframes tkl-pop { from { opacity: 0; } }

@media (hover: hover) and (pointer: fine) {
  .tkl-row:hover { background: var(--s2); }
  .tkl-row:hover .tkl-chev { transform: translateX(3px); color: var(--text); }
  .tkl-row:hover .tkl-grip { opacity: 1; color: var(--text-2); }
  .tkl-more:hover { background: var(--s3); color: var(--text); }
  .tkl-pop button:hover { background: var(--s2); }
}

/* ---------- compacto (< 900 px del contenedor) ---------- */
@container tkl (max-width: 899px) {
  .tkl-cols { display: none; }
  .tkl-row { grid-template-columns: 24px 10px minmax(0, 1fr) auto 40px; grid-template-areas: "grip sw nm val more" "grip sw share day more"; column-gap: 10px; row-gap: 2px; padding: 10px 4px 10px 8px; min-height: 72px; }
  .tkl-grip { grid-area: grip; } .tkl-sw { grid-area: sw; height: 44px; align-self: center; }
  .tkl-nm { grid-area: nm; } .tkl-val { grid-area: val; } .tkl-share { grid-area: share; } .tkl-day { grid-area: day; grid-auto-flow: column; gap: 6px; } .tkl-more { grid-area: more; width: 40px; }
  .tkl-ct, .tkl-ret, .tkl-spk, .tkl-chev { display: none; }
  .tkl-sub { display: none; }
  .tkl[data-single] .tkl-share { display: none; }
  .tkl[data-single] .tkl-sub { display: block; }
}

/* ---------- popovers ---------- */
.tkl-pop { position: fixed; z-index: 1150; min-width: 188px; max-width: calc(100vw - 16px); padding: 6px; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-2), var(--inset); }
.tkl-pop > button[role="menuitem"] { all: unset; box-sizing: border-box; width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: var(--r-sm); font-size: 15px; color: var(--text); cursor: pointer; }
.tkl-pop > button[role="menuitem"]:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: -2px; background: var(--s2); }
.tkl-pop .is-danger { color: var(--loss); }
.tkl-conf { width: 280px; max-width: 100%; padding: 8px; display: grid; gap: 6px; }
.tkl-conf p { margin: 0; font-size: 14.5px; line-height: 1.4; color: var(--text-2); }
.tkl-conf p strong { color: var(--text); font-weight: 600; }
.tkl-conf-b { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.tkl-danger { color: var(--loss); }
.tkl-conf-b .btn:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

/* ---------- hojas ---------- */
.tkl-modal { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 16px; overscroll-behavior: contain; }
.tkl-mback { position: absolute; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(5px); opacity: 0; transition: opacity 160ms var(--ease-out); }
.tkl-modal[data-open] .tkl-mback { opacity: 1; transition-duration: 220ms; }
.tkl-mpanel { position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-2), var(--inset); opacity: 0; transform: translateY(10px) scale(0.98); transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out); }
.tkl-modal[data-open] .tkl-mpanel { opacity: 1; transform: none; transition: opacity 240ms var(--ease-expo), transform 240ms var(--ease-expo); }
.tkl-mpanel:focus { outline: none; }
.tkl-mx { position: absolute; top: 8px; right: 8px; z-index: 2; }
.tkl-mscroll { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 28px; border-radius: inherit; scrollbar-width: thin; }
.tkl-mt { font-size: 22px; letter-spacing: -0.03em; line-height: 1.15; padding-right: 40px; margin: 0 0 14px; }
.tkl-lead { margin: 0 0 16px; font-size: 15px; line-height: 1.5; color: var(--text-2); }
.tkl-lead code { font-family: var(--mono); font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--s2); color: var(--text); }
.tkl-form { display: grid; gap: 14px; }
.tkl-fld { display: grid; gap: 6px; min-width: 0; }
.tkl-fld label { font-size: 14px; font-weight: 500; }
.tkl-fld label span { color: var(--text-3); font-weight: 400; }
.tkl-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tkl-fld select { width: 100%; min-height: 52px; padding: 0 14px; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: none; }
.tkl-fld select:focus-visible { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 30%, transparent); }
.tkl-err { margin: 0; min-height: 0; font-size: 13.5px; color: var(--loss); }
.tkl-err:empty { display: none; }
.tkl-mact { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tkl-drop { position: relative; display: grid; place-items: center; min-height: 150px; padding: 20px; border: 1.5px dashed var(--line); border-radius: var(--r-md); text-align: center; cursor: pointer; transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out); }
.tkl-drop[data-over] { background: var(--s2); border-color: var(--accent-ink); }
.tkl-drop:focus-within { border-color: var(--accent-ink); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 30%, transparent); }
.tkl-file { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.tkl-drop-t { display: grid; gap: 4px; justify-items: center; color: var(--text-2); font-size: 14px; pointer-events: none; }
.tkl-drop-t strong { color: var(--text); font-size: 16px; font-weight: 600; }
.tkl-sum { margin: 12px 0 0; min-height: 20px; font-size: 14px; color: var(--text-2); }
@media (hover: hover) and (pointer: fine) { .tkl-drop:hover { background: var(--s2); } }
@media (max-width: 559px) {
  .tkl-modal { padding: 0; align-items: flex-end; }
  .tkl-mpanel { max-width: none; max-height: 94dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; opacity: 1; transform: translateY(100%); transition: transform 160ms var(--ease-out); }
  .tkl-modal[data-open] .tkl-mpanel { transform: none; transition: transform 300ms var(--ease-expo); }
  .tkl-mscroll { padding: 22px 16px calc(22px + env(safe-area-inset-bottom)); }
  .tkl-two { grid-template-columns: 1fr; }
}

/* ---------- detalle ---------- */
.tkl-detail { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
#tklPanel { grid-template-columns: minmax(0, 1fr); min-width: 0; } /* ninguna pestaña puede ensanchar el detalle */
.tkl-nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.tkl-addtx { margin-left: auto; } .tkl-addtx .ic { width: 16px; height: 16px; }
.tkl-backb { gap: 4px; padding-left: 8px; }
.tkl-backb .tkl-ic { width: 16px; height: 16px; }
.tkl-crumb ol { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--text-3); min-width: 0; }
.tkl-crumb li + li::before { content: '›'; margin-right: 8px; }
.tkl-crumb li[aria-current] { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tkl-dhead { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 16px; row-gap: 14px; align-items: center; padding: 20px; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1), var(--inset); }
.tkl-dsw { width: 14px; height: 56px; border-radius: 7px; background: var(--pc); }
.tkl-dtitle { min-width: 0; }
.tkl-dname { margin: 0; font-size: 28px; line-height: 1.1; font-weight: 600; letter-spacing: -0.03em; outline: none; overflow-wrap: anywhere; }
.tkl-ddesc { margin: 4px 0 0; font-size: 14.5px; color: var(--text-2); }
.tkl-dval { display: grid; justify-items: end; gap: 2px; text-align: right; }
.tkl-dv { font-size: 28px; line-height: 1.1; font-weight: 600; letter-spacing: -0.03em; }
.tkl-dsub { display: grid; font-size: 14px; gap: 1px; }
.tkl-dfx { font-size: 13.5px; color: var(--text-3); margin-bottom: 4px; }
.tkl-dmeta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; padding-top: 14px; border-top: 1px solid var(--line); }
.tkl-dmeta div { display: grid; gap: 2px; }
.tkl-dmeta dt { font-size: 13px; color: var(--text-3); }
.tkl-dmeta dd { margin: 0; font-size: 15px; font-weight: 500; }
.tkl-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.tkl-tabs button { all: unset; box-sizing: border-box; min-height: 44px; padding: 0 14px; font-size: 15px; font-weight: 500; color: var(--text-3); white-space: nowrap; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tkl-tabs { position: relative; overscroll-behavior-x: contain; }
.tkl-tabw { position: relative; }
.tkl-tabw::before, .tkl-tabw::after { content: ''; position: absolute; top: 0; bottom: 1px; width: 32px; z-index: 2; pointer-events: none; opacity: 0; transition: opacity 180ms var(--ease-out); }
.tkl-tabw::before { left: 0; background: linear-gradient(90deg, var(--bg), transparent); }
.tkl-tabw::after { right: 0; background: linear-gradient(270deg, var(--bg), transparent); }
.tkl-tabw.can-l::before, .tkl-tabw.can-r::after { opacity: 1; }
.tkl-tabs button { transition: color 180ms var(--ease-out); }
.tkl-tabs button[aria-selected="true"] { color: var(--text); }
.tkl-ind { position: absolute; left: 0; bottom: 0; height: 2px; width: 1px; transform-origin: 0 50%; border-radius: 1px; background: var(--accent); pointer-events: none; transition: transform 260ms var(--ease-in-out); } /* el largo va en scaleX: width animaba layout */
@media (hover: hover) and (pointer: fine) { .tkl-tabs button:not(:disabled):not([aria-selected="true"]):hover { color: var(--text-2); } }
@media (prefers-reduced-motion: reduce) { .tkl-ind, .tkl-tabs button, .tkl-tabw::before, .tkl-tabw::after { transition: none; } }
.tkl-tabs button:disabled { opacity: 0.5; cursor: default; }
.tkl-tabs button:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: -2px; }
/* segundo nivel ("Análisis y plan"): más bajo y discreto que las secciones; oculto fuera de su grupo */
.tkl-subw { margin-top: 2px; }
.tkl-subw[hidden] { display: none; }
.tkl-subtabs { border-bottom-color: transparent; }
.tkl-subtabs button { min-height: 40px; font-size: 14px; }
/* selector rápido de portafolio junto al nombre */
.tkl-dnamew { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tkl-swb { all: unset; box-sizing: border-box; flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; margin: -8px 0; border-radius: var(--r-sm); color: var(--text-3); cursor: pointer; transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 120ms var(--ease-out); }
.tkl-swb .tkl-ic { width: 18px; height: 18px; transform: rotate(90deg); }
.tkl-swb:active { transform: scale(0.97); }
.tkl-swb:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: -2px; }
.tkl-swb[aria-expanded="true"] { background: var(--s2); color: var(--text); }
@media (hover: hover) and (pointer: fine) { .tkl-swb:hover { background: var(--s2); color: var(--text); } }
.tkl-pop-sw { min-width: 220px; max-width: min(320px, calc(100vw - 16px)); }
.tkl-pop-sw [data-sw] { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tkl-pop-sw [aria-current="true"] { color: var(--accent-ink); font-weight: 600; }
.tkl-swn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tkl-swc { flex: none; color: var(--text-3); font-size: 12.5px; font-weight: 400; }
.tkl-tp { display: grid; gap: 14px; padding-top: 16px; }
.tkl-soon { padding: 18px 20px; border: 1px dashed var(--line); border-radius: var(--r-md); color: var(--text-2); }
.tkl-soon strong { color: var(--text); font-weight: 600; font-size: 16px; }
.tkl-soon p { margin: 4px 0 0; font-size: 14.5px; line-height: 1.5; }
.tkl-poslist { list-style: none; margin: 0; padding: 0; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: clip; }
.tkl-pos { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 56px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.tkl-pos:last-child { border-bottom: 0; }
.tkl-pos-empty { display: block; color: var(--text-3); font-size: 14.5px; }
.tkl-pn { display: grid; min-width: 0; line-height: 1.3; }
.tkl-pn strong { font-size: 15px; font-weight: 600; }
.tkl-pn span { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tkl-mk { display: grid; place-items: center; width: 28px; height: 28px; }
.tkl-chip { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--s3); font-size: 13px; font-weight: 600; }
.tkl-ghost { will-change: transform; }
@media (max-width: 640px) {
  .tkl-dhead { grid-template-columns: auto minmax(0, 1fr); padding: 16px; }
  .tkl-dval { grid-column: 1 / -1; justify-items: start; text-align: left; }
  .tkl-dname, .tkl-dv { font-size: 24px; }
  .tkl-dsw { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .tkl-row, .tkl-chev, .tkl-more, .tkl-grip { transition: none; }
  .tkl[data-enter] .tkl-bar i, .tkl[data-enter] .tkl-spl, .tkl[data-enter] .tkl-spd { animation: none; }
  .tkl-mpanel, .tkl-modal[data-open] .tkl-mpanel { transform: none !important; transition: opacity 120ms linear !important; }
  .tkl-modal[data-open] .tkl-mpanel { opacity: 1; }
}
