/* Mois. The calendar of small tanks leads; everything else defers to it. Tokens only.
   Spacing on the scale 4 / 8 / 12 / 16 / 24 / 40 (--s0..--s5). */

/* ---------------------------------------------------------------- header */
.mo-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin: 6px 0 0; }
.mo-title { margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mo-title__year { font-size: 20px; color: var(--ink-2); font-weight: 600; font-stretch: 102%; letter-spacing: 0; } /* the year whispers, like « AED » */
.mo-nav { display: flex; gap: var(--s1); flex: none; margin-right: -2px; }
.mo-nav__btn { background: var(--sunk); }
.mo-nav__btn .ico { width: 20px; height: 20px; stroke-width: 2; }
.mo-nav__btn:disabled { opacity: .35; cursor: default; transform: none; }
.mo-nav[aria-busy="true"] .mo-nav__btn { opacity: .55; }
.mo-notices:not(:empty) { display: grid; gap: var(--s1); margin-top: var(--s3); }
.mo-notice { margin-top: var(--s4); }
.mo-notice__s { display: block; }

/* the month change: a page turn. The stage spans the screen edge to edge (so a month sliding
   out is clipped by the screen, not by the gutter); each month keeps the gutter inside. */
.mo-stage {
  position: relative; overflow: clip;
  margin-inline: calc(-1 * (var(--gutter) + var(--safe-l))) calc(-1 * (var(--gutter) + var(--safe-r)));
}
.mo-body { padding-inline: calc(var(--gutter) + var(--safe-l)) calc(var(--gutter) + var(--safe-r)); }
.mo-body--leaving { position: absolute; top: 0; left: 0; right: 0; pointer-events: none; }

/* ---------------------------------------------------------------- summary */
.mo-top { position: relative; margin-top: var(--s2); }
/* what the compact bar follows: the gap under the summary, so the bar only appears once the
   sentence has gone (never a title over a half-hidden line) */
.mo-sentinel { position: absolute; left: 0; top: 100%; width: 1px; height: var(--s4); pointer-events: none; }
.mo-summary { font-size: var(--t-body); font-weight: 560; line-height: 1.35; }
.mo-saved { display: flex; align-items: center; gap: var(--s1); margin-top: var(--s2); font-size: var(--t-sub); color: var(--ink-2); }
.mo-saved strong { color: var(--ink); font-weight: 680; }
.mo-carry { margin-top: var(--s2); font-size: var(--t-sub); color: var(--ink-2); }
.mo-saved__mark { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--sunk); color: var(--ink); }
.mo-saved__mark .ico { width: 15px; height: 15px; stroke-width: 1.9; }

/* ---------------------------------------------------------------- the calendar */
.mo-cal { margin-top: var(--s4); }
.mo-dow, .mo-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); column-gap: var(--s1); }
.mo-dow { font-size: var(--t-micro); font-weight: 640; color: var(--ink-2); text-align: center; margin-bottom: var(--s1); }
.mo-grid { row-gap: var(--s1); }
.mo-day, .mo-blank { position: relative; display: block; height: 58px; min-width: 0; }
.mo-day {
  border-radius: 13px; -webkit-user-select: none; user-select: none;
  transition: transform var(--d-snappy) var(--e-snappy);
}
button.mo-day:active { transform: scale(.94); transition-duration: var(--d-press); transition-timing-function: var(--e-press); }
.mo-day__glass { position: absolute; inset: 0; width: 100%; height: 100%; }
/* the date: quiet on the days to come, so the past (colour) and today lead */
.mo-day__n {
  position: absolute; left: 0; right: 0; top: 6px; text-align: center;
  font-size: var(--t-micro); font-weight: 560; line-height: 1; color: var(--ink-2);
}
.mo-day[data-state="past"] .mo-day__n { color: var(--ink); font-weight: 650; }
/* today: the live Perso tank, ringed in ink like a selection; its figure sits on an ink chip,
   readable whatever the liquid's colour, theme or level */
.mo-day[data-state="today"]::after {
  content: ""; position: absolute; inset: -3px; border-radius: 16px; box-shadow: 0 0 0 2px var(--ink); pointer-events: none;
}
.mo-day[data-state="today"] .mo-day__n { color: var(--ink); font-weight: 760; }
.mo-day__fig {
  position: absolute; left: 50%; bottom: 6px; translate: -50% 0;
  min-width: 26px; height: 18px; padding: 0 6px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink);
  font-size: var(--t-micro); font-weight: 760; font-stretch: 106%; letter-spacing: -.005em; line-height: 1;
}
.mo-day__fig[hidden] { display: none; }
/* while simulating, today's chip shows the real figure: it steps back, the dashed ghost says why */
.view[data-sim] .mo-day[data-state="today"] .mo-day__fig { background: var(--ink-2); }
/* days before the budget started: an empty outline, nothing to read */
.mo-day[data-state="before"] { box-shadow: inset 0 0 0 1px var(--hair-2); }
.mo-day[data-state="before"] .mo-day__n { color: var(--ink-3); font-weight: 520; }

.mo-legend { display: grid; gap: var(--s1); margin-top: var(--s3); font-size: var(--t-foot); line-height: 1.3; color: var(--ink-2); }
.mo-legend[hidden] { display: none; }
.mo-legend__row { display: flex; align-items: center; gap: var(--s1); min-height: 18px; }
.mo-legend__row strong { color: var(--ink); font-weight: 700; }
.mo-legend__glass { width: 12px; height: 16px; flex: none; }
.mo-legend__odo { display: inline-flex; }
.mo-legend__before { width: 12px; height: 16px; flex: none; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--hair-2); }

/* stale or offline: every figure and line greys, liquids included (the glasses do it on canvas) */
.view[data-stale] .mo-day__n,
.view[data-stale] .mo-summary,
.view[data-stale] .mo-saved strong,
.view[data-stale] .mo-legend__row strong,
.view[data-stale] .mo-trend__item.is-last .mo-trend__fig,
.view[data-stale] .mo-trend__item.is-last .mo-trend__label,
.view[data-stale] .mo-eom__n { color: var(--ink-2); }
.view[data-stale] .mo-day__fig { background: var(--ink-2); }
.view[data-stale] .mo-day[data-state="today"]::after { box-shadow: 0 0 0 2px var(--ink-2); }

/* ---------------------------------------------------------------- simulator (shared, css/ui.css) */
.mo-sim { margin-top: var(--s4); } /* closer than a section: the slider sits near the days it moves */

/* ---------------------------------------------------------------- « Ton perso par jour » */
.mo-trend__row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--s1); margin-top: var(--s4); }
.mo-trend__item { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.mo-trend__figbox { height: 18px; display: flex; align-items: flex-end; } /* every glass starts on the same line */
.mo-trend__fig { font-size: var(--t-sub); font-weight: 700; font-stretch: 106%; letter-spacing: -.01em; line-height: 1; color: var(--ink-2); }
.mo-trend__glass { width: 100%; max-width: 44px; height: 72px; margin-top: var(--s1); }
.mo-trend__label { margin-top: var(--s1); font-size: var(--t-micro); color: var(--ink-2); white-space: nowrap; }
.mo-trend__item.is-last .mo-trend__fig { color: var(--ink); font-size: 17px; font-weight: 800; }
.mo-trend__item.is-last .mo-trend__label { color: var(--ink); font-weight: 650; }
/* a figure wider than its column (four digits, bold) stays inside it and inside the gutters:
   the last (bold) one shrinks a little to its column and ends on the gutter */
.mo-trend__row { container-type: inline-size; }
.mo-trend__item.is-last .mo-trend__fig { font-size: min(17px, 4.4cqi); }
.mo-trend__item.is-last .mo-trend__figbox { align-self: flex-end; }
.mo-trend__text { margin-top: var(--s3); max-width: 32em; }
.mo-trend__s { display: block; }

/* ---------------------------------------------------------------- « Fin du mois » */
.mo-eom__fig { display: flex; align-items: baseline; gap: var(--s1); margin-top: var(--s2); }
/* .fit-line: a long forecast (a six-digit deficit) or a zoomed text shrinks to the line, never past it */
.mo-eom__fig { --fit-max: var(--t-figure); --fit-rest: 50px; }
.mo-eom__n { font-size: var(--t-figure); font-weight: 800; font-stretch: 114%; letter-spacing: -.035em; line-height: 1; margin-left: -.03em; }
.mo-eom__unit { font-size: var(--t-sub); font-weight: 560; font-stretch: 104%; letter-spacing: .02em; color: var(--ink-2); }
.mo-eom__delta { margin-top: var(--s2); font-size: var(--t-sub); color: var(--ink-2); }
.mo-eom__empty { padding-top: var(--s2); }

/* ---------------------------------------------------------------- loading */
.mo-skel-line { height: 20px; width: 62%; margin-top: var(--s2); }
.mo-skel-cell { display: block; height: 58px; border-radius: 13px; }
.view[data-loading] .mo-cal { margin-top: var(--s4); }

/* ---------------------------------------------------------------- the day sheet */
.mo-ds-head { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: end; column-gap: var(--s3); margin-top: 2px; }
.mo-ds-glass { position: relative; width: 64px; height: 86px; }
.mo-ds-glass canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mo-ds-head__text { min-width: 0; padding-bottom: 2px; }
.mo-ds-score { display: flex; align-items: baseline; gap: 6px; }
.mo-ds-score__n { font-size: var(--t-figure); font-weight: 800; font-stretch: 114%; letter-spacing: -.035em; line-height: 1; }
.mo-ds-score__of { font-size: var(--t-sub); font-weight: 560; color: var(--ink-2); }
.mo-ds-zone { margin-top: 6px; font-size: var(--t-sub); color: var(--ink-2); font-weight: 520; }
.mo-ds-fig { display: flex; align-items: baseline; gap: 6px; }
.mo-ds-fig__n { font-size: var(--t-figure); font-weight: 800; font-stretch: 114%; letter-spacing: -.035em; line-height: 1; }
.mo-ds-fig__unit { font-size: 14px; font-weight: 560; font-stretch: 104%; letter-spacing: .02em; color: var(--ink-2); }
.mo-ds-body { margin-top: var(--s2); }
.mo-ds-body > .group:first-child { margin-top: var(--s4); }
.mo-ds-over { margin: 2px 0 var(--s1); font-size: var(--t-sub); color: var(--ink-2); }
.mo-ds-none { padding: 14px 0 4px; font-size: var(--t-sub); color: var(--ink-2); }
.mo-ds-plan__row { display: flex; justify-content: space-between; align-items: baseline; min-height: 48px; padding: 12px 0; font-size: var(--t-body); font-weight: 580; border-bottom: 1px solid var(--hair); }
.mo-ds-plan__row:last-child { border-bottom: 0; }
.mo-ds-plan__fig { font-weight: 680; }
.mo-ds-note { margin-top: var(--s3); font-size: var(--t-sub); color: var(--ink-2); }
.mo-ds-end { height: 1px; }
.mo-ds-skel { height: 52px; margin-top: var(--s2); border-radius: 12px; }
.mo-ds-skel--short { width: 60%; }
.mo-ds-skel--fig { height: 44px; width: 70%; margin: 0; }
.sheet__page[data-stale] .mo-ds-score__n,
.sheet__page[data-stale] .mo-ds-fig__n { color: var(--ink-2); }
