.cf-page { max-width: 1600px; margin: 0 auto; padding: 22px; color: var(--color-text); }
.cf-heading, .cf-section-head, .cf-inline-form, .cf-row-form, .cf-controls, .cf-bu-filter { display: flex; align-items: center; gap: 12px; }
.cf-heading, .cf-section-head { justify-content: space-between; }
.cf-tabs { display: grid; grid-template-columns: repeat(4, 1fr); margin: 20px 0; padding: 4px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface-2); }
.cf-tab { padding: 10px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--color-muted); font-weight: 650; cursor: pointer; }
.cf-tab.active { color: var(--color-accent); background: var(--color-surface); box-shadow: 0 1px 4px rgba(15, 23, 42, .12); }
.cf-panel { display: grid; gap: 16px; }
.cf-loading, .cf-empty { padding: 52px 20px; text-align: center; color: var(--color-muted); }
.cf-controls { flex-wrap: wrap; padding: 14px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); }
.cf-controls.compact { align-items: end; }
.cf-controls label, .cf-inline-form label { display: grid; gap: 5px; font-size: 12px; font-weight: 650; color: var(--color-muted); }
.cf-controls input, .cf-controls select, .cf-inline-form input, .cf-inline-form select, .cf-row-form input, .cf-grid input { min-height: 34px; padding: 7px 9px; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface); color: var(--color-text); }
.cf-bu-filter { flex-wrap: wrap; }
.cf-chip { border: 1px solid var(--color-border); border-radius: 999px; padding: 6px 10px; background: var(--color-surface); color: var(--color-muted); cursor: pointer; }
.cf-chip.active { color: #075985; border-color: #7dd3fc; background: #e0f2fe; }
.cf-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.cf-card, .cf-section { border: 1px solid var(--color-border); border-radius: 11px; background: var(--color-surface); box-shadow: 0 1px 3px rgba(15, 23, 42, .06); }
.cf-card { display: grid; gap: 8px; padding: 16px; }
.cf-card span { color: var(--color-muted); font-size: 12px; }.cf-card strong { font-size: 24px; }
.cf-section { padding: 16px; overflow: hidden; }.cf-section h2 { margin: 0; font-size: 15px; }.cf-section p { margin: 4px 0 0; color: var(--color-muted); font-size: 12px; }
.cf-chart-scroll, .cf-table-wrap { width: 100%; overflow-x: auto; }.cf-chart { display: block; min-width: 900px; width: 100%; height: 360px; }
.cf-chart text { font-size: 9px; fill: var(--color-muted); }.cf-axis { stroke: var(--color-border); }.cf-bar { cursor: pointer; }
.cf-legend { display: flex; justify-content: center; gap: 18px; color: var(--color-muted); font-size: 12px; }.cf-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; background: var(--c); }
.cf-runway { display: grid; gap: 5px; margin-left: auto; }.cf-runway strong { font-size: 23px; }.cf-runway .negative { color: #b91c1c; }
.cf-period-row { cursor: pointer; }.cf-period-row:hover { background: var(--color-surface-2); }
.cf-inline-form { flex-wrap: wrap; align-items: end; }.cf-inline-form .grow { flex: 1; min-width: 180px; }.cf-row-form { display: grid; grid-template-columns: 1fr 150px auto auto; }
.cf-delete { border: 0; background: transparent; color: #b91c1c; cursor: pointer; }.cf-grid input { width: 100%; min-width: 90px; }
.cf-badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }.cf-badge.in { color: #166534; background: #dcfce7; }.cf-badge.out { color: #991b1b; background: #fee2e2; }
.cf-dialog-backdrop { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: rgba(15, 23, 42, .55); }
.cf-dialog { width: min(1100px, 96vw); max-height: 88vh; overflow: auto; border-radius: 12px; background: var(--color-surface); box-shadow: 0 24px 70px rgba(0,0,0,.3); }.cf-dialog-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); }.cf-dialog-head h2 { margin: 0; }.cf-dialog-head button { border: 0; background: none; font-size: 26px; cursor: pointer; }.cf-dialog-body { padding: 18px; }
@media (max-width: 900px) { .cf-page { padding: 14px; }.cf-kpis { grid-template-columns: repeat(2, 1fr); }.cf-tabs { grid-template-columns: repeat(2, 1fr); }.cf-row-form { grid-template-columns: 1fr 120px; }.cf-runway { margin-left: 0; width: 100%; } }
@media (max-width: 600px) { .cf-page { padding: 10px; }.cf-kpis { grid-template-columns: 1fr; }.cf-tabs { grid-template-columns: 1fr; }.cf-inline-form, .cf-controls { align-items: stretch; }.cf-inline-form label, .cf-inline-form button, .cf-controls label { width: 100%; }.cf-row-form { grid-template-columns: 1fr; }.cf-card strong { font-size: 19px; } }

/* ── Cashflow REAL (pàgina nova, 2026-07) ──────────────────────────────────── */
.cfr-accions { display: flex; gap: 8px; align-items: center; }
.cfr-info { border: 0; background: transparent; color: var(--color-muted); cursor: pointer; font-size: 12px; padding: 0 2px; }
.cfr-info:hover { color: var(--color-accent); }
.cfr-bancs { display: grid; gap: 3px; }
.cfr-banc { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; font-size: 13px; color: var(--color-muted); }
.cfr-banc span:last-of-type { font-variant-numeric: tabular-nums; }
.cfr-banc small { font-size: 10px; }
.cfr-avisos { font-size: 11px; color: #b45309; cursor: help; }
.cfr-frescor { margin: 8px 0 0; font-size: 11px; color: var(--color-muted); display: flex; flex-wrap: wrap; gap: 10px; }
.cfr-detall > summary { cursor: pointer; list-style: none; }
.cfr-detall > summary::-webkit-details-marker { display: none; }
.cfr-detall > summary h2::before { content: '▸ '; color: var(--color-muted); }
.cfr-detall[open] > summary h2::before { content: '▾ '; }
.cfr-estat { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.cfr-estat.real { color: #166534; background: #dcfce7; }
.cfr-estat.previst { color: #92400e; background: #fef3c7; }
.cfr-notes { margin: 8px 0 0; padding-left: 18px; color: var(--color-muted); font-size: 12px; }
.cfr-notes li { margin: 3px 0; }
.cf-card .negative, td.negative { color: #b91c1c; }
.cfr-card-saldo strong { font-size: 24px; }

/* ── Caixes KPI alineades (4 files compartides via subgrid, 2026-07-21) ────── */
.cfr-card-vencuts { cursor: pointer; transition: box-shadow .15s ease, border-color .15s ease; }
.cfr-card-vencuts:hover, .cfr-card-vencuts:focus-visible {
  border-color: var(--color-accent); box-shadow: 0 3px 12px rgba(15, 23, 42, .13); outline: none; }
.cfr-vencuts-aldia { font-size: 24px; font-weight: 700; color: #166534; }
.cfr-mini-cap { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--color-muted); }
.cfr-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.cfr-kpi-xifra strong { font-size: 24px; line-height: 1.15; color: var(--color-text); display: block; }
.cfr-kpi-xifra.cfr-2col strong { font-size: 21px; }
.cfr-kpi-xifra strong.negative { color: #b91c1c; }
.cfr-kpi-sec small { font-size: 12px; color: var(--color-muted); }
.cfr-kpi-sec { display: grid; gap: 6px; align-content: start; }
.cfr-nota-peu { font-size: 11px; color: var(--color-muted); }
/* Files compartides entre les 4 caixes: títol / capçaleres / xifres / detall
   sempre al mateix nivell (només en layout de 4 columnes). */
@media (min-width: 901px) {
  @supports (grid-template-rows: subgrid) {
    .cfr-kpis { row-gap: 6px; }
    .cfr-kpis > .cf-card { grid-template-rows: subgrid; grid-row: span 4; }
  }
}

/* ── Barra de filtres (F4) + botó icona de configuració (F5) ────────────────── */
.cfr-filtres-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); }
.cfr-seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface-2); }
.cfr-seg-btn { border: 0; border-radius: 999px; padding: 6px 14px; background: transparent; color: var(--color-muted); font-weight: 650; font-size: 13px; cursor: pointer; }
.cfr-seg-btn:hover { color: var(--color-text); }
.cfr-seg-btn.active { background: var(--color-surface); color: var(--color-accent); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.cfr-filtres-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--color-border); border-radius: 8px; padding: 7px 12px; background: var(--color-surface); color: var(--color-text); font-weight: 650; font-size: 13px; cursor: pointer; }
.cfr-filtres-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.cfr-filtres-btn svg { flex: none; }
.cfr-filtres-bar .cf-bu-filter { flex-basis: 100%; }
.cf-bu-filter[hidden] { display: none; }
.cfr-icon-btn { display: inline-flex; align-items: center; padding: 8px 10px; }

/* ── Editor de rappels de patrocini ────────────────────────────────────────── */
.cfr-rap-intro { margin: 0 0 14px; color: var(--color-muted); font-size: 13px; }
.cfr-rap-row { padding: 14px 0; border-top: 1px solid var(--color-border); }
.cfr-rap-row:first-of-type { border-top: 0; }
.cfr-rap-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.cfr-rap-actiu { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.cfr-rap-actiu strong { font-size: 15px; }
.cfr-rap-vol { font-size: 12px; color: var(--color-muted); }
.cfr-rap-vol strong { color: var(--color-text); }
.cfr-rap-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin: 10px 0 8px; }
.cfr-rap-pct { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; }
.cfr-rap-pct input { width: 84px; min-height: 32px; padding: 6px 8px; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface); color: var(--color-text); }
.cfr-rap-base { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.cfr-rap-tipus-list { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0; }
.cfr-rap-tipus { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.cfr-rap-tipus input:disabled + * , .cfr-rap-tipus:has(input:disabled) { color: var(--color-muted); }
.cfr-rap-tipus small { color: var(--color-muted); }
.cfr-rap-detall { font-size: 11px; color: var(--color-muted); }
.cfr-rap-estim { margin-top: 8px; font-size: 13px; }
.cfr-rap-estim strong { font-size: 17px; color: var(--color-accent); }
.cfr-rap-actions { margin-top: 16px; display: flex; justify-content: flex-end; }

/* ── Gràfic nou (cashflow_chart.js) ────────────────────────────────────────── */
.cfr-chart-host { position: relative; width: 100%; min-height: 380px; }
.cfr-chart-wrap { width: 100%; overflow: hidden; cursor: grab; user-select: none; -webkit-user-select: none; }
.cfr-chart-wrap.cfr-grabbing { cursor: grabbing; }
.cfr-chart-svg { display: block; width: 100%; height: 380px; }
.cfr-axis-label { fill: var(--color-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.cfr-mark-label { fill: var(--color-muted); font-size: 10px; font-weight: 600; }
.cfr-grid-line { stroke: var(--color-border); opacity: .5; }
.cfr-baseline { stroke: var(--color-border); stroke-width: 1.5; }
.cfr-today-line { stroke: var(--color-muted); stroke-width: 1.25; }
.cfr-tall-line { stroke: var(--color-muted); stroke-width: 1.25; stroke-dasharray: 5 4; opacity: .85; }
.cfr-polissa-line { stroke: #b91c1c; stroke-width: 1.25; stroke-dasharray: 6 4; opacity: .9; pointer-events: none; }
.cfr-polissa-label { fill: #b91c1c; font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; }
.cfr-past-shade { fill: #64748b; opacity: .05; pointer-events: none; }
.cfr-crosshair { stroke: var(--color-muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }

.cfr-bar { cursor: pointer; transition: opacity .15s ease; }
.cfr-bar-in { fill: #16a34a; }
.cfr-bar-out { fill: #dc2626; }
.cfr-bars.cfr-hovering .cfr-bar:not(.cfr-hover) { opacity: .4; }
.cfr-saldo-line { fill: none; stroke: #1e293b; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.cfr-saldo-line.past { opacity: .55; }
.cfr-saldo-dot { fill: #1e293b; }
.cfr-saldo-dot.past { opacity: .55; }

/* Totals a les barres (dalt entrades / baix sortides) i saldo sobre cada punt. */
.cfr-bar-total { font-size: 9px; font-weight: 650; font-variant-numeric: tabular-nums; pointer-events: none; }
.cfr-bar-total.in { fill: #15803d; }
.cfr-bar-total.out { fill: #b91c1c; }
.cfr-saldo-label { fill: #1e293b; font-size: 9px; font-weight: 650; font-variant-numeric: tabular-nums;
  pointer-events: none; paint-order: stroke; stroke: var(--color-surface); stroke-width: 3px; stroke-linejoin: round; }

.cfr-chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 150px; padding: 8px 10px;
  border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface);
  box-shadow: 0 6px 20px rgba(15, 23, 42, .14); font-size: 12px; color: var(--color-text); }
.cfr-tip-titol { font-weight: 700; margin-bottom: 4px; }
.cfr-tip-row { display: flex; justify-content: space-between; gap: 14px; }
.cfr-tip-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

.cfr-leg-real::before { opacity: .55; }
.cfr-leg-proj::before { opacity: 1; }

/* Animacions: barres creixen des de la baseline (esglaonat ≤30), línia es
   dibuixa (dashoffset) al primer render; fade suau en re-render (zoom/pan). */
@keyframes cfr-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes cfr-draw { to { stroke-dashoffset: 0; } }
@keyframes cfr-fadein { from { opacity: .35; } to { opacity: 1; } }
.cfr-anim .cfr-bar-in { transform-box: fill-box; transform-origin: 50% 100%; animation: cfr-grow .45s ease both; }
.cfr-anim .cfr-bar-out { transform-box: fill-box; transform-origin: 50% 0%; animation: cfr-grow .45s ease both; }
.cfr-line-anim .cfr-saldo-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: cfr-draw .7s ease forwards; }
.cfr-plot.cfr-fade { animation: cfr-fadein .25s ease; }

@media (prefers-reduced-motion: reduce) {
  .cfr-anim .cfr-bar-in, .cfr-anim .cfr-bar-out { animation: none; transform: none; }
  .cfr-line-anim .cfr-saldo-line { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
  .cfr-plot.cfr-fade { animation: none; }
}

/* ── Editor de Configuració (mapping · mes tancat · patrocinis) ─────────────── */
.cfr-cfg-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--color-border); }
.cfr-cfg-tab { border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; padding: 8px 14px; background: transparent; color: var(--color-muted); font-weight: 650; cursor: pointer; }
.cfr-cfg-tab:hover { color: var(--color-text); }
.cfr-cfg-tab.active { color: var(--color-accent); background: var(--color-surface-2); border-color: var(--color-border); }
.cfr-cfg-intro { margin: 0 0 12px; color: var(--color-muted); font-size: 12px; }
.cfr-cfg-h { margin: 20px 0 6px; font-size: 14px; }
.cfr-cfg-actions, .cfr-cfg-patro-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* Barra d'assignació massiva + comptador de seleccionades. */
.cfr-cfg-mapbar, .cfr-cfg-mesbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 9px; background: var(--color-surface-2); }
.cfr-cfg-mapbar label, .cfr-cfg-mesbar label { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 650; color: var(--color-muted); }
.cfr-cfg-mapbar select, .cfr-cfg-mesbar select, .cfr-cfg-map select, .cfr-cfg-exc select, .cfr-cfg-map input, .cfr-cfg-exc input, .cfr-cfg-quotes input {
  min-height: 32px; padding: 5px 8px; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface); color: var(--color-text); }
.cfr-cfg-count { margin-left: auto; font-size: 12px; font-weight: 650; color: var(--color-accent); }

/* Taules d'editor (mapping, excepcions, quotes). */
.cfr-cfg-map, .cfr-cfg-exc, .cfr-cfg-quotes { width: 100%; font-size: 13px; }
.cfr-cfg-map td, .cfr-cfg-exc td, .cfr-cfg-quotes td { padding: 5px 8px; vertical-align: middle; }
.cfr-cfg-map tbody tr { cursor: pointer; user-select: none; }
.cfr-cfg-map tbody tr:hover { background: var(--color-surface-2); }
.cfr-cfg-map tbody tr.sel { background: #e0f2fe; }
.cfr-cfg-map tbody tr.sel td { color: #075985; }
.cfr-cfg-edit { width: 190px; }
.cfr-cfg-edit select { width: 100%; }
.cfr-cfg-nom { color: var(--color-muted); font-size: 12px; }
.cfr-cfg-exc input[data-exc="compte"] { width: 130px; }
.cfr-cfg-exc input[data-exc="nota"] { width: 100%; min-width: 120px; }
.cfr-cfg-quadre-buit { color: var(--color-muted); font-size: 12px; padding: 8px 0; }

/* Blocs de patrocini. */
.cfr-cfg-patro { padding: 14px 0; border-top: 1px solid var(--color-border); }
.cfr-cfg-patro:first-of-type { border-top: 0; }
.cfr-cfg-patro-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cfr-cfg-patro-head strong { font-size: 15px; }
.cfr-cfg-patro-meta, .cfr-cfg-rappel { font-size: 12px; color: var(--color-muted); }
.cfr-cfg-patro-btns { display: inline-flex; gap: 8px; margin-left: auto; }
.cfr-cfg-patro-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cfr-patro-estat { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.cfr-patro-estat.on { background: rgba(22,163,74,.14); color: #15803d; }
.cfr-patro-estat.off { background: rgba(148,163,184,.2); color: var(--color-muted); }
.btn.cfr-patro-del.armat { background: #dc2626; border-color: #dc2626; color: #fff; }
.cfr-alta-form { padding: 14px; margin-bottom: 12px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface, rgba(0,0,0,.02)); }
.cfr-alta-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; }
.cfr-alta-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--color-muted); }
.cfr-alta-row input, .cfr-alta-row select { min-width: 220px; }
.cfr-alta-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.cfr-cfg-quotes input[data-q="data"] { width: 150px; }
.cfr-cfg-quotes input[data-q="base"], .cfr-cfg-quotes input[data-q="caixa"] { width: 110px; }
.cfr-cfg-quotes input[data-q="nota"] { width: 100%; min-width: 100px; }
.cfr-cfg-quotes tfoot td { font-weight: 700; border-top: 1px solid var(--color-border); }
.cf-link { border: 0; background: none; padding: 0; color: var(--color-accent); cursor: pointer; text-decoration: underline; font: inherit; }

@media (prefers-color-scheme: dark) {
  .cfr-cfg-map tbody tr.sel { background: rgba(56, 189, 248, .16); }
  .cfr-cfg-map tbody tr.sel td { color: #bae6fd; }
}
