/* estilo claro tipo Glassnode Market Compass */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e5e7eb;
  --ink: #111827;
  --ink2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --gold: #a87b00;
  --good: #1e7e34; --good-bg: #e6f4ea; --good-line: #b7dfc2;
  --bad: #c62828;  --bad-bg: #fdecec;  --bad-line: #f3b8b8;
  --neu-bg: #f3f4f6; --neu-line: #d1d5db;
  --warn-bg: #fff8e1;
  /* bands from bearish to bullish, and the neutral scale */
  --r2: #d93025; --r1: #f8cbc6; --n: #fbe2a9; --g1: #d4edd9; --g2: #9cc8a6;
  --q1: #eef7f0; --q2: #ddefe2; --q3: #c8e5d0; --q4: #afd8bb; --q5: #93c8a2;   /* percentiles: verde claro */
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 14px/1.5 Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: 12px; background: var(--neu-bg); padding: 1px 5px; border-radius: 4px; }

/* barra superior */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 0 28px; min-height: 56px;
       background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.brand::before { content: ''; width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, #f3c74b, #a87b00); }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a { color: var(--ink2); padding: 6px 12px; border-radius: 6px; font-weight: 500; }
.top nav a:hover { background: var(--neu-bg); text-decoration: none; }
.top nav a.active { background: var(--neu-bg); color: var(--ink); font-weight: 600; }
.top .state { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.top .state a { color: var(--muted); }
.top button { background: #fff; color: var(--ink2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px; cursor: pointer; font-weight: 500; }
.top button:hover { background: var(--neu-bg); }
.top .state .pill-state.busy { color: var(--gold); font-weight: 600; }

/* answer of the Refresh button, under the top bar */
.toast { position: fixed; top: 66px; right: 28px; z-index: 20; max-width: 440px; padding: 10px 14px; font-size: 13px; background: #fff;
         border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 8px; box-shadow: 0 6px 18px rgba(17, 24, 39, .12); }
.toast.no { border-left-color: #f0a500; }

/* Status page: refresh in progress, per-section states and recent refreshes */
.progress { height: 10px; max-width: 900px; margin: 12px 0 6px; background: var(--neu-bg); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #f3c74b, var(--gold)); transition: width .6s; }
.doing { font-size: 14px; margin: 8px 0 14px; }
.chip { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--neu-bg); color: var(--muted); white-space: nowrap; }
.chip.running { background: var(--warn-bg); color: var(--gold); }
.chip.done { background: var(--good-bg); color: var(--good); }
.chip.failed { background: var(--bad-bg); color: var(--bad); }
table.plain.run { margin-top: 8px; }
table.plain.run .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.plain.run tr.running td { background: #fffbea; }
table.plain.run .run-err { max-width: 420px; font-size: 12px; color: var(--bad); }
table.plain.explain td { max-width: 1000px; }
details.run-log { border-top: 1px solid var(--line); padding: 7px 0; }
details.run-log > summary { cursor: pointer; font-size: 13px; }

main { max-width: 1400px; margin: 0 auto; padding: 24px 28px 48px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.muted, .meta, .note { color: var(--muted); }
.meta { font-size: 12px; }
.note { font-size: 13px; margin: 2px 0 10px; }

/* portada */
.hero { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.4fr); gap: 16px; margin-bottom: 28px; }
.hero h1 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.price { font-size: 36px; font-weight: 700; margin: 6px 0 2px; }
.price small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.group-title { display: flex; align-items: baseline; gap: 12px; margin: 30px 0 12px; font-size: 17px; }
.group-title span { font-size: 13px; color: var(--muted); font-weight: 400; }
.lens-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.lens-grid > .lens { flex: 0 1 312px; min-width: 270px; }
.hero .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); }
.hero .kpi { min-width: 0; }
.hero-right { display: flex; flex-direction: column; gap: 16px; }
.hero-chart { margin-top: 0; padding-bottom: 8px; }
.read ul { margin: 0; padding-left: 18px; }
.read li { margin: 6px 0; }
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* lens card */
.lens { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px 14px;
        color: inherit; transition: box-shadow .15s, border-color .15s; }
.lens:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(17, 24, 39, .07); border-color: #d6d9de; }
.lens-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lens-top > span:last-child { white-space: nowrap; }
.lens-name { font-weight: 600; font-size: 16px; }
.chg { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--neu-bg); color: var(--ink2); white-space: nowrap; }
.chg.good { background: var(--good-bg); color: var(--good); }
.chg.bad { background: var(--bad-bg); color: var(--bad); }
.lens-mid { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 12px 0 20px; }
.pill { font-weight: 600; font-size: 14px; padding: 3px 13px; border-radius: 999px; border: 1px solid var(--neu-line); background: var(--neu-bg); color: var(--ink2); }
.pill.small { font-size: 12px; padding: 2px 10px; }
.pill.good { background: var(--good-bg); border-color: var(--good-line); color: var(--good); }
.pill.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.score { font-size: 24px; font-weight: 700; white-space: nowrap; }
.score small { font-size: 13px; color: var(--faint); font-weight: 500; margin-left: 2px; }
.bar { position: relative; display: flex; height: 30px; }
.seg { display: flex; align-items: center; justify-content: center; min-width: 0; padding: 0 4px; font-size: 11.5px; line-height: 1.15;
       color: #80868e; text-align: center; overflow: hidden; }
.seg:first-child { border-radius: 6px 0 0 6px; }
.seg:last-child { border-radius: 0 6px 6px 0; }
.seg.on { color: var(--ink); font-weight: 600; }
.seg.r2 { background: var(--r2); color: rgba(255, 255, 255, .8); } .seg.r2.on { color: #fff; }
.seg.r1 { background: var(--r1); } .seg.n { background: var(--n); }
.seg.g1 { background: var(--g1); } .seg.g2 { background: var(--g2); }
.seg.q1 { background: var(--q1); } .seg.q2 { background: var(--q2); } .seg.q3 { background: var(--q3); }
.seg.q4 { background: var(--q4); } .seg.q5 { background: var(--q5); }
/* Gold Rainbow lens: cold (blue) to hot (red), same colours as the chart */
.seg.rb0 { background: rgb(18,96,235); color: #fff; } .seg.rb1 { background: rgb(74,195,217); } .seg.rb2 { background: rgb(0,180,67); color: #fff; }
.seg.rb3 { background: rgb(139,220,57); } .seg.rb4 { background: rgb(255,231,0); } .seg.rb5 { background: rgb(255,200,87); }
.seg.rb6 { background: rgb(255,153,51); } .seg.rb7 { background: rgb(255,99,0); color: #fff; } .seg.rb8 { background: rgb(180,0,0); color: #fff; }
.seg.rb0, .seg.rb1, .seg.rb2, .seg.rb3, .seg.rb4, .seg.rb5, .seg.rb6, .seg.rb7, .seg.rb8 { font-size: 10px; padding: 0 1px; opacity: .55; }
.seg[class*=" rb"].on { opacity: 1; font-weight: 700; }
.marker { position: absolute; top: -13px; width: 0; height: 0; transform: translateX(-50%);
          border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 11px solid var(--ink); }
.ticks { position: relative; height: 18px; margin-top: 3px; font-size: 11px; color: var(--muted); }
.tick { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.cap { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.lens.big .score { font-size: 34px; }
.lens.big .lens-name { font-size: 18px; }

/* KPIs */
.kpis { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.kpi { display: flex; flex-direction: column; min-width: 140px; padding: 8px 12px; border-radius: 8px; background: var(--neu-bg); }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 19px; font-weight: 700; }
.kpi .sub { font-size: 11px; color: var(--muted); }
.kpi.good .value { color: var(--good); }
.kpi.bad .value { color: var(--bad); }

.warn { background: var(--warn-bg); border-left: 4px solid #f0a500; padding: 6px 10px; font-size: 13px; border-radius: 4px; }
.err { background: var(--bad-bg); border-left: 4px solid var(--bad); padding: 6px 10px; font-size: 13px; margin: 8px 0; border-radius: 4px; }
.err pre, td pre { white-space: pre-wrap; font-size: 11px; max-height: 300px; overflow: auto; }

/* section pages */
.sec-head h1 { margin: 0 0 2px; font-size: 26px; }
.sec-head .headline { font-size: 17px; font-weight: 600; margin: 10px 0; }
.sec-head p { max-width: 1050px; }
.sec-head .lens-grid { margin: 16px 0 4px; }
.block { margin-top: 16px; }
.fig-switch, .week-picker { margin: 4px 0 8px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.block h2 { font-size: 17px; margin: 0; }

/* Incrementum Signal: the signal as a tree of cards (its week picker is in charts.js) */
.sig-box { min-width: 1080px; padding-bottom: 6px; }
.sig-pick { font-size: 13px; color: var(--muted); }
.sig-pick .week-picker { margin-left: 6px; color: var(--ink); }
.sig-tree, .sig-tree ul { display: flex; position: relative; width: 100%; margin: 0; padding: 22px 0 0; list-style: none; }
.sig-tree { padding-top: 6px; }
.sig-tree li { position: relative; display: flex; flex: 1 1 0; flex-direction: column; align-items: center; min-width: 0; padding: 22px 6px 0; }
/* connectors: each card hangs from a line that runs between the centres of the first and the last card of its row */
.sig-tree li::before, .sig-tree li::after { content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 22px; border-top: 1.5px solid #bfc5cd; }
.sig-tree li::after { right: auto; left: 50%; border-left: 1.5px solid #bfc5cd; }
.sig-tree li:first-child::before, .sig-tree li:last-child::after { border: 0 none; }
.sig-tree li:last-child::before { border-right: 1.5px solid #bfc5cd; border-radius: 0 6px 0 0; }
.sig-tree li:first-child::after { border-radius: 6px 0 0 0; }
.sig-tree li:only-child::before, .sig-tree li:only-child::after { display: none; }
.sig-tree li:only-child { padding-top: 0; }
.sig-tree ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 22px; border-left: 1.5px solid #bfc5cd; }
.tn { display: flex; flex-direction: column; width: 100%; max-width: 300px; padding: 9px 12px 9px; text-align: left; background: #fff;
      border: 1px solid var(--line); border-top: 3px solid var(--neu-line); border-radius: 8px; transition: background-color .3s, border-color .3s; }
.tn[data-c="g"] { background: #f5fbf6; border-top-color: #7fb98b; }
.tn[data-c="y"] { background: #fffcf2; border-top-color: #e6b94d; }
.tn[data-c="r"] { background: #fef7f6; border-top-color: #e0766c; }
.sig-tree > li > .tn { max-width: 340px; }
.sig-tree > li > ul > li > .tn { max-width: 440px; }
.tn-name { font-size: 12px; font-weight: 600; color: var(--muted); }
.tn-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.tn-head { font-size: 19px; font-weight: 700; text-transform: capitalize; }
.sig-tree > li > .tn .tn-head { font-size: 24px; }
.tn-rest { font-size: 12.5px; color: var(--ink2); }
.tn-small { margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.tn-bar { position: relative; display: flex; height: 8px; margin: 12px 0 2px; }
.tn-bar .seg { padding: 0; }
.tn-bar .seg:first-of-type { border-radius: 4px 0 0 4px; }
.tn-bar .seg:last-of-type { border-radius: 0 4px 4px 0; }
.tn-mark { position: absolute; top: -8px; width: 0; height: 0; transform: translateX(-50%); transition: left .3s;
           border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid var(--ink); }
.tn-ends { position: relative; display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); }
.tn-ends i { position: absolute; transform: translateX(-50%); font-style: normal; }
/* under the tree: what each half needs to turn */
.sig-next h3 { margin: 26px 0 10px; font-size: 14px; text-align: center; color: var(--ink2); }
.sig-next-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 1040px; margin: 0 auto; }
.sig-next .tn { max-width: none; }
.sig-next .tn-head { text-transform: none; }
.block .body { overflow-x: auto; }
.block .method { font-size: 13px; color: var(--ink2); max-width: 1100px; }

/* centered tables */
table { border-collapse: collapse; font-size: 13px; }
.block .body table { margin: 12px auto; font-variant-numeric: tabular-nums; }
.block .body table th, .block .body table td { padding: 6px 11px; border-bottom: 1px solid #eceef1; text-align: right; }
.block .body table td { white-space: nowrap; }
.block .body table thead th { background: #f6f7f9; color: var(--ink2); font-weight: 600; border-bottom: 1px solid var(--line); }
.block .body table tbody th { text-align: left; font-weight: 600; color: var(--ink2); background: #fff; }
.tables { display: flex; flex-wrap: wrap; justify-content: safe center; gap: 8px 28px; }   /* safe: una tabla mas ancha que la tarjeta se corta a la derecha (con scroll), no a la izquierda */
.tables h3 { font-size: 14px; margin: 10px 0 0; text-align: center; color: var(--ink2); }
table.plain th, table.plain td { padding: 4px 8px; border-bottom: 1px solid var(--line); }
table.plain th { text-align: left; color: var(--muted); font-weight: 600; }
table.plain td { text-align: left; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
}

/* section shown inside another page (Consensus in Forecast) */
.sec-head.sub { border-left: 4px solid #7c3aed; margin-top: 28px; }
html { scroll-padding-top: 72px; }   /* links to #consensus do not land under the sticky top bar (56 px) */
.sec-head.sub h2 { margin: 0 0 2px; font-size: 22px; }

/* Tech debt page: markdown of TECH_DEBT.md */
.md { max-width: 1100px; line-height: 1.55; }
.md h2 { font-size: 20px; margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.md h2:first-child { margin-top: 0; }
.md h3 { font-size: 15px; margin: 18px 0 6px; }
.md ul { margin: 6px 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md em { color: var(--muted); }

/* collapsible panel (e.g. InHouse model details in Forecast) */
details.fold { margin: 16px 0; }
details.fold > summary { cursor: pointer; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
                         padding: 12px 20px; font-weight: 600; color: var(--ink2); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: '\25B8'; display: inline-block; margin-right: 8px; transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary:hover { border-color: var(--neu-line); }
details.fold[open] > .card { margin-top: 12px; }

/* note that changes with the selector option */
.pane-note { margin: 0 0 6px; }

/* Consensus report picker and Shadow Price band control */
.report-picker, .band-control, .start-pick { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; font-size: 13px; color: var(--ink2); }
.report-picker select, .band-control input, .start-pick select, .start-pick input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.band-control input { width: 80px; }
.band-control button, .start-pick button { padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; font: inherit; }
.body.loading { opacity: .5; transition: opacity .2s; }

/* CPPI: the pickers (a form that reloads the page for another start date or a past day, and links that step fix by fix) and what the strategy says at the fix */
.start-pick { flex-wrap: wrap; }
.stand-box { margin: 12px 0 12px; padding: 12px 16px 10px; border: 1.5px solid #4169e1; border-left-width: 6px; border-radius: 10px; background: #f5f7ff; }
.stand-form { align-items: flex-end; margin: 0; }
.stand-form label { display: flex; flex-direction: column; gap: 2px; }
.stand-form label > span:first-child { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #4169e1; }
.stand-form button { color: #fff; font-weight: 600; background: #4169e1; border-color: #4169e1; }
.stand-form button.alt { color: #4169e1; background: #fff; }
.stand-form .pair { display: flex; gap: 6px; }
.stand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 0 0 10px; }
.stand-date { font-size: 32px; font-weight: 700; line-height: 1.15; }
.stand-note { font-size: 14px; color: var(--muted); }
.stand-note.past { color: #b45309; font-weight: 600; }
.start-pick input[type="number"] { width: 110px; }
/* CPPI: where the money is, as the bands of an account statement. Each row: a title, a bar split in parts, and what each part is */
.bands { max-width: 1050px; margin: 6px 0 18px; padding: 14px 16px 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.band-row { margin: 0 0 14px; }
.band-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; margin-bottom: 4px; }
.band-title span { font-size: 14px; font-weight: 700; }
.band-title small { font-size: 12.5px; color: var(--muted); }
.band { position: relative; display: flex; height: 26px; overflow: hidden; border-radius: 6px; background: #eef0f3; }
.band span { min-width: 4px; height: 100%; }
.band .tb, .band-key .tb { background: #c3c9d1; }
.band .pf, .band-key .pf { background: #4169e1; }
.band .mg, .band-key .mg { background: #cd853f; }
.band .fe, .band-key .fe { background: #f2cf7a; }
.band .au, .band-key .au { background: #ffa500; }
.band.mini { height: 12px; margin: 9px 0 5px; }
.now-dates { margin: 2px 0 10px; max-width: none; font-size: 15px; color: var(--ink2); }
.now-dates b { color: var(--ink); }
.choices .tn-small { font-size: 13px; line-height: 1.5; color: var(--ink2); }
.choices .tn:not([data-c]) { opacity: .82; }
.band-tick { position: absolute; top: 0; width: 0; height: 100%; border-left: 2px dashed #6b7280; }
.band-ends { position: relative; display: flex; justify-content: space-between; margin-top: 2px; font-size: 11px; color: var(--faint); }
.band-ends i { position: absolute; transform: translateX(-50%); font-style: normal; white-space: nowrap; }
.band-key { display: flex; flex-wrap: wrap; gap: 3px 26px; margin-top: 5px; font-size: 13px; color: var(--ink2); }
.band-key i { display: inline-block; width: 11px; height: 11px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }
.band-key b { color: var(--ink); }
.band-note { margin: 7px 0 0; padding: 6px 10px; max-width: none; font-size: 13px; color: var(--ink2); background: #fff9e8; border-left: 3px solid #f2cf7a; border-radius: 4px; }
.start-more > summary { margin: 18px 0 4px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink2); }
/* CPPI: the rules as a flow chart. Left: what is asked at every fix, top to bottom; right: what each answer does. .on marks the path of the day */
.flow { max-width: 1100px; margin: 10px auto 0; }
.flow-row { display: flex; align-items: center; gap: 10px; }
.flow-q { flex: 0 0 250px; padding: 11px 14px; text-align: center; font-size: 14px; font-weight: 600; color: var(--ink2); background: #fff;
          border: 1.5px solid var(--line); border-radius: 24px; }
.flow-q.on { color: var(--ink); background: #f5fbf6; border-color: #7fb98b; }
.flow-yes { flex: 0 0 62px; text-align: center; font-size: 13px; color: var(--faint); white-space: nowrap; }
.flow-yes.on { color: #2e7d46; font-weight: 700; }
.flow-down { width: 250px; padding: 3px 0; text-align: center; font-size: 13px; color: var(--faint); }
.flow-down.on { color: #2e7d46; font-weight: 700; }
.flow .tn { flex: 1; max-width: none; }
.flow .tn-head { font-size: 16px; text-transform: none; }
.flow .tn-small { margin-top: 4px; font-size: 13px; line-height: 1.5; color: var(--ink2); }
.flow-foot { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.start-pick a { margin-left: 6px; white-space: nowrap; }
.start-says { max-width: 1000px; margin: 12px 0 4px; padding: 10px 14px; border-left: 4px solid #4169e1; border-radius: 4px; background: var(--neu-bg); font-size: 15px; font-weight: 600; }

/* two charts side by side (e.g. Options surfaces), aligned at the bottom because the right one has a picker and a note above;
   stacked on narrow screens */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
