/* Informes */
.rp-print-head { display: none; }

.rp-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.btn.is-disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

.rp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.rp-live { background: rgba(24, 227, 160, 0.18); color: var(--pos); }

.rp-body { display: grid; gap: 20px; min-width: 0; }
.rp-body > * { min-width: 0; }
.rp-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.rp-grid > * { min-width: 0; }
@media (min-width: 900px) { .rp-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
@media (min-width: 900px) and (max-width: 1199px) { .rp-duo { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 1200px) { .rp-duo { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.rp-body .panel-title { margin-bottom: 16px; }
.rp-title-ico { justify-content: flex-start; }
.rp-title-ico .icon { width: 20px; height: 20px; color: var(--muted); }

/* Resumen */
.rp-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 561px) { .rp-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rp-summary .stat b { font-size: clamp(17px, 2.2vw, 22px); }

.rp-delta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; margin-top: 6px; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.rp-delta-val { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; font-variant-numeric: tabular-nums; }
.rp-delta .icon { width: 13px; height: 13px; stroke-width: 2.6; }
.rp-delta.is-good .rp-delta-val { color: var(--pos); }
.rp-delta.is-bad .rp-delta-val { color: var(--neg); }
.rp-delta.is-flat .rp-delta-val { color: var(--muted); }
.rp-new { margin-left: 0; height: 20px; font-size: 11px; }

/* Gastos por categoría */
.rp-none { margin: 0; color: var(--muted); }
.rp-cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.rp-cat {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px; row-gap: 4px; align-items: center;
  grid-template-areas: 'ico name amt' 'ico bar bar' 'ico var var';
}
.rp-cat-ico { grid-area: ico; align-self: start; width: 40px; height: 40px; border-radius: 14px; }
.rp-cat-ico .icon { width: 20px; height: 20px; }
.rp-cat-name { grid-area: name; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-cat-amt { grid-area: amt; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-cat-bar { grid-area: bar; display: flex; align-items: center; gap: 10px; min-width: 0; }
.rp-cat-bar .meter { flex: 1; height: 7px; }
.rp-cat-share { flex: none; min-width: 38px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-cat-var { grid-area: var; min-height: 0; }
.rp-cat-var .rp-delta { margin-top: 0; }
.rp-cat-var:empty { display: none; }

/* Datos del periodo */
.rp-fact-list { display: grid; gap: 4px; }
.rp-fact { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rp-fact:first-child { border-top: 0; padding-top: 0; }
.rp-fact-ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text); }
.rp-fact-ico .icon { width: 18px; height: 18px; }
.rp-fact-text { display: grid; gap: 1px; min-width: 0; }
.rp-fact-label { font-size: 14px; font-weight: 600; }
.rp-fact-hint { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.rp-fact-value { font-family: var(--font-display); font-weight: 650; font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Los 5 gastos más grandes */
.rp-top-list { list-style: none; margin: 0; padding: 0; display: grid; }
.rp-top-item { display: grid; grid-template-columns: 22px auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rp-top-item:first-child { border-top: 0; padding-top: 0; }
.rp-top-item:last-child { padding-bottom: 0; }
.rp-top-item .tx-ico { width: 40px; height: 40px; border-radius: 14px; }
.rp-top-item .tx-ico .icon { width: 20px; height: 20px; }
.rp-rank { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--muted); text-align: center; }
.rp-top-body { display: grid; gap: 1px; min-width: 0; }
.rp-top-desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-top-meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-top-amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--neg); }

/* Presupuestos */
.rp-bd-list { display: grid; gap: 16px; }
.rp-bd { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; }
.rp-bd .meter { grid-column: 1 / -1; height: 8px; }
.rp-bd-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rp-bd-ico { width: 28px; height: 28px; flex: none; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--c); }
.rp-bd-ico .icon { width: 15px; height: 15px; }
.rp-bd-label { min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-bd-pct { font-family: var(--font-display); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--muted); }
.rp-bd.is-warn .rp-bd-pct { color: var(--amber); }
.rp-bd.is-over .rp-bd-pct { color: var(--red); }
:root[data-theme='light'] .rp-bd.is-warn .rp-bd-pct { color: #9A6200; }
:root[data-theme='light'] .rp-bd.is-over .rp-bd-pct { color: var(--neg); }
.rp-bd-text { grid-column: 1 / -1; font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }

/* Metas de ahorro */
.rp-goal-list { display: grid; gap: 18px; }
.rp-goal {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px; row-gap: 6px; align-items: center;
  grid-template-areas: 'ico name pct' 'ico bar bar' 'ico text text';
}
.rp-goal-ico { grid-area: ico; align-self: start; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--g); color: #fff; box-shadow: 0 10px 22px -14px var(--glow); }
.rp-goal-ico .icon { width: 20px; height: 20px; }
.rp-goal.theme-noir .rp-goal-ico { border: 1px solid var(--line); }
.rp-goal.is-done .rp-goal-ico { background: var(--mint); color: #04332E; box-shadow: none; }
.rp-goal-name { grid-area: name; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-goal-pct { grid-area: pct; font-family: var(--font-display); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.rp-goal .meter { grid-area: bar; height: 8px; }
.rp-goal .meter > i { background: var(--g); }
.rp-goal.theme-noir .meter > i { background: var(--muted); }
.rp-goal-text { grid-area: text; font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.rp-goal-text b { color: var(--text); font-weight: 650; }

/* Mes a mes */
.rp-key-inc { background: var(--mint); }
.rp-key-exp { background: var(--pink); }
.rp-chart { margin-bottom: 18px; }
.hide-amounts .rp-chart text[text-anchor='end'] { visibility: hidden; }
.hide-amounts .rp-chart svg { pointer-events: none; }
.rp-table-wrap { overflow-x: auto; }
.rp-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.rp-table th, .rp-table td { padding: 9px 10px; text-align: right; white-space: nowrap; border-top: 1px solid var(--line); }
.rp-table thead th { border-top: 0; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.rp-table th:first-child, .rp-table td:first-child { text-align: left; padding-left: 0; }
.rp-table th:last-child, .rp-table td:last-child { padding-right: 0; }
.rp-table tbody th { font-weight: 600; }
.rp-table td.pos { color: var(--pos); }
.rp-table td.neg { color: var(--neg); }
.rp-table tfoot th, .rp-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

.rp-foot { margin: 0; font-size: 12.5px; color: var(--muted); }

@media (max-width: 560px) {
  .rp-toolbar .seg { width: 100%; }
  .rp-toolbar .seg button { flex: 1; justify-content: center; }
  .rp-toolbar .month-nav .month-label { min-width: 0; }
  .rp-toolbar .btn { flex: 1 1 100%; }
  .rp-btn-text { display: none; }
  .rp-head { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .rp-actions { justify-content: flex-start; }
  .rp-chart .lines text { font-size: 10px; }
  .rp-chart .lines text[text-anchor='middle']:nth-of-type(odd) { display: none; }
  .rp-summary { gap: 8px; }
  .rp-summary .stat { padding: 12px 10px; }
  .rp-summary .stat b { font-size: clamp(14px, 4.4vw, 18px); }
  .rp-delta { font-size: 12px; }
  .rp-fact { gap: 10px; }
  .rp-table { font-size: 13px; }
  .rp-table th, .rp-table td { padding: 8px 6px; }
}

@media (max-width: 380px) {
  .rp-summary { grid-template-columns: 1fr; }
  .rp-summary .stat { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 10px; }
  .rp-summary .stat b { text-align: right; font-size: 16px; }
  .rp-summary .stat .rp-delta { grid-column: 1 / -1; margin-top: 2px; }
  .rp-top-item { grid-template-columns: auto minmax(0, 1fr) auto; }
  .rp-rank { display: none; }
}

/* Secciones completas: cuentas, deudas, contratos, recurrentes e históricos */
.rp-sub { margin: -8px 0 16px; font-size: 13.5px; color: var(--muted); }
.rp-subtitle { margin: 22px 0 12px; font-size: 14px; font-weight: 650; color: var(--muted); letter-spacing: 0; }
.rp-kpis + .rp-subtitle { margin-top: 24px; }
.rp-subtitle:first-child { margin-top: 0; }

.rp-kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin-bottom: 4px; }
.rp-kpi { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.rp-kpi small { color: var(--muted); font-size: 12.5px; }
.rp-kpi b { font-family: var(--font-display); font-size: clamp(17px, 2.2vw, 21px); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.rp-kpi b.pos { color: var(--pos); }
.rp-kpi b.neg { color: var(--neg); }
.rp-kpi-hint { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.rp-tiles { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.rp-subtitle + .rp-tiles { margin-top: 0; }
.rp-tile { display: grid; align-content: start; gap: 10px; min-width: 0; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.rp-tile-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.rp-tile-text { display: grid; gap: 2px; min-width: 0; }
.rp-tile-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-tile-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-tile-value { text-align: right; min-width: 0; }
.rp-stack { display: grid; gap: 1px; justify-items: end; }
.rp-stack .rp-tile-sub { overflow: visible; }
.rp-big, .rp-mid { font-family: var(--font-display); font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; }
.rp-big { font-size: 17px; }
.rp-mid { font-size: 15px; }
.rp-big.neg, .rp-mid.neg { color: var(--neg); }
.rp-mid.pos { color: var(--pos); }
.rp-tile .rp-delta { margin-top: 0; }
.rp-tile .meter { height: 7px; }
.rp-tile-line { font-size: 13px; line-height: 1.5; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.rp-tile-line b { color: var(--text); font-weight: 650; }
.rp-tile > .rp-tile-line + .rp-tile-line { margin-top: -4px; }

@media (max-width: 560px) {
  .rp-tiles { grid-template-columns: minmax(0, 1fr); }
  .rp-tile { padding: 12px 14px; }
  .rp-kpis { gap: 10px; }
}

/* Pantallas muy estrechas: el importe pasa debajo del nombre para que este se lea entero */
@media (max-width: 479px) {
  .rp-tile-head { grid-template-columns: auto minmax(0, 1fr); row-gap: 8px; }
  .rp-tile-title, .rp-tile-sub { white-space: normal; overflow-wrap: anywhere; }
  .rp-tile-value { grid-column: 1 / -1; text-align: left; }
  .rp-kpis { gap: 8px; }
  .rp-kpi { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 10px; padding: 10px 14px; }
  .rp-kpi b { text-align: right; }
  .rp-kpi-hint { grid-column: 1 / -1; }
  .rp-stack { grid-auto-flow: column; justify-content: start; align-items: baseline; gap: 8px; justify-items: start; }
}
