:root {
  color-scheme: only light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e2e1dc;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --accent: #b84e17;
  --series-1: #2a78d6;   /* Target / Total */
  --series-2: #eb6834;   /* Real / Total + Tax */
  --series-3: #1baf7a;   /* Margin / MX + EE. UU. */
  --good: #0b7a3e;
  --bad: #c2362f;
  --radius: 10px;
}


* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--surface-0); color: var(--text-primary); }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 1.2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .25rem; }
code { font-size: .9em; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }

.inline { display: inline; margin: 0; }

.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.small { padding: 5px 12px; font-size: .9rem; color: #fff !important; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button.link { background: none; border: 0; color: var(--text-secondary); font: inherit; cursor: pointer; padding: 0; }
button.link.danger { color: var(--bad); }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.hint { color: var(--text-muted); font-size: .85rem; margin: .2rem 0 .6rem; }
.error { color: var(--bad); font-weight: 600; }
.okmsg { color: var(--good); font-weight: 600; }
.ok { color: var(--good); }
.bad { color: var(--bad); }
.muted { color: var(--text-muted); }
.tag { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile .lbl { color: var(--text-secondary); font-size: .85rem; }
.tile .big { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--text-muted); font-size: .8rem; }
progress { width: 100%; height: 6px; margin-top: 6px; accent-color: var(--series-1); }

.chart-box { position: relative; height: 340px; }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--text-secondary); font-size: .9rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
th { color: var(--text-secondary); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.form label { display: block; margin: 10px 0; font-weight: 600; font-size: .9rem; }
.form input[type=text], .form input:not([type]), .form input[type=date], .form input[type=password] { display: block; width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-0); color: var(--text-primary); font: inherit; font-size: 16px; margin-top: 4px; }
.form .hint { font-weight: 400; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 14px 0; padding: 4px 12px 8px; }
legend { color: var(--text-secondary); font-size: .85rem; padding: 0 6px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

.login { max-width: 360px; margin: 10vh auto; }
.login h1 { text-align: center; }
.login label { display: block; margin-bottom: 12px; font-weight: 600; font-size: .9rem; }
.login input { display: block; width: 100%; padding: 10px; margin-top: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-0); color: var(--text-primary); font-size: 16px; }
.login .btn { width: 100%; }

.month { margin: 20px 0 8px; }
.weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.week { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: .85rem; }
.week.closed { opacity: .75; }
.week.now { border-color: var(--accent); }
.week header { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; margin-bottom: 6px; }
.week header span { color: var(--text-muted); }
.week ul { list-style: none; margin: 0 0 6px; padding: 0; }
.week li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--grid); }
.week dl { display: grid; grid-template-columns: 1fr auto; margin: 0; color: var(--text-secondary); }
.week dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Semanas: cuadrícula horizontal tipo hoja ---- */
.wrap.wide { max-width: none; }
.grid-head { display: flex; align-items: center; gap: 12px; }
.grid-head .small-btn { padding: 4px 10px; font-size: .85rem; }
.sheet-wrap { overflow: auto; max-height: calc(100vh - 170px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.sheet { border-collapse: separate; border-spacing: 0; font-size: .8rem; width: max-content; }
.sheet th, .sheet td { border-bottom: 1px solid var(--grid); border-right: 1px solid var(--grid); padding: 3px 8px; white-space: nowrap; }
.sheet thead th { position: sticky; background: var(--surface-1); z-index: 2; }
.sheet thead tr:first-child th { top: 0; }
.sheet thead tr:nth-child(2) th { top: 27px; }
.sheet th.m { text-align: left; font-size: .85rem; color: var(--text-primary); border-right: 2px solid var(--border); }
.sheet th.w { min-width: 150px; text-align: left; font-weight: 600; }
.sheet th.w small { display: block; font-weight: 400; color: var(--text-muted); }
.sheet th.w.now { background: color-mix(in srgb, var(--accent) 14%, var(--surface-1)); }
.sheet .rowh { position: sticky; left: 0; z-index: 1; background: var(--surface-1); text-align: left; min-width: 170px; color: var(--text-secondary); font-weight: 600; border-right: 2px solid var(--border); }
.sheet thead .rowh.corner { z-index: 3; top: 0; }
.sheet td { min-width: 150px; height: 24px; }
.sheet tr.item td { display: table-cell; }
.sheet tr.item td .concept { color: var(--text-secondary); margin-right: 10px; }
.sheet tr.item td .amt { float: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.sheet td.closed { color: var(--text-muted); background: color-mix(in srgb, var(--surface-0) 55%, var(--surface-1)); }
.sheet td.closed .amt, .sheet td.closed .concept { color: var(--text-muted); }
.sheet td.now { background: color-mix(in srgb, var(--accent) 7%, var(--surface-1)); }
.sheet tr.sum td, .sheet tr.sum th { border-top: 0; }
.sheet tr.sum.first td, .sheet tr.sum.first th { border-top: 2px solid var(--border); }
.sheet tr.sum.strong td, .sheet tr.sum.strong th { font-weight: 700; color: var(--text-primary); }
.sheet tr.sum.muted td { color: var(--text-muted); }

/* ---- Barra superior y menú inferior tipo app ---- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--surface-1); border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 700; }
.topbar .who { color: var(--text-muted); font-size: .85rem; }
body.with-tabs { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; align-items: stretch;
  background: var(--surface-1); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabbar .tab, .tabbar .tab-form { flex: 1; max-width: 120px; }
.tabbar .tab-form { margin: 0; display: flex; }
.tabbar .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--text-muted); font: inherit; font-size: .72rem; background: none; border: 0; cursor: pointer; padding: 4px 0; width: 100%; }
.tabbar .tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar .tab.on { color: var(--accent); font-weight: 600; }
.tabbar .tab.add svg { background: var(--accent); color: #fff; border-radius: 50%; padding: 4px; width: 32px; height: 32px; margin-top: -6px; }
.tabbar .tab.add { color: var(--text-secondary); }
.sheet-wrap { max-height: calc(100vh - 190px - env(safe-area-inset-bottom)); }
.sheet td.pos { color: var(--good); }
.sheet td.neg { color: var(--bad); }

@media (max-width: 640px) {
  .wrap { padding: 0 10px 24px; }
  h1 { font-size: 1.25rem; margin: .8rem 0 .5rem; }
  .wrap.wide .hint { display: none; }
  .sheet .rowh { min-width: 112px; max-width: 112px; white-space: normal; font-size: .72rem; line-height: 1.2; }
  .sheet th.w, .sheet td { min-width: 138px; }
  .sheet-wrap { max-height: calc(100vh - 150px - env(safe-area-inset-bottom)); }
}

/* ---- Projection editable ---- */
:root { --paid-bg: #e3f0d9; --c-yellow: #fff4c7; --c-pink: #fbd8f2; --c-blue: #dbe6f5; --c-orange: #fbdcc4; --c-red: #f6c9c6; --c-gray: #e3e3e0; }

.grid-head { flex-wrap: wrap; }
.legend-chips { display: flex; gap: 6px; margin-left: auto; font-size: .72rem; }
.chip { padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-secondary); }
.chip.paid { background: var(--paid-bg); }
.chip.proj { font-style: italic; color: var(--text-muted); }
.chip.excl { text-decoration: line-through; color: var(--text-muted); }
.sheet td.cell-item, .sheet td.editable, .sheet td.add-cell { cursor: pointer; }
.sheet td.cell-item:hover, .sheet td.editable:hover, .sheet td.add-cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.sheet td.paid { background: var(--paid-bg) !important; }
.sheet td.c-yellow { background: var(--c-yellow); } .sheet td.c-pink { background: var(--c-pink); }
.sheet td.c-blue { background: var(--c-blue); } .sheet td.c-orange { background: var(--c-orange); }
.sheet td.c-red { background: var(--c-red); } .sheet td.c-gray { background: var(--c-gray); }
.sheet td.excl .concept, .sheet td.excl .amt { text-decoration: line-through; color: var(--text-muted); }
.sheet td.proj { font-style: italic; color: var(--text-muted); }
.sheet tr.sum.strong td.proj { color: var(--text-secondary); }
.sheet td.add-cell { color: var(--text-muted); font-size: .72rem; }
.sheet tr.add td.add-cell:not(:hover) { color: transparent; }
.sheet tr.add td.add-cell.now:not(:hover), .sheet tr.add td.add-cell.future:not(:hover) { color: var(--text-muted); }
.proj-chart { margin-top: 12px; }
.proj-chart .chart-box { height: 280px; }
.sheet-wrap { max-height: calc(100vh - 240px - env(safe-area-inset-bottom)); }

dialog.editor { border: 1px solid var(--border); border-radius: 14px; padding: 18px; width: min(420px, calc(100vw - 24px)); background: var(--surface-1); color: var(--text-primary); }
dialog.editor::backdrop { background: rgba(0, 0, 0, .35); }
dialog.editor h3 { margin: 0; }
dialog.editor select, dialog.editor input:not([type=checkbox]) { display: block; width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-0); color: var(--text-primary); font: inherit; font-size: 16px; margin-top: 4px; }
dialog.editor label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.dlg-actions .spacer { flex: 1; }
.btn.danger { color: var(--bad); border-color: var(--bad); }

@media (max-width: 640px) {
  .legend-chips { display: none; }
  .sheet-wrap { max-height: calc(100vh - 200px - env(safe-area-inset-bottom)); }
  .proj-chart .chart-box { height: 240px; }
}

/* ---- Projection: una semana a la vez ---- */
:root { --topbar-h: 45px; --tabbar-h: 68px; }
.topbar { min-height: var(--topbar-h); }
.topbar .who { font-size: .82rem; }
body.no-page-scroll { overflow: hidden; padding-bottom: 0; }
body.no-page-scroll .wrap { padding: 0; }
.snap-y { height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto; scroll-snap-type: y proximity; overscroll-behavior: contain; }
.pane { scroll-snap-align: start; }
.pane-weeks { min-height: 100%; display: flex; flex-direction: column; }
.pager-bar { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 8px 12px 4px; }
.nav-arrow { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.pager { flex: 1; display: flex; overflow-x: auto; overflow-y: visible; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.pager::-webkit-scrollbar { display: none; }
.week-page { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; padding: 6px 14px 10px; }
.week-page > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.wp-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.wp-month { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.wp-head h2 { margin: 0; font-size: 1.2rem; }
.wp-head h2 small { color: var(--text-muted); font-weight: 400; font-size: .85rem; margin-left: 4px; }
.badge { font-size: .72rem; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.badge.now { background: var(--accent); border-color: var(--accent); color: #fff; }
.wp-items { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wp-items .it { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--grid); background: transparent; color: var(--text-primary); font: inherit; font-size: .92rem; text-align: left; cursor: pointer; }
.wp-items .it:last-child { border-bottom: 0; }
.wp-items .it .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wp-items .it .concept { overflow: hidden; text-overflow: ellipsis; }
.wp-items .it.paid { background: var(--paid-bg); }
.wp-items .it.c-yellow { background: var(--c-yellow); } .wp-items .it.c-pink { background: var(--c-pink); }
.wp-items .it.c-blue { background: var(--c-blue); } .wp-items .it.c-orange { background: var(--c-orange); }
.wp-items .it.c-red { background: var(--c-red); } .wp-items .it.c-gray { background: var(--c-gray); }
.wp-items .it.excl .concept, .wp-items .it.excl .amt { text-decoration: line-through; color: var(--text-muted); }
.wp-items .it.add { color: var(--accent); justify-content: center; font-weight: 600; }
.wp-sum { margin: 10px auto 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
.wp-sum .sr { display: flex; justify-content: space-between; padding: 7px 12px; border-bottom: 1px solid var(--grid); }
.wp-sum .sr:last-child { border-bottom: 0; }
.wp-sum .sr dt { color: var(--text-secondary); }
.wp-sum .sr dd { margin: 0; font-variant-numeric: tabular-nums; }
.wp-sum .sr dd.proj { font-style: italic; color: var(--text-muted); }
.wp-sum .sr.strong dt, .wp-sum .sr.strong dd { font-weight: 700; color: var(--text-primary); }
.wp-sum .sr.strong dd.proj { color: var(--text-secondary); }
.wp-sum .sr.first { border-top: 0; }
.wp-sum .sr.editable { cursor: pointer; }
.wp-sum .sr.editable dd::before { content: '✎'; margin-right: 6px; color: var(--text-muted); font-style: normal; font-size: .8em; }
.week-page.closed .wp-items, .week-page.closed .wp-sum { opacity: .92; }
.swipe-hint { text-align: center; color: var(--text-muted); font-size: .72rem; margin: 2px 0 8px; }
.pane-chart { min-height: 75%; padding: 14px; max-width: 900px; margin: 0 auto; }
.pane-chart h2 { font-size: 1rem; margin: 0 0 6px; }
.pane-chart .chart-box { height: 320px; }

/* ---- Projection v2: la gráfica vive dentro de cada semana ---- */
.proj-wrap { display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.proj-wrap .pager { flex: 1; min-height: 0; align-items: stretch; }
.proj-wrap .week-page { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 18px; }
.wp-chart { margin: 10px auto 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 8px 6px; }
.wp-chart-box { position: relative; height: 300px; }

/* ---- Projection v3 ---- */
/* Toda la pantalla en columna: barra superior, contenido y menú, sin huecos ni cálculos de altura. */
body.no-page-scroll { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
body.no-page-scroll .topbar { order: 0; flex: none; }
body.no-page-scroll .wrap { order: 1; flex: 1; min-height: 0; width: 100%; }
body.no-page-scroll .tabbar { order: 2; position: static; flex: none; }
body.no-page-scroll .proj-wrap { height: 100%; }
.pager-bar { justify-content: space-between; max-width: 600px; width: 100%; margin: 0 auto; padding: 8px 12px 6px; }
.week-title { flex: 1; display: flex; flex-direction: column; align-items: center; background: none; border: 0; color: var(--text-primary); font: inherit; cursor: pointer; padding: 2px 6px; touch-action: manipulation; }
.week-title .wt-month { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.week-title .wt-main { font-weight: 700; font-size: 1.02rem; }
.week-title .wt-back { font-size: .72rem; color: var(--accent); min-height: 1em; }
.week-title.is-now .wt-main { color: var(--accent); }
.week-page.now .wp-items, .week-page.now .wp-sum, .week-page.now .wp-chart { border-color: var(--accent); border-width: 1.5px; }
.wp-items { margin-top: 2px; }
.wp-chart { padding: 8px 4px 4px; }
button, .tab, .it, .sr { touch-action: manipulation; }

/* Diálogo de edición: arriba, para que el teclado no tape los botones */
dialog.editor { margin: 8vh auto auto; max-height: 84vh; overflow: auto; }
dialog.editor h3:focus { outline: none; }
.dlg-actions .btn { padding: 10px 16px; min-height: 42px; }

/* ---- Sin barra superior; menú de cuenta; Backend; Dashboard ---- */
body { padding-top: env(safe-area-inset-top); }
body.no-page-scroll { height: 100vh; height: 100dvh; }
button.tab { appearance: none; }
.acct-menu { border: 1px solid var(--border); border-radius: 16px; padding: 8px; width: min(360px, calc(100vw - 24px)); background: var(--surface-1); color: var(--text-primary);
  margin: auto auto calc(84px + env(safe-area-inset-bottom)); }
.acct-menu::backdrop { background: rgba(0, 0, 0, .35); }
.acct-menu form { margin: 0; }
.acct-who { margin: 6px 10px 8px; color: var(--text-muted); font-size: .85rem; }
.acct-item { display: block; width: 100%; text-align: left; padding: 12px 12px; border: 0; border-radius: 10px; background: none; color: var(--text-primary); font: inherit; font-size: 1rem; text-decoration: none; cursor: pointer; }
.acct-item small { display: block; color: var(--text-muted); font-size: .78rem; }
.acct-item:hover { background: var(--surface-0); }
.acct-item.danger { color: var(--bad); }
.acct-item.muted { color: var(--text-secondary); text-align: center; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-1); border: 1px solid var(--border); margin-bottom: 12px; flex-wrap: wrap; }
.segmented .seg { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text-secondary); font-size: .9rem; }
.segmented .seg.on { background: var(--accent); color: #fff; font-weight: 600; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.chart-box.tall { height: 380px; }
.wealth-card { margin-top: 4px; }
.fixed-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.fx { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--grid); background: var(--surface-1); color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; }
.fx:last-child { border-bottom: 0; }
.fx:hover { background: var(--surface-0); }
.fx.off { opacity: .55; }
.fx-day { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-0); border: 1px solid var(--border); font-weight: 700; font-size: .9rem; }
.fx-name small { display: block; color: var(--text-muted); font-size: .75rem; }
.fx-amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .chart-box.tall { height: 300px; } }
.fx.bx .fx-day { font-size: .78rem; }
[hidden] { display: none !important; }

/* Semana: botón circular + y total de gastos debajo de los gastos */
.wp-items .add-row { position: relative; height: 0; border-top: 1px solid var(--grid); }
.wp-items .add-circle { position: absolute; left: 50%; top: 0; transform: translate(-50%, -50%); width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-size: 1.3rem; line-height: 1; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.18); z-index: 1; touch-action: manipulation; }
.wp-items .it-total { display: flex; justify-content: space-between; padding: 16px 12px 9px; font-weight: 700; background: var(--surface-0); }
.wp-items .it-total .amt { font-variant-numeric: tabular-nums; }
.wp-items { overflow: visible; }
.wp-items > .it:first-child, .wp-list > .it:first-child { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.wp-items .it-total { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }

/* ---- Dashboard con pestañas deslizables ---- */
.dash-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 10px; margin: 0 -2px; }
.dash-tabs::-webkit-scrollbar { display: none; }
.dtab { flex: none; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap; touch-action: manipulation; }
.dtab.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.dash-panes { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; align-items: flex-start; }
.dash-panes::-webkit-scrollbar { display: none; }
.dpane { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always; padding: 0 1px; }
.total-card { display: flex; flex-direction: column; gap: 4px; }
.total-card .lbl { color: var(--text-secondary); font-size: .85rem; }
.total-card .big { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-card .big small { font-size: .9rem; color: var(--text-muted); font-weight: 400; }
.total-card .sub { color: var(--text-muted); font-size: .8rem; }
.total-card .split { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-secondary); font-size: .9rem; }
.fund-card { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ring { --p: 0; width: 170px; height: 170px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--series-3) calc(var(--p) * 1%), var(--grid) 0); }
.ring > div { width: 132px; height: 132px; border-radius: 50%; background: var(--surface-1); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring strong { font-size: 2rem; line-height: 1; }
.ring span { color: var(--text-muted); font-size: .8rem; }
.kv { width: 100%; margin: 0; }
.kv > div { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px solid var(--grid); }
.kv dt { color: var(--text-secondary); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- Projection v4: encabezado por mes (verde / gris), botón Hoy flotante, indicadores ---- */
:root { --month-a: #d9ead3; --month-a-text: #274e13; --month-b: #ececea; --month-b-text: #3c3c3a; }
.mc-0 { background: var(--month-a); color: var(--month-a-text); }
.mc-1 { background: var(--month-b); color: var(--month-b-text); }
.pager-bar { display: grid; grid-template-columns: 54px 1fr 54px; gap: 0; padding: 0; max-width: none; margin: 0; border-bottom: 1px solid var(--border); }
.pager-bar .edge { border: 0; font: inherit; font-size: 1.7rem; line-height: 1; cursor: pointer; touch-action: manipulation; color: inherit; opacity: .9; }
.pager-bar .edge:not(.mc-0):not(.mc-1) { background: var(--surface-1); color: var(--text-muted); }
.pager-bar .edge.prev { border-right: 2px solid rgba(0, 0, 0, .12); }
.pager-bar .edge.next { border-left: 2px solid rgba(0, 0, 0, .12); }
.pager-bar .week-title { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 4px 7px; cursor: default; }
.week-title .wt-month { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; opacity: .75; color: inherit; }
.week-title .wt-main { font-size: 1.15rem; font-weight: 700; color: inherit; line-height: 1.2; }
.week-title .wt-dates { font-size: .78rem; opacity: .85; color: inherit; }
.week-title.is-now .wt-main, .week-title.is-now .wt-main { color: inherit; }
.week-title.is-now .wt-dates { color: var(--accent); opacity: 1; font-weight: 700; }
.week-title .wt-back { display: none; }
.week-page.now .wp-items, .week-page.now .wp-sum, .week-page.now .wp-chart { border-color: var(--border); border-width: 1px; }
.today-fab { position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 30; padding: 10px 18px; border-radius: 99px; border: 0;
  background: var(--accent); color: #fff; font: inherit; font-weight: 700; box-shadow: 0 3px 12px rgba(0, 0, 0, .22); cursor: pointer; touch-action: manipulation; }
.today-fab[hidden] { display: none; }
.wp-ind { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px auto 0; }
.ind { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-1); font: inherit; text-align: left; cursor: pointer; color: var(--text-primary); }
.ind-l { font-size: .75rem; color: var(--text-secondary); }
.ind-v { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ind-s { font-size: .72rem; color: var(--text-muted); }
.ind.warn { background: #fdf3dc; border-color: #f0d79a; }
.ind.bad { background: #fbe3e1; border-color: #efb3ad; }
.ind.bad .ind-v { color: var(--bad); }
/* Hoja: encabezados de mes con color alterno */
.sheet th.m.mc-0, .sheet th.w.mc-0 { background: var(--month-a); color: var(--month-a-text); }
.sheet th.m.mc-1, .sheet th.w.mc-1 { background: var(--month-b); color: var(--month-b-text); }
.sheet th.w.now { box-shadow: inset 0 -3px 0 var(--accent); }
.sheet th.w.now small { color: var(--accent); font-weight: 700; }

/* ---- Colores exactos de la hoja y flechas de arriba a abajo ---- */
:root { --mA-month: #a8d08d; --mA-week: #c5e0b3; --mB-month: #bfbfbf; --mB-week: #d8d8d8; --sheet-ink: #000; }
.mc-0 { background: var(--mA-week); color: var(--sheet-ink); }
.mc-1 { background: var(--mB-week); color: var(--sheet-ink); }
.pager-bar { align-items: stretch; }
.pager-bar .edge { align-self: stretch; height: auto; min-height: 100%; display: flex; align-items: center; justify-content: center; opacity: 1; padding: 0; color: var(--sheet-ink); }
.pager-bar .edge.prev { border-right: 1px solid rgba(0, 0, 0, .25); }
.pager-bar .edge.next { border-left: 1px solid rgba(0, 0, 0, .25); }
.pager-bar .week-title { padding: 0; justify-content: flex-start; color: var(--sheet-ink); }
.week-title .wt-month { display: block; width: 100%; text-align: center; padding: 4px 0 3px; font-weight: 700; opacity: 1; border-bottom: 1px solid rgba(0, 0, 0, .12); }
.week-title.mc-0 .wt-month { background: var(--mA-month); }
.week-title.mc-1 .wt-month { background: var(--mB-month); }
.week-title .wt-main { padding-top: 4px; color: var(--sheet-ink); }
.week-title .wt-dates { padding-bottom: 6px; opacity: 1; color: var(--sheet-ink); }
.week-title.is-now .wt-dates { color: var(--accent); }
.sheet th.m.mc-0 { background: var(--mA-month); color: var(--sheet-ink); }
.sheet th.m.mc-1 { background: var(--mB-month); color: var(--sheet-ink); }
.sheet th.w.mc-0 { background: var(--mA-week); color: var(--sheet-ink); }
.sheet th.w.mc-1 { background: var(--mB-week); color: var(--sheet-ink); }
.sheet th.w small { color: rgba(0, 0, 0, .65); }

/* ---- Filas de totales con los colores de la hoja ---- */
.row-gastos { --rbg: #bfbfbf; --rbg-v: #bfbfbf; --rink: #000; }
.row-fel { --rbg: #d9e2f3; --rbg-v: #d9e2f3; --rink: #000; }
.row-fer { --rbg: #ffccff; --rbg-v: #ffccff; --rink: #000; }
.row-tax { --rbg: #fce5cd; --rbg-v: #f7caac; --rink: #000; }
.row-eq { --rbg: #ffccff; --rbg-v: #ffccff; --rink: #000; }
.row-ws { --rbg: #d9e2f3; --rbg-v: #d9e2f3; --rink: #000; }
.row-fund { --rbg: #c5e0b3; --rbg-v: #c5e0b3; --rink: #000; }
.row-wealth { --rbg: #d9d9d9; --rbg-v: #d9d9d9; --rink: #7f7f7f; }
.wp-sum { overflow: hidden; }
.wp-sum .sr[class*="row-"] { background: linear-gradient(90deg, var(--rbg) 0 58%, var(--rbg-v) 58% 100%); border-bottom-color: rgba(0, 0, 0, .08); }
.wp-sum .sr[class*="row-"] dt { color: var(--rink); font-weight: 700; }
.wp-sum .sr[class*="row-"] dd { color: var(--rink); }
.wp-sum .sr.row-eq dd, .wp-sum .sr.row-ws dd, .wp-sum .sr.row-fund dd { font-weight: 700; }
.wp-sum .sr.row-fund dt { font-weight: 400; }
.wp-sum .sr[class*="row-"] dd.proj { color: rgba(0, 0, 0, .5); }
.wp-sum .sr.row-wealth dd.proj { color: #9a9a9a; }
.wp-sum .sr.editable dd::before { color: rgba(0, 0, 0, .45); }
.wp-items .it-total { background: #bfbfbf; color: #000; }
.sheet tr.sum[class*="row-"] th.rowh { background: var(--rbg); color: var(--rink); }
.sheet tr.sum[class*="row-"] td { background: var(--rbg-v); color: var(--rink); }
.sheet tr.sum[class*="row-"] td.proj { color: rgba(0, 0, 0, .5); }

/* ---- Tonos sutiles, líneas entre filas, mes parejo, botón Hoy arriba ---- */
:root { --mA-week: #e5f1dd; --mB-week: #eeeeee; --mA-month: #e5f1dd; --mB-month: #eeeeee; }
.mc-0 { background: var(--mA-week); }
.mc-1 { background: var(--mB-week); }
.week-title .wt-month, .week-title.mc-0 .wt-month, .week-title.mc-1 .wt-month { background: transparent; border-bottom: 0; font-weight: 600; padding-top: 6px; }
.sheet th.m.mc-0 { background: #d6e9ca; } .sheet th.m.mc-1 { background: #e2e2e2; }
.sheet th.w.mc-0 { background: var(--mA-week); } .sheet th.w.mc-1 { background: var(--mB-week); }
.row-gastos { --rbg: #e2e2e2; --rbg-v: #e2e2e2; }
.row-fel, .row-ws { --rbg: #eef2fa; --rbg-v: #eef2fa; }
.row-fer, .row-eq { --rbg: #ffe8ff; --rbg-v: #ffe8ff; }
.row-tax { --rbg: #fde3c8; --rbg-v: #fde3c8; }
.row-fund { --rbg: #e5f1dd; --rbg-v: #e5f1dd; }
.row-wealth { --rbg: #eeeeee; --rbg-v: #eeeeee; }
.wp-sum .sr[class*="row-"] { background: var(--rbg); border-bottom: 1px solid rgba(0, 0, 0, .1); }
.wp-sum .sr[class*="row-"]:last-child { border-bottom: 0; }
.wp-items .it-total { background: #e2e2e2; }
.sheet tr.sum[class*="row-"] td, .sheet tr.sum[class*="row-"] th { border-bottom: 1px solid rgba(0, 0, 0, .1); }
.proj-wrap { position: relative; }
.today-fab { position: absolute; top: 74px; left: 50%; right: auto; bottom: auto; transform: translateX(-50%); padding: 7px 16px; font-size: .88rem; }

/* Pagados más claros y divisiones visibles; marca de pago CRA; fila suma total de taxes */
:root { --paid-bg: #eef6e8; }
.wp-items .it { border-bottom: 1px solid rgba(0, 0, 0, .08); }
.row-taxg { --rbg: #feefdf; --rbg-v: #feefdf; --rink: #000; }
.wp-sum .sr.row-taxg dt { font-weight: 400; }
.pay-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px; background: #f4c7a1; color: #6b3410; font-size: .68rem; font-weight: 700; vertical-align: middle; }
.sheet td.pay-cell { box-shadow: inset 0 0 0 2px #e8a46d; }
.pay-dot { display: inline-block; padding: 0 4px; border-radius: 4px; background: #f4c7a1; color: #6b3410; font-size: .62rem; font-weight: 700; font-style: normal; }

/* ---- Wealth Monitor: gráfica alta + bloque de captura ---- */
.chart-box.taller { height: 520px; }
@media (max-width: 640px) { .chart-box.taller { height: 420px; } }
.cap-head { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; text-align: center; margin-bottom: 8px; }
.cap-head strong { display: block; font-size: 1.05rem; }
.cap-head small { color: var(--text-muted); font-size: .75rem; }
.cap-nav { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-1); font-size: 1.3rem; cursor: pointer; color: var(--text-primary); }
.cap-nav:disabled { opacity: .35; cursor: default; }
.cap-rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; text-align: center; }
.cap-rate { display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; border-radius: 8px; background: var(--surface-1); border: 1px solid var(--border); }
.cap-rate span { font-size: .72rem; color: var(--text-muted); letter-spacing: .02em; }
.cap-rate b { font-size: .95rem; font-variant-numeric: tabular-nums; }
.cap-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 10px; background: #eeeeee; margin-bottom: 8px; }
.cap-seg button { border: 0; background: transparent; padding: 7px 0; border-radius: 8px; font-weight: 600; font-size: .85rem; color: var(--text-secondary); cursor: pointer; }
.cap-seg button.on { background: #fff; color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.cap-table td, .cap-table th { padding: 7px 8px; font-size: .9rem; }
.cap-table tr.tot td { font-weight: 700; background: #eef2fa; }
.cap-table tr.sub td { color: var(--text-secondary); }

/* ---- Gráfica expandida ---- */
.wp-chart { position: relative; cursor: zoom-in; }
.expand-hint { position: absolute; top: 6px; right: 8px; z-index: 1; font-size: .72rem; color: var(--text-secondary); background: var(--surface-0); border: 1px solid var(--border); border-radius: 99px; padding: 1px 8px; pointer-events: none; }
.chart-dlg { width: calc(100vw - 16px); max-width: 1200px; height: min(80vh, 640px); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); color: var(--text-primary); }
.chart-dlg[open] { display: flex; flex-direction: column; }
.chart-dlg::backdrop { background: rgba(0, 0, 0, .4); }
.cd-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.cd-head .hint { margin: 0; flex: 1; font-size: .75rem; }
.cd-close { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-0); font-size: 1rem; cursor: pointer; color: var(--text-primary); }
.cd-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.cd-inner { position: relative; height: 100%; padding: 8px 8px 4px; box-sizing: border-box; }

/* ---------- Tags de gastos ---------- */
.tpill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: .68rem; font-weight: 600; line-height: 1.5; letter-spacing: .01em; white-space: nowrap; border: 1px solid transparent; }
.tpill.tg-0 { background: #e3eefb; color: #1c5cab; }
.tpill.tg-1 { background: #fde6dc; color: #a8431b; }
.tpill.tg-2 { background: #dcf3ea; color: #0e6e4b; }
.tpill.tg-3 { background: #fdf0d2; color: #8a5d00; }
.tpill.tg-4 { background: #fbe5ee; color: #a3365f; }
.tpill.tg-5 { background: #dff0df; color: #005c00; }
.tpill.tg-6 { background: #e7e4f9; color: #4a3aa7; }
.tpill.tg-7 { background: #fbe2e2; color: #a52c2b; }
.tpill.none { background: transparent; color: var(--text-muted); border-color: var(--border); }
.wp-items .it .amt-wrap { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cell-item .tpill { margin-left: 6px; }
.fx-amt .tpill { margin-right: 8px; vertical-align: 1px; }
.tag-pick { border: 0; padding: 0; margin: 4px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick legend { font-size: .85rem; color: var(--text-secondary); margin-bottom: 6px; padding: 0; }
.tag-pick label { display: inline-flex; cursor: pointer; margin: 0; }
.tag-pick input { position: absolute; opacity: 0; pointer-events: none; }
.tag-pick .tpill { font-size: .82rem; padding: 5px 12px; opacity: .55; }
.tag-pick input:checked + .tpill { opacity: 1; border-color: currentColor; }
.tag-pick input:focus-visible + .tpill { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Backend → Gastos ---------- */
.sp-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 18px; margin-bottom: 12px; }
.sp-filters label { margin: 0; }
.sp-total { display: flex; flex-direction: column; margin-bottom: 12px; }
.sp-total span { font-size: .8rem; color: var(--text-secondary); }
.sp-total strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.sp-total small { color: var(--text-muted); }
.sp-bars { display: flex; flex-direction: column; gap: 2px; }
.sp-bar { display: grid; grid-template-columns: 130px 1fr 120px; align-items: center; gap: 10px; padding: 7px 6px; border: 0; border-radius: 8px; background: transparent; font: inherit; color: var(--text-primary); cursor: pointer; text-align: left; }
.sp-bar:hover, .sp-bar.on { background: #f1f1ef; }
.sp-name { display: flex; align-items: center; gap: 6px; }
.sp-name .tpill { font-size: .78rem; }
.sp-name small, .sp-amt small { color: var(--text-muted); font-size: .72rem; }
.sp-track { height: 10px; background: #eeeeee; border-radius: 4px; overflow: hidden; }
.sp-fill { display: block; height: 100%; border-radius: 4px; }
.sp-amt { text-align: right; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; }
.sp-mt td, .sp-mt th { font-size: .82rem; padding: 6px 8px; }
.sp-list { display: flex; flex-direction: column; }
.sp-it { display: grid; grid-template-columns: 64px 1fr 92px 90px; align-items: center; gap: 10px; padding: 8px 6px; border: 0; border-bottom: 1px solid rgba(0,0,0,.08); background: transparent; font: inherit; font-size: .9rem; color: var(--text-primary); text-align: left; cursor: pointer; }
.sp-it.fut { color: var(--text-muted); font-style: italic; }
.sp-it .sp-d { color: var(--text-muted); font-size: .78rem; }
.sp-it .sp-c { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-it .sp-a { text-align: right; font-variant-numeric: tabular-nums; }
.tag-edit { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tag-edit .tpill { font-size: .85rem; padding: 4px 6px 4px 12px; }
.tag-edit .tpill button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: .75rem; padding: 0 4px; }
.tag-add { display: flex; gap: 8px; margin-bottom: 8px; }
.tag-add input { flex: 1; }
@media (max-width: 560px) { .sp-bar { grid-template-columns: 105px 1fr 92px; gap: 6px; } }

/* Color por tag: pill y fondo del gasto pagado */
:root { --tag-fixed: #eef6e8; --tag-budget: #dcebcf; --tag-car: #fbd8f2; --tag-imprevisto: #fff4c7; --tag-health: #d8edf7; --tag-planeado: #e7e2f8; }
.tpill.tk-fixed { background: var(--tag-fixed); color: #3b6b1f; border-color: rgba(59, 107, 31, .35); }
.tpill.tk-budget { background: var(--tag-budget); color: #2a5214; border-color: rgba(42, 82, 20, .35); }
.tpill.tk-car { background: var(--tag-car); color: #8a2f78; border-color: rgba(138, 47, 120, .35); }
.tpill.tk-imprevisto { background: var(--tag-imprevisto); color: #7a5c00; border-color: rgba(122, 92, 0, .35); }
.tpill.tk-health { background: var(--tag-health); color: #1d6a85; border-color: rgba(29, 106, 133, .35); }
.tpill.tk-planeado { background: var(--tag-planeado); color: #4a3aa7; border-color: rgba(74, 58, 167, .35); }
.wp-items .it.paid.pt-fixed, .sheet td.paid.pt-fixed { background: var(--tag-fixed) !important; }
.wp-items .it.paid.pt-budget, .sheet td.paid.pt-budget { background: var(--tag-budget) !important; }
.wp-items .it.paid.pt-car, .sheet td.paid.pt-car { background: var(--tag-car) !important; }
.wp-items .it.paid.pt-imprevisto, .sheet td.paid.pt-imprevisto { background: var(--tag-imprevisto) !important; }
.wp-items .it.paid.pt-health, .sheet td.paid.pt-health { background: var(--tag-health) !important; }
.wp-items .it.paid.pt-planeado, .sheet td.paid.pt-planeado { background: var(--tag-planeado) !important; }

/* Más aire vertical entre bloques de cada semana */
.week-page .wp-sum, .week-page .wp-chart, .week-page .wp-ind { margin-top: 20px; }
.week-page .wp-items { margin-top: 16px; }

.sp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.sp-chip { border: 1px solid var(--border); background: var(--surface-1); border-radius: 999px; padding: 4px 8px; font: inherit; font-size: .8rem; cursor: pointer; color: var(--text-secondary); display: inline-flex; align-items: center; }
.sp-chip.on { border-color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--text-primary); color: var(--text-primary); }
.sp-chip .tpill { font-size: .75rem; }
.sp-head { display: grid; grid-template-columns: 64px 1fr 92px 90px; gap: 10px; padding: 6px 6px; border-bottom: 1.5px solid rgba(0,0,0,.18); position: sticky; top: 0; background: var(--surface-1); z-index: 1; }
.sp-th { border: 0; background: transparent; font: inherit; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); text-align: left; padding: 0; cursor: pointer; white-space: nowrap; }
.sp-th.r { text-align: right; }
.sp-th.on { color: var(--text-primary); }
.sp-it .tpill { justify-self: start; }

/* ---------- Dashboard: pestañas subrayadas ---------- */
.dash-tabs { gap: 0; border-bottom: 1px solid var(--border); padding: 0; margin: 0 0 14px; }
.dtab { border: 0; border-radius: 0; background: transparent; padding: 10px 14px 9px; color: var(--text-muted); border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.dtab.on { background: transparent; color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

/* ---------- Tablas de gastos fijos y presupuestos ---------- */
.card-head .spacer { flex: 1; }
.year-sel { width: auto; padding: 5px 8px; font-size: .88rem; margin-right: 6px; }
.ftab { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 8px; }
.ft-head, .ft-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 66px 74px; align-items: center; gap: 10px; padding: 9px 12px; }
.bt-row { grid-template-columns: minmax(0, 1fr) 66px 74px; }
.ft-row .tpill { font-size: .64rem; padding: 0 6px; }
.ft-head { background: var(--surface-0); border-bottom: 1.5px solid rgba(0,0,0,.15); padding-top: 7px; padding-bottom: 7px; }
.ft-th { border: 0; background: transparent; font: inherit; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); text-align: left; padding: 0; cursor: pointer; white-space: nowrap; }
.ft-th.r { text-align: right; } .ft-th.on { color: var(--text-primary); }
.ft-row { border: 0; border-bottom: 1px solid rgba(0,0,0,.08); background: var(--surface-1); color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; }
.ft-row:hover { background: #f6f6f4; }
.ft-row.off { opacity: .5; }
.ft-day { font-variant-numeric: tabular-nums; color: var(--text-secondary); font-weight: 600; }
.ft-name { min-width: 0; }
.ft-name small { display: block; color: var(--text-muted); font-size: .75rem; }
.ft-amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.ft-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 12px; background: var(--surface-0); border-top: 1.5px solid rgba(0,0,0,.15); }
.ft-total span { font-weight: 700; }
.ft-total strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

/* ---------- Tax y salarios ---------- */
.yr-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid rgba(0,0,0,.08); background: var(--surface-1); flex-wrap: wrap; }
.yr-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.yr-main strong { font-size: 1.15rem; }
.yr-main small { color: var(--text-muted); font-size: .78rem; width: 100%; }
.yr-st { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: #eeeeee; color: var(--text-secondary); }
.yr-st.ok { background: #e5f1dd; color: #2f5a17; }
.yr-st.warn { background: #fdf0d2; color: #7a5c00; }
.yr-act { display: flex; gap: 6px; flex-wrap: wrap; }
.inc-row { grid-template-columns: 34px minmax(0, 1fr) 72px 72px; }
.muted-amt { color: var(--text-muted); font-weight: 500; }
.imp-row { cursor: default; }
.inst-tab { margin-top: 10px; }
.btn.small.ghost { color: var(--accent) !important; background: transparent; }

.yr-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.yr-sel { width: auto; font-size: 1.25rem; font-weight: 700; padding: 6px 10px; }
.yr-top small { color: var(--text-muted); }
.yr-card .yr-act { margin-bottom: 4px; }
.tr-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); margin: 8px 0; }
.tr-item { display: grid !important; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid rgba(0,0,0,.08); margin: 0 !important; font-weight: 500; cursor: pointer; }
.tr-item.done { opacity: .5; }
.tr-item input { width: 20px; height: 20px; accent-color: var(--accent); }
.tr-c small { display: block; color: var(--text-muted); font-size: .75rem; font-weight: 400; }
.tr-a { font-variant-numeric: tabular-nums; }

/* Dashboard: sin deslizar entre pestañas */
.dash-panes { display: block; overflow: visible; scroll-snap-type: none; }
.dpane { padding: 0; }
.dpane[hidden] { display: none; }

/* ---------- Hoja inferior (selector de semana / captura) ---------- */
.bsheet { position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 640px; max-height: 78vh; padding: 0; border: 0; border-radius: 18px 18px 0 0; background: var(--surface-1); color: var(--text-primary); box-shadow: 0 -8px 30px rgba(0,0,0,.18); }
.bsheet[open] { display: flex; flex-direction: column; animation: bs-up .22s ease-out; }
.bsheet::backdrop { background: rgba(0,0,0,.35); }
@keyframes bs-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bsheet[open] { animation: none; } }
.bs-grip { width: 38px; height: 4px; border-radius: 4px; background: #d6d6d2; margin: 8px auto 2px; }
.bs-head { display: flex; align-items: center; gap: 8px; padding: 6px 14px 10px; border-bottom: 1px solid var(--border); }
.bs-head .spacer { flex: 1; }
.bs-title { font-size: 1.05rem; }
.bs-years { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.bs-year { border: 0; background: transparent; padding: 6px 12px; border-radius: 99px; font: inherit; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.bs-year.on { background: #f3e3d9; color: var(--accent); }
.bs-today { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 99px; padding: 5px 12px; font: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; }
.bs-body { overflow-y: auto; padding: 6px 14px calc(16px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.bs-month { padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,.06); }
.bs-mname { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 6px; }
.bs-month.cur .bs-mname { color: var(--accent); }
.bs-weeks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.bs-wk { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-0); font: inherit; color: var(--text-primary); cursor: pointer; position: relative; }
.bs-wk.closed { color: var(--text-secondary); background: #f6f6f4; }
.bs-wn { font-weight: 700; font-size: .9rem; }
.bs-wd { font-size: .7rem; color: var(--text-muted); }
.bs-wk.now { border-color: var(--accent); }
.bs-wk.now::after { content: ''; position: absolute; top: 5px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.bs-wk.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.bs-wk.sel .bs-wd { color: rgba(255,255,255,.85); }
.bs-wk.sel.now::after { background: #fff; }
.bs-list { display: flex; flex-direction: column; }
.bs-cap { display: flex; justify-content: space-between; padding: 10px 6px; border: 0; border-radius: 8px; background: transparent; font: inherit; color: var(--text-primary); cursor: pointer; }
.bs-cap.sel { background: #f3e3d9; color: var(--accent); font-weight: 700; }
.bs-capv { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.bs-cap.sel .bs-capv { color: inherit; }
.week-title { cursor: pointer !important; }
.cap-title { border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.cap-title strong { display: block; font-size: 1.05rem; }
.cap-title small { color: var(--text-muted); font-size: .75rem; }

.chart-box { position: relative; }
.zoom-reset { position: absolute; top: 6px; right: 6px; border: 1px solid var(--accent); background: rgba(255,255,255,.92); color: var(--accent); border-radius: 99px; padding: 4px 12px; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.zoom-hint { font-size: .72rem; margin: 6px 0 0; text-align: center; }
#wealthChart { touch-action: pan-y; }

/* ---------- Escritorio: varias semanas + gráfica continua ---------- */
.pager { --per: 1; }
.pager.multi .week-page { flex: 0 0 calc(100% / var(--per)); padding: 6px 8px 10px; opacity: .72; transition: opacity .15s; cursor: pointer; }
.pager.multi .week-page.sel { opacity: 1; cursor: default; }
.pager.multi .week-page > * { max-width: none; }
.pager.multi .week-page.sel .wp-items, .pager.multi .week-page.sel .wp-sum { border-color: var(--accent); }
.pager.multi .wp-chart { display: none; }
.wp-spacer { flex: 0 0 calc((var(--per) - 1) / 2 * (100% / var(--per))); }
.track { flex: 0 0 230px; position: relative; border-top: 1px solid var(--border); background: var(--surface-1); }
.track[hidden] { display: none; }
/* Inicio de año */
.year-start { max-width: 560px; margin: 4px auto 0; padding: 4px 10px; border-radius: 8px; background: #f3e3d9; color: var(--accent); font-weight: 700; font-size: .8rem; text-align: center; letter-spacing: .02em; }
.pager.multi .week-page.ys { border-left: 2px dashed var(--accent); }
.sheet th.ys, .sheet td.ys { border-left: 3px solid var(--accent) !important; }
/* Hoja: gráfica arriba, alineada con las columnas */
.sheet-track { position: relative; height: 210px; margin-bottom: 6px; background: var(--surface-1); overflow: hidden; border-bottom: 1px solid var(--border); }

.pager:not(.multi) .year-start { display: none; }
.week-title.ys .wt-month { color: var(--accent); }

/* Escritorio: indicadores una sola vez, arriba de la gráfica continua */
.pager.multi .wp-ind { display: none; }
.track { flex: 0 0 290px; display: flex; flex-direction: column; }
.track-box { position: relative; flex: 1; min-height: 0; }
.track-ind .wp-ind { display: flex; gap: 8px; margin: 0; padding: 6px 10px 2px; justify-content: flex-end; }
.track-ind .ind { flex: 0 0 auto; flex-direction: row; align-items: baseline; gap: 8px; padding: 4px 12px; border-radius: 99px; }
.track-ind .ind-v { font-size: .95rem; }
/* Hoja: gráfica abajo, la tabla deja espacio */
.sheet-wrap { max-height: max(300px, calc(100vh - 420px)); }
.sheet-track { margin: 6px 0 0; border-bottom: 0; border-top: 1px solid var(--border); }

/* Indicadores centrados */
.track-ind .wp-ind { justify-content: center; }
/* Barras de scroll discretas en las tarjetas de semana */
@supports not selector(::-webkit-scrollbar) { .week-page { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.18) transparent; } }
.week-page::-webkit-scrollbar { width: 6px; }
.week-page::-webkit-scrollbar-button { display: none; height: 0; }
.week-page::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 6px; }
.week-page::-webkit-scrollbar-track { background: transparent; }
/* Pill fijo en la semana actual */
.today-pill { position: sticky; top: 4px; z-index: 3; display: block; width: max-content; margin: 0 auto -26px; padding: 3px 14px; border-radius: 99px; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.2); pointer-events: none; }
/* Escritorio: flechas pegadas a la semana central */
.pager-bar.multi { grid-template-columns: 1fr minmax(0, var(--cardw, 400px)) 1fr; }
.pager-bar.multi .edge.prev { justify-content: flex-end; padding-right: 22px; }
.pager-bar.multi .edge.next { justify-content: flex-start; padding-left: 22px; }
.pager-bar.multi .edge { border-radius: 0; }
/* Dashboard escritorio */
body.dash .wrap.wide { max-width: 1680px; }
body.dash .dpane:not([data-pane="wealth"]) { max-width: 1100px; margin-left: auto; margin-right: auto; }
.wealth-grid { display: flex; flex-direction: column-reverse; gap: 0; }
.last-pill { display: inline-block; margin-top: 3px; padding: 1px 10px; border-radius: 99px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; }
@media (min-width: 1100px) {
  .wealth-grid { display: grid; grid-template-columns: minmax(330px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
  .wealth-grid > .card { margin: 0; }
  .wealth-grid .cap-card { position: sticky; top: 12px; }
  .wealth-grid .chart-box.taller { height: max(460px, calc(100vh - 230px)); }
}

.last-pill.ghost { visibility: hidden; }
@media (min-width: 1100px) { body.dash .wrap.wide { padding-bottom: 0; } }

/* ---------- Dashboard escritorio: columnas por pestaña ---------- */
.fund-pct { text-align: center; color: var(--text-secondary); font-weight: 600; margin: 8px 0 0; }
.tfsa-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tfsa-card { display: flex; flex-direction: column; gap: 2px; }
.tfsa-card .lbl { font-size: .8rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .03em; }
.tfsa-card .big { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tfsa-card .sub { font-size: .78rem; color: var(--text-muted); margin-bottom: 8px; }
.tm-row { grid-template-columns: 78px minmax(0, 1fr) 70px 90px; }
@media (min-width: 1100px) {
  body.dash .dpane[data-pane="gastos"], body.dash .dpane[data-pane="tax"], body.dash .dpane[data-pane="tfsa"] { max-width: 1440px; }
  .dpane > .card, .dpane .card { margin-top: 0; }
  /* Fondo de emergencia: anillo a la izquierda, datos a la derecha */
  .fund-card { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 32px; align-items: center; padding: 28px; }
  .fund-left { display: flex; flex-direction: column; align-items: center; }
  .fund-left .ring { width: 220px; height: 220px; }
  /* Fijos y presupuestos: total angosto + dos columnas iguales */
  .dpane[data-pane="gastos"]:not([hidden]) { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .dpane[data-pane="gastos"] > .card { margin: 0; }
  /* Tax y salarios: año arriba a todo lo ancho, tres columnas iguales abajo */
  .dpane[data-pane="tax"]:not([hidden]) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .dpane[data-pane="tax"] #planPane, .dpane[data-pane="tax"] #instPane { display: contents; }
  .dpane[data-pane="tax"] .yr-card { grid-column: 1 / -1; }
  .dpane[data-pane="tax"] .card { margin: 0; }
  /* TFSA: personas en columna angosta, movimientos más ancho */
  .tfsa-cols { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr); gap: 16px; align-items: start; }
  .tfsa-people { display: flex; flex-direction: column; gap: 16px; }
  .tfsa-cols .card, .tfsa-top { margin: 0 0 16px; }
  .tfsa-people .card { margin: 0; }
}

/* Fondo de emergencia: dos tarjetas, anillo por meses */
.fund-grid { display: flex; flex-direction: column; }
.fund-ring-card, .fund-data-card { display: flex; flex-direction: column; }
.fund-ring-card h2, .fund-data-card h2 { margin: 0 0 8px; font-size: 1.05rem; }
.fund-ring { width: 100%; max-width: 380px; margin: 0 auto; display: block; }
.fr-track { fill: none; stroke: #ecebe7; }
.fr-fill { fill: none; stroke: #1baf7a; }
.fr-fill.part { stroke: #4cc597; }
.fr-lbl { font-size: 11px; fill: var(--text-muted); font-weight: 600; }
.fr-lbl.done { fill: #128a5f; }
.fr-big { font-size: 46px; font-weight: 800; fill: var(--text-primary); }
.fr-sub { font-size: 14px; fill: var(--text-muted); }
.fr-pct { font-size: 13px; font-weight: 700; fill: #128a5f; }
.fr-note { text-align: center; margin-top: 6px; }
.fund-data-card .btn { align-self: flex-start; margin-top: auto; }
@media (min-width: 1100px) {
  .fund-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; }
  .fund-grid > .card { margin: 0; padding: 22px 24px; }
  .fund-ring { max-width: 420px; }
}

.fr-fill.z1 { stroke: #e34948; } .fr-fill.z1.part { stroke: #ee7d7c; }
.fr-fill.z2 { stroke: #eb6834; } .fr-fill.z2.part { stroke: #f29a6f; }
.fr-lbl.done.z1 { fill: #c23b3a; } .fr-lbl.done.z2 { fill: #c4531f; }
.fd-sub { font-size: .9rem; margin: 18px 0 8px; }
.fd-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #ecebe7; }
.fd-bar span { display: block; height: 100%; }
.fd-ca { background: #1baf7a; } .fd-ab { background: #2a78d6; }
.fd-leg { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: .88rem; }
.fd-leg > div { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; }
.fd-leg .fl-v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.fd-leg b { font-weight: 600; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.ca { background: #1baf7a; } .sw.ab { background: #2a78d6; }
.fund-trend-box { height: 260px; }
@media (min-width: 1100px) { .fund-trend-card { grid-column: 1 / -1; } .fund-grid { row-gap: 16px; } }

/* Gasto mensual por categoría */
#monthlyTotal .card-head { margin-bottom: 2px; }
.mo-tab { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.mo-cat { display: flex; justify-content: space-between; padding: 7px 12px; background: var(--surface-0); font-weight: 700; font-size: .82rem; border-top: 1px solid var(--border); }
.mo-cat:first-child { border-top: 0; }
.mo-cat span:last-child { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.mo-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px 6px 22px; border-top: 1px solid rgba(0,0,0,.05); font-size: .88rem; }
.mo-n small { display: block; color: var(--text-muted); font-size: .72rem; }
.mo-v { font-variant-numeric: tabular-nums; }
.mo-total { display: flex; justify-content: space-between; padding: 10px 12px; border-top: 1.5px solid rgba(0,0,0,.15); font-weight: 800; font-variant-numeric: tabular-nums; }
/* Gastos fijos con periodo */
.fx-row { grid-template-columns: 24px minmax(0, 1fr) 92px 66px 74px; }
.ft-per { font-size: .78rem; color: var(--text-secondary); white-space: nowrap; }
.ft-per small { display: block; color: var(--text-muted); font-size: .7rem; }
.ft-per .muted { color: var(--text-muted); font-style: italic; }
/* Equivalencias de salario */
.sal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 6px; }
.sal-head h3 { margin: 0; font-size: .95rem; }
.sal-seg { width: 180px; margin: 0; }
.sal-tab { margin-top: 8px; }
.sal-row { grid-template-columns: minmax(0, 1fr) 84px 84px 84px; cursor: default; }
@media (min-width: 1100px) { .dpane[data-pane="gastos"]:not([hidden]) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Escritorio: encabezado por semana (mes centrado sobre sus semanas) ---------- */
.week-strip { display: none; }
.pager-bar.multi { position: relative; display: block; height: 78px; padding: 0; overflow: hidden; }
.pager-bar.multi > .week-title { display: none; }
.pager-bar.multi .week-strip { display: block; position: absolute; inset: 0; }
.pager-bar.multi .week-strip[hidden] { display: none; }
.ws-inner { position: absolute; top: 0; left: 0; height: 100%; will-change: transform; }
.ws-month { position: absolute; top: 0; height: 26px; }
.ws-month span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.ws-week { position: absolute; top: 0; height: 100%; padding: 24px 6px 6px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font: inherit; color: inherit; cursor: pointer; opacity: .5; transition: opacity .15s; }
.ws-month, .ws-week { background-clip: padding-box; }
.ws-week b { font-size: 1rem; }
.ws-week small { font-size: .74rem; }
.ws-week.sel { opacity: 1; cursor: pointer; }
.ws-week.sel b { font-size: 1.2rem; }
.ws-week.sel small { color: var(--accent); font-weight: 600; }
.ws-week.sel small::after { content: ' ▾'; }
.ws-week.now:not(.sel) b::after { content: ' · hoy'; color: var(--accent); font-weight: 700; }
.ws-week:hover { opacity: .8; }
.ws-week.sel:hover { opacity: 1; }
/* flechas: pegadas a la semana central, sobre el encabezado */
.pager-bar.multi .edge { position: absolute; top: 0; bottom: 0; z-index: 2; width: 44px; height: auto; min-height: 0; background: transparent !important; border: 0 !important; color: var(--text-primary); display: flex; align-items: center; justify-content: center; padding: 0 !important; }
.pager-bar.multi .edge.prev { left: calc(50% - var(--cardw, 400px) / 2 - 2px); transform: translateX(-100%); justify-content: flex-end; }
.pager-bar.multi .edge.next { left: calc(50% + var(--cardw, 400px) / 2 + 2px); justify-content: flex-start; }
.pager-bar.multi .edge span { font-size: 1.6rem; }
/* Tarjetas: resumen fijo abajo; solo los gastos hacen scroll; espacio vacío en gris claro */
.pager.multi .week-page { display: flex; flex-direction: column; overflow: hidden; }
.pager.multi .wp-items { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.pager.multi .wp-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; background: #f7f7f5; border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.pager.multi .wp-list .it:not(.paid):not([class*="pt-"]) { background: var(--surface-1); }
.pager.multi .wp-list .it:last-child { border-bottom: 1px solid var(--grid); }
.pager.multi .wp-sum, .pager.multi .year-start, .pager.multi .add-row, .pager.multi .it-total { flex: none; }
.wp-list { scrollbar-width: thin; }
@supports selector(::-webkit-scrollbar) { .wp-list { scrollbar-width: auto; } }
.wp-list::-webkit-scrollbar { width: 6px; }
.wp-list::-webkit-scrollbar-button { display: none; height: 0; }
.wp-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 6px; }
.pager.multi .week-page > * { width: 100%; max-width: none; margin-left: 0; margin-right: 0; }
.pager.multi .week-page > .today-pill { width: max-content; margin: 0 auto -26px; }
/* Encabezado: el fondo conserva el color del mes; solo el texto se deslava */
.ws-week { opacity: 1 !important; }
.ws-week b, .ws-week small { opacity: .5; transition: opacity .15s; }
.ws-week:hover b, .ws-week:hover small { opacity: .8; }
.ws-week.sel b, .ws-week.sel small { opacity: 1; }
.ws-week.now:not(.sel) b::after { content: none; }
.ws-week.mc-0, .ws-month.mc-0 { background: var(--mA-week); }
.ws-week.mc-1, .ws-month.mc-1 { background: var(--mB-week); }
.ws-month { z-index: 1; background: transparent !important; }
/* ---------- Escritorio con pantalla baja (laptop): todo más compacto, sin tocar pantallas grandes ---------- */
.pager.multi .wp-list { min-height: 120px; }
.pager.multi .week-page { overflow-y: auto; }
.track { flex-basis: clamp(170px, 28vh, 290px); }
@media (min-width: 1000px) and (max-height: 1000px) {
  .pager-bar.multi { height: 62px; }
  .ws-month span { top: 4px; font-size: .66rem; }
  .ws-week { padding-top: 18px; }
  .ws-week b { font-size: .9rem; } .ws-week.sel b { font-size: 1.05rem; }
  .ws-week small { font-size: .68rem; }
  .today-fab { top: 58px; padding: 5px 13px; font-size: .8rem; }
  .pager.multi .week-page { padding-top: 4px; }
  .pager.multi .wp-items { margin-top: 10px; }
  .pager.multi .wp-items .it { padding: 6px 10px; font-size: .86rem; }
  .pager.multi .wp-items .it-total { padding: 12px 10px 6px; font-size: .9rem; }
  .pager.multi .wp-sum { margin-top: 12px; }
  .pager.multi .wp-sum .sr { padding: 4px 10px; font-size: .84rem; }
  .pager.multi .pay-tag { font-size: .62rem; }
  .track-ind .wp-ind { padding: 3px 10px 0; }
  .track-ind .ind { padding: 2px 10px; }
  .track-ind .ind-l, .track-ind .ind-s { font-size: .68rem; }
  .track-ind .ind-v { font-size: .85rem; }
}
.pager.multi .wp-items { min-height: 178px; }
@media (min-width: 1000px) and (max-height: 800px) {
  .track { flex-basis: 150px; }
  .pager.multi .wp-list { min-height: 100px; }
  .pager.multi .wp-items { min-height: 152px; }
  .pager.multi .wp-sum .sr { padding: 3px 10px; font-size: .8rem; }
  .pager.multi .wp-items .it { padding: 5px 10px; font-size: .82rem; }
}

/* Colores de tags propios */
.tpill.tc-teal, .swatch.tc-teal { background: #d6f1ee; color: #11685f; border-color: #11685f55; }
.wp-items .it.paid.pc-teal, .sheet td.paid.pc-teal { background: #d6f1ee !important; }
.tpill.tc-rose, .swatch.tc-rose { background: #fbe0e6; color: #9c2a47; border-color: #9c2a4755; }
.wp-items .it.paid.pc-rose, .sheet td.paid.pc-rose { background: #fbe0e6 !important; }
.tpill.tc-indigo, .swatch.tc-indigo { background: #e1e5fa; color: #3646a3; border-color: #3646a355; }
.wp-items .it.paid.pc-indigo, .sheet td.paid.pc-indigo { background: #e1e5fa !important; }
.tpill.tc-brown, .swatch.tc-brown { background: #f1e4d8; color: #7a4b25; border-color: #7a4b2555; }
.wp-items .it.paid.pc-brown, .sheet td.paid.pc-brown { background: #f1e4d8 !important; }
.tpill.tc-lime, .swatch.tc-lime { background: #ebf5d3; color: #4c6b0e; border-color: #4c6b0e55; }
.wp-items .it.paid.pc-lime, .sheet td.paid.pc-lime { background: #ebf5d3 !important; }
.tpill.tc-slate, .swatch.tc-slate { background: #e3e7ec; color: #3d4b5c; border-color: #3d4b5c55; }
.wp-items .it.paid.pc-slate, .sheet td.paid.pc-slate { background: #e3e7ec !important; }
.tpill.tc-coral, .swatch.tc-coral { background: #ffe1d6; color: #a3401f; border-color: #a3401f55; }
.wp-items .it.paid.pc-coral, .sheet td.paid.pc-coral { background: #ffe1d6 !important; }
.tpill.tc-olive, .swatch.tc-olive { background: #ecebd5; color: #5e5a1d; border-color: #5e5a1d55; }
.wp-items .it.paid.pc-olive, .sheet td.paid.pc-olive { background: #ecebd5 !important; }

.tag-colors { display: flex; align-items: center; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.tag-colors .tpill { min-width: 70px; justify-content: center; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid; cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--text-primary); }
/* Filtros: solo el pill, sin otro pill alrededor */
.sp-chip { border: 0 !important; background: transparent !important; padding: 2px !important; box-shadow: none !important; }
.sp-chip .tpill { font-size: .8rem; padding: 3px 11px; transition: box-shadow .12s; }
.sp-chip.on .tpill { box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3.5px var(--text-primary); }
.tpill.all { background: var(--surface-0); color: var(--text-primary); border-color: var(--border); }
/* Tabla de gastos más completa */
.sp-search { width: min(320px, 55%); padding: 6px 10px; font-size: .88rem; }
.sp-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .84rem; color: var(--text-secondary); margin: 4px 0 6px; }
.sp-stats b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.sp-head, .sp-it { grid-template-columns: 64px minmax(0, 1fr) 150px 96px 92px 90px; }
.sp-it .sp-c small { display: block; font-size: .7rem; color: var(--text-muted); font-style: normal; }
.sp-cat { font-size: .82rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-st { font-size: .75rem; font-weight: 600; }
.sp-st.st-paid { color: #2f7d32; } .sp-st.st-pend { color: #8a5d00; } .sp-st.st-proj { color: var(--text-muted); font-style: italic; }
@media (max-width: 760px) { .sp-head, .sp-it { grid-template-columns: 58px minmax(0, 1fr) 80px 76px; } .sp-head .opt, .sp-it .opt { display: none; } }
/* Divisiones de mes en el encabezado de semanas */
.ws-month { height: 100%; pointer-events: none; }
.ws-month + .ws-month, .ws-month:not(:first-child) { border-left: 1px solid rgba(0,0,0,.22); }
.ws-month { z-index: 1; }
/* Flechas un poco más separadas de la semana central */
.pager-bar.multi .edge.prev { left: calc(50% - var(--cardw, 400px) / 2 - 10px); }
.pager-bar.multi .edge.next { left: calc(50% + var(--cardw, 400px) / 2 + 10px); }
/* Proyección: letra un poco más chica, como en las otras páginas */
.wp-items .it { font-size: .86rem; }
.wp-items .it-total { font-size: .9rem; }
.wp-sum .sr { font-size: .88rem; }
.ind-v { font-size: 1.05rem; }

/* Celular: gastos + resumen llenan la pantalla (resumen fijo abajo, solo gastos con scroll); la gráfica queda debajo */
.pager.multi .wp-main { display: contents; }
.pager:not(.multi) .wp-main { height: 100%; display: flex; flex-direction: column; }
.pager:not(.multi) .wp-main .wp-items { flex: 1 1 auto; min-height: 150px; display: flex; flex-direction: column; margin-top: 10px; }
.pager:not(.multi) .wp-main .wp-list { flex: 1 1 auto; min-height: 92px; overflow-y: auto; overscroll-behavior: contain; background: #f7f7f5; border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.pager:not(.multi) .wp-list .it:not(.paid):not([class*="pt-"]):not([class*="pc-"]) { background: var(--surface-1); }
.pager:not(.multi) .wp-list .it:last-child { border-bottom: 1px solid var(--grid); }
.pager:not(.multi) .wp-main .wp-sum { flex: none; margin-top: 16px; }
.pager:not(.multi) .wp-main .add-row, .pager:not(.multi) .wp-main .it-total { flex: none; }
.pager:not(.multi) .week-page > .wp-chart { margin-top: 24px; }
.pager:not(.multi) .wp-main > .wp-items, .pager:not(.multi) .wp-main > .wp-sum { width: 100%; margin-left: 0; margin-right: 0; }
.pager:not(.multi) .today-pill { position: relative; top: 4px; }
.pager.multi .wp-main > .wp-items, .pager.multi .wp-main > .wp-sum { width: 100%; max-width: none; margin-left: 0; margin-right: 0; }

/* Botón + siempre encima de las filas */
.wp-items .add-row { z-index: 4; }
.wp-items .add-circle { z-index: 5; }
/* Celular: suma total de Tax Savings plegable */
.taxg-toggle { display: none; }
.pager:not(.multi) .taxg-toggle { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: 6px; border: 0; border-radius: 50%; background: rgba(0,0,0,.06); color: var(--text-secondary); font-size: .75rem; cursor: pointer; vertical-align: 1px; transition: transform .15s; }
.pager:not(.multi) .row-taxg { display: none; }
.pager.show-taxg:not(.multi) .row-taxg { display: flex; }
.pager.show-taxg:not(.multi) .taxg-toggle { transform: rotate(180deg); }
/* iOS: la lista con scroll se pinta en su propia capa; el + necesita capa propia encima */
.wp-list { position: relative; z-index: 1; }
.wp-items .add-row { position: relative; z-index: 3; transform: translateZ(0); -webkit-transform: translateZ(0); }
.wp-items .add-circle { -webkit-transform: translate(-50%, -50%) translateZ(1px); transform: translate(-50%, -50%) translateZ(1px); }

.tr-item { grid-template-columns: 24px 1fr 96px; }
input.tr-a { width: 96px; text-align: right; padding: 5px 8px; font-variant-numeric: tabular-nums; }

/* Gasto mensual: un color por categoría */
.mo-row.mz-0 { background: #eef4fb; } .mo-cat.mz-0 { background: #dde9f7; }
.mo-row.mz-1 { background: #fdf1e7; } .mo-cat.mz-1 { background: #fbe2cf; }
.mo-row.mz-2 { background: #eef7ec; } .mo-cat.mz-2 { background: #dcefd8; }
.mo-row.mz-3 { background: #f6eefa; } .mo-cat.mz-3 { background: #ecdcf4; }
.mo-row.mz-4 { background: #fdf7e3; } .mo-cat.mz-4 { background: #faedc4; }
.mo-row.mz-5 { background: #eaf6f5; } .mo-cat.mz-5 { background: #d4eeeb; }
.mo-row.mz-6 { background: #fbecee; } .mo-cat.mz-6 { background: #f7d7dc; }
.mo-row.mz-7 { background: #f1f0ec; } .mo-cat.mz-7 { background: #e3e1da; }
/* Gastos fijos: bandas de color cada 5 días del mes */
.ft-row.fx-row.band-a { background: var(--surface-1); }
.ft-row.fx-row.band-b { background: #ebf1f9; }
.ft-row.fx-row:hover { filter: brightness(.98); }
.ft-row.fx-row.band-b { background: #e2ebf7 !important; }
.ft-row.fx-row.band-start { border-top: 2px solid rgba(0,0,0,.18); }
.ft-row.fx-row.band-a { background: var(--tag-fixed) !important; }
.ft-row.fx-row.band-b { background: var(--tag-budget) !important; }
.ft-row.fx-row.band-start { border-top: 1px solid rgba(0,0,0,.08); }
.ft-per { white-space: normal !important; line-height: 1.3; overflow: visible; text-overflow: clip; }

/* Gasto mensual: 12 meses */
.mo-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-top: 12px; align-items: end; }
.mo-bar { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 4px 0 2px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--text-secondary); min-width: 0; }
.mo-bar:hover { background: var(--surface-0); }
.mo-bar.sel { background: var(--surface-0); color: var(--text); }
.mo-bv { font-size: .6rem; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.02em; }
.mo-bf { height: 64px; width: 70%; max-width: 22px; display: flex; align-items: flex-end; }
.mo-bf i { display: block; width: 100%; background: #cfc8bd; border-radius: 4px 4px 0 0; }
.mo-bar.max .mo-bf i { background: #e0a77e; }
.mo-bar.sel .mo-bf i { background: var(--accent); }
.mo-bl { font-size: .66rem; white-space: nowrap; }
.mo-bar.sel .mo-bl { font-weight: 700; }
.mo-stats { margin-top: 6px; flex-wrap: wrap; }
.mo-row { align-items: center; }
.mo-row .mo-n { flex: 1; min-width: 0; }
.mo-tl { display: grid; grid-template-columns: repeat(12, 6px); gap: 2px; flex: none; }
.mo-tl i { width: 6px; height: 10px; border-radius: 2px; background: rgba(0,0,0,.07); }
.mo-tl i.on { background: rgba(0,0,0,.32); }
.mo-tl i.sel { outline: 1.5px solid var(--accent); outline-offset: 0; }
.mo-tl i.on.sel { background: var(--accent); }
.mo-v { min-width: 58px; text-align: right; }
.mo-row.idle .mo-n, .mo-row.idle .mo-v { color: var(--text-muted); }
.mo-bl small { display: block; font-size: .58rem; color: var(--text-muted); font-weight: 400; line-height: 1; }
.mo-bars { align-items: start; }

/* Backend: tabs fijas y mismo ancho en todas */
.bk-tabs a.dtab { text-decoration: none; display: inline-block; }
.bk-narrow { max-width: 760px; }
.sp-top { display: grid; gap: 16px; align-items: start; }
.sp-top > .card { margin: 0; }
@media (min-width: 1000px) { .sp-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .sp-top .chart-card { min-height: 100%; } }
#spItems { margin-top: 16px; }
/* Tabla de gastos con líneas y columnas iguales */
@media (min-width: 761px) {
  .sp-head, .sp-it { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; padding: 0; }
  .sp-head { border: 1px solid var(--border); border-bottom-width: 1.5px; border-bottom-color: rgba(0,0,0,.18); border-radius: 8px 8px 0 0; }
  .sp-list { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 8px 8px; overflow: hidden; }
  .sp-head > *, .sp-it > * { padding: 8px 12px; border-right: 1px solid var(--border); min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
  .sp-head > :last-child, .sp-it > :last-child { border-right: 0; }
  .sp-it > .sp-a { align-items: flex-end; }
  .sp-head .sp-th.r { align-items: flex-end; }
  .sp-it > .sp-tg { align-items: flex-start; }
  .sp-it:last-child { border-bottom: 0; }
  .sp-it:hover { background: rgba(0,0,0,.025); }
}
