:root {
  color-scheme: light;
  --ink: #252238;
  --muted: #665f79;
  --brand: #633ec5;
  --brand-deep: #4d2bab;
  --canvas: #f6f5fa;
  --line: #e8e4f0;
  --wash: #f3eefc;
  --surface: #fff;
  --panel-radius: 22px;
  --shadow: 0 2px 4px #22104706, 0 10px 28px #22104706;
}

.access-page {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(18px, 5vw, 64px) 16px;
}
.access-card {
  width: min(100%, 440px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 16px 60px #34215a12, var(--shadow);
}
.access-brand {
  display: flex;
  align-items: center;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 96px;
  padding: 20px clamp(20px, 6vw, 32px);
  color: white;
  background: radial-gradient(ellipse at 88% 30%, #704ab5, transparent 64%), #322053;
}
.access-brand .brand { position: relative; z-index: 1; }
.access-brand .brand span { color: #cdb5ff; }
.access-brand .brand img { width: 34px; margin-right: 8px; }
.access-wallet {
  width: 136px;
  height: auto;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%) rotate(-3deg);
  pointer-events: none;
}
.access-content { padding: clamp(20px, 6vw, 32px); }
.access-content h1 {
  font-size: clamp(1.65rem, 5vw, 2rem);
  line-height: 1.14;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}
.access-intro, .access-hint { color: var(--muted); overflow-wrap: anywhere; }
.access-intro { margin-top: 8px; text-wrap: pretty; }
.access-hint { margin-top: 5px; font-size: .875rem; }
/* Two buttons side by side, one pressed: the access mode, and what the forecast slider sets in Statistiche. */
.auth-mode, .forecast-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  border-radius: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  background: #f8f7fb;
}
.auth-mode { margin-bottom: 22px; }
.auth-mode button, .forecast-mode button {
  min-height: 42px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 650;
}
.auth-mode button[aria-pressed="true"], .forecast-mode button[aria-pressed="true"] {
  background: white;
  color: var(--brand-deep);
  box-shadow: 0 1px 4px #22104716;
}
.access-content label { margin-top: 17px; }
.access-content input { min-height: 46px; font-size: 1rem; }
.access-content .btn { min-height: 46px; white-space: normal; }
#auth-submit, #account-retry { width: 100%; margin-top: 20px; }
#account-retry { margin-top: 10px; }
.access-error {
  margin-top: 14px;
  padding: 9px 12px;
  background: #fcf0ef;
  border-radius: 9px;
  color: #882e35;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.access-content button:disabled, .session-footer button:disabled { opacity: .65; cursor: progress; }
.migration-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
  padding: 16px;
  margin: 18px 0 0;
  border-radius: 12px;
  background: #f7f4fc;
}
.migration-preview dt { font-size: .85rem; color: var(--muted); }
.migration-preview dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.migration-actions { display: grid; gap: 8px; margin-top: 20px; }
.migration-actions .text-button, .access-signout { min-height: 42px; }
.access-signout { margin-top: 12px; }
.session-footer, .session-sync, .session-actions { display: flex; align-items: center; }
.session-footer { justify-content: space-between; flex-wrap: wrap; gap: 4px 20px; }
.session-sync, .session-actions { gap: 8px; min-width: 0; }
.session-footer .text-button { min-height: 44px; padding-inline: 5px; }
#session-name, #sync-status { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .access-page { align-items: start; padding-top: 20px; }
  .access-brand { min-height: 80px; }
  .access-wallet { width: 116px; }
}
/* On the narrowest phones the wallet peeks in from the edge of the card and leaves its room to the brand. */
@media (max-width: 380px) {
  .access-wallet { width: 100px; right: -22px; }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 1rem/1.5 Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
button, input, select { font: inherit; }
button, a { touch-action: manipulation; }
button { border: 0; background: none; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #8564e5;
  outline-offset: 3px;
}
/* Headings receive the focus from scripts (tabindex="-1") so that screen readers start there. They are not controls,
   and the browser would otherwise draw its own focus ring around them on page load. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
i { display: inline-flex; flex-shrink: 0; }
i svg { width: 1.18em; height: 1.18em; stroke-width: 1.75; }
[hidden] { display: none !important; }
/* Read by screen readers, not shown. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar, main {
  width: min(1120px, calc(100% - 56px));
  margin-inline: auto;
}
.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  container-type: inline-size;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  justify-self: start;
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.085em;
}
.brand img { width: 38px; margin-right: 10px; }
.brand span { color: var(--brand); }
nav, nav a, .account { display: flex; align-items: center; }
nav {
  padding: 4px;
  gap: 2px;
  border: 1px solid #eeeaf5;
  border-radius: 13px;
  background: #f8f7fb;
}
/* The menu is in two pairs: on a narrow screen with large text it goes on two rows of two, never three and one. */
.nav-pair { display: flex; gap: 2px; }
nav a {
  justify-content: center;
  gap: 8px;
  min-height: 39px;
  padding: 6px 13px;
  border-radius: 9px;
  font-size: .875rem;
  font-weight: 650;
  white-space: nowrap;
  color: var(--muted);
}
nav a:hover { background: #efebf8; }
nav a[aria-current] {
  color: var(--brand-deep);
  background: var(--surface);
  box-shadow: 0 1px 4px #22104715;
}
.account {
  justify-self: end;
  gap: 9px;
  padding: 4px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 650;
}
.account i, .tile, .icon-button, .outline-icon { display: inline-grid; place-items: center; }
.account i {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--wash);
  color: var(--brand);
}
.account:hover { background: var(--wash); }
/* One row only where it fits, even with DejaVu Sans, wider than the fonts of phones and computers. Each threshold
   is the larger of its value for 16 px text and the same value in em, which grows with the text size chosen in the
   browser. «Budget personale» depends on the width of the bar, which stops at 1120 px: from 20 px of text it never
   fits in one row. The thresholds are measured on «NoSpesa.»: a longer brand needs them measured again. */
@container (max-width: 960px) or (max-width: 60em) {
  .account span { display: none; }
}
@media (max-width: 872px), (max-width: 54.5em) {
  .topbar { grid-template-columns: 1fr auto; min-height: 0; gap: 8px; padding-block: 8px 9px; }
  .account { grid-column: 2; grid-row: 1; }
  .account span { display: inline; }
  nav { grid-column: 1 / -1; flex-wrap: wrap; }
  .nav-pair, nav a { flex: 1 1 0; }
}
@media (max-width: 680px), (max-width: 42.5em) {
  /* With very large text on the narrowest screens the brand keeps the account button on the screen. */
  .brand { font-size: min(1.85rem, 13vw); }
  .brand img { width: 33px; }
  nav a { flex-direction: column; gap: 2px; padding: 5px 2px; min-height: 44px; font-size: clamp(.68rem, 2.85vw, .84rem); }
}
/* On the narrowest phones, and with large text on wider ones too, «Budget personale» leaves its room to the brand. */
@container (max-width: 320px) or (max-width: 20em) {
  .account span { display: none; }
}

.pagehead, .card-title, .month-head, .hero-foot, .countdown, .account-row, .legend, .legend span, footer span {
  display: flex;
  align-items: center;
}
.pagehead, .card-title, .month-head, .hero-foot { justify-content: space-between; }
.pagehead { gap: 12px; margin: 34px 0 21px; }
#overview-actions { display: none; }
.overline {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
  margin-bottom: 4px;
}
.overline::first-letter { text-transform: uppercase; }
h1 { font-size: clamp(2.15rem, 4vw, 3rem); line-height: 1.1; letter-spacing: -.065em; }
h2 { font-size: 1.26rem; line-height: 1.22; letter-spacing: -.037em; }
h3 { font-size: 1rem; letter-spacing: -.02em; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 680;
  line-height: 1.28;
  text-align: center;
  white-space: nowrap;
}
.btn.secondary { border-color: #e2ddeb; background: var(--surface); }
.btn.secondary:hover { border-color: #c7b7e9; background: var(--wash); }
.btn.primary { background: var(--brand); color: white; box-shadow: 0 2px 4px #4d2bab24; }
.btn.primary:hover { background: var(--brand-deep); }
#example {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -3px 0 17px;
  font-size: .875rem;
  color: var(--muted);
}
.example-label {
  background: #eee8f9;
  color: #4e397c;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 650;
}
#example button, .text-button, .list-link {
  color: var(--brand-deep);
  font-weight: 650;
  padding: 3px 0;
}
#example button:hover, .text-button:hover, .list-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.details {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.overview-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: inherit;
  min-width: 0;
}
.panel, .hero {
  min-width: 0;
  border-radius: var(--panel-radius);
  box-shadow: var(--shadow);
}
.panel {
  padding: 22px 24px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.card-title { gap: 8px; }
.hero {
  display: flex;
  flex-direction: column;
  padding: 18px 26px 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 97% 18%, #6943ba 0%, transparent 62%),
    linear-gradient(133deg, #251444 4%, #3a2268 62%, #503289);
  color: white;
}
.hero::before, .hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 290px;
  height: 290px;
  right: -42px;
  top: -32px;
  border: 1px solid #e7d8ff29;
  border-radius: 50%;
  pointer-events: none;
}
.hero::after {
  width: 330px;
  height: 330px;
  right: -62px;
  top: -52px;
}
.hero-main {
  display: flex;
  align-items: center;
  flex: 1;
  min-height: 180px;
  position: relative;
}
.hero-text { position: relative; z-index: 1; width: min(69%, 400px); }
.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #e7d9ff;
  font-weight: 650;
}
.hero-label i { color: #c7a9ff; }
.daily {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 9px;
  margin: 10px 0 7px;
}
.daily strong {
  font-size: clamp(2.65rem, 5.25vw, 4.75rem);
  font-weight: 740;
  line-height: 1.05;
  letter-spacing: -.067em;
  overflow-wrap: anywhere;
}
.daily span, #daily-note, .countdown { color: #eee4ff; }
#daily-note { font-size: .91rem; min-height: 1.4em; }
#tomorrow-forecast {
  margin-top: 8px;
  color: #f6f0ff;
  font-size: .9rem;
  line-height: 1.45;
  text-wrap: pretty;
}
#tomorrow-forecast strong { white-space: nowrap; }
.backup-settings {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.backup-settings .actions { justify-content: start; margin-top: 10px; }
#daily-estimate {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  margin-top: 7px;
  color: #e3d6f5;
  font-size: .82rem;
}
#daily-estimate strong { color: #fff; font-weight: 650; }
.wallet {
  position: absolute;
  right: -7px;
  top: 50%;
  width: 40%;
  max-width: 255px;
  height: auto;
  transform: translateY(-50%) rotate(-4deg);
  filter: drop-shadow(0 11px 14px #1e09484f);
  pointer-events: none;
}
.hero-foot {
  position: relative;
  gap: 14px;
  margin-top: 12px;
  border-top: 1px solid #eee4ff38;
  padding: 13px 0;
}
.countdown { gap: 8px; font-size: .875rem; }
#formula {
  display: grid;
  place-items: center;
  align-self: center;
  width: 29px;
  height: 32px;
  flex: 0 0 29px;
  padding: 0;
  border-radius: 8px;
  color: #eee4ff;
}
#formula:hover { background: #f3ebff25; }
.hero-action { background: #efe6ff; color: #37205f; }
.hero-action:hover { background: #fff; }
.hero button:focus-visible { outline-color: #e7d5ff; }

.icon-button, .outline-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  background: #f6f3fa;
  color: #615478;
}
.icon-button:hover { background: #ece4f9; color: var(--brand-deep); }
.account-row { gap: 12px; margin-top: 12px; }
.account-row + .account-row { margin-top: 11px; }
.account-row p, .row-desc { font-size: .875rem; color: var(--muted); }
.account-row b {
  display: block;
  font-size: 1.28rem;
  letter-spacing: -.04em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.account-row small {
  margin-inline-start: auto;
  padding: 3px 8px;
  border-radius: 7px;
  background: #e8f6ee;
  color: #24654b;
  font-weight: 650;
  font-size: .85rem;
  white-space: nowrap;
}
.tile {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex-shrink: 0;
}
.tile i { font-size: 1.1rem; }
.lilac { color: #643da1; background: #f0e7fb; }
.mint { color: #286849; background: #e3f5ec; }
.peach { color: #994c24; background: #fce9d9; }
.blue { color: #375c88; background: #e8f0fc; }
.pink { color: #983e65; background: #fae7ef; }
.tile.category-tile {
  color: color-mix(in srgb, var(--ink) 72%, var(--category-color));
  background: color-mix(in srgb, var(--surface) 80%, var(--category-color));
}
.income-action {
  width: 100%;
  margin-top: 12px;
  background: #e8f6ee;
  color: #24654b;
}
.income-action:hover { background: #d6ecdf; }
#allocation {
  margin-top: 17px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
#allocation-bar {
  display: block;
  appearance: none;
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 10px;
  background: #eee9fa;
  color: #805bd6;
  overflow: hidden;
}
#allocation-bar::-webkit-progress-bar { background: #eee9fa; }
#allocation-bar::-webkit-progress-value { background: #805bd6; border-radius: 10px; }
#allocation-bar::-moz-progress-bar { background: #805bd6; border-radius: 10px; }
.allocation-labels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
  font-size: .875rem;
}
.allocation-labels > :last-child { text-align: right; }
.allocation-caption {
  display: flex;
  align-items: center;
  min-height: 25px;
  gap: 4px;
  color: var(--muted);
}
.allocation-labels > :last-child .allocation-caption { justify-content: end; }
/* The amount to set aside goes under the deadlines, on the left like the filled part of the bar, which shows the two
   together; what is left stays on the right. */
.allocation-labels.with-target { row-gap: 6px; }
.allocation-labels.with-target > :last-child { grid-column: 2; grid-row: 1; }
.allocation-labels.with-target > #allocation-target { grid-column: 1 / -1; }
.allocation-labels b { display: block; overflow-wrap: anywhere; }
.little-info {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border-radius: 7px;
  color: var(--muted);
}
.little-info:hover { background: var(--wash); }

.filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 16px;
}
.filter-row:not(:has(> :not([hidden]))) { display: none; }
#expense-filter { width: auto; max-width: 100%; font-size: .875rem; }
.filter-row .btn { max-width: 100%; color: var(--brand-deep); white-space: normal; }
.expenses .card-title { margin-bottom: 16px; }
.list-head, .exp-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(66px, .28fr) minmax(90px, .3fr) 18px;
  align-items: center;
  gap: 9px;
}
.list-head {
  border-bottom: 1px solid var(--line);
  padding: 0 4px 8px;
  color: var(--muted);
  font-size: .775rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .065em;
}
.list-head span:nth-child(3), .amount { text-align: right; }
.exp-row {
  width: 100%;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.exp-row:hover { background: #fbf9fe; }
@media screen {
  .details.single #expense-list .exp-row:nth-child(n+31) {
    content-visibility: auto;
    contain-intrinsic-block-size: auto 2.5rem;
  }
}
.exp-name { display: flex; gap: 10px; min-width: 0; align-items: center; }
.exp-name > span:last-child { min-width: 0; }
.exp-name strong, .row-desc { display: block; }
.exp-name strong { font-size: .94rem; line-height: 1.35; overflow-wrap: anywhere; }
.row-desc { font-size: .82rem; }
.rule-row .row-desc { color: var(--muted); overflow-wrap: anywhere; }
/* Spese → Ricorrenze. On a computer the column names the next instalment: in the row «Prossima» is for screen readers.
   The ended rules show «Fine» above their last day. */
.rule-row:not(.ended) .recent-date-note { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.rule-row.ended strong { color: var(--muted); }
.recurring-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: -4px 0 16px; }
.recurring-summary span { color: var(--muted); font-size: .85rem; font-weight: 650; }
.recurring-summary strong { font-size: 1.3rem; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.recurring-summary small { color: var(--muted); font-size: .82rem; }
.ended-rules > summary {
  padding: 16px 4px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .775rem;
  font-weight: 650;
  letter-spacing: .065em;
  text-transform: uppercase;
  cursor: pointer;
}
.ended-rules > summary:hover { color: var(--ink); }
.ended-rules > summary:focus-visible { outline: 3px solid #8564e5; outline-offset: 3px; }
.category-label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.category-swatch {
  display: inline-block;
  flex: none;
  width: .65rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--category-color, var(--brand));
  box-shadow: inset 0 0 0 1px #25223830;
}
.exp-date { font-size: .875rem; color: var(--muted); }
.payment-hour { display: block; font-variant-numeric: tabular-nums; }
.recent-date-note { display: block; font-size: .78rem; }
#recent-expenses-panel .card-title { margin-bottom: 2px; }
@media (min-width: 681px) {
  #recent-expenses-panel .exp-row {
    grid-template-columns: minmax(0, 1fr) minmax(70px, .28fr) minmax(92px, .4fr) 14px;
  }
}
.amount { font-size: .935rem; font-weight: 650; overflow-wrap: anywhere; }
.exp-row > i { justify-self: end; color: #76688d; font-size: .85rem; }
.list-link { display: block; margin: 14px auto 0; min-height: 36px; font-size: .875rem; }

.month-head { margin: 14px 0 9px; }
.month-head > div { display: flex; gap: 6px; }
.month-head .icon-button { width: 36px; height: 36px; }
.weekdays, #month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
}
.weekdays { margin-bottom: 4px; color: var(--muted); font-size: .8rem; font-weight: 650; }
.day {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 42px;
  padding: 0;
  font-size: .875rem;
  margin-block: 0 1px;
}
.day-number {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(100%, 42px);
  height: 100%;
  border-radius: 11px;
}
.day.dim { color: #827991; }
.day:hover .day-number { box-shadow: inset 0 0 0 1px #9e85d6; }
#month-grid:not(.selecting) .day.today .day-number,
.selecting .day.range-start .day-number,
.selecting .day.range-end .day-number { background: var(--brand); color: white; font-weight: 750; }
.selecting .day.today:not(.range-start, .range-end) .day-number {
  box-shadow: inset 0 0 0 2px var(--brand);
  color: var(--brand-deep);
  font-weight: 750;
}
.selecting .day.in-range::before {
  content: '';
  position: absolute;
  inset: 3px 0;
  background: #ebe3fa;
}
.selecting .day.range-start::before { left: 50%; }
.selecting .day.range-end::before { right: 50%; }
.selecting .day.range-start.range-end::before { content: none; }
.markers {
  display: flex;
  gap: 3px;
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
}
em { display: block; width: 6px; height: 6px; border-radius: 50%; }
.expense-dot { background: #8760d7; }
.income-dot { background: #39986f; }
#month-grid:not(.selecting) .today .markers em, .selecting .range-start .markers em, .selecting .range-end .markers em { outline: 1px solid white; }
.legend {
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: .875rem;
  color: var(--muted);
}
.legend span, footer span { gap: 7px; }
footer { margin: 22px 0 26px; font-size: .825rem; color: var(--muted); }
.details.single { grid-template-columns: minmax(0, 1fr); }
.single .calendar { max-width: 660px; width: 100%; justify-self: center; }
.empty { padding: 24px 0; text-align: center; color: var(--muted); }

dialog {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 23px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 70px #25134546;
}
dialog::backdrop { background: #22153780; }
#review-recurring {
  margin-bottom: 14px;
  background: var(--wash);
  color: var(--brand-deep);
}
dialog:has(#review-form) {
  width: min(610px, calc(100vw - 20px));
  overscroll-behavior: contain;
}
.review-bulk, .review-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-block: 12px;
}
.review-bulk select { flex: 1 1 155px; min-width: 0; }
.review-bulk label { width: 100%; margin: 0; }
.review-pagination { justify-content: space-between; }
.review-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(108px,135px);
  align-items: center;
  gap: 8px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.review-item-meta { min-width: 0; overflow-wrap: anywhere; }
.review-item-meta strong, .review-item-meta small { display: block; }
.review-item-meta small { color: var(--muted); }
.review-row select { padding-block: 6px; font-size: .875rem; }
#review-summary {
  margin-block: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--wash);
  font-size: .9rem;
  color: var(--brand-deep);
}
.review-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
@media (max-width: 480px) {
  dialog:has(#review-form) { padding: 16px; }
  .review-actions {
    position: sticky;
    bottom: -16px;
    padding: 10px 0 max(12px, env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .review-actions > button { flex: 1 1 auto; white-space: normal; }
}
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.dialog-head h2 { overflow-wrap: anywhere; }
.category-list {
  display: grid;
  gap: 4px;
}
.category-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .925rem;
  font-weight: 650;
  text-align: start;
  overflow-wrap: anywhere;
}
.category-row:hover { background: var(--wash); }
.category-row .category-swatch { width: 1rem; }
.category-row > i:last-child { color: var(--muted); }
.category-color-field {
  display: flex;
  align-items: center;
  gap: 10px;
}
.category-color-field #category-color {
  width: 60px;
  padding: 4px 6px;
  cursor: pointer;
}
#category-hex {
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--wash);
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
label { display: block; font-size: .9rem; font-weight: 650; margin: 14px 0 6px; }
input, select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #d8cfe6;
  border-radius: 9px;
  color: var(--ink);
  background: white;
}
select {
  appearance: none;
  padding-right: 34px;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23665f79' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 11px center;
}
.description-control { position: relative; }
.description-control input { padding-right: 46px; }
.description-toggle {
  position: absolute;
  inset: 0 0 0 auto;
  width: 44px;
  display: grid;
  place-items: center;
  color: var(--brand-deep);
}
.description-toggle::before {
  content: '';
  width: 7px;
  height: 7px;
  margin-bottom: 4px;
  border: solid currentColor;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}
.description-toggle[aria-expanded="true"]::before { transform: rotate(225deg); margin: 4px 0 0; }
.description-options {
  max-height: min(13rem, 27dvh);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 4px;
  margin: 5px 0 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 4px 14px #27134112;
}
.description-options li {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 7px 10px;
  overflow-wrap: anywhere;
  border-radius: 6px;
  cursor: pointer;
}
.description-options li:hover, .description-options [aria-selected="true"] {
  color: var(--brand-deep);
  background: var(--wash);
}
.repeat-fields {
  margin-top: 14px;
  padding: 0 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf9fe;
}
.repeat-fields input { min-width: 0; }
.repeat-hint { margin-top: 8px; color: var(--muted); font-size: .82rem; }
.weekday-fieldset {
  min-width: 0;
  margin: 14px 0 0;
  padding: 0;
  border: 0;
}
.weekday-fieldset legend { padding: 0; font-size: .9rem; font-weight: 650; }
.weekday-options {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 6px;
}
.weekday-option {
  position: relative;
  display: block;
  margin: 0;
}
.weekday-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.weekday-option span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid #d8cfe6;
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: .8rem;
}
.weekday-option input:hover + span { border-color: #9579d6; }
.weekday-option input:checked + span {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}
.weekday-option input:focus-visible + span {
  outline: 3px solid #8564e5;
  outline-offset: 2px;
}
.actions { display: flex; justify-content: end; gap: 9px; flex-wrap: wrap; margin-top: 20px; }
.danger { color: #9d3559; }
.help, .hint { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.hint { margin: 8px 0; }
.entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.entry > span, .entry > b { overflow-wrap: anywhere; }
#receipt-list .entry > div { min-width: 0; overflow-wrap: anywhere; }
#receipt-list small { display: block; color: var(--muted); font-size: .875rem; }
#toast.show {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  width: max-content;
  max-width: calc(100% - 22px);
  transform: translateX(-50%);
  z-index: 5;
  background: #302047;
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 15px #2520383d;
  font-size: .875rem;
  text-align: center;
}
#toast:empty { display: none; }

@media (max-width: 860px) {
  .topbar, main { width: calc(100% - 38px); }
  .details { grid-template-columns: minmax(0, 1.4fr) minmax(275px, 1fr); gap: 14px; }
  .panel { padding: 18px; }
  .hero { padding-inline: 20px; }
  .hero-foot { flex-wrap: wrap; gap: 5px 12px; }
  .list-head, .exp-row { grid-template-columns: minmax(0, 1fr) 62px 75px 12px; gap: 5px; }
  .exp-name .tile { width: 34px; height: 34px; border-radius: 9px; }
}

@media (max-width: 680px) {
  .topbar, main { width: calc(100% - 32px); }
  #overview-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
  }
  #overview-actions .btn {
    min-width: 0;
    min-height: 46px;
    padding-inline: 8px;
    gap: 6px;
    white-space: normal;
  }
  .quick-income { color: #205e43; background: #e3f4ea; border-color: #c7e4d4; }
  .quick-income:hover { background: #d7eddf; }
  #quick-spend, #record-income { display: none; }
  #overview-actions:not([hidden]) + .pagehead { margin-top: 16px; }
  .pagehead { margin: 22px 0 15px; }
  .pagehead > div { min-width: 0; }
  .pagehead h1 { font-size: clamp(1.6rem, 7.1vw, 2.15rem); }
  #setup { padding-inline: 10px; }
  #example { margin: 0 0 13px; }
  .details { grid-template-columns: minmax(0, 1fr); }
  .details:not(.single) .expenses .list-head { display: none; }
  .details:not(.single) .expenses .exp-row {
    grid-template-columns: minmax(0, 1fr) fit-content(55%);
    grid-template-areas: "name amount" "name date";
    gap: 2px 10px;
    min-height: 52px;
  }
  .details:not(.single) .expenses .exp-name { grid-area: name; }
  .details:not(.single) .expenses .amount { grid-area: amount; }
  .details:not(.single) .expenses .exp-date {
    grid-area: date;
    text-align: right;
    font-size: .82rem;
  }
  .details:not(.single) .expenses .payment-hour,
  .details:not(.single) .expenses .recent-date-note { display: inline; }
  .details:not(.single) .expenses .payment-hour::before { content: ' · '; }
  .details:not(.single) .expenses .exp-row > i { display: none; }
  .details:not(.single) .expenses .list-link { min-height: 44px; margin-top: 6px; }
  .hero-foot { flex-wrap: nowrap; gap: 8px; }
  .hero-main { min-height: 140px; }
  .wallet { right: -6px; width: 36%; }
  .hero-text { width: 72%; padding-top: 4px; }
  .hero::before, .hero::after { right: -100px; }
  .hero::after { right: -120px; }
  .daily strong { font-size: clamp(2.45rem, 9.75vw, 4rem); }
  .panel, .hero { border-radius: 18px; }
}

@media (max-width: 480px) {
  .pagehead { align-items: end; }
  .pagehead .overline { text-wrap: pretty; }
  .hero-foot { flex-direction: column; align-items: stretch; gap: 10px; }
  .hero-foot .hero-action { width: 100%; }
  .expenses .card-title h2 { min-width: 0; font-size: 1.12rem; }
  .expenses .card-title .btn { gap: 5px; padding-inline: 9px; font-size: .8rem; }
  .filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  #expense-filter { grid-column: 1 / -1; width: 100%; }
  .filter-row .btn { padding-inline: 5px; gap: 5px; font-size: .8125rem; }
  .list-head { letter-spacing: .035em; font-size: .69rem; }
  .exp-name .tile { display: none; }
  /* Spese → Ricorrenze: name and amount on the first line, then category and schedule across the whole row, then the
     next day. The wrappers of name and description step aside, so that the description can run under the amount. */
  .list-head:has(+ .rule-list) { display: none; }
  .rule-list .exp-row { grid-template-columns: minmax(0, 1fr) auto 10px; row-gap: 3px; }
  .rule-list .exp-name, .rule-list .exp-name > span:last-child { display: contents; }
  .rule-list .exp-name strong { grid-column: 1; grid-row: 1; }
  .rule-list .amount { grid-column: 2; grid-row: 1; align-self: start; white-space: nowrap; }
  .rule-list .row-desc { grid-column: 1 / span 2; grid-row: 2; }
  .rule-list .exp-row > i { grid-column: 3; grid-row: 1 / span 3; }
  .rule-list .exp-date { grid-column: 1 / span 2; grid-row: 3; font-size: .8rem; }
  /* As specific as the rule that hides «Prossima» on a computer, and later: here the word is shown. */
  .rule-list .rule-row .recent-date-note { position: static; display: inline; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; font-size: inherit; }
}

@media (max-width: 365px) {
  .topbar, main { width: calc(100% - 24px); }
  .list-head, .exp-row { grid-template-columns: minmax(0, 1fr) 58px 68px 10px; }
  .card-title .btn, #setup { gap: 5px; padding-inline: 8px; }
  #setup { max-width: 124px; white-space: normal; }
}

#stats-period-control { min-width: 0; }
#stats-period-control label { margin: 0 0 3px; font-size: .8rem; color: var(--muted); }
#stats-period { width: auto; max-width: 100%; font-weight: 650; }
.stats-lead { min-width: 0; border-radius: var(--panel-radius); }
.stats-lead {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(20px, 3vw, 32px);
  color: white;
  background: linear-gradient(115deg, #2c194e 10%, #492883 82%, #583598);
}
.stats-lead::before {
  content: '';
  position: absolute;
  z-index: -1;
  width: 480px;
  aspect-ratio: 1;
  border-radius: 50%;
  right: -290px;
  bottom: -310px;
  background: repeating-radial-gradient(circle at center, transparent 0 17px, #ffffff18 18px 19px, transparent 20px 23px);
}
.stats-lead h2 { font-size: 1rem; letter-spacing: -.025em; }
.stats-lead h2 { display: flex; align-items: center; gap: 9px; color: #eee7ff; }
.stats-lead > strong {
  display: block; margin: 5px 0 8px;
  font-size: clamp(2.35rem, 4.2vw, 3.8rem);
  line-height: 1.08; letter-spacing: -.065em; overflow-wrap: anywhere;
}
#report-period { color: #ede4ff; font-size: .85rem; text-wrap: pretty; }
.row-chevron { color: var(--muted); }
#legacy-report-dates { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; }
.description-chart { list-style: none; padding: 0; margin: 18px 0 0; }
.description-chart li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) 8em;
  align-items: center;
  gap: 14px;
  padding-block: 10px;
}
.description-chart-name { font-weight: 600; overflow-wrap: anywhere; }
.description-chart-count { text-align: end; color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.description-chart-track { height: 8px; background: var(--wash); border-radius: 4px; overflow: hidden; }
.description-chart-track > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
@media (max-width: 680px) {
  .description-chart li { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .description-chart-track { grid-column: 1 / -1; grid-row: 2; }
  .description-chart-count { grid-column: 2; grid-row: 1; }
  #stats-period { font-size: .875rem; }
  .stats-lead { padding: 20px; }
}
@media (max-width: 480px) {
  .pagehead:has(#stats-period-control:not([hidden])) { flex-wrap: wrap; }
  #stats-period-control {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  #stats-period-control label { margin: 0; }
  #stats-period { flex: 1; min-width: 0; width: 100%; }
}
#movement-filters {
  display: grid;
  grid-template-columns: minmax(145px, 1.4fr) minmax(155px, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}
#movement-filters > * { min-width: 0; }
#report-period-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 13px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--wash);
  font-size: .84rem;
}
#report-period-filter button { flex-shrink: 0; }
@media (max-width: 480px) {
  #movement-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
  #movement-filters > * { font-size: .875rem; }
}
@media (max-width: 365px) {
  #movement-filters { grid-template-columns: minmax(0, 1fr); }
}

/* Spese: switch for the payments due after today */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin: 0 0 14px;
  font-size: .875rem;
  cursor: pointer;
}
.switch input {
  appearance: none;
  position: relative;
  flex: none;
  width: 42px;
  min-height: 0;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #d6cde6;
  cursor: inherit;
  transition: background-color .15s;
}
.switch input::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px #25223840;
  transition: transform .15s;
}
.switch input:checked { background: var(--brand); }
.switch input:checked::before { transform: translateX(18px); }
.switch input:disabled { opacity: .55; }
.switch:has(input:disabled) { cursor: default; color: var(--muted); }
.switch-count {
  min-width: 1.6em;
  padding: 1px 7px;
  border-radius: 7px;
  background: var(--wash);
  color: var(--brand-deep);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.ledger-heading {
  padding: 16px 4px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .775rem;
  font-weight: 650;
  letter-spacing: .065em;
  text-transform: uppercase;
}
.ledger-heading:first-child { padding-top: 6px; }
@media (prefers-reduced-motion: reduce) {
  .switch input, .switch input::before { transition: none; }
}

/* Calendario: range controls and summary */
.range-hint {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--wash);
  color: var(--brand-deep);
  font-size: .84rem;
  text-align: center;
  text-wrap: pretty;
}
#range-controls { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.range-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.range-presets button {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid #e2ddeb;
  border-radius: 999px;
  background: var(--surface);
  font-size: .82rem;
  font-weight: 650;
}
.range-presets button:hover { border-color: #c7b7e9; background: var(--wash); }
.range-presets button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: white; }
.range-presets button:disabled { opacity: .45; cursor: default; }
.range-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.range-dates > div { min-width: 0; }
.range-dates label { margin: 0 0 4px; color: var(--muted); font-size: .8rem; }
.range-dates input { min-height: 40px; padding: 7px 9px; font-size: .9rem; }
.details.calendar-view #overview-side { grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); align-items: start; }
.details.calendar-view .calendar { max-width: none; position: sticky; top: 16px; }
.range-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.range-heading { min-width: 0; }
.range-heading h2 { overflow-wrap: anywhere; }
.range-budget {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 9px;
  background: var(--wash);
  color: var(--brand-deep);
  font-size: .875rem;
  font-weight: 600;
}
.range-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.range-total { min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfaff; }
.range-total > span { display: block; color: var(--muted); font-size: .8rem; font-weight: 650; }
.range-total strong { display: block; margin-top: 2px; font-size: 1.3rem; line-height: 1.2; letter-spacing: -.04em; overflow-wrap: anywhere; }
.range-total small { display: block; margin-top: 4px; color: var(--muted); font-size: .78rem; line-height: 1.35; overflow-wrap: anywhere; }
#range-in.positive, #range-net.positive, .range-day-in { color: #24654b; }
#range-net.negative { color: #9d3559; }
.range-insights { margin-top: 14px; }
.range-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.range-fact { min-width: 0; padding: 10px 12px; border-radius: 12px; background: var(--wash); }
.range-fact span, .range-fact small { display: block; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.range-fact span { font-weight: 650; }
.range-fact strong { display: block; font-size: 1.05rem; letter-spacing: -.02em; overflow-wrap: anywhere; }
.range-subtitle { margin: 16px 0 0; font-size: .875rem; color: var(--muted); }
.split-bar { display: flex; gap: 2px; height: 8px; margin: 8px 0 10px; }
.split-bar span { min-width: 3px; border-radius: 4px; background: var(--category-color); }
.split-legend { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: .86rem; }
.split-legend li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: baseline; gap: 8px; }
.split-legend li > span:nth-child(2) { overflow-wrap: anywhere; }
.split-share { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.split-legend b { font-variant-numeric: tabular-nums; text-align: end; }
.range-list { margin-top: 20px; }
.range-day + .range-day { margin-top: 16px; }
.range-list.single-day .range-day-head { display: none; }
.range-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 7px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
  font-weight: 650;
}
.range-day-head > span:first-child { color: var(--ink); }
.range-day-sum { font-variant-numeric: tabular-nums; text-align: end; }
.exp-row.agenda-row { grid-template-columns: minmax(0, 1fr) auto minmax(76px, auto) 18px; }
.agenda-row .exp-date { font-variant-numeric: tabular-nums; }
.agenda-row.pending .amount { color: #6d6382; font-weight: 600; }
.income-row { cursor: default; }
.income-row:hover { background: none; }
.income-amount { color: #24654b; }
@media (max-width: 760px) {
  .details.calendar-view #overview-side { grid-template-columns: minmax(0, 1fr); }
  .details.calendar-view .calendar { position: static; max-width: 660px; }
}
@media (max-width: 480px) {
  .range-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .range-total:first-child { grid-column: 1 / -1; }
  .range-total strong { font-size: 1.15rem; }
  .exp-row.agenda-row { grid-template-columns: minmax(0, 1fr) auto minmax(64px, auto) 10px; gap: 6px; }
}
@media (max-width: 365px) {
  .day { height: 38px; }
}

/* Statistiche: tabs, figures, charts and forecasts */
#statistics-panel {
  --series-1: #633ec5;
  --series-2: #dc5f1c;
  --series-3: #00957a;
  display: grid;
  gap: 16px;
}
.stats-tabs, .list-tabs {
  display: inline-flex;
  justify-self: start;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #ece8f4;
}
.stats-tabs [role="tab"], .list-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 7px 16px;
  border-radius: 9px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}
.stats-tabs [role="tab"]:hover, .list-tabs a:hover { color: var(--ink); }
.stats-tabs [role="tab"][aria-selected="true"], .list-tabs a[aria-current="page"] { background: var(--surface); color: var(--brand-deep); box-shadow: 0 1px 4px #22104715; }
/* Spese: «Movimenti | Ricorrenze», with the number of active rules. With the text enlarged in the settings of a phone,
   the tabs go one under the other instead of sticking out of the screen; each tab keeps its words on one line. */
.list-tabs { justify-self: start; flex-wrap: wrap; }
.tab-count {
  min-width: 1.6em;
  padding: 1px 7px;
  border-radius: 7px;
  background: var(--wash);
  color: var(--brand-deep);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.tab-count:empty { display: none; }
.stats-section { display: grid; gap: 16px; min-width: 0; }
.stats-custom { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 12px; padding-block: 14px; }
.stats-custom > div { min-width: 0; }
.stats-custom label { margin: 0 0 4px; color: var(--muted); font-size: .8rem; }
.stats-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 16px; }
.delta { font-size: .85rem; font-weight: 650; }
.stats-lead .delta {
  align-self: start;
  margin-top: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #ffffff1f;
  color: #fff;
  text-wrap: pretty;
}
.stats-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stats-metric {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metric-label { color: var(--muted); font-size: .8rem; font-weight: 650; }
.stats-metric > strong {
  margin-top: 3px;
  font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  line-height: 1.2;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.stats-metric > small { margin-top: 3px; color: var(--muted); font-size: .76rem; line-height: 1.35; overflow-wrap: anywhere; }
#stats-income.positive, #stats-net.positive { color: #24654b; }
#stats-net.negative { color: #9d3559; }
[data-trend="up"] { color: #9d3559; }
[data-trend="down"] { color: #24654b; }
.stats-lead [data-trend] { color: #fff; }
.trend { font-weight: 700; white-space: nowrap; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stats-column { display: grid; gap: 16px; min-width: 0; }
.stats-wide { grid-column: 1 / -1; }
.stats-grid > .panel, .stats-column > .panel { min-width: 0; }
.chart-head { display: grid; gap: 4px; }
.chart-sub { color: var(--muted); font-size: .85rem; line-height: 1.45; text-wrap: pretty; }
.panel > h2 + .chart-sub { margin-top: 4px; }
.chart-readout {
  min-height: 2.9em;
  margin: 12px 0 6px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--wash);
  color: var(--ink);
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.chart { --gutter: 3.6rem; position: relative; border-radius: 10px; outline-offset: 4px; touch-action: pan-y; }
.chart-plot { position: relative; height: 170px; margin-left: var(--gutter); }
.chart.compact .chart-plot { height: 140px; }
.chart-grid { position: absolute; inset: 0; pointer-events: none; }
.chart-grid span { position: absolute; left: 0; right: 0; border-top: 1px solid #ece9f2; }
.chart-grid span.zero { border-top-color: #c9c3d6; }
.chart-grid em {
  position: absolute;
  right: 100%;
  top: -.6em;
  width: max-content;
  margin-right: 6px;
  color: var(--muted);
  font-size: .7rem;
  font-style: normal;
  line-height: 1.2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chart-slots { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--count), minmax(0, 1fr)); }
.chart-slot { position: relative; display: flex; align-items: flex-end; justify-content: center; min-width: 0; height: 100%; cursor: crosshair; }
.chart-slot.active { background: #f3eefc80; }
.chart-bar { width: min(24px, calc(100% - 2px)); border-radius: 4px 4px 0 0; background: var(--series-1); }
.chart-bar.highlight { background: var(--brand-deep); }
.chart-slot.active .chart-bar { background: #3c1f8f; }
.chart-slot[data-future]::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: min(24px, calc(100% - 2px));
  border-top: 2px dotted #c9c3d6;
}
.chart-axis {
  display: grid;
  grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  margin: 6px 0 0 var(--gutter);
  color: var(--muted);
  font-size: .7rem;
  line-height: 1.2;
}
.chart-axis span { grid-row: 1; justify-self: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.chart-lines path { fill: none; stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.chart-lines .series-current { stroke: var(--series-1); }
.chart-lines .series-previous { stroke: var(--series-2); stroke-dasharray: 5 4; }
.chart-slots.lines .chart-slot.active::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 50%;
  border-left: 1px solid #b7add0;
}
.chart-slots.lines .chart-slot.active { background: none; }
.chart-dot {
  position: absolute;
  left: 50%;
  display: none;
  width: 10px;
  height: 10px;
  margin: 0 0 -5px -5px;
  border: 2px solid var(--surface);
  border-radius: 50%;
}
.chart-dot.series-current { background: var(--series-1); }
.chart-dot.series-previous { background: var(--series-2); }
.chart-slot.active .chart-dot { display: block; }
.chart-end-label {
  position: absolute;
  margin: 0 0 8px 6px;
  padding: 1px 5px;
  border-radius: 5px;
  background: #ffffffe0;
  color: var(--ink);
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.chart-end-label { transform: translate(var(--shift-x, 0), var(--shift-y, 0)); }
.chart-end-label.before { --shift-x: -100%; margin-left: -6px; }
.chart-end-label.below { --shift-y: calc(100% + 16px); }
/* Labels for some days under the axis of a line chart, each in a box of fixed width: a large deadline, the hypothetical
   expense, the income. A dashed guide marks the same day in the chart. */
.chart-events { position: relative; height: 1.3em; margin: 3px 0 0 var(--gutter); color: var(--muted); font-size: .7rem; line-height: 1.3; }
.chart-event { position: absolute; top: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.chart-event.start { text-align: left; }
.chart-event.end { text-align: right; }
.chart-event.income { color: var(--ink); font-weight: 650; }
.chart-event.whatif { color: var(--brand-deep); font-weight: 650; }
.chart-guide { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #d3cce0; pointer-events: none; }
/* Below zero the forecast is short of money: the same tint as the warning. */
.chart-below-zero { position: absolute; left: 0; right: 0; bottom: 0; background: #fbe9ef; pointer-events: none; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .8rem; }
.chart-legend li { display: flex; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.legend-line { flex: none; width: 22px; border-top: 2px solid var(--series-1); }
.legend-line.series-previous { border-top: 2px dashed var(--series-2); }
.chart-data { margin-top: 12px; font-size: .85rem; }
.chart-data summary { width: max-content; max-width: 100%; color: var(--brand-deep); font-weight: 650; cursor: pointer; }
.table-scroll { max-height: 320px; margin-top: 8px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.chart-data table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.chart-data th, .chart-data td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.chart-data th:first-child { text-align: left; white-space: normal; font-weight: 600; }
.chart-data thead th { position: sticky; top: 0; background: #faf9fd; color: var(--muted); font-size: .75rem; }
.chart-data tbody tr:last-child > * { border-bottom: 0; }
#report-bars { margin-top: 8px; }
.report-row {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.report-row:last-child { border-bottom: 0; }
.report-row:hover { background: #f8f6fc; }
.report-row .tile { width: 38px; height: 38px; border-radius: 11px; }
.report-main { display: grid; gap: 6px; min-width: 0; }
.report-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.report-name { font-weight: 650; overflow-wrap: anywhere; }
.report-top strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-track { height: 8px; border-radius: 4px; background: var(--wash); }
.report-track > span { display: block; height: 100%; border-radius: 4px; background: var(--category-color); }
.report-meta { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.row-chevron { color: var(--muted); }
.split-legend.parts li { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 1px; }
.split-legend.parts small { grid-column: 2 / -1; color: var(--muted); font-size: .76rem; }
#stats-kinds, #month-split { margin-top: 12px; }
.hour-list { display: grid; gap: 12px; margin: 14px 0 0; padding: 0; list-style: none; }
.hour-list li { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.hour-name { font-weight: 650; font-size: .9rem; }
.hour-name small { display: block; color: var(--muted); font-size: .74rem; font-weight: 500; }
.hour-track { height: 8px; border-radius: 4px; background: var(--wash); }
.hour-track > span { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.hour-value { text-align: end; font-variant-numeric: tabular-nums; }
.hour-value b { display: block; font-size: .9rem; }
.hour-value small { color: var(--muted); font-size: .74rem; }
#hours-note:empty { display: none; }
#top-expenses { margin-top: 8px; }
.forecast .chart-head { margin-bottom: 4px; }
.forecast-empty { display: grid; justify-items: start; gap: 12px; margin-top: 12px; color: var(--muted); }
/* «Fino alla prossima entrata»: the chart with its legend, the simulation beside or below it, and how the estimate is
   reached. Above the slider every text keeps to one line, so the slider never moves while it is dragged. */
.forecast-graph { min-width: 0; }
#forecast-legend { flex-wrap: nowrap; }
#forecast-legend li > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forecast-sim { min-width: 0; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfaff; }
.forecast-lead { display: grid; gap: 2px; }
.forecast-lead > span { overflow: hidden; color: var(--muted); font-weight: 650; font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
#forecast-leftover, .big-figure {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
#forecast-leftover { color: #24654b; }
#forecast-leftover.negative { color: #9d3559; }
#forecast-sentence { margin-top: 10px; color: var(--muted); font-size: .85rem; line-height: 1.45; text-wrap: pretty; }
.forecast-min { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .9rem; }
.forecast-min.warning { padding: 9px 12px; border-radius: 10px; background: #fbe9ef; color: #8a2d4d; }
.forecast-min i { flex: none; }
/* The slider of the simulation, tall enough for a finger. */
.forecast-mode { margin-top: 12px; }
.forecast-mode button[aria-disabled="true"] { opacity: .45; cursor: default; }
/* The other figure of the choice, right under the slider: what is saved, or what is spent. */
#forecast-daily-other { margin-top: 2px; color: var(--muted); font-size: .85rem; line-height: 1.45; text-wrap: pretty; }
.forecast-control-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 12px; }
.forecast-control-head label { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#forecast-daily-value { flex: none; font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* The bounds sit beside the track, clear of the focus ring. */
.forecast-slider { display: flex; align-items: center; gap: 10px; margin-top: 4px; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.forecast-slider span { flex: none; }
#forecast-daily {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  accent-color: var(--brand);
  cursor: pointer;
}
#forecast-daily:focus-visible { outline-offset: 0; }
.forecast-presets { margin-top: 10px; }
.forecast-presets button[aria-disabled="true"], .forecast-presets button[aria-disabled="true"]:hover { border-color: #e2ddeb; background: var(--surface); opacity: .45; cursor: default; }
/* The hypothetical expense, at the bottom of the simulation: amount, day and «Togli» side by side, wrapping when narrow.
   On the narrowest phones the words of «Prova una spesa ipotetica» wrap inside the box rather than sticking out of it. */
.forecast-whatif-open { max-width: 100%; margin-top: 12px; white-space: normal; text-wrap: balance; }
.forecast-whatif { min-width: 0; margin: 12px 0 0; padding: 8px 12px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.forecast-whatif legend { padding: 0 4px; font-size: .9rem; font-weight: 650; }
.forecast-whatif-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
.forecast-whatif-fields > div { flex: 1 1 8.5rem; min-width: 0; }
.forecast-whatif label { margin: 2px 0 5px; font-size: .82rem; }
.forecast-whatif input[aria-invalid="true"] { border-color: #9d3559; }
.forecast-whatif-error { margin-top: 8px; color: #9d3559; font-size: .85rem; font-weight: 650; }
.forecast-whatif .hint { margin: 8px 0 0; font-size: .8rem; }
/* How the estimate is reached: one row per step, the amount on the right, the subtotal and the result in bold. */
.forecast-breakdown { max-width: 36rem; margin-top: 18px; }
.forecast-breakdown h3 { margin: 0 0 4px; }
.forecast-breakdown dl { margin: 0; }
.forecast-breakdown dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.forecast-breakdown dt { min-width: 0; font-size: .9rem; overflow-wrap: anywhere; }
.forecast-breakdown dt small { display: block; margin-top: 1px; color: var(--muted); font-size: .76rem; line-height: 1.35; }
.forecast-breakdown dd { flex: none; margin: 0; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.forecast-breakdown .subtotal dt, .forecast-breakdown .total dt { font-weight: 750; }
.forecast-breakdown .total { border-bottom: 0; }
.forecast-breakdown .total dd { font-size: 1.05rem; font-weight: 750; color: #24654b; }
.forecast-breakdown .total dd.negative { color: #9d3559; }
#month-forecast .big-figure { display: block; margin-top: 8px; }
.delta-line { margin-top: 4px; color: var(--muted); font-size: .875rem; }
.upcoming-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 8px; }
.upcoming-summary strong { font-size: 1.6rem; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.upcoming-summary span { color: var(--muted); font-size: .85rem; }
.upcoming-overdue { margin-top: 10px; padding: 8px 11px; border-radius: 9px; background: #fff3e8; color: #8a4417; font-size: .85rem; }
#upcoming-list { margin-top: 8px; }
.commitments-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.commitments-totals > div { min-width: 0; padding: 11px 13px; border-radius: 12px; background: var(--wash); }
.commitments-totals span, .commitments-totals small { display: block; color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.commitments-totals span { font-weight: 650; }
.commitments-totals strong { display: block; font-size: 1.3rem; letter-spacing: -.04em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#commitments-share:empty { display: none; }
#commitments-list { margin-top: 6px; }
.commit-row {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 14px;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.commit-row:last-child { border-bottom: 0; }
.commit-row:hover { background: #f8f6fc; }
.commit-row .tile { width: 38px; height: 38px; border-radius: 11px; }
.commit-main { display: grid; gap: 2px; min-width: 0; }
.commit-main strong { overflow-wrap: anywhere; }
.commit-main .row-desc { color: var(--muted); overflow-wrap: anywhere; }
.commit-end { color: #8a4417 !important; }
.commit-amount { text-align: end; font-variant-numeric: tabular-nums; }
.commit-amount b { display: block; white-space: nowrap; }
.commit-amount small { color: var(--muted); font-size: .74rem; }
@media (max-width: 980px) {
  .stats-summary { grid-template-columns: minmax(0, 1fr); }
}
/* Up to 980 px the readout of the forecast sits above the slider: a fixed height keeps the slider still when a day read
   on the chart gives way to the summary. A longer description ends with an ellipsis; the table and screen readers have
   it whole. The text sits in its own element, without padding, so that the lines past the ellipsis are hidden right
   under it and none shows cut in half in the padding of the box. */
@media (max-width: 980px) {
  #forecast-readout { height: calc(4.2em + 14px); min-height: 0; }
  #forecast-readout-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; max-height: 4.2em; overflow: hidden; }
}
@media (max-width: 365px) {
  #forecast-readout { height: calc(5.6em + 14px); }
  #forecast-readout-text { -webkit-line-clamp: 4; line-clamp: 4; max-height: 5.6em; }
}
/* On a wide screen the simulation stands beside the chart, and how the estimate is reached goes under the chart.
   :not([hidden]) keeps the hidden attribute stronger than this rule on the id. */
@media (min-width: 981px) {
  /* The second row takes what a tall simulation adds, so the list stays right under the chart. */
  #forecast-body:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 360px); grid-template-rows: auto 1fr; column-gap: 24px; align-items: start; margin-top: 12px; }
  .forecast-graph { grid-column: 1; grid-row: 1; }
  .forecast-graph > #forecast-legend { margin-top: 0; }
  .forecast-sim { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }
  .forecast-breakdown { grid-column: 1; grid-row: 2; }
  #forecast-body > .chart-data { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .stats-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stats-metric { padding: 12px 13px; }
  .stats-tabs, .list-tabs { justify-self: stretch; }
  .stats-tabs [role="tab"], .list-tabs a { flex: 1; justify-content: center; }
  .chart { --gutter: 3.2rem; }
  .chart-plot { height: 150px; }
  .hour-list li { grid-template-columns: 6.4em minmax(0, 1fr) auto; gap: 9px; }
}
@media (max-width: 365px) {
  .stats-custom { grid-template-columns: minmax(0, 1fr); }
  /* «Movimenti | Ricorrenze 12» without icons, so that both tabs fit in 320 px. After the rules of the tabs, to win. */
  .list-tabs a { gap: 5px; padding-inline: 8px; }
  .list-tabs a > i { display: none; }
  /* A little less padding keeps «Per arrivare a zero · 87,00 €» on one line on the narrowest phones. With an amount to
     set aside the buttons also take the size of the text beside them, for «Per mettere da parte · 90,00 €». */
  .forecast-sim { padding-inline: 10px; }
  .forecast-lead > span { font-size: .78rem; }
  .forecast-presets button { padding-inline: 8px; }
  .forecast-presets:has(#forecast-use-target:not([hidden])) button { font-size: .78rem; }
  .report-row, .commit-row { grid-template-columns: minmax(0, 1fr) 10px; }
  .commit-row { grid-template-columns: minmax(0, 1fr) auto 10px; }
  .report-row .tile, .commit-row .tile { display: none; }
}
@media (max-width: 480px) {
  /* Rows in Statistiche: name and amount on the first line, the date below the name. */
  #statistics-panel .exp-row { grid-template-columns: minmax(0, 1fr) auto 10px; row-gap: 3px; }
  #statistics-panel .exp-row .exp-name { grid-column: 1; grid-row: 1; }
  #statistics-panel .exp-row .amount { grid-column: 2; grid-row: 1; white-space: nowrap; }
  #statistics-panel .exp-row > i { grid-column: 3; grid-row: 1 / span 2; }
  #statistics-panel .exp-row .exp-date { grid-column: 1 / span 2; grid-row: 2; color: var(--muted); font-size: .78rem; }
  #statistics-panel .exp-row .payment-hour { display: inline; }
  #statistics-panel .exp-row .payment-hour::before { content: ' · '; }
  /* Two figures side by side do not fit on a phone: a yearly total such as 11.000,00 € would break before the euro sign. */
  .commitments-totals { grid-template-columns: minmax(0, 1fr); }
}
