:root {
  /* tema claro */
  --navy-1: #0b1f4d;
  --navy-2: #163a8a;
  --bg: #eef2f9;
  --bg-glow: radial-gradient(1200px 500px at 85% -120px, rgba(61, 123, 255, .14), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --border: #e1e8f3;
  --text: #0c1830;
  --muted: #61708c;
  --accent: #2563eb;
  --accent-2: #06b6d4;
  --accent-soft: #e4edff;
  --pos: #0f9f68;
  --neg: #e23d4b;
  --warn: #c28410;
  --shadow: 0 1px 2px rgba(12, 24, 48, .05), 0 6px 20px rgba(12, 24, 48, .06);
  --radius: 18px;
  --on-navy: #ffffff;
  --on-navy-muted: rgba(255, 255, 255, .7);
  --top-bg: linear-gradient(180deg, #0b1f4d, #0d2560);
  --top-border: transparent;
  --hero-bg: linear-gradient(145deg, #1a47b8 0%, #0e2a6e 45%, #0a1b44 100%);
  --tabs-bg: rgba(255, 255, 255, .88);
  --c1: #2563eb; --c2: #4f8cff;
  /* paleta categórica validada (orden fijo, apto daltonismo) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948; --s-neutral: #a3aec2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy-1: #0a1735; --navy-2: #12306e;
    --bg: #050a16;
    --bg-glow: radial-gradient(900px 480px at 90% -160px, rgba(61, 123, 255, .22), transparent 60%), radial-gradient(700px 400px at -10% 30%, rgba(6, 182, 212, .07), transparent 60%);
    --surface: #0b1426; --surface-2: #111d35; --border: #1a2846;
    --text: #e8eefa; --muted: #8796b4;
    --accent: #4d8dff; --accent-2: #22d3ee; --accent-soft: #13254d;
    --pos: #2bd99a; --neg: #ff6474; --warn: #f2b84b;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
    --top-bg: rgba(5, 10, 22, .78); --top-border: rgba(255, 255, 255, .06);
    --hero-bg: linear-gradient(145deg, #1b4fd1 0%, #0f2f7d 42%, #0a1838 100%);
    --tabs-bg: rgba(8, 14, 28, .86);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767; --s-neutral: #56647e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --navy-1: #0a1735; --navy-2: #12306e;
  --bg: #050a16;
  --bg-glow: radial-gradient(900px 480px at 90% -160px, rgba(61, 123, 255, .22), transparent 60%), radial-gradient(700px 400px at -10% 30%, rgba(6, 182, 212, .07), transparent 60%);
  --surface: #0b1426; --surface-2: #111d35; --border: #1a2846;
  --text: #e8eefa; --muted: #8796b4;
  --accent: #4d8dff; --accent-2: #22d3ee; --accent-soft: #13254d;
  --pos: #2bd99a; --neg: #ff6474; --warn: #f2b84b;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
  --top-bg: rgba(5, 10, 22, .78); --top-border: rgba(255, 255, 255, .06);
  --hero-bg: linear-gradient(145deg, #1b4fd1 0%, #0f2f7d 42%, #0a1838 100%);
  --tabs-bg: rgba(8, 14, 28, .86);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767; --s-neutral: #56647e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 700; }
h3 { font-size: 12px; margin: 18px 0 6px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
small, .hint, .sub, .label { color: var(--muted); }
.hint { font-size: 12.5px; margin: 6px 0; }
.sub { font-size: 13px; margin: 4px 2px 10px; }
.label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num, .big, .mid, .val { font-variant-numeric: tabular-nums; }

/* encabezado azul */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--navy-1);
  color: var(--on-navy);
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 760px; margin: 0 auto; }
.top-row + .top-row { margin-top: 10px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--c2), var(--c1)); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.seg { display: flex; background: rgba(255, 255, 255, .1); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 13px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--on-navy-muted); }
.seg button.on { background: #fff; color: var(--navy-1); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--on-navy-muted); cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.knob { width: 34px; height: 20px; border-radius: 10px; background: rgba(255, 255, 255, .18); position: relative; transition: .2s; flex: none; }
.knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + .knob { background: var(--c2); }
.switch input:checked + .knob::after { left: 17px; }
.switch input:focus-visible + .knob { outline: 2px solid #fff; outline-offset: 2px; }
.status { display: flex; align-items: center; gap: 6px; border: 0; background: rgba(255, 255, 255, .08); font-size: 12px; color: var(--on-navy-muted); padding: 4px 10px; border-radius: 20px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--on-navy-muted); }
.status[data-kind="ok"] .dot { background: #2fd38a; }
.status[data-kind="err"] .dot { background: #f2b84b; }
.status[data-kind="busy"] .dot { background: #7fb0ff; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.empty { text-align: center; padding: 30px 18px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.empty .btns { justify-content: center; }
.btn { border: 0; background: var(--accent); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 700; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--neg); border: 1px solid var(--neg); }
.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 700; }
.link.danger { color: var(--neg); font-size: 12px; font-weight: 600; }
.banner { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

/* tarjeta principal */
.hero {
  background: linear-gradient(140deg, var(--navy-2) 0%, var(--navy-1) 70%);
  border: 0; color: var(--on-navy); position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(77, 141, 255, .35), transparent 70%);
}
.hero .label { color: var(--on-navy-muted); }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 16px; }
.hero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: relative; z-index: 1; }
.hero-row > div { background: rgba(255, 255, 255, .07); border-radius: 12px; padding: 10px 12px; }
.mid { font-size: 19px; font-weight: 750; }
.hero .pos { color: #4be3a0; }
.hero .neg { color: #ff8a8d; }
.hero .hint, .hero small { color: var(--on-navy-muted); }
.note { font-size: 12px; color: var(--on-navy-muted); margin: 14px 0 0; border-top: 1px solid rgba(255, 255, 255, .14); padding-top: 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 13px; min-width: 0; box-shadow: var(--shadow); }
.stat .val { font-size: 17px; font-weight: 750; margin-top: 5px; overflow-wrap: anywhere; }
.stat .hint { margin: 4px 0 0; font-size: 11.5px; }

/* distribución */
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 4px 0 12px; }
.stack span { display: block; min-width: 3px; }
.legend { display: flex; flex-direction: column; }
.legend div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; font-size: 14px; border-top: 1px solid var(--border); }
.legend div:first-child { border-top: 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: 0; }
.legend span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

.row { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; border-top: 1px solid var(--border); background: none; padding: 10px 0; text-align: left; gap: 10px; }
.row:first-of-type { border-top: 0; }
.row > span { display: flex; flex-direction: column; }
.row .lead { flex-direction: row; align-items: center; gap: 10px; }
.r { text-align: right; align-items: flex-end; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 10px; font-weight: 800; letter-spacing: -.03em; flex: none; overflow: hidden; }
.nowrap { white-space: nowrap; }
.a-row > b { white-space: nowrap; }
.foot { font-size: 12px; color: var(--muted); padding: 0 4px; }

/* activos */
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
select, input[type="number"], input[type="date"], input[type="search"], .form input { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 9px 11px; min-width: 0; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }
.asset { display: flex; gap: 11px; align-items: center; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 12px; box-shadow: var(--shadow); }
.asset .body { flex: 1; min-width: 0; }
.a-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.a-row + .a-row { margin-top: 3px; }
.a-row b, .a-row small { font-variant-numeric: tabular-nums; }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-weight: 700; vertical-align: 1px; }
.tag.warn { color: var(--warn); }
.chg { font-size: 11.5px; font-weight: 700; margin-left: 4px; padding: 1px 5px; border-radius: 6px; }
.chg.pos { background: color-mix(in srgb, var(--pos) 13%, transparent); }
.chg.neg { background: color-mix(in srgb, var(--neg) 13%, transparent); }

/* movimientos */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--border); background: var(--surface); padding: 7px 12px; border-radius: 18px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.search { width: 100%; margin: 10px 0 4px; }
.month { margin-top: 18px; }
.mov { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.m-l { display: flex; flex-direction: column; min-width: 0; }
.m-l small { overflow-wrap: anywhere; }
.m-r { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; white-space: nowrap; }

/* más */
.mp { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 8px; align-items: center; margin: 8px 0; }
.explain details { border-top: 1px solid var(--border); padding: 10px 0; }
.explain summary { font-weight: 650; cursor: pointer; }
.explain p { color: var(--muted); font-size: 13.5px; margin: 8px 0 2px; }

/* barra inferior */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(15, 27, 51, .05);
}
.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.tabs svg { width: 38px; height: 26px; padding: 3px 9px; border-radius: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: background .2s; }
.tabs circle { fill: currentColor; stroke: none; }
.tabs button.on { color: var(--accent); }
.tabs button.on svg { background: var(--accent-soft); }

/* hoja inferior */
dialog#sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 760px; max-height: 88vh;
  background: var(--surface); color: var(--text); border-radius: 20px 20px 0 0;
}
dialog#sheet::backdrop { background: rgba(5, 12, 30, .6); }
#sheetBody { padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-h { display: flex; justify-content: space-between; align-items: flex-start; position: sticky; top: -14px; background: var(--surface); padding: 4px 0 10px; margin-top: -4px; z-index: 1; }
.sheet-h h2 { font-size: 21px; margin: 0; }
.x { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; }
.dl { margin: 0; }
.dl div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form .two { display: flex; gap: 10px; }
.form .two > label { flex: 1; min-width: 0; }
.form input, .form select { color: var(--text); width: 100%; font-weight: 400; }
.form input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.form label.chk { flex-direction: row; color: var(--text); font-size: 14px; align-items: center; }
[hidden] { display: none !important; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 520px; margin: 0 auto; background: var(--navy-1); color: #fff;
  padding: 12px 15px; border-radius: 14px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }

/* encabezados de tarjeta y selectores chicos */
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-h h2 { margin: 0; }
.seg-sm { display: flex; background: var(--surface-2); border-radius: 9px; padding: 2px; }
.seg-sm button { border: 0; background: none; padding: 4px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--muted); }
.seg-sm button.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(15, 27, 51, .12); }

/* hero: variación del día */
.today { display: flex; align-items: center; gap: 8px; margin: -8px 0 16px; font-size: 13px; color: var(--on-navy-muted); position: relative; z-index: 1; }
.pill { font-weight: 700; padding: 3px 9px; border-radius: 20px; background: rgba(255, 255, 255, .1); font-variant-numeric: tabular-nums; }

/* evolución */
.period { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.period .mid { font-size: 18px; }
.chart { position: relative; margin: 4px -2px 0; min-height: 60px; touch-action: pan-y; }
.chart-empty { height: 180px; display: grid; place-items: center; color: var(--muted); font-size: 13px; background: var(--surface-2); border-radius: 12px; }
.chart-svg { display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis { stroke: var(--border); stroke-width: 1.2; }
.chart-svg .ylab, .chart-svg .xlab { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .dot, .chart-svg .mk { stroke: var(--surface); stroke-width: 2; }
.chart-svg .hit { fill: transparent; }
.chart-svg .bar { transition: opacity .15s; }
.tip {
  position: absolute; top: -6px; z-index: 3; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(10, 20, 40, .16); min-width: 140px;
}
.tip b { display: block; margin-bottom: 3px; font-size: 12px; }
.tip div { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.tip div span { margin-left: auto; color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; padding-left: 10px; }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tip .tip-note { color: var(--text); font-weight: 600; }
.legend-inline { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend-inline span { display: flex; align-items: center; gap: 6px; }
.legend-inline i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.legend-inline i.dash { height: 0; border-top: 2px dashed; background: none; }
.legend-inline i.round { width: 8px; height: 8px; border-radius: 50%; }
.compare { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.compare .label { margin-bottom: 4px; }
.cmp { display: grid; grid-template-columns: minmax(0, 1.3fr) 1fr auto; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.cmp.me span:first-child { font-weight: 700; }
.cmp b { font-variant-numeric: tabular-nums; min-width: 58px; text-align: right; }
.cmp-bar { position: relative; height: 6px; background: var(--surface-2); border-radius: 3px; }
.cmp-bar::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border); }
.cmp-bar span { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.cmp-bar .up { left: 50%; background: var(--pos); }
.cmp-bar .down { right: 50%; background: var(--neg); }

/* distribución */
.dist { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut-host { flex: none; width: 168px; height: 168px; margin: 0 auto; }
.dist .legend { flex: 1; min-width: 180px; }
.legend b { color: var(--text); }
.donut .seg { stroke: var(--surface); stroke-width: 2; transition: opacity .15s; cursor: pointer; }
.donut .seg.dim { opacity: .3; }
.donut .d-top { fill: var(--text); font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.donut .d-sub { fill: var(--muted); font-size: 11px; }

/* activos */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary .mid { font-size: 16px; margin-top: 3px; }
.summary small { font-size: 12px; }
.toolbar { margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 10px; }
.kpis > div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }

/* botón flotante */
.fab {
  position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 6;
  width: 50px; height: 50px; border-radius: 16px; border: 0;
  background: linear-gradient(135deg, var(--c2), var(--accent)); color: #fff;
  box-shadow: 0 8px 22px rgba(31, 94, 255, .38); display: grid; place-items: center;
}
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; fill: none; }
body[data-view="mas"] .fab, body[data-view="empty"] .fab { display: none; }
main { padding-bottom: 70px; }

@media (min-width: 640px) {
  .fab { right: max(18px, calc(50vw - 380px + 18px)); }
  .grid { grid-template-columns: repeat(4, 1fr); }
  dialog#sheet { margin: auto; border-radius: 20px; }
}

/* simulación "misma plata, mismas fechas" */
.sim-h, .sim-r { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 1.1fr .8fr; gap: 8px; align-items: baseline; }
.sim-h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-top: 6px; }
.sim-h span:not(:first-child), .sim-r span:not(:first-child) { text-align: right; }
.sim-r { padding: 6px 0; font-size: 13.5px; font-variant-numeric: tabular-nums; border-top: 1px solid var(--border); }
.sim-r.me span:first-child { font-weight: 700; }

/* herramientas de gráfico: rangos y "ver todo" */
.chart-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 0; }
.chart-tools:has(.seg-sm) { margin-bottom: 8px; }
.chart-reset { margin-left: auto; border: 0; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 8px; }
.chart-tools .chart-reset { position: relative; z-index: 2; }
.chart:not(:has(.seg-sm)) .chart-reset { position: absolute; right: 0; top: -2px; }
.tip { transition: left .08s linear, top .12s ease; }
.tip .tip-note { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.tip .tip-note i { border-radius: 50%; }
.chart, .chart * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.chart-svg { cursor: crosshair; }
.chart-svg:active { cursor: grabbing; }

/* desglose del período */
.breakdown { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.breakdown .label { margin-bottom: 4px; }
.breakdown > div:not(.label) { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.breakdown span { color: var(--muted); }
.breakdown small { margin-left: 4px; font-size: 11.5px; }
.breakdown b { font-variant-numeric: tabular-nums; font-weight: 650; }
.breakdown .sum { border-top: 1px dashed var(--border); }
.breakdown .sum span, .breakdown .tot span { color: var(--text); font-weight: 650; }
.breakdown .tot { border-top: 1px solid var(--border); margin-top: 2px; }
.breakdown .tot b { font-size: 15px; font-weight: 750; }

/* ranking por período */
.card-h h2 small { font-weight: 500; color: var(--muted); font-size: 12.5px; margin-left: 4px; }
.seg-sm.ranges { display: inline-flex; margin-bottom: 4px; }
.rank-cols { display: grid; grid-template-columns: 1fr; gap: 0 24px; }
.rank-cols h3 { margin-top: 14px; }
@media (min-width: 640px) { .rank-cols { grid-template-columns: 1fr 1fr; } }
/* orden en Activos */
.toolbar { align-items: flex-start; }
.chips.sort { flex: 1; min-width: 0; }
.chips.sort .chip { padding: 5px 10px; font-size: 12.5px; }

/* dividendos y rentas */
.inc-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.inc-kpis .mid { font-size: 16px; }
.inc-kpis .label i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 1px; }
.inc-kpis small { font-size: 12px; }
.inc-list { display: flex; flex-direction: column; }
.inc-row { display: grid; grid-template-columns: minmax(0, 1.2fr) 1fr auto; gap: 12px; align-items: center; width: 100%; border: 0; border-top: 1px solid var(--border); background: none; padding: 8px 0; text-align: left; }
.inc-row:first-child { border-top: 0; }
.inc-name { display: flex; flex-direction: column; }
.inc-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.inc-bar span { display: block; height: 100%; border-radius: 3px; }
.inc-row > b { font-variant-numeric: tabular-nums; min-width: 70px; text-align: right; }
.tip .tip-total { border-top: 1px solid var(--border); margin-top: 3px; padding-top: 3px; color: var(--text); font-weight: 600; }
.card-h .seg-sm { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.inc-name { align-items: flex-start; text-align: left; justify-self: start; }
.inc-row > * { min-width: 0; }


/* ================= look v2 ================= */
html, body { background: var(--bg); }
body {
  background-image: var(--bg-glow); background-repeat: no-repeat; background-attachment: fixed;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -.005em;
}
.top {
  background: var(--top-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--top-border);
}
.brand h1 { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: none; display: block; flex: none; }
.brand-mark svg { width: 32px; height: 32px; display: block; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .1); color: var(--on-navy); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#themeBtn .sun { display: none; }
#themeBtn[data-dark="1"] .sun { display: block; }
#themeBtn[data-dark="1"] .moon { display: none; }
.seg { background: rgba(255, 255, 255, .1); }
.seg button.on { background: #fff; color: #0a1735; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }

.card, .stat, .asset {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, var(--accent) 4%), var(--surface));
  border-color: var(--border);
}
.card { border-radius: var(--radius); padding: 18px; }
h2 { font-size: 16px; letter-spacing: -.01em; }

/* tarjeta principal: más protagonista */
.hero {
  background: var(--hero-bg); border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 20px 50px -18px rgba(29, 78, 216, .55);
  padding: 22px 18px 18px;
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: linear-gradient(200deg, #000 0%, transparent 65%); mask-image: linear-gradient(200deg, #000 0%, transparent 65%);
}
.hero::after { background: radial-gradient(circle, rgba(34, 211, 238, .32), transparent 70%); width: 260px; height: 260px; right: -90px; top: -110px; }
.hero > * { position: relative; z-index: 1; }
.hero .big { font-size: 38px; font-weight: 850; letter-spacing: -.035em; margin: 6px 0 16px; text-shadow: 0 2px 18px rgba(0, 0, 0, .25); }
.hero-row > div { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .08); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.hero .pos { color: #5cf0b4; }
.hero .neg { color: #ff9aa4; }
.pill { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .1); }

.mid { font-weight: 800; letter-spacing: -.02em; }
.stat .val { font-weight: 800; letter-spacing: -.02em; }
.label { font-size: 11px; letter-spacing: .08em; }

.btn { background: linear-gradient(135deg, var(--c2), var(--accent)); box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 12px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn.danger { background: transparent; box-shadow: none; }
.chip.on { background: linear-gradient(135deg, var(--c2), var(--accent)); border-color: transparent; }
.seg-sm button.on { background: var(--accent); color: #fff; box-shadow: none; }

.avatar {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 30%, var(--surface-2)), var(--surface-2));
  color: var(--text); border: 1px solid var(--border); border-radius: 11px;
}
.asset { border-radius: 16px; transition: transform .15s ease, border-color .15s ease; }
.asset:active { transform: scale(.985); }
@media (hover: hover) { .asset:hover, .res:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); } }

.tabs {
  background: var(--tabs-bg); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .12);
}
.tabs button.on svg { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.fab { border-radius: 18px; background: linear-gradient(135deg, var(--accent-2), var(--accent) 60%); box-shadow: 0 12px 28px -8px color-mix(in srgb, var(--accent) 80%, transparent); }

dialog#sheet { background: var(--surface); border: 1px solid var(--border); }
dialog#sheet::backdrop { background: rgba(2, 6, 16, .65); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
select, input[type="number"], input[type="date"], input[type="search"], .form input { background: var(--surface-2); border-color: var(--border); }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; }
#toast { background: #0d1a38; border: 1px solid rgba(255, 255, 255, .08); }

/* buscador de activos */
.picker { display: flex; flex-direction: column; gap: 6px; }
.picker .hint { margin: 2px 0 0; }
.results { display: flex; flex-direction: column; gap: 4px; }
.res, .picked {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 8px 10px;
}
.picked { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: var(--accent-soft); }
.res-b { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.res-b small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res .tag, .picked .tag { flex: none; }
.res-more { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; padding: 4px 2px; font-size: 13px; }
.link.muted { color: var(--muted); }

/* importador */
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.preview { border-top: 1px solid var(--border); padding-top: 8px; }
.theme-seg { display: inline-flex; }

.brand-mark img { width: 32px; height: 32px; display: block; border-radius: 9px; box-shadow: 0 4px 14px -4px rgba(34, 211, 238, .45); }

/* botón "Cargar nuevos movimientos" */
.load-cta {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin: 0 0 12px;
  padding: 12px 14px; border-radius: 16px; color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-2) 14%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent-2) 35%, var(--border));
}
.load-cta svg { width: 34px; height: 34px; flex: none; padding: 7px; border-radius: 11px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.load-cta span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.load-cta small { color: var(--muted); font-size: 12.5px; }
.load-cta .chev { width: 20px; height: 20px; padding: 0; background: none; stroke: var(--muted); }
.load-card.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 70%, transparent); } 100% { box-shadow: var(--shadow); } }
.period small { font-size: 11.5px; }
.legend-inline i.dot { height: 0; border-top: 3px dotted; background: none; }
