/* Estilos del panel de patrimonio: tomados del prototipo (reference/patrimonio.html). */
/* Layout: panel de patrimonio de una columna — encabezado fijo, indicadores, gráfico de evolución, composición, y pestañas Historial / Cuentas. Hermano del panel de Inventario (mismo sistema visual). */
:root{
  --bg:#eef1f5; --surface:#ffffff; --surface-2:#f3f5f8; --surface-3:#e9edf2;
  --border:#d8dee6; --border-2:#c6ced8;
  --fg:#1a2330; --muted:#5d6775; --faint:#8b95a3;
  --accent:#0d7a8c; --accent-weak:#d6edf1; --accent-fg:#ffffff; --accent-line:#0d7a8c;
  --pos:#157a46; --pos-weak:#dcf0e4;
  --neg:#b4232a; --neg-weak:#f6dcdd;
  --warn:#9a5b06; --warn-weak:#f7e7cf;
  --c-banks:#0072B2; --c-cash:#009E73; --c-nac:#E69F00; --c-deu:#CC79A7; --c-inv:#7f9c1f;
  --shadow:0 1px 2px rgba(20,30,45,.06), 0 6px 18px rgba(20,30,45,.05);
  --radius:12px; --radius-sm:8px;
  color-scheme:light;
}
@media (prefers-color-scheme:dark){ :root:not([data-theme="light"]){
  --bg:#0f141b; --surface:#161d26; --surface-2:#1b232e; --surface-3:#222d3a;
  --border:#28323f; --border-2:#34404f;
  --fg:#e7ecf3; --muted:#97a2b2; --faint:#6c7686;
  --accent:#2fb6c9; --accent-weak:#123842; --accent-fg:#06222a; --accent-line:#2fb6c9;
  --pos:#54c98a; --pos-weak:#13311f;
  --neg:#f17a80; --neg-weak:#3a1517;
  --warn:#e8b464; --warn-weak:#3a2a10;
  --c-banks:#3685c4; --c-cash:#189a6f; --c-nac:#bd8428; --c-deu:#bd73a4; --c-inv:#86992c;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 8px 22px rgba(0,0,0,.35);
  color-scheme:dark;
}}
:root[data-theme="dark"]{
  --bg:#0f141b; --surface:#161d26; --surface-2:#1b232e; --surface-3:#222d3a;
  --border:#28323f; --border-2:#34404f;
  --fg:#e7ecf3; --muted:#97a2b2; --faint:#6c7686;
  --accent:#2fb6c9; --accent-weak:#123842; --accent-fg:#06222a; --accent-line:#2fb6c9;
  --pos:#54c98a; --pos-weak:#13311f;
  --neg:#f17a80; --neg-weak:#3a1517;
  --warn:#e8b464; --warn-weak:#3a2a10;
  --c-banks:#3685c4; --c-cash:#189a6f; --c-nac:#bd8428; --c-deu:#bd73a4; --c-inv:#86992c;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 8px 22px rgba(0,0,0,.35);
  color-scheme:dark;
}

*{box-sizing:border-box}
body{background:var(--bg);color:var(--fg);font-family:"IBM Plex Sans",system-ui,-apple-system,Segoe UI,Roboto,sans-serif;font-size:14px;line-height:1.45;margin:0;-webkit-font-smoothing:antialiased}
.num{font-family:"IBM Plex Mono",ui-monospace,monospace;font-variant-numeric:tabular-nums}
h1,h2,h3{margin:0;text-wrap:balance;font-weight:600;letter-spacing:-.01em}
button{font-family:inherit;font-size:inherit;cursor:pointer}
input,select{font-family:inherit;font-size:14px;color:var(--fg)}
a{color:var(--accent)}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}

header.app{position:sticky;top:env(safe-area-inset-top,0px);z-index:30;background:color-mix(in srgb,var(--surface) 88%,transparent);backdrop-filter:saturate(1.3) blur(8px);border-bottom:1px solid var(--border)}
.hrow{max-width:1080px;margin:0 auto;padding:12px 16px;display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.brand{display:flex;align-items:center;gap:10px;margin-right:auto;min-width:0}
.logo{width:30px;height:30px;border-radius:8px;background:var(--accent);display:grid;place-items:center;flex:none}
.logo svg{width:18px;height:18px}
.brand .t{font-weight:700;font-size:16px;letter-spacing:-.02em;line-height:1}
.brand .s{font-size:11px;color:var(--muted)}
.tabs{display:flex;gap:2px;background:var(--surface-2);border:1px solid var(--border);border-radius:10px;padding:3px}
.tab{border:0;background:transparent;color:var(--muted);padding:7px 13px;border-radius:7px;font-weight:600;font-size:13px}
.tab[aria-selected="true"]{background:var(--surface);color:var(--fg);box-shadow:var(--shadow)}
.hbtns{display:flex;gap:8px;align-items:center}
.icbtn{width:34px;height:34px;border-radius:9px;border:1px solid var(--border);background:var(--surface);color:var(--muted);display:grid;place-items:center}
.icbtn:hover{color:var(--fg);border-color:var(--border-2)} .icbtn svg{width:17px;height:17px}
.btn{height:38px;padding:0 15px;border-radius:9px;border:1px solid var(--border);background:var(--surface);color:var(--fg);font-weight:600;display:inline-flex;align-items:center;gap:7px;white-space:nowrap}
.btn:hover{border-color:var(--border-2)} .btn svg{width:16px;height:16px}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-fg)} .btn.primary:hover{filter:brightness(1.05)}
.btn.sm{height:32px;padding:0 11px;font-size:13px}

main{max-width:1080px;margin:0 auto;padding:18px 16px 40px}

.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(158px,1fr));gap:12px;margin-bottom:16px}
.kpi{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:13px 15px;box-shadow:var(--shadow);min-width:0}
.kpi .k{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);font-weight:600}
.kpi .v{font-family:"IBM Plex Mono",monospace;font-variant-numeric:tabular-nums;font-size:22px;font-weight:600;letter-spacing:-.02em;margin-top:6px;line-height:1.1;overflow-wrap:anywhere}
.kpi.big{grid-column:span 2}
.kpi.big .v{font-size:30px}
@media(max-width:520px){.kpi.big{grid-column:span 2}}
.kpi .sub{font-size:11.5px;color:var(--faint);margin-top:3px}
.kpi .v.accent{color:var(--accent)} .kpi .v.pos{color:var(--pos)} .kpi .v.neg{color:var(--neg)}
.delta{font-size:12px;font-weight:600;font-family:"IBM Plex Mono",monospace;display:inline-flex;align-items:center;gap:3px;margin-top:4px}
.delta.up{color:var(--pos)} .delta.down{color:var(--neg)} .delta.flat{color:var(--muted)}

.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);margin-bottom:16px}
.card-h{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:14px 16px 0}
.card-h h2{font-size:15px}
.card-h .rng{display:flex;gap:2px;background:var(--surface-2);border:1px solid var(--border);border-radius:8px;padding:2px}
.card-h .rng button{border:0;background:transparent;color:var(--muted);font-weight:600;font-size:12px;padding:4px 9px;border-radius:6px}
.card-h .rng button[aria-selected="true"]{background:var(--surface);color:var(--fg);box-shadow:var(--shadow)}
.chartwrap{padding:8px 10px 12px;position:relative}
svg.chart{display:block;width:100%;height:auto;touch-action:pan-y}
.chart .grid{stroke:var(--border);stroke-width:1}
.chart .axis{fill:var(--faint);font-size:11px;font-family:"IBM Plex Mono",monospace}
.chart .area{fill:url(#grad)}
.chart .line{fill:none;stroke:var(--accent-line);stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
.chart .end{fill:var(--accent-line)}
.chart .cross{stroke:var(--border-2);stroke-width:1;stroke-dasharray:3 3}
.chart .hit{fill:var(--accent-line)}
.tip{position:absolute;pointer-events:none;background:var(--fg);color:var(--bg);padding:6px 9px;border-radius:8px;font-size:12px;font-weight:600;white-space:nowrap;transform:translate(-50%,-115%);box-shadow:0 4px 14px rgba(0,0,0,.25);opacity:0;transition:opacity .1s}
.tip .d{font-family:"IBM Plex Mono",monospace}
.tip .dt{font-size:10.5px;opacity:.75;font-weight:500}

/* composición */
.comp{padding:4px 16px 16px;display:flex;flex-direction:column;gap:11px}
.comp .row{display:flex;flex-direction:column;gap:5px}
.comp .lab{display:flex;justify-content:space-between;align-items:baseline;gap:10px;font-size:13px}
.comp .lab .n{display:flex;align-items:center;gap:7px;font-weight:500}
.comp .lab .n .sw{width:9px;height:9px;border-radius:2px;flex:none}
.comp .lab .amt{font-family:"IBM Plex Mono",monospace;font-variant-numeric:tabular-nums;font-weight:600}
.comp .track{height:8px;border-radius:5px;background:var(--surface-3);overflow:hidden}
.comp .fill{height:100%;border-radius:5px}
.comp .pct{font-size:11px;color:var(--faint);font-family:"IBM Plex Mono",monospace}
.comp .sep{height:1px;background:var(--border);margin:2px 0}
.comp .net{display:flex;justify-content:space-between;align-items:baseline;font-weight:700}
.comp .net .amt{font-family:"IBM Plex Mono",monospace;font-size:17px}

/* historial */
.hist .it{display:flex;align-items:center;gap:12px;padding:12px 16px;border-bottom:1px solid var(--border);cursor:pointer}
.hist .it:last-child{border-bottom:0}
.hist .it:hover{background:var(--surface-2)}
.hist .dt{font-weight:600;min-width:0}
.hist .dt .sub{font-size:11.5px;color:var(--muted);font-weight:400}
.hist .pat{margin-left:auto;text-align:right;font-family:"IBM Plex Mono",monospace;font-weight:600}
.hist .d{font-size:11.5px;font-weight:600;font-family:"IBM Plex Mono",monospace}
.hist .d.up{color:var(--pos)} .hist .d.down{color:var(--neg)} .hist .d.flat{color:var(--muted)}

/* cuentas */
.grp{padding:6px 16px 12px}
.grp h3{font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);margin:14px 0 8px;display:flex;align-items:center;gap:7px}
.grp h3 .sw{width:9px;height:9px;border-radius:2px}
.acct{display:flex;align-items:center;gap:10px;padding:9px 11px;border:1px solid var(--border);border-radius:9px;margin-bottom:7px;background:var(--surface-2)}
.acct .nm{font-weight:500;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.acct .sp{margin-left:auto;display:flex;gap:4px}
.acct .mini{width:28px;height:28px;border-radius:7px;border:1px solid var(--border);background:var(--surface);display:grid;place-items:center;color:var(--muted)}
.acct .mini:hover{color:var(--fg);border-color:var(--border-2)} .acct .mini svg{width:14px;height:14px}
.acct.arch{opacity:.5}

.empty{padding:42px 20px;text-align:center;color:var(--muted)}
.empty svg{width:40px;height:40px;color:var(--faint);margin-bottom:10px}
.empty h3{font-size:16px;color:var(--fg);margin-bottom:5px}
.empty p{max-width:360px;margin:0 auto 16px}
.skel{height:14px;border-radius:5px;background:linear-gradient(90deg,var(--surface-2),var(--surface-3),var(--surface-2));background-size:200% 100%;animation:sh 1.2s infinite}
@keyframes sh{0%{background-position:200% 0}100%{background-position:-200% 0}}
@media (prefers-reduced-motion:reduce){.skel{animation:none}}

/* modal */
.backdrop{position:fixed;inset:0;background:rgba(10,15,22,.5);backdrop-filter:blur(2px);z-index:50;display:flex;align-items:flex-end;justify-content:center}
@media(min-width:560px){.backdrop{align-items:center;padding:20px}}
.modal{background:var(--surface);border:1px solid var(--border);width:100%;max-width:470px;max-height:92vh;display:flex;flex-direction:column;border-radius:16px 16px 0 0;box-shadow:0 -8px 40px rgba(0,0,0,.25)}
@media(min-width:560px){.modal{border-radius:16px}}
.mhead{display:flex;align-items:flex-start;gap:12px;padding:18px 18px 4px;flex:none}
.mhead .mi{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;flex:none;background:var(--accent-weak);color:var(--accent)}
.mhead .mi.neg{background:var(--neg-weak);color:var(--neg)}
.mhead .mi svg{width:19px;height:19px}
.mhead h2{font-size:17px} .mhead .ms{font-size:12.5px;color:var(--muted);margin-top:2px}
.mbody{padding:14px 18px 8px;display:flex;flex-direction:column;gap:12px;overflow:auto}
.field{display:flex;flex-direction:column;gap:5px}
.field label{font-size:12px;font-weight:600;color:var(--muted)}
.inp{height:40px;border-radius:9px;border:1px solid var(--border-2);background:var(--surface-2);color:var(--fg);padding:0 12px;width:100%}
.inp:focus{border-color:var(--accent);background:var(--surface)}
select.inp{padding-right:28px}
.crow{display:flex;align-items:center;gap:10px}
.crow .cn{flex:1;min-width:0;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.crow .prefix{position:relative;width:140px;flex:none}
.crow .prefix span{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--faint);font-family:"IBM Plex Mono",monospace;font-size:13px;pointer-events:none}
.crow .prefix input{height:38px;width:100%;border-radius:8px;border:1px solid var(--border-2);background:var(--surface-2);color:var(--fg);padding:0 10px 0 24px;font-family:"IBM Plex Mono",monospace;text-align:right;font-variant-numeric:tabular-nums}
.crow .prefix input:focus{border-color:var(--accent);background:var(--surface)}
.crow .rmd{width:30px;height:38px;flex:none;border:1px solid var(--border-2);background:var(--surface-2);color:var(--neg);border-radius:8px;font-size:18px;line-height:1;display:grid;place-items:center}
.crow .rmd:hover{background:var(--neg-weak);border-color:var(--neg)}
.ghead{font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:600;margin:6px 0 2px;display:flex;align-items:center;gap:7px}
.ghead .sw{width:8px;height:8px;border-radius:2px}
.runtot{position:sticky;bottom:0;background:var(--surface);border-top:1px solid var(--border);padding:10px 18px;display:flex;justify-content:space-between;align-items:center;font-weight:700;flex:none}
.runtot .amt{font-family:"IBM Plex Mono",monospace;font-size:17px}
.mactions{display:flex;gap:10px;padding:12px 18px 18px;flex:none}
.mactions .btn{flex:1;height:42px;justify-content:center}
.err{color:var(--neg);font-size:12px;font-weight:500;padding:0 18px}

#toasts{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(18px + env(safe-area-inset-bottom,0px));z-index:80;display:flex;flex-direction:column;gap:8px;align-items:center;pointer-events:none;width:calc(100% - 32px);max-width:380px}
.toast{background:var(--fg);color:var(--bg);padding:10px 16px;border-radius:10px;font-weight:600;font-size:13px;box-shadow:0 8px 28px rgba(0,0,0,.3);display:flex;align-items:center;gap:9px;animation:pop .25s}
.toast svg{width:16px;height:16px;flex:none} .toast.err{background:var(--neg);color:#fff}
@keyframes pop{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.footnote{text-align:center;color:var(--faint);font-size:11.5px;margin-top:16px;line-height:1.5}
