/* Expensas LR — diseño
   Tipografía: la de apple.com (SF Pro Display para títulos, SF Pro Text para texto; respaldo Helvetica Neue, Helvetica, Arial).
   Paleta: grises de Apple + verde roble y oro tomados del logo del barrio. */

:root {
  color-scheme: light dark;
  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --bg: light-dark(#f5f5f7, #000000);
  --surface: light-dark(#ffffff, #161617);
  --surface-2: light-dark(#fafafc, #1c1c1e);
  --surface-3: light-dark(#ededf0, #2c2c2e);
  --ink: light-dark(#1d1d1f, #f5f5f7);
  --ink-2: light-dark(#424245, #d2d2d7);
  --muted: light-dark(#6e6e73, #a1a1a6);
  --faint: light-dark(#86868b, #86868b);
  --line: light-dark(#d2d2d7, #3a3a3c);
  --line-2: light-dark(#e8e8ed, #2c2c2e);

  --brand: light-dark(#1e5440, #63b893);
  --brand-2: light-dark(#2a7356, #82cba9);
  --brand-ink: light-dark(#ffffff, #04140d);
  --brand-soft: light-dark(#e8f1ec, #10241b);
  --gold: light-dark(#9a7631, #d8b46b);
  --gold-2: light-dark(#c9a45c, #ebcd8d);
  --gold-soft: light-dark(#f7f0e2, #282114);
  --link: light-dark(#0066cc, #2997ff);

  --ok: light-dark(#1f7a37, #30d158);
  --ok-soft: light-dark(#e6f4ea, #0f2a17);
  --warn: light-dark(#a8510a, #ff9f0a);
  --warn-soft: light-dark(#fdf0e3, #2e1d07);
  --bad: light-dark(#c4001a, #ff453a);
  --bad-soft: light-dark(#fdeaec, #330d0b);
  --info: light-dark(#0066cc, #2997ff);
  --info-soft: light-dark(#e8f1fb, #0b2036);

  --c1: #2e7d5b; --c2: #c49a3c; --c3: #3f78c0; --c4: #a58f5d; --c5: #2fa7a6; --c6: #d0704f; --c7: #7fa24a; --c8: #6a8fb3; --c9: #7c8796;

  --rail-bg: light-dark(#143a2c, #0d2a1f);
  --rail-ink: #e8f1ec;
  --rail-muted: #9fc0af;
  --rail-line: rgb(255 255 255 / .12);
  --rail-active: light-dark(#1f5440, #1b4a37);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 8px 28px -14px rgb(0 0 0 / .16);
  --ease: cubic-bezier(.25, .1, .25, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: linear(0, .25 8%, .64 17%, .95 27%, 1.06 37%, 1.07 44%, 1.02 57%, .995 72%, 1);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-text); font-size: 15px; line-height: 1.47; letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-variant-numeric: tabular-nums;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid color-mix(in oklab, var(--link) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
::selection { background: color-mix(in oklab, var(--gold-2) 45%, transparent); }
h1, h2, h3, .display { font-family: var(--font-display); margin: 0; }
small { font-size: inherit; }

/* ---------- estructura ---------- */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; transition: grid-template-columns .55s var(--spring); }
.rail {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 18px; padding: 22px 14px 18px;
  background: var(--rail-bg); color: var(--rail-ink); border-right: 1px solid rgb(0 0 0 / .25); overflow-y: auto; overflow-x: hidden; box-shadow: 10px 0 34px -22px rgb(0 0 0 / .55); z-index: 5;
  transition: padding .45s var(--spring);
  scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / .2) transparent;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; border-bottom: 1px solid var(--rail-line); }
.brand-logo { width: 54px; height: 54px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1.5px var(--gold-2), 0 8px 18px -8px rgb(0 0 0 / .6); transition: transform .6s var(--spring); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.05); }
.brand b { display: block; font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; color: #fff; }
.brand small { display: block; color: var(--rail-muted); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sec { font-size: 12px; color: var(--gold-2); font-weight: 500; padding: 14px 10px 4px; letter-spacing: .02em; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 10px; color: var(--rail-ink); text-decoration: none;
  font-size: 14.5px; font-weight: 500; transition: background .2s var(--ease), color .2s var(--ease);
}
.nav a:hover { background: rgb(255 255 255 / .07); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--rail-active); color: #fff; box-shadow: inset 0 0 0 .5px rgb(255 255 255 / .1); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gold-2); }
.nav a[aria-current="page"] .lbl { font-weight: 600; }
.tile { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(180deg, color-mix(in oklab, var(--t) 80%, #fff), var(--t)); box-shadow: inset 0 0 0 .5px rgb(255 255 255 / .3), 0 1px 3px rgb(0 0 0 / .35); }
.tile svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; color: #fff; background: #d93a30; }
.nav .count[hidden] { display: none; }
.rail-foot { margin-top: auto; display: grid; gap: 10px; }
.rail-foot .priv { font-size: 12.5px; color: var(--rail-muted); line-height: 1.45; padding: 12px; border-radius: 12px; background: rgb(0 0 0 / .18); border: 1px solid var(--rail-line); display: flex; gap: 9px; }
.rail-foot .priv svg { width: 16px; height: 16px; flex: none; stroke: var(--gold-2); fill: none; stroke-width: 1.8; margin-top: 1px; }
.rail-foot .btn { color: var(--rail-ink); border-color: var(--rail-line); background: transparent; }
.rail-foot .btn:hover { background: rgb(255 255 255 / .08); }

.main { padding: 14px clamp(16px, 3.2vw, 48px) 96px; min-width: 0; max-width: 1480px; }
.topbar { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; position: sticky; top: 0; z-index: 20; padding: 10px 0; background: color-mix(in oklab, var(--bg) 84%, transparent); backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px); }
.segmented { position: relative; display: flex; gap: 8px; padding: 2px 2px 8px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.mcard {
  position: relative; flex: none; min-width: 116px; padding: 9px 13px 11px; border-radius: 12px; cursor: pointer; text-align: left; line-height: 1.25;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); display: grid; gap: 1px;
  transition: transform .35s var(--spring), background .25s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease), color .25s var(--ease);
}
.mcard b { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.mcard .mm { font-size: 12.5px; color: var(--muted); transition: color .25s var(--ease); }
.mcard .mbar { display: block; height: 4px; border-radius: 4px; margin-top: 7px; background: color-mix(in oklab, var(--brand) 14%, var(--surface-3)); overflow: hidden; }
.mcard .mbar i { display: block; height: 100%; width: var(--w); border-radius: 4px; background: var(--c1); transform-origin: left; transition: background .25s var(--ease); }
.mcard.entra { animation: mrise .6s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 55ms); }
.mcard.entra .mbar i { animation: growx .9s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 55ms + 160ms); }
@keyframes mrise { from { opacity: 0; transform: translateY(8px) scale(.96); } }
.mcard:hover { transform: translateY(-2px); border-color: color-mix(in oklab, var(--brand) 40%, var(--line-2)); box-shadow: 0 10px 22px -14px rgb(20 58 44 / .5); }
.mcard:active { transform: scale(.97); }
.mcard[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 12px 24px -12px rgb(20 58 44 / .65); transform: translateY(-1px); }
.mcard[aria-pressed="true"] b { color: var(--brand-ink); }
.mcard[aria-pressed="true"] .mm { color: color-mix(in oklab, var(--brand-ink) 75%, transparent); }
.mcard[aria-pressed="true"] .mbar { background: rgb(255 255 255 / .22); }
.mcard[aria-pressed="true"] .mbar i { background: var(--gold-2); }
:root[data-theme="dark"] .mcard[aria-pressed="true"] .mbar { background: rgb(0 0 0 / .25); }
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 16px; border-radius: 980px; border: 1px solid transparent;
  background: var(--surface-3); color: var(--ink); cursor: pointer; font-size: 14px; font-weight: 500; text-decoration: none; transition: background .2s var(--ease), transform .15s var(--ease);
}
.btn:hover { background: color-mix(in oklab, var(--surface-3) 85%, var(--ink) 9%); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- tipografía de página ---------- */
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: clamp(30px, 3.4vw, 40px); font-weight: 600; line-height: 1.1; letter-spacing: 0; }
.page-sub { color: var(--muted); font-size: 17px; line-height: 1.47; letter-spacing: -0.022em; margin: 8px 0 0; max-width: 70ch; }
.section { margin-top: 40px; }
.section-head { margin-bottom: 14px; }
.section-head h2 { font-size: 21px; font-weight: 600; letter-spacing: .011em; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; max-width: 80ch; }
.mut { color: var(--muted); }
.faint { color: var(--faint); }

/* ---------- notas aclaratorias ---------- */
.note { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.note > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: none; stroke: var(--info); stroke-width: 1.8; stroke-linecap: round; }
.note b { color: var(--ink); font-weight: 600; }
.note ul { margin: 4px 0 0; padding-left: 18px; }
.note li + li { margin-top: 3px; }
.note.gold { background: var(--gold-soft); } .note.gold > svg { stroke: var(--gold); }
.note.warn { background: var(--warn-soft); } .note.warn > svg { stroke: var(--warn); }
.note.ok { background: var(--ok-soft); } .note.ok > svg { stroke: var(--ok); }
.ihelp { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font-size: 10.5px; font-weight: 700; font-style: normal; color: var(--muted); border: 1.2px solid var(--line); cursor: help; margin-left: 6px; flex: none; }

/* ---------- grillas y tarjetas ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: stretch; gap: 24px; }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { position: relative; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-h span { color: var(--muted); font-size: 12.5px; }
button.card { text-align: left; cursor: pointer; font: inherit; color: inherit; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
button.card:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 14px 30px -18px rgb(0 0 0 / .3); }
button.card[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }

/* ---------- KPI ---------- */
.card.t-verde { background: color-mix(in oklab, var(--brand) 7%, var(--surface)); border-color: color-mix(in oklab, var(--brand) 22%, var(--line-2)); }
.card.t-oro { background: color-mix(in oklab, var(--gold-2) 13%, var(--surface)); border-color: color-mix(in oklab, var(--gold-2) 38%, var(--line-2)); }
.card.t-cielo { background: color-mix(in oklab, var(--info) 7%, var(--surface)); border-color: color-mix(in oklab, var(--info) 22%, var(--line-2)); }
.card.t-aviso { background: color-mix(in oklab, var(--warn) 8%, var(--surface)); border-color: color-mix(in oklab, var(--warn) 26%, var(--line-2)); }
.card.t-rojo { background: color-mix(in oklab, var(--bad) 6%, var(--surface)); border-color: color-mix(in oklab, var(--bad) 22%, var(--line-2)); }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .lab { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; }
.kpi .val { font-family: var(--font-display); font-size: clamp(22px, 2vw, 28px); font-weight: 600; letter-spacing: -0.012em; line-height: 1.12; white-space: nowrap; }
.cents { font-size: .62em; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi .sub { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 980px; width: fit-content; }
.delta.up { color: var(--bad); background: var(--bad-soft); }
.delta.down { color: var(--ok); background: var(--ok-soft); }
.delta.up-good { color: var(--ok); background: var(--ok-soft); }
.delta.down-bad { color: var(--bad); background: var(--bad-soft); }
.delta.flat { color: var(--muted); background: var(--surface-3); }

/* ---------- hero ---------- */
.hero { display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 6px 0; }
.hero-kicker { display: flex; align-items: center; gap: 10px; color: var(--gold); font-weight: 600; font-size: 14px; }
.hero-kicker::before { content: ""; width: 26px; height: 1.5px; background: var(--gold-2); border-radius: 2px; }
.hero h1 { font-size: clamp(42px, 5.2vw, 64px); font-weight: 600; letter-spacing: -0.009em; line-height: 1.05; }
.hero .lead { font-size: 19px; line-height: 1.45; color: var(--ink-2); letter-spacing: .005em; max-width: 34em; margin: 0; }
.hero .lead b { color: var(--ink); font-weight: 600; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 980px; font-size: 12.5px; font-weight: 500; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.alta { background: var(--bad-soft); color: var(--bad); }
.chip.media { background: var(--warn-soft); color: var(--warn); }
.chip.baja { background: var(--info-soft); color: var(--info); }
.chip.info { background: var(--surface-3); color: var(--muted); }
.chip.dato { background: var(--brand-soft); color: var(--brand); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* escena 3D */
.scene-card { padding: 0; overflow: hidden; min-height: 430px; background: radial-gradient(120% 90% at 50% 0%, var(--surface) 30%, var(--surface-2)); }
.scene-title { position: absolute; left: 22px; top: 18px; z-index: 3; pointer-events: none; }
.scene-title b { font-size: 15px; font-weight: 600; display: block; }
.scene-title span { font-size: 12.5px; color: var(--muted); }
.scene { position: absolute; inset: 58px 0 46px 0; perspective: 1200px; perspective-origin: 50% 25%; display: grid; place-items: center; cursor: grab; touch-action: pan-y; }
.scene:active { cursor: grabbing; }
.world { position: relative; width: 0; height: 0; transform-style: preserve-3d; transform: translateY(96px) rotateX(var(--rx, -20deg)) rotateY(var(--ry, -26deg)); }
.floor { position: absolute; left: calc(var(--fw) / -2); top: calc(var(--fd) / -2); width: var(--fw); height: var(--fd); transform: rotateX(90deg); border-radius: 16px;
  background: linear-gradient(var(--line-2) 1px, transparent 1px) 0 0 / 36px 36px, linear-gradient(90deg, var(--line-2) 1px, transparent 1px) 0 0 / 36px 36px, color-mix(in oklab, var(--surface-3) 40%, transparent);
  mask-image: radial-gradient(closest-side, #000 60%, transparent); -webkit-mask-image: radial-gradient(closest-side, #000 60%, transparent); }
.tower { position: absolute; transform-style: preserve-3d; transform: translate3d(var(--x), 0, 0); }
.prism { position: absolute; left: 0; bottom: 0; width: var(--w); height: calc(var(--h) * 1px); transform-style: preserve-3d; transform-origin: bottom center;
  transform: translate3d(var(--ox), 0, 0) scaleY(var(--grow, 0.001)); transition: transform 1.2s var(--spring) var(--delay, 0s); }
.scene.in .prism { --grow: 1; }
.face { position: absolute; display: block; backface-visibility: hidden; }
.face.f { width: var(--w); height: 100%; left: 0; bottom: 0; background: linear-gradient(180deg, color-mix(in oklab, var(--c) 85%, #fff), var(--c)); transform: translateZ(calc(var(--d) / 2)); }
.face.b { width: var(--w); height: 100%; left: 0; bottom: 0; background: color-mix(in oklab, var(--c) 55%, #000); transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); }
.face.r { width: var(--d); height: 100%; left: calc(var(--w) / 2 - var(--d) / 2); bottom: 0; background: color-mix(in oklab, var(--c) 70%, #000); transform: rotateY(90deg) translateZ(calc(var(--w) / 2)); }
.face.l { width: var(--d); height: 100%; left: calc(var(--w) / 2 - var(--d) / 2); bottom: 0; background: color-mix(in oklab, var(--c) 80%, #000); transform: rotateY(-90deg) translateZ(calc(var(--w) / 2)); }
.face.t { width: var(--w); height: var(--d); left: 0; top: calc(var(--d) / -2); background: color-mix(in oklab, var(--c) 72%, #fff); transform: rotateX(90deg); }
.tower[data-sel="true"] .face.f { box-shadow: inset 0 0 0 2px var(--gold-2); }
.tower .tag { position: absolute; left: 4px; top: 16px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; pointer-events: none; transform: translateZ(34px) rotateY(calc(var(--ry, -26deg) * -1)) rotateX(calc(var(--rx, -20deg) * -1)); }
.tower[data-sel="true"] .tag { color: var(--gold); }
.scene-legend { position: absolute; left: 22px; bottom: 15px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); z-index: 3; pointer-events: none; }
.scene-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.scene-hint { position: absolute; right: 20px; top: 21px; font-size: 12px; color: var(--faint); z-index: 3; pointer-events: none; }
@media (max-width: 520px) { .scene-hint { display: none; } }

/* ---------- hallazgos ---------- */
.list { display: grid; gap: 10px; }
.finding { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; transition: border-color .2s var(--ease); }
.finding[open] { border-color: var(--line); box-shadow: var(--shadow); }
.finding summary { list-style: none; display: grid; grid-template-columns: 4px minmax(0, 1fr) auto 16px; gap: 14px; align-items: center; padding: 14px 16px; cursor: pointer; }
.finding summary::-webkit-details-marker { display: none; }
.finding summary:hover { background: var(--surface-2); }
.finding .bar { align-self: stretch; border-radius: 4px; background: var(--faint); }
.finding .bar.alta { background: var(--bad); } .finding .bar.media { background: var(--warn); } .finding .bar.baja { background: var(--info); }
.finding .t { font-weight: 600; line-height: 1.35; font-size: 15px; }
.finding .m { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.finding .amt { font-weight: 600; font-size: 15px; white-space: nowrap; text-align: right; }
.finding .chev { width: 14px; height: 14px; stroke: var(--faint); fill: none; stroke-width: 2; transition: transform .25s var(--ease); }
.finding[open] .chev { transform: rotate(90deg); }
.finding .body { padding: 0 18px 18px 34px; display: grid; gap: 12px; color: var(--ink-2); font-size: 14px; animation: rise .3s var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(-4px); } }
.finding .ask { padding: 11px 13px; border-radius: 10px; background: var(--brand-soft); }
.finding .ask b, .finding .ref b { color: var(--ink); }
.finding .ref { font-size: 13px; color: var(--muted); }
.finding .ctl { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line-2); padding-top: 12px; }
.field { padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; }
.finding .ctl input[type=text] { flex: 1; min-width: 200px; }
.check-inline { display: inline-flex; gap: 7px; align-items: center; font-size: 13.5px; cursor: pointer; }

/* ---------- tablas ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); max-height: 72vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--ink); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in oklab, var(--brand) 4%, transparent); }
td.n, th.n { text-align: right; white-space: nowrap; }
tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; position: sticky; bottom: 0; }
tr.exp td { background: var(--surface-2); }
tr.click { cursor: pointer; }
.tag-sf { color: var(--warn); font-weight: 600; font-size: 12.5px; }
.heat { border-radius: 6px; padding: 2px 6px; display: inline-block; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .field { min-width: 170px; padding: 8px 12px; }
.toolbar input[type=search] { min-width: 240px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

/* ---------- gráficos ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font-text); }
.chart .gridl { stroke: var(--line-2); }
.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.3s var(--ease-out) .05s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.fade-in { opacity: 0; animation: fade .6s var(--ease) .45s forwards; }
@keyframes fade { to { opacity: 1; } }
.grow-y { transform-origin: bottom; transform-box: fill-box; animation: growy .9s var(--spring) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes growy { from { transform: scaleY(0); } }
.pop { transform-origin: center; transform-box: view-box; animation: pop .8s var(--spring) backwards; animation-delay: calc(var(--i, 0) * 50ms); }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
.hit { fill: transparent; cursor: crosshair; }
.donut-seg { transition: opacity .2s; }
.donut-wrap:hover .donut-seg { opacity: .5; } .donut-wrap .donut-seg:hover { opacity: 1; }
.legend-c { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.legend-c i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 210px) minmax(60px, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; font-size: 13.5px; border-bottom: 1px solid var(--line-2); }
.bar-row:last-child { border-bottom: 0; }
.bar-row .tr { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.bar-row .fl { height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transform-origin: left; animation: growx .9s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 35ms); }
.bar-row .fl.neg { background: var(--bad); }
.bar-row .fl.gold { background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
@keyframes growx { from { transform: scaleX(0); } }
.tip { position: fixed; z-index: 100; pointer-events: none; padding: 10px 12px; border-radius: 12px; background: color-mix(in oklab, var(--surface) 94%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); color: var(--ink); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; max-width: 320px; box-shadow: 0 16px 36px -14px rgb(0 0 0 / .35); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; }
.tip.on { opacity: 1; transform: none; }

/* ---------- carga ---------- */
.drop { display: block; border: 1.5px dashed var(--line); border-radius: 20px; padding: 42px 24px; text-align: center; background: var(--surface-2); cursor: pointer; transition: background .2s, border-color .2s, transform .2s var(--ease); }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop.over { transform: scale(1.01); }
.drop svg { width: 44px; height: 44px; stroke: var(--brand); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.drop b { display: block; font-family: var(--font-display); font-size: 21px; font-weight: 600; margin: 10px 0 4px; }
.check { display: flex; gap: 10px; align-items: baseline; font-size: 13.5px; padding: 3px 0; }
.check .ic { width: 16px; flex: none; font-weight: 700; }
.check.ok .ic { color: var(--ok); } .check.no .ic { color: var(--bad); }
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: var(--p, 0%); background: var(--brand); transition: width .25s var(--ease); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.kbd { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); }
details.plain > summary { cursor: pointer; color: var(--link); font-size: 13.5px; list-style: none; }
details.plain > summary::-webkit-details-marker { display: none; }
dialog { border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--ink); padding: 0; width: min(760px, 94vw); box-shadow: 0 40px 90px -30px rgb(0 0 0 / .5); }
dialog::backdrop { background: rgb(0 0 0 / .4); backdrop-filter: blur(6px); }
dialog[open] { animation: dlg .35s var(--spring); }
@keyframes dlg { from { opacity: 0; transform: scale(.96) translateY(8px); } }
dialog .dh { padding: 20px 22px 6px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
dialog .dh h2 { font-size: 24px; font-weight: 600; }
dialog .db { padding: 8px 22px 22px; display: grid; gap: 12px; max-height: 70vh; overflow: auto; }
dialog textarea { width: 100%; min-height: 260px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px; line-height: 1.55; }

/* transición entre secciones */
::view-transition-old(root) { animation: .18s var(--ease) both vt-out; }
::view-transition-new(root) { animation: .32s var(--ease-out) both vt-in; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-hero, .g-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; gap: 10px; padding: 12px 14px; border-right: 0; border-bottom: 1px solid rgb(0 0 0 / .25); }
  .nav a[aria-current="page"]::before { display: none; }
  .brand { padding: 0 2px 10px; }
  .brand-logo { width: 42px; height: 42px; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .nav-sec { display: none; }
  .nav a { white-space: nowrap; padding: 6px 10px 6px 6px; }
  .rail-foot { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .topbar { position: static; }
  .top-actions { display: none; }
  .scene-card { min-height: 360px; }
  .bar-row { grid-template-columns: minmax(90px, 130px) minmax(40px, 1fr) auto; }
  .finding summary { grid-template-columns: 4px minmax(0, 1fr) 16px; }
  .finding .amt { grid-column: 2; text-align: left; }
  .finding .body { padding-left: 18px; }
  .hero .lead { font-size: 17px; }
  .toolbar input[type=search] { min-width: 0; flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  .prism { --grow: 1; }
}
@media print {
  .rail, .topbar, .scene-card, .no-print { display: none !important; }
  .app { display: block; } body { background: #fff; color: #000; }
  .card, .finding, .table-wrap { box-shadow: none; break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
}

/* ---------- barra plegable (riel de íconos) ---------- */
.rail-toggle { display: none; }
.rail .lbl, .brand > div, .rail-foot .btn span { white-space: nowrap; overflow: hidden; max-width: 220px; transition: opacity .28s var(--ease) .18s, max-width .45s var(--spring), transform .35s var(--ease-out) .12s; }
.nav-sec { transition: opacity .25s var(--ease) .15s, padding .4s var(--spring), font-size .3s var(--ease); }
.brand-logo { transition: transform .6s var(--spring), width .5s var(--spring), height .5s var(--spring); }
.tile { transition: transform .35s var(--spring), box-shadow .25s var(--ease); }
.nav a:hover .tile { transform: scale(1.1) rotate(-3deg); }
.rail-foot .priv { transition: opacity .25s var(--ease) .15s, max-height .45s var(--spring), padding .4s var(--spring); max-height: 120px; overflow: hidden; }
@media (min-width: 881px) {
  .rail-toggle {
    display: grid; place-items: center; position: fixed; z-index: 40; top: 34px; left: 251px; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; padding: 0;
    background: var(--rail-bg); border: 1.5px solid var(--gold-2); color: var(--gold-2);
    box-shadow: 0 6px 16px -6px rgb(0 0 0 / .55); transition: left .55s var(--spring), transform .25s var(--ease), background .25s var(--ease), color .25s var(--ease);
  }
  .rail-toggle:hover { background: var(--gold-2); color: #143a2c; transform: scale(1.1); }
  .rail-toggle:active { transform: scale(.94); }
  .rail-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .55s var(--spring); }
  .app[data-rail="min"] { grid-template-columns: 82px minmax(0, 1fr); }
  .app[data-rail="min"] .rail-toggle { left: 68px; }
  .app[data-rail="min"] .rail-toggle svg { transform: rotate(180deg); }
  .app[data-rail="min"] .rail { padding-left: 15px; padding-right: 15px; }
  .app[data-rail="min"] .rail .lbl, .app[data-rail="min"] .brand > div, .app[data-rail="min"] .rail-foot .btn span { opacity: 0; max-width: 0; transform: translateX(-8px); transition-delay: 0s, 0s, 0s; }
  .app[data-rail="min"] .brand { justify-content: center; padding: 4px 0 16px; gap: 0; }
  .app[data-rail="min"] .brand-logo { width: 44px; height: 44px; }
  .app[data-rail="min"] .nav a { justify-content: center; gap: 0; padding: 6px 0; }
  .app[data-rail="min"] .nav a[aria-current="page"]::before { left: -15px; }
  .app[data-rail="min"] .nav-sec { font-size: 0; opacity: 1; padding: 11px 0 5px; position: relative; }
  .app[data-rail="min"] .nav-sec::after { content: ""; position: absolute; left: 14px; right: 14px; top: 50%; height: 1px; background: var(--rail-line); }
  .app[data-rail="min"] .nav .count { position: absolute; top: 2px; right: 6px; min-width: 0; width: 10px; height: 10px; padding: 0; font-size: 0; border: 2px solid var(--rail-bg); box-sizing: content-box; margin: 0; }
  .app[data-rail="min"] .rail-foot .priv { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; border-width: 0; transition-delay: 0s; }
  .app[data-rail="min"] .rail-foot .btn { width: 42px; height: 42px; padding: 0; margin: 0 auto; border-radius: 50%; gap: 0; }
  .app[data-rail="min"] .rail-foot .btn svg { width: 18px; height: 18px; }
}
@media (max-width: 880px) { .brand > div { max-width: none; } }
@media print { .rail-toggle { display: none !important; } }
