/* ============================================================
   MEMORIA — Plaza de Mercado del Barrio Bolívar
   Estilo editorial / revista · luz · hueso
   ============================================================ */

:root {
  --paper: #faf7f0;
  --paper-2: #f2ede2;
  --ink: #1c1a17;
  --ink-soft: #4a4640;
  --line: #dcd5c6;
  --blue: #3c5070;
  --blue-deep: #2a3a52;
  --green: #7ba05b;
  --orange: #d98a3d;
  --red: #c0504d;
  --purple: #7d5ba6;
  --yellow: #d9b44a;
  --brown: #8a6f4e;
  --gray: #9a958c;
  --gray-dark: #55524c;
  --serif: "Playfair Display", "Georgia", "Times New Roman", serif;
  --sans: "Inter", "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 272px;
  --maxw: 880px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--blue); color: #fff; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ============ LAYOUT ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--blue-deep);
  color: #e8e4da;
  padding: 34px 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar__brand {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.2;
  color: #fff;
  letter-spacing: 0.2px;
}
.sidebar__brand span {
  display: block;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 2.6px;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 7px;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar__nav a {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 7px;
  color: #cfc9bc;
  font-size: 13.2px;
  line-height: 1.35;
  transition: background 0.18s, color 0.18s;
}
.sidebar__nav a:hover { background: rgba(255,255,255,0.07); color: #fff; text-decoration: none; }
.sidebar__nav a.is-active { background: rgba(255,255,255,0.12); color: #fff; }

.sidebar__nav .num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--orange);
  min-width: 22px;
}

.sidebar__foot {
  margin-top: auto;
  font-size: 11px;
  color: #8d99ad;
  line-height: 1.55;
  border-top: 1px solid rgba(255,255,255,0.14);
  padding-top: 16px;
}

/* ============ MAIN ============ */
.main { min-width: 0; }

.chapter {
  padding: 92px clamp(28px, 6vw, 84px) 40px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 0;
}
.chapter:last-of-type { border-bottom: 0; }

.chapter__inner { max-width: var(--maxw); margin: 0 auto; }

.kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 18px;
}
.kicker::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.chapter h2 {
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.4px;
  margin-bottom: 20px;
}

.lead {
  font-size: 19px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 74ch;
  margin-bottom: 34px;
}

.chapter h3 {
  font-family: var(--serif);
  font-size: 24px;
  margin: 46px 0 14px;
  letter-spacing: -0.2px;
}

.chapter h4 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--blue);
  margin: 34px 0 12px;
}

.chapter p { margin-bottom: 16px; max-width: 74ch; }

/* ============ HERO (apertura) ============ */
.hero {
  position: relative;
  padding: 110px clamp(28px, 6vw, 84px) 74px;
  background:
    linear-gradient(160deg, var(--blue-deep) 0%, var(--blue) 62%, #46607f 100%);
  color: #fff;
  overflow: hidden;
}
.hero::after {
  content: "BB";
  position: absolute;
  right: -30px;
  bottom: -80px;
  font-family: var(--serif);
  font-size: 340px;
  font-style: italic;
  color: rgba(255,255,255,0.05);
  line-height: 1;
  pointer-events: none;
}
.hero__inner { max-width: var(--maxw); margin: 0 auto; position: relative; z-index: 1; }
.hero .kicker { color: var(--orange); }
.hero .kicker::after { background: rgba(255,255,255,0.25); }

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(38px, 6vw, 66px);
  line-height: 1.05;
  letter-spacing: -1px;
  margin-bottom: 22px;
}
.hero h1 em { font-style: italic; color: #f0c48a; }

.hero__lead {
  font-size: 19px;
  color: #d7dde6;
  max-width: 64ch;
  margin-bottom: 40px;
}

.hero__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.16);
}
.hero__meta div {
  background: rgba(20,32,50,0.55);
  padding: 15px 18px;
}
.hero__meta dt {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #93a3ba;
  margin-bottom: 5px;
}
.hero__meta dd {
  font-family: var(--serif);
  font-size: 17px;
  color: #fff;
}

/* ============ TABLAS ============ */
.table-wrap {
  overflow-x: auto;
  margin: 22px 0 30px;
  border: 1px solid var(--line);
  background: #fff;
}
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.2px;
}
table.t th {
  background: var(--blue-deep);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-align: left;
  padding: 11px 14px;
}
table.t td {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
table.t tbody tr:nth-child(even) { background: var(--paper); }
table.t tbody tr:hover { background: #eef2f8; }
table.t .num-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tr.total-row td { font-weight: 700; background: #fff6dd; border-top: 2px solid var(--yellow); }

/* ============ TARJETAS / GRIDS ============ */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin: 22px 0; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 22px 0; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
}
.card .card__num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 30px;
  color: var(--orange);
  line-height: 1;
}
.card .card__title { font-weight: 700; margin: 8px 0 6px; font-size: 15.5px; }
.card .card__text { font-size: 13.8px; color: var(--ink-soft); line-height: 1.55; }

.stat {
  background: #fff;
  border-top: 3px solid var(--blue);
  padding: 18px 20px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
  color: var(--blue-deep);
  margin-bottom: 6px;
}
.stat span { font-size: 12.5px; color: var(--ink-soft); }

/* ============ NOTA / CALLOUT ============ */
.note {
  border-left: 4px solid var(--orange);
  background: #fdf6ea;
  padding: 15px 20px;
  margin: 22px 0;
  font-size: 14.5px;
  border-radius: 0 8px 8px 0;
}
.note strong { color: var(--brown); }
.note.pending { border-left-color: var(--red); background: #fbeeee; }
.note.pending strong { color: var(--red); }

/* ============ VIDEO SLOT ============ */
.vslot {
  position: relative;
  background: #12161d;
  border-radius: 12px;
  overflow: hidden;
  margin: 26px 0;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9aa7b8;
  text-align: center;
}
.vslot video { width: 100%; height: 100%; object-fit: cover; }
.vslot__ph { padding: 24px; }
.vslot__ph .code {
  font-family: var(--serif);
  font-style: italic;
  font-size: 42px;
  color: var(--orange);
  display: block;
  line-height: 1;
  margin-bottom: 10px;
}
.vslot__ph .name { font-size: 15px; color: #d7dde6; font-weight: 600; }
.vslot__ph .hint { font-size: 12.5px; margin-top: 6px; color: #6c7a8d; }

/* ============ FIGURAS ============ */
figure.fig { margin: 26px 0; }
figure.fig img { border: 1px solid var(--line); background: #fff; }
figure.fig figcaption {
  font-size: 12.5px;
  color: var(--ink-soft);
  padding: 9px 2px 0;
  display: flex;
  gap: 8px;
}
figure.fig figcaption b { color: var(--blue); white-space: nowrap; }

/* ============ SVG PLANTA ============ */
.floorplan { margin: 26px 0; }
.floorplan__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.floorplan__tabs button {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  padding: 9px 18px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s;
}
.floorplan__tabs button:hover { border-color: var(--blue); color: var(--blue); }
.floorplan__tabs button.is-active {
  background: var(--blue-deep);
  border-color: var(--blue-deep);
  color: #fff;
}
.floorplan__stage {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.floorplan__stage svg { width: 100%; height: auto; display: block; }
.floorplan__panel { display: none; }
.floorplan__panel.is-active { display: block; }

.zone { cursor: pointer; transition: opacity 0.15s; }
.zone:hover { opacity: 0.82; }
.zone-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  fill: var(--ink);
  pointer-events: none;
  text-anchor: middle;
}
.zone-area {
  font-family: var(--sans);
  font-size: 9.5px;
  fill: var(--ink-soft);
  pointer-events: none;
  text-anchor: middle;
}

.tooltip {
  position: absolute;
  z-index: 30;
  background: var(--blue-deep);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 9px 13px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -120%);
  transition: opacity 0.12s;
  max-width: 250px;
  box-shadow: 0 8px 24px rgba(20,30,46,0.3);
}
.tooltip.is-on { opacity: 1; }
.tooltip b { color: #f0c48a; display: block; }

/* ============ LEYENDA ============ */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 0 0; font-size: 12.5px; }
.legend i {
  display: inline-block;
  width: 13px; height: 13px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -2px;
}

/* ============ MATRIZ COMPATIBILIDAD ============ */
.matrix-wrap { overflow-x: auto; margin: 22px 0; }
table.matrix { border-collapse: collapse; font-size: 13px; background: #fff; }
table.matrix th, table.matrix td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: center;
}
table.matrix th { background: var(--blue-deep); color: #fff; font-size: 11.5px; }
table.matrix th.rowh { text-align: left; min-width: 110px; }
table.matrix td.rowh {
  text-align: left;
  font-weight: 600;
  background: var(--paper-2);
  font-size: 12px;
}
table.matrix td.cell { cursor: pointer; font-size: 16px; transition: background 0.12s; }
table.matrix td.cell:hover { background: #eef2f8; }
table.matrix td.cell.is-dim { opacity: 0.25; }
#matrix-msg {
  min-height: 44px;
  font-size: 13.5px;
  background: var(--paper-2);
  border: 1px dashed var(--line);
  padding: 11px 16px;
  border-radius: 8px;
  color: var(--ink-soft);
}

/* ============ GRÁFICAS JS (SVG bars) ============ */
.chart { margin: 20px 0 28px; background: #fff; border: 1px solid var(--line); padding: 20px; border-radius: 10px; }
.chart h5 { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--blue); margin-bottom: 14px; }
.chart svg { width: 100%; height: auto; }

/* ============ TABLA CENSO (anexo) ============ */
.censo-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}
.censo-tools input[type="search"], .censo-tools select {
  font-family: var(--sans);
  font-size: 13.5px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  color: var(--ink);
}
.censo-tools input[type="search"] { flex: 1; min-width: 210px; }
.censo-count { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; }
.censo-scroll { max-height: 560px; overflow-y: auto; border: 1px solid var(--line); background: #fff; }
.censo-scroll table.t { font-size: 13px; }
.censo-scroll thead th { position: sticky; top: 0; z-index: 2; }

/* ============ DIAGNÓMICO / CHIPS ============ */
.chips { display: flex; flex-wrap: wrap; gap: 9px; margin: 16px 0 24px; }
.chip {
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px 13px;
  border-radius: 999px;
  color: var(--ink-soft);
}
.chip b { color: var(--blue-deep); }

/* ============ ACORDEÓN ============ */
.acc { border: 1px solid var(--line); background: #fff; border-radius: 10px; overflow: hidden; margin: 20px 0; }
.acc__item + .acc__item { border-top: 1px solid var(--line); }
.acc__head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 15px 20px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
}
.acc__head:hover { background: var(--paper); }
.acc__head::after { content: "+"; font-family: var(--serif); font-size: 22px; color: var(--orange); transition: transform 0.2s; }
.acc__item.is-open .acc__head::after { transform: rotate(45deg); }
.acc__body { display: none; padding: 0 20px 18px; font-size: 14.5px; color: var(--ink-soft); }
.acc__item.is-open .acc__body { display: block; }

/* ============ DECISIONES ============ */
.decision {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px 26px;
  margin: 20px 0;
}
.decision__tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #fff;
  background: var(--purple);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.decision h4 { margin-top: 0 !important; font-size: 17px !important; text-transform: none !important; letter-spacing: 0 !important; color: var(--ink) !important; font-family: var(--serif); font-weight: 700; }
.decision .slot-notas {
  margin-top: 14px;
  border: 1px dashed var(--line);
  background: var(--paper);
  padding: 13px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--gray);
  font-style: italic;
}

/* ============ FIGSLOT (imagen con placeholder) ============ */
figure.figslot { margin: 26px 0; }
figure.figslot img {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
}
figure.figslot .figslot__ph {
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 34px 24px;
  text-align: center;
  color: var(--ink-soft);
}
figure.figslot .figslot__ph .code {
  font-family: var(--serif);
  font-style: italic;
  font-size: 30px;
  color: var(--orange);
  display: block;
  line-height: 1;
  margin-bottom: 8px;
}
figure.figslot .figslot__ph .name {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--blue-deep);
}
figure.figslot .figslot__ph .hint {
  display: block;
  font-size: 12.5px;
  margin-top: 6px;
  color: var(--gray);
}

/* ============ FUENTES ============ */
ul.sources {
  list-style: none;
  margin: 18px 0 30px;
  border-top: 1px solid var(--line);
}
ul.sources li {
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-soft);
  max-width: none;
}
ul.sources li strong { color: var(--blue-deep); }

/* ============ BARRAS DE BALANCE (trazabilidad) ============ */
.barchart { margin: 20px 0 28px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.barchart h5 { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--blue); margin-bottom: 16px; }
.bar-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 34px; gap: 12px; align-items: center; margin-bottom: 10px; }
.bar-row .bar-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.bar-row .bar-track { display: flex; height: 22px; border-radius: 5px; overflow: hidden; background: var(--paper-2); }
.bar-row .seg { height: 100%; min-width: 0; }
.bar-row .seg.a { background: var(--green); }
.bar-row .seg.p { background: var(--orange); }
.bar-row .seg.n { background: var(--red); }
.bar-row .seg.s { background: var(--gray); }
.bar-row .bar-total { font-size: 13px; font-weight: 700; color: var(--blue-deep); text-align: right; font-variant-numeric: tabular-nums; }
.barchart .bar-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-soft); margin-top: 14px; }
.barchart .bar-legend i { display: inline-block; width: 13px; height: 13px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }

/* ============ ESTADOS (matriz de determinantes) ============ */
.st { font-weight: 700; white-space: nowrap; }
.st.a { color: #4f7a3a; }
.st.p { color: #b5731f; }
.st.n { color: var(--red); }
.st.s { color: var(--gray); }

/* ============ PIE ============ */
.site-footer {
  padding: 46px clamp(28px, 6vw, 84px) 60px;
  background: var(--blue-deep);
  color: #97a5bb;
  font-size: 13px;
}
.site-footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  justify-content: space-between;
}
.site-footer__brand strong {
  color: #fff;
  font-family: var(--serif);
  font-size: 18px;
  display: block;
  margin-bottom: 6px;
}
.site-footer__brand span { color: var(--orange); }
.site-footer__meta { display: flex; flex-direction: column; gap: 4px; text-align: right; }
.site-footer a { color: var(--orange); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    max-height: none;
    padding: 22px;
  }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .sidebar__nav a { background: rgba(255,255,255,0.07); font-size: 12.5px; padding: 7px 12px; }
  .sidebar__nav .num { min-width: auto; }
  .sidebar__foot { display: none; }
  .chapter { padding-top: 64px; }
  .site-footer__meta { text-align: left; }
  .bar-row { grid-template-columns: 96px minmax(0, 1fr) 30px; gap: 8px; }
}

/* ============ DECISIONES CON FOTO ============ */
.decision { position: relative; overflow: hidden; }
.decision::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--dec-bg);
  background-size: cover;
  background-position: center;
  opacity: 0.25;
  z-index: 0;
  pointer-events: none;
}
.decision > * { position: relative; z-index: 1; }
.decision--foto { padding-right: 286px; }
.decision--foto .decision__img {
  position: absolute;
  top: -1px;
  right: -1px;
  bottom: -1px;
  width: 260px;
  height: auto;
  object-fit: cover;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 11px 11px 0;
  z-index: 2;
}

/* ============ BANNER CON FOTO DE FONDO ============ */
.banner {
  position: relative;
  margin: 46px 0 14px;
  min-height: 210px;
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background-color: var(--blue-deep);
  background-image: var(--banner-img);
  background-size: cover;
  background-position: center 62%;
}
.banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(14, 18, 24, 0.88) 0%, rgba(14, 18, 24, 0.45) 55%, rgba(14, 18, 24, 0.12) 100%);
}
.banner__inner { position: relative; z-index: 1; width: 100%; padding: 22px 26px 24px; }
.banner__tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.banner h3 { color: #fff !important; margin: 0 !important; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45); }

@media (max-width: 720px) {
  .decision--foto { padding-right: 26px; }
  .decision--foto .decision__img {
    position: static;
    width: 100%;
    height: 210px;
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
}
