/* The dashboard of the CSPD operator and the MOFA officer (templates/backoffice/dashboard.html): number cards and
 * server-rendered SVG charts. Linked after fees.css and before theme.css. Like fees.css it uses only the custom
 * properties of app.css, no color of its own, so the dark scheme and the brand settings cover it
 * (TestPaymentCSSUsesTokens). Spacing is 0.75rem inside a card, 1rem between cards of a row and 1.5rem between rows.
 * Logical properties only, so the right-to-left pages need no second set of rules. */

.dash-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; margin-block-end: 1.5rem; }
.dash-updated { display: flex; align-items: center; gap: 0.5rem; margin: 0; color: var(--muted); font-size: 0.9rem; }
.dash-updated .icon { flex: none; color: var(--primary); }
.dash-updated time { color: var(--fg); font-variant-numeric: tabular-nums; }

/* Number cards: two columns on phones, as many as fit from 40rem. The cards of a row have the same height. */
.dash-kpis { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 0 1.5rem; padding: 0; list-style: none; }
.dash-kpis > .dash-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
.dash-kpi { display: flex; flex-direction: column; min-inline-size: 0; padding: 1rem; }
.dash-kpi .stat-label { align-items: flex-start; font-size: 0.9rem; line-height: 1.3; overflow-wrap: anywhere; }
.dash-kpi .stat-label .icon { flex: none; }
.dash-kpi .stat-value { margin-block: 0.75rem 0.25rem; font-size: 2.25rem; font-weight: 700; }
.dash-kpi .stat-note { margin-block-end: 0; }
.dash-kpi.tone-ok { background: var(--green-bg); border-inline-start-color: var(--green); }
.dash-kpi.tone-warn { background: var(--amber-bg); border-inline-start-color: var(--amber); }
.dash-kpi.tone-bad { background: var(--red-bg); border-inline-start-color: var(--red); }
.dash-kpi-link { margin-block-start: 0.75rem; min-block-size: 2.5rem; padding-inline: 0.75rem; font-size: 0.925rem; }
/* The cards of a row share their rows, so labels, numbers, notes and links line up whatever the label length. */
@supports (grid-template-rows: subgrid) {
  .dash-kpis > .dash-kpi { display: grid; grid-template-rows: subgrid; grid-row: span 4; row-gap: 0; }
  .dash-kpi .dash-kpi-link { align-self: end; }
}

/* Chart cards: one column on phones, two from 72rem. The column chart takes the whole row. */
.dash-charts { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
.dash-charts > .card { display: flex; flex-direction: column; min-inline-size: 0; margin: 0; }
.dash-chart .card-head h2 .icon { flex: none; }
.ch-figure { display: flex; flex: 1; flex-direction: column; gap: 1rem; margin: 0; }
.ch-body { display: flex; flex: 1; flex-wrap: wrap; align-items: center; align-content: center; justify-content: center; gap: 1rem 1.5rem; }
.ch-body-wide { flex: none; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0.75rem; }
/* In the column layout the legend keeps its own height (its 10rem basis is a width for the donut row). */
.ch-body-wide .ch-legend { flex: none; }
.ch-cap { margin-block-start: auto; color: var(--muted); font-size: 0.875rem; }
.dash-chart .empty { flex: 1; justify-content: center; }
@media (min-width: 72rem) {
  .dash-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-columns { grid-column: 1 / -1; }
}
@media (min-width: 40rem) {
  .dash-kpis { grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); }
  .dash-kpis > .dash-kpi:last-child:nth-child(odd) { grid-column: auto; }
  .dash-kpi { padding: 1.25rem 1.5rem; }
}

/* The series colors. --ch is the color of the series, the shapes and the legend swatches read it. */
.ch-s1 { --ch: var(--primary); }
.ch-s2 { --ch: var(--brand-cyan); }
.ch-s3 { --ch: var(--green); }
.ch-s4 { --ch: var(--amber); }
.ch-s5 { --ch: var(--red); }
.ch-s6 { --ch: var(--neutral-dark); }
.ch-seg { stroke: var(--ch); }
.ch-ring { stroke: var(--line); }
.ch-fill, .ch-col { fill: var(--ch); }
.ch-track { fill: var(--tint-blue); }
.ch-axis { fill: var(--neutral-dark); }
.ch-swatch { flex: none; inline-size: 0.75rem; block-size: 0.75rem; background: var(--ch); border-radius: 0.2rem; }
.ch-total { fill: var(--fg); font-size: 6.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Donut: a ring of fixed size next to its legend, wrapping under it on narrow screens. */
.ch-donut { flex: none; inline-size: 10rem; max-inline-size: 100%; block-size: auto; }
.ch-legend { display: grid; flex: 1 1 10rem; gap: 0.6rem; min-inline-size: 0; margin: 0; padding: 0; list-style: none; }
.ch-legend li { display: flex; align-items: center; gap: 0.6rem; }
.ch-name { flex: 1; min-inline-size: 0; color: var(--fg); overflow-wrap: anywhere; }
.ch-num { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Bars: label and number over a thin bar. The list is the legend, the bar svg is decoration. */
.ch-bars { display: grid; gap: 0.9rem; margin: 0; padding: 0; list-style: none; }
.ch-bars li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.3rem 0.6rem; align-items: center; }
.ch-bar { grid-column: 1 / -1; inline-size: 100%; block-size: 0.6rem; border-radius: 999px; overflow: hidden; }
html[dir="rtl"] .ch-bar, html[dir="rtl"] .ch-cols { transform: scaleX(-1); }

/* Columns: one rectangle per day, the oldest day at the reading start. */
.ch-cols { display: block; inline-size: 100%; block-size: 9rem; }
.ch-axis-labels { display: flex; justify-content: space-between; gap: 1rem; margin: 0; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
