/* AMT Journal — Algoritmos (lista y ficha) */
.al { display: flex; flex-direction: column; gap: 16px; }
.al .page-head { margin-bottom: 6px; }

/* ---------- KPIs ---------- */
.al-kpis .kpi-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.al-kpi-of { font-size: 15px; font-weight: 500; letter-spacing: -.01em; color: var(--text-3); }
.al-kpi-name { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 18px; letter-spacing: -.02em; line-height: 26.4px; }

/* ---------- lista: filas tipo tabla ---------- */
.al-list { container-type: inline-size; overflow: hidden; }
.al-cols, .al-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px 52px 72px 96px 100px 84px 96px 92px 28px;
  column-gap: 16px;
  align-items: center;
  padding: 0 14px 0 18px;
}
.al-cols { height: 38px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.al-r { text-align: right; }
.al-row { position: relative; padding-top: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); transition: background .12s; }
.al-row:last-child { border-bottom: none; }
.al-row:hover { background: rgba(255, 255, 255, .025); }

.al-name { display: grid; grid-template-columns: 7px minmax(0, 1fr); column-gap: 13px; align-items: start; min-width: 0; }
.al-name .status-dot { margin-top: 7px; }
.al-name-main { min-width: 0; }
.al-row-link { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -.005em; color: var(--text); }
/* enlace estirado: toda la fila navega a la ficha; el menú queda por encima */
.al-row-link::after { content: ""; position: absolute; inset: 0; }
.al-row-link:focus-visible { outline: none; }
.al-row-link:focus-visible::after { outline: 2px solid rgba(61, 123, 255, .7); outline-offset: -2px; border-radius: var(--r-sm); }
.al-row:hover .al-row-link { color: #fff; }
.al-meta { margin-top: 2px; font-size: 12px; color: var(--text-3); }

.al-num { text-align: right; font-size: 13px; white-space: nowrap; }
.al-strong { font-weight: 600; }
.al-row .al-col-dd { color: var(--text-2); }
.al-row .al-col-last { font-size: 12.5px; color: var(--text-3); }
.al-row .al-col-spark { display: flex; justify-content: flex-start; min-height: 28px; }
.al-col-menu { position: relative; z-index: 1; display: flex; justify-content: flex-end; }

@container (max-width: 1060px) {
  .al-cols, .al-row { grid-template-columns: minmax(0, 1fr) 84px 52px 72px 96px 100px 84px 92px 28px; }
  .al-list .al-col-spark { display: none; }
}
@container (max-width: 940px) {
  .al-cols, .al-row { grid-template-columns: minmax(0, 1fr) 84px 52px 72px 96px 100px 84px 28px; }
  .al-list .al-col-last { display: none; }
}
@container (max-width: 840px) {
  .al-cols, .al-row { grid-template-columns: minmax(0, 1fr) 84px 52px 72px 96px 100px 28px; }
  .al-list .al-col-dd { display: none; }
}
/* estrecho: cada fila pasa a ficha de dos líneas con sus cifras etiquetadas */
@container (max-width: 760px) {
  .al-cols { display: none; }
  .al-row { grid-template-columns: auto auto minmax(0, 1fr) auto; column-gap: 22px; row-gap: 14px; padding: 15px 16px; }
  .al-name { grid-column: 1 / -1; }
  .al-row-link { margin-right: 124px; }
  .al-col-status { position: absolute; top: 15px; right: 50px; }
  .al-col-menu { position: absolute; top: 12px; right: 10px; }
  .al-num { text-align: left; min-width: 0; }
  .al-row .al-strong { text-align: right; }
  .al-num::before {
    content: attr(data-label);
    display: block; margin-bottom: 4px;
    font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3);
    overflow: hidden; text-overflow: ellipsis;
  }
}

/* ---------- lista vacía ---------- */
.al-empty .empty { padding: 56px 24px 44px; }
.al-empty .empty-text { max-width: 460px; }
.al-steps { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line-soft); }
.al-step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; padding: 20px 22px 22px; }
.al-step + .al-step { border-left: 1px solid var(--line-soft); }
.al-step-n { font-family: var(--mono); font-size: 11.5px; line-height: 20px; color: var(--text-3); }
.al-step-title { font-size: 13px; font-weight: 600; line-height: 20px; }
.al-step p { margin-top: 3px; font-size: 12.5px; line-height: 1.55; color: var(--text-3); }

/* ---------- ficha: cabecera ---------- */
.al-back { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-3); transition: color .14s; }
.al-back:hover { color: var(--text); }
.al-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: 6px; }
.al-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.al-head-main { flex: 1 1 420px; min-width: 0; }
.al-head-title { display: flex; align-items: center; gap: 13px; font-size: 22px; font-weight: 600; letter-spacing: -.03em; line-height: 1.2; }
.al-head-title span { min-width: 0; overflow-wrap: anywhere; }
.al-head-meta { display: flex; flex-wrap: wrap; row-gap: 2px; margin-top: 6px; font-size: 13px; color: var(--text-3); }
.al-head-meta > span + span::before { content: "·"; margin: 0 8px; color: var(--text-4); }
.al-head-desc { margin-top: 10px; max-width: 720px; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.al-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.al-head-actions .seg { margin-right: 4px; }
.al-head-actions .seg button { height: 28px; }

/* ---------- ficha: curva + live vs. esperado ---------- */
.al-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(476px, .82fr); gap: 16px; }
.al-top > .card { display: flex; flex-direction: column; }
.al-top .card-head { align-items: flex-start; }
.al-chart { padding: 10px 14px 14px; }

.al-lve .card-body { flex: 1; display: flex; flex-direction: column; }
.al-lve-tbl th, .al-lve-tbl td { padding-left: 10px; padding-right: 10px; }
.al-lve-tbl tbody tr:last-child td { border-bottom: 1px solid var(--line-soft); }
.al-lve-tbl tbody tr:hover { background: none; }
.al-lve-state { width: 1%; text-align: right; }
.al-verdict { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; align-items: start; padding: 16px 18px 0; }
.al-verdict-ic { width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: rgba(255, 255, 255, .03); color: var(--text-2); }
.al-verdict p { padding-top: 3px; font-size: 13px; font-weight: 500; line-height: 1.55; color: var(--text); }
.al-verdict-pos .al-verdict-ic { color: var(--pos); background: var(--pos-soft); border-color: var(--pos-line); }
.al-verdict-neg .al-verdict-ic { color: var(--neg); background: var(--neg-soft); border-color: var(--neg-line); }
.al-sample { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 18px 0; }
.al-sample-ic { display: grid; place-items: center; height: 20px; color: var(--warn); }
.al-sample p { font-size: 12.5px; line-height: 1.55; color: var(--text-2); }
.al-legend { margin-top: auto; padding: 16px 18px 16px; font-size: 12px; line-height: 1.55; color: var(--text-3); }
.al-lve-empty { flex: 1; display: grid; place-items: center; }
.al-lve-empty .empty { padding: 28px 24px 36px; }

/* ---------- ficha: sin operaciones todavía ---------- */
.al-wait .empty { padding: 48px 24px 40px; }
.al-wait .empty-text { max-width: 480px; }
.al-exp { border-top: 1px solid var(--line-soft); }
.al-exp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 0 18px; }
.al-exp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 4px 0 6px; }
.al-exp-cell { display: flex; flex-direction: column; gap: 7px; padding: 10px 18px 14px; min-width: 0; }
.al-exp-cell + .al-exp-cell { border-left: 1px solid var(--line-soft); }
.al-exp-cell .num { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.al-exp-none { display: flex; align-items: center; justify-content: space-between; gap: 14px 24px; flex-wrap: wrap; padding: 16px 18px; }
.al-exp-none p { flex: 1 1 320px; max-width: 640px; font-size: 12.5px; line-height: 1.55; color: var(--text-3); }

/* ---------- ficha: operaciones ---------- */
.al-count { font-size: 12.5px; color: var(--text-3); }
.al-inst { display: inline-flex; align-items: center; gap: 12px; }
.al-inst .sym { min-width: 36px; }

/* ---------- ficha: conexión ---------- */
.al-conn > .card-head { align-items: flex-start; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.al-conn-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.al-conn-col { min-width: 0; display: flex; flex-direction: column; gap: 24px; padding: 20px 18px 22px; }
.al-conn-col + .al-conn-col { border-left: 1px solid var(--line-soft); }
.al-block { min-width: 0; }
.al-block > .cap { display: block; margin-bottom: 10px; }

.al-well {
  display: flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 6px 7px 6px 12px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.al-well > svg { flex: none; color: var(--text-3); }
.al-url { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; color: var(--text); scrollbar-width: none; }
.al-url::-webkit-scrollbar { display: none; }
.al-mask { color: var(--text-3); letter-spacing: .08em; }
.al-nokey { font-family: var(--sans); font-size: 13px; color: var(--text-3); }
.al-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; margin-top: 12px; font-size: 12.5px; line-height: 1.5; }
.al-kv dt { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.al-kv dd { color: var(--text-3); }
.al-hint { margin-top: 10px; font-size: 12.5px; line-height: 1.55; color: var(--text-3); }

.al-fields { font-size: 12.5px; line-height: 1.5; }
.al-fields td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; color: var(--text-2); }
.al-fields td:first-child { width: 104px; font-family: var(--mono); font-size: 12px; color: var(--text); white-space: nowrap; }
.al-fields td:nth-child(2) { width: 64px; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.al-fields td:last-child { padding-right: 0; }
.al-fields tr:last-child td { border-bottom: none; }
.al-fields .al-fields-group td { padding: 14px 0 6px; font-family: var(--sans); font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.al-fields .al-fields-group:first-child td { padding-top: 0; }

.al-code-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; margin-bottom: 10px; }
.al-code-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.al-code-tools .btn-sm { height: 30px; }
/* el panel de código llena el alto de la columna vecina y desplaza su contenido por dentro */
.al-block-code { flex: 1 1 auto; display: flex; flex-direction: column; }
.al-code {
  flex: 1 1 0; min-height: 420px; overflow: auto;
  padding: 14px 16px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--mono); font-size: 12px; line-height: 1.7; letter-spacing: -.01em;
  color: var(--text-2);
  white-space: pre; tab-size: 4;
}
.al-code code { font: inherit; }
.al-code:focus-visible { outline: none; border-color: var(--blue-line); }
.al-cm { color: var(--text-3); }
.al-ph { color: var(--warn); }

.al-resp { list-style: none; display: flex; flex-direction: column; }
.al-resp li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.al-resp li:last-child { border-bottom: none; padding-bottom: 0; }
.al-resp code { font-family: var(--mono); font-size: 12px; color: var(--text); }

/* ---------- modales ---------- */
.al-form-exp p { margin-top: 5px; font-size: 12.5px; line-height: 1.55; color: var(--text-3); }
.al-key-warn { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 11px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--warn-line); border-radius: var(--r-md); background: var(--warn-soft); }
.al-key-warn span { color: var(--warn); padding-top: 2px; }
.al-key-warn p { font-size: 13px; line-height: 1.55; color: var(--text); }
.al-key-value { user-select: all; }

/* ---------- responsive ---------- */
@media (max-width: 1360px) and (min-width: 921px) {
  /* seis KPIs no caben en una fila con la barra lateral visible */
  .al-kpis-6 { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .al-kpis-6 > .kpi:nth-child(n + 4) { border-top: 1px solid var(--line-soft); }
  .al-kpis-6 > .kpi:nth-child(3n + 1) { border-left: none; }
}
@media (max-width: 1100px) and (min-width: 921px) {
  .al-kpis:not(.al-kpis-6) { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .al-kpis:not(.al-kpis-6) > .kpi:nth-child(odd) { border-left: none; }
  .al-kpis:not(.al-kpis-6) > .kpi:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
}
@media (max-width: 1180px) {
  .al-top { grid-template-columns: minmax(0, 1fr); }
  .al-conn-grid { grid-template-columns: minmax(0, 1fr); }
  .al-conn-col + .al-conn-col { border-left: none; border-top: 1px solid var(--line-soft); }
  .al-code { flex: none; min-height: 0; max-height: 468px; }
}
@media (max-width: 640px) {
  .al-steps { grid-template-columns: minmax(0, 1fr); }
  .al-step + .al-step { border-left: none; border-top: 1px solid var(--line-soft); }
  .al-head-title { font-size: 20px; }
  .al-head-actions { width: 100%; }
  .al-head-actions .seg { flex: 1; margin-right: 0; }
  .al-head-actions .seg button { flex: 1; padding: 0 6px; }
  .al-chart { padding: 8px 6px 10px; }
  .al-lve-tbl th, .al-lve-tbl td { padding-left: 7px; padding-right: 7px; }
  .al-lve-tbl th:first-child, .al-lve-tbl td:first-child { padding-left: 16px; }
  .al-lve-tbl th:last-child, .al-lve-tbl td:last-child { padding-right: 16px; }
  .al-lve-dev, .al-hide-sm { display: none; }
  .al-kpis .kpi-spark { display: none; }
  .al-trades th, .al-trades td { padding-left: 8px; padding-right: 8px; }
  .al-trades th:first-child, .al-trades td:first-child { padding-left: 16px; }
  .al-trades th:last-child, .al-trades td:last-child { padding-right: 16px; }
  .al-exp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .al-exp-cell:nth-child(odd) { border-left: none; }
  .al-exp-cell:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
  .al-conn-col { padding: 18px 16px 20px; }
  .al-code { max-height: 400px; font-size: 11.5px; }
  .al-fields td:nth-child(2) { display: none; }
}
