/* 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;
  /* bandas de bajista a alcista y escala neutra */
  --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); }
.pill-state.busy { color: var(--gold); font-weight: 600; }

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; }

/* tarjeta de lente */
.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); }
.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; }

/* paginas de seccion */
.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 { 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; }
.block .body { overflow-x: auto; }
.block .method { font-size: 13px; color: var(--ink2); max-width: 1100px; }

/* tablas centradas */
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; }
}

/* seccion que vive dentro de otra pagina (Consensus en Forecast) */
.sec-head.sub { border-left: 4px solid #7c3aed; margin-top: 28px; }
html { scroll-padding-top: 72px; }   /* los enlaces a #consensus no quedan tapados por la barra de arriba (sticky, 56 px) */
.sec-head.sub h2 { margin: 0 0 2px; font-size: 22px; }

/* pagina de deuda tecnica: markdown de 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); }

/* panel desplegable (ej. detalles del modelo InHouse en 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; }

/* nota que cambia con la opcion del selector */
.pane-note { margin: 0 0 6px; }

/* selector de reporte de Consensus y control de bandas del shadow price */
.report-picker, .band-control { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; font-size: 13px; color: var(--ink2); }
.report-picker select, .band-control input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.band-control input { width: 80px; }
.band-control 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; }

/* dos graficos lado a lado (ej. superficies de Options), alineados abajo porque el de la derecha lleva selector y nota encima;
   en pantallas angostas uno debajo del otro */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
