:root{
  --bg:#F4F4F3; --surface:#FFFFFF; --surface-2:#ECECEA; --text:#000000; --muted:#5B5B58; --line:#DEDEDB;
  --accent:#FFC800; --accent-ink:#000000; --ok:#1E7A3A; --warn:#A8480F; --bad:#B3261E;
  --s-ing:#1F6FEB; --s-gas:#E8590C;
  --radius:16px; --pill-h:64px; --font:"Switzer",system-ui,-apple-system,sans-serif; --display:"Anton",Impact,sans-serif;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){
  --bg:#0E0E0E; --surface:#181818; --surface-2:#232323; --text:#F4F4F3; --muted:#A7A7A3; --line:#2E2E2E; --ok:#4FBF75; --warn:#F0924F; --bad:#F2746D;
  --s-ing:#4C8DF6; --s-gas:#E8590C; color-scheme:dark;
}}
:root[data-theme="dark"]{ --bg:#0E0E0E; --surface:#181818; --surface-2:#232323; --text:#F4F4F3; --muted:#A7A7A3; --line:#2E2E2E; --ok:#4FBF75; --warn:#F0924F; --bad:#F2746D; --s-ing:#4C8DF6; --s-gas:#E8590C; color-scheme:dark; }

*{box-sizing:border-box} [hidden]{display:none!important} html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font);font-size:16px;line-height:1.45;overflow-x:hidden;min-height:100dvh}
a{color:inherit} button{font:inherit;color:inherit} svg{display:block}
h1,h2,h3{font-family:var(--display);font-weight:400;letter-spacing:.01em;margin:0;text-transform:uppercase;line-height:1.05}
h1{font-size:32px} h2{font-size:22px} h3{font-size:17px}
.app{max-width:1180px;margin:0 auto;padding:16px 16px calc(var(--pill-h) + 32px)}
.num{font-variant-numeric:tabular-nums}

/* cabecera */
.top{position:sticky;top:0;z-index:5;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 16px;background:var(--bg);border-bottom:1px solid var(--line)}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;min-width:0}
.brand__logo{width:30px;height:38px;object-fit:contain}
.brand__logo--dark{display:none}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]) .brand__logo--light{display:none} :root:not([data-theme="light"]) .brand__logo--dark{display:block} }
:root[data-theme="dark"] .brand__logo--light{display:none} :root[data-theme="dark"] .brand__logo--dark{display:block}
.brand__txt{display:flex;flex-direction:column;min-width:0}
.brand__t{font-family:var(--display);font-size:20px;text-transform:uppercase;line-height:1}
.brand__s{font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top__nav{display:none;align-items:center;gap:6px}
.top__nav a{text-decoration:none;padding:8px 12px;border-radius:999px;font-weight:600;font-size:15px}
.top__nav a.is-active{background:var(--text);color:var(--bg)}

/* píldora móvil (máx. 5 botones) */
.pill{position:fixed;left:50%;transform:translateX(-50%);bottom:max(12px,env(safe-area-inset-bottom));z-index:6;display:flex;gap:4px;padding:6px;background:var(--surface);border:1px solid var(--line);border-radius:999px;box-shadow:0 8px 30px rgba(0,0,0,.18);width:min(440px,calc(100% - 24px))}
.pill a,.pill button{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:3px;padding:7px 2px;border:0;background:none;border-radius:999px;text-decoration:none;font-size:11px;font-weight:600;color:var(--muted);cursor:pointer}
.pill span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.pill svg,.ico{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.pill a.is-active{color:var(--text);background:var(--surface-2)}
.pill .pill__main{background:var(--accent);color:var(--accent-ink)}
@media (min-width:900px){ .pill{display:none} .top__nav{display:flex} .app{padding-bottom:48px} }

/* bloques */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:16px;margin-bottom:12px;min-width:0}
.row{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.muted{color:var(--muted)} .small{font-size:13px} .xs{font-size:12px}
.sec{margin:26px 0 10px;display:flex;align-items:end;justify-content:space-between;gap:12px;flex-wrap:wrap}
.head{display:flex;align-items:end;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:6px 0 14px}
.kpis{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
@media (min-width:640px){.kpis{grid-template-columns:repeat(3,minmax(0,1fr))}} @media (min-width:1024px){.kpis{grid-template-columns:repeat(6,minmax(0,1fr))}}
.kpis--3{grid-template-columns:repeat(3,minmax(0,1fr))!important}
.kpi{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:12px 14px;min-width:0}
.kpi__v{font-family:var(--display);font-size:26px;line-height:1.05;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.kpi__l{font-size:11px;color:var(--muted);margin-top:4px;text-transform:uppercase;letter-spacing:.04em}
.kpi__s{font-size:12px;color:var(--muted);margin-top:2px}
.kpi--accent{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)} .kpi--accent .kpi__l,.kpi--accent .kpi__s{color:var(--accent-ink);opacity:.75}
a.kpi{text-decoration:none;display:block}
.neg{color:var(--bad)}
.kpis--3 .kpi__v{font-size:20px}
@media (min-width:640px){ .kpis--3 .kpi__v{font-size:26px} }

/* botones */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:10px 16px;border-radius:999px;border:1px solid var(--text);background:var(--text);color:var(--bg);font-weight:600;cursor:pointer;text-decoration:none;min-height:42px;white-space:nowrap}
.btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.btn--accent{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.btn--ghost{background:transparent;color:var(--text);border-color:var(--line)}
.btn--danger{background:transparent;color:var(--bad);border-color:var(--bad)}
.btn--sm{padding:6px 12px;min-height:34px;font-size:14px}
.btn--block{width:100%}
.btn:disabled{opacity:.5;cursor:default}
.iconbtn{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex:none;border-radius:50%;border:1px solid var(--line);background:var(--surface);cursor:pointer;color:var(--text)}
.iconbtn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.acts{display:flex;gap:8px;flex-wrap:wrap}

/* formularios */
.field{display:block;margin-bottom:12px;min-width:0}
.field>span{display:block;font-size:13px;font-weight:600;margin-bottom:5px}
.field input,.field select,.field textarea,.input{width:100%;min-width:0;padding:11px 12px;border:1px solid var(--line);border-radius:12px;background:var(--bg);color:var(--text);font:inherit;font-size:16px}
.field textarea{min-height:80px;resize:vertical}
.field .hint{font-size:12px;color:var(--muted);margin-top:4px}
.field input:focus,.field select,.field textarea:focus{outline-color:var(--text)}
.grid2{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0 12px}
.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0 10px}
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{display:inline-flex;align-items:center;gap:6px;padding:8px 12px;border-radius:999px;border:1px solid var(--line);background:var(--surface);cursor:pointer;font-size:14px;font-weight:500;color:var(--text)}
.chip.is-on{background:var(--text);color:var(--bg);border-color:var(--text)}
.seg{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;background:var(--surface-2);border-radius:999px;padding:4px;gap:4px}
.seg button{border:0;background:none;border-radius:999px;padding:9px 10px;font-weight:600;cursor:pointer;color:var(--muted)}
.seg button.is-on{background:var(--surface);color:var(--text);box-shadow:0 1px 3px rgba(0,0,0,.12)}
.tag{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.04em;background:var(--surface-2);color:var(--text);white-space:nowrap}
.tag--warn{color:var(--warn)} .tag--bad{color:var(--bad)} .tag--ok{color:var(--ok)}
.tag svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}
.dot{display:inline-block;width:10px;height:10px;border-radius:50%;flex:none;box-shadow:0 0 0 1px var(--line)}

/* filtros */
.filters{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px;margin-bottom:12px}
.filters .input{padding:9px 10px;font-size:15px}
.filters .full{grid-column:1/-1}
@media (min-width:900px){ .filters{grid-template-columns:1.2fr 1fr 1fr 1fr 1.6fr} .filters .full{grid-column:auto} }

/* desglose del importe */
.desglose{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;background:var(--surface-2);border-radius:12px;padding:10px 12px;margin:-2px 0 12px}
.desglose b{display:block;font-family:var(--display);font-weight:400;font-size:18px;line-height:1.1;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.desglose span{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.03em}

/* lista de movimientos */
.mlist{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
.mrow{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:4px 12px;align-items:center;padding:12px 14px;border-top:1px solid var(--line);cursor:pointer;text-align:left;width:100%;background:none;border-left:0;border-right:0;border-bottom:0;color:var(--text)}
.mrow:first-child{border-top:0}
.mrow:hover{background:var(--surface-2)}
.mrow__ico{width:34px;height:34px;border-radius:10px;display:flex;align-items:center;justify-content:center;background:var(--surface-2)}
.mrow__ico svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.mrow__t{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mrow__s{font-size:13px;color:var(--muted);display:flex;align-items:center;gap:6px;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mrow__s .dot{width:8px;height:8px}
.mrow__a{text-align:right;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap}
.mrow__tags{grid-column:2/-1;display:flex;gap:6px;flex-wrap:wrap}
.mrow__tags:empty{display:none}
.mrow__d{font-size:12px;color:var(--muted);font-weight:500;display:none!important}
@media (min-width:640px){ .mrow__d{display:block!important} }
.mday{padding:8px 14px;font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);background:var(--surface-2);border-top:1px solid var(--line)}
.mday:first-child{border-top:0}

/* tablas */
.tbl{width:100%;border-collapse:collapse;font-size:14px;font-variant-numeric:tabular-nums}
.tbl th,.tbl td{padding:9px 8px;border-bottom:1px solid var(--line);text-align:right;white-space:nowrap}
.tbl th:first-child,.tbl td:first-child{text-align:left;white-space:normal}
.tbl th{font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);font-weight:600}
.tbl tfoot td{font-weight:700;border-bottom:0}
.tblwrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
.tbl .nm{display:flex;align-items:center;gap:8px}

/* gráfico */
.chartbox{position:relative;width:100%}
.chart{width:100%;height:220px;display:block;overflow:visible}
.chart .s-ing{fill:var(--s-ing)} .chart .s-gas{fill:var(--s-gas)}
.chart .grid{stroke:var(--line);stroke-width:1} .chart .base{stroke:var(--muted);stroke-width:1}
.chart text{fill:var(--muted);font-size:11px;font-family:var(--font)}
.chart .hit{fill:transparent;cursor:default} .chart .hit:hover,.chart .hit.is-on{fill:var(--text);fill-opacity:.06}
.legend{display:flex;gap:16px;flex-wrap:wrap;font-size:13px;color:var(--muted);margin:0 0 8px}
.legend i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:6px;vertical-align:-1px}
.tip{position:absolute;pointer-events:none;background:var(--surface);color:var(--text);border:1px solid var(--line);border-radius:12px;padding:8px 10px;font-size:13px;box-shadow:0 6px 24px rgba(0,0,0,.16);white-space:nowrap;z-index:3;transform:translate(-50%,-100%);font-variant-numeric:tabular-nums}
.tip b{display:block;margin-bottom:2px}
.tip i{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:6px}

/* barras de categoría */
.cbar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:8px 0;border-top:1px solid var(--line);font-size:14px}
.cbar:first-child{border-top:0}
.cbar__b{grid-column:1/-1;height:6px;border-radius:3px;background:var(--surface-2);overflow:hidden}
.cbar__b i{display:block;height:100%;border-radius:3px}
.cbar__n{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* hoja modal */
.sheet{border:0;padding:0;background:transparent;max-width:none;width:100%;max-height:100dvh;margin:auto 0 0;position:fixed;inset:0;color:var(--text)}
.sheet::backdrop{background:rgba(0,0,0,.5)}
.sheet__box{background:var(--surface);color:var(--text);border-radius:22px 22px 0 0;padding:18px 16px max(24px,env(safe-area-inset-bottom));max-height:94dvh;overflow:auto;overscroll-behavior:contain;width:100%;margin-top:auto}
@media (min-width:640px){ .sheet{margin:auto} .sheet__box{border-radius:22px;max-width:600px;margin:auto;max-height:90dvh} }
.sheet__head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}
.sheet__foot{display:flex;gap:8px;flex-wrap:wrap;justify-content:space-between;margin-top:8px;padding-top:12px;border-top:1px solid var(--line)}
.sheet__foot .acts{margin-left:auto}

/* justificantes */
.files{display:flex;flex-direction:column;gap:8px;margin-bottom:12px}
.file{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:10px;align-items:center;background:var(--surface-2);border-radius:12px;padding:8px 8px 8px 10px}
.file__thumb{width:40px;height:40px;border-radius:8px;object-fit:cover;background:var(--surface);display:flex;align-items:center;justify-content:center}
.file__thumb svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2}
.file__n{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.file__s{font-size:12px;color:var(--muted)}
.drop{display:flex;align-items:center;justify-content:center;gap:10px;border:1.5px dashed var(--line);border-radius:12px;padding:14px;cursor:pointer;color:var(--muted);font-weight:600;text-align:center}
.drop svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.drop.is-over{border-color:var(--text);color:var(--text)}

/* varios */
.toast{position:fixed;left:50%;transform:translateX(-50%) translateY(20px);bottom:calc(var(--pill-h) + 28px);background:var(--text);color:var(--bg);padding:10px 16px;border-radius:999px;font-weight:600;opacity:0;transition:.2s;pointer-events:none;z-index:99;max-width:calc(100% - 32px);text-align:center}
.toast.is-on{opacity:1;transform:translateX(-50%) translateY(0)}
@media (min-width:900px){.toast{bottom:24px}}
.empty{padding:28px 16px;text-align:center;color:var(--muted);border:1px dashed var(--line);border-radius:var(--radius)}
.login{max-width:420px;margin:10vh auto 0}
.login__logo{width:64px;height:auto;margin:0 auto 18px}
.alert{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:12px;background:var(--surface-2);font-size:14px;margin-bottom:12px}
.alert svg{width:18px;height:18px;flex:none;margin-top:1px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.alert--warn{color:var(--warn)} .alert--warn span{color:var(--text)}
.clave{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:20px;letter-spacing:.06em;background:var(--surface-2);border-radius:12px;padding:14px;text-align:center;user-select:all;overflow-wrap:anywhere}
.cols{display:grid;gap:12px}
@media (min-width:1024px){ .cols{grid-template-columns:minmax(0,1fr) minmax(0,1fr)} }
.list-item{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-top:1px solid var(--line);min-width:0}
.list-item:first-child{border-top:0}
.list-item>div{min-width:0}
.ev{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 12px;text-decoration:none;align-items:center}
.ev__n{font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ev__r{text-align:right;font-family:var(--display);font-size:22px;font-variant-numeric:tabular-nums;white-space:nowrap}
.ev__m{grid-column:1/-1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;background:var(--surface-2);border-radius:12px;padding:8px 10px;font-size:13px}
.ev__m b{display:block;font-variant-numeric:tabular-nums}
.ev__m span{font-size:11px;color:var(--muted);text-transform:uppercase}
.evgrid{display:grid;gap:12px}
@media (min-width:640px){ .evgrid{grid-template-columns:repeat(2,minmax(0,1fr))} } @media (min-width:1024px){ .evgrid{grid-template-columns:repeat(3,minmax(0,1fr))} }
.evgrid .card{margin:0}
.spin{display:inline-block;width:18px;height:18px;border:2px solid var(--line);border-top-color:var(--text);border-radius:50%;animation:g .8s linear infinite}
@keyframes g{to{transform:rotate(360deg)}}
.loading{padding:40px;display:flex;justify-content:center}
.switch{display:flex;align-items:center;gap:10px;cursor:pointer;font-size:14px;font-weight:600}
.switch input{width:18px;height:18px;accent-color:var(--text)}
@media (prefers-reduced-motion: reduce){ *{transition:none!important;animation:none!important} }
