/* ===================== Statistiche (design system iLovePaghe) ===================== */
.stScroller{ width: 100%; max-width: var(--page-max); margin: 0 auto; padding: var(--page-pad-top) var(--page-pad-x) 64px; }
.stHeader{ display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.stUpdate{ display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font-size: var(--fs-13); }
.stUpdate i{ width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.stUpdate[data-state="live"] i{ background: var(--success-solid); box-shadow: 0 0 0 3px var(--success-soft); }
.stUpdate[data-state="error"] i{ background: var(--warning-solid); }
.stGrid{ display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 20px; align-items: stretch; }
.stCard{ display: flex; flex-direction: column; min-width: 0; min-height: 360px; padding: 20px 22px 18px; border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); }
.stCardHead{ display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.stTitleGroup{ display: flex; align-items: center; gap: 12px; min-width: 0; }
.stTitleGroup h2{ color: var(--text); font-size: var(--fs-15); font-weight: 600; }
.stTitleGroup p{ color: var(--text-2); font-size: var(--fs-13); }
.stIcon{ display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; background: var(--inverse); color: var(--on-inverse); }
.stIcon svg{ width: 18px; height: 18px; }
/* Solid tiles, same family as the Home cards */
.stIcon.stBlue{ background: var(--brand); color: #fff; }
.stIcon.stPurple{ background: var(--data-3); color: #fff; }
.stIcon.stTeal{ background: var(--success-solid); color: #fff; }
/* Same meaning as on the Home: people in ink, payroll in blue. */
.stOrganico .stIcon{ background: var(--inverse); color: var(--on-inverse); }
.stPayroll .stIcon{ background: var(--brand); color: #fff; }
.stSr{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stYear select,
.stMonth input,
.stPayrollMonth select{ height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); color: var(--text); font-size: var(--fs-13); text-transform: capitalize; }
.stYear select:disabled{ opacity: .5; }
.stFoot{ margin-top: auto; padding-top: 12px; color: var(--text-3); font-size: var(--fs-12); }
.stNotice{ display: grid; place-items: center; flex: 1 1 auto; min-height: 200px; padding: 24px; color: var(--text-2); font-size: var(--fs-14); text-align: center; }
.stNotice button{ margin-top: 10px; height: 32px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); color: var(--text); font-size: var(--fs-13); font-weight: 500; }

/* Organico */
.stPeopleBody{ display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 24px; flex: 1 1 auto; }
.stRing{ position: relative; width: 180px; height: 180px; }
.stRing svg{ width: 100%; height: 100%; }
.stRingTrack{ stroke: var(--bg-muted); }
.stRingNumber{ position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.stRingNumber strong{ color: var(--text); font-size: var(--fs-36); font-weight: 600; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stRingNumber span{ color: var(--text-2); font-size: var(--fs-13); }
.stLegend{ display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.stLegend li{ display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--divider); color: var(--text-2); font-size: var(--fs-13); }
.stLegend li:last-child{ border-bottom: 0; }
.stLegend li > span:first-child{ display: inline-flex; align-items: center; gap: 8px; }
.stLegend i{ width: 8px; height: 8px; border-radius: 50%; }
.stLegendValue{ display: inline-flex; align-items: baseline; gap: 8px; }
.stLegendValue b{ color: var(--text); font-size: var(--fs-15); font-weight: 600; font-variant-numeric: tabular-nums; }
.stLegendValue small{ color: var(--text-3); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }

/* Retribuzioni */
.stPayrollBody{ display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; }
.stPayrollSummary{ display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stPayrollSummary > div{ display: grid; gap: 2px; }
.stAnnualLabel{ color: var(--text-2); font-size: var(--fs-13); }
.stAmount{ color: var(--text); font-size: var(--fs-28); font-weight: 600; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.stCoverage,
.stDelta{ color: var(--text-3); font-size: var(--fs-12); }
.stSelectedMonth{ justify-items: end; text-align: right; }
.stChart{ position: relative; flex: 1 1 auto; min-height: 180px; }
.stChart svg{ display: block; width: 100%; height: 100%; overflow: visible; }
.stChart text{ fill: var(--text-3); font-family: var(--font-sans); font-size: 11px; }
.stGridLine{ stroke: var(--divider); }
.stTrendLine{ stroke: var(--brand); }
/* Flat line, no tinted area: same language as the Home charts. */
.stFillA{ stop-color: var(--brand); stop-opacity: 0; }
.stFillB{ stop-color: var(--brand); stop-opacity: 0; }
.stDot{ fill: var(--surface); stroke: var(--brand); }
.stDot.isSelected{ fill: var(--brand); }
.stChartPoint{ cursor: pointer; outline: none; }
.stChartPoint:focus-visible .stDot{ stroke-width: 3; }
.stDetails{ display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-lg); color: var(--text); font-size: var(--fs-14); font-weight: 500; text-align: left; }
.stDetails:hover{ background: var(--bg-subtle); }
.stDetails small{ display: block; color: var(--text-3); font-size: var(--fs-12); font-weight: 400; text-transform: capitalize; }
.stDetailsArrow{ color: var(--text-3); font-size: 18px; }

/* Ore lavorate */
.stHoursBody{ display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; }
.stHoursTotal strong{ display: block; color: var(--text); font-size: var(--fs-28); font-weight: 600; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.stHoursTotal span{ color: var(--text-3); font-size: var(--fs-12); }
.stRankingViewport{ position: relative; flex: 1 1 auto; min-height: 0; max-height: 360px; overflow: auto; }
.stRankingList{ display: grid; margin: 0; padding: 0; list-style: none; }
.stRankingList li{ display: grid; grid-template-columns: 22px 32px minmax(0, 1fr); align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--divider); }
.stRankingList li:first-child{ border-top: 0; }
.stRank{ color: var(--text-3); font-size: var(--fs-12); font-variant-numeric: tabular-nums; text-align: right; }
.stAvatar{
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: hsl(var(--av-h, 220) calc(var(--av-s, 16%) * .9) 47%) !important;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.stRankData{ display: grid; gap: 4px; min-width: 0; }
.stRankData > div:first-child{ display: flex; justify-content: space-between; gap: 10px; }
.stRankData strong{ overflow: hidden; color: var(--text); font-size: var(--fs-13); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.stRankData > div:first-child span{ color: var(--text); font-size: var(--fs-13); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stBarTrack{ height: 4px; border-radius: 999px; background: var(--bg-muted); overflow: hidden; }
.stBarTrack i{ display: block; height: 100%; border-radius: inherit; background: var(--success-solid); }
.stRankData small{ color: var(--text-3); font-size: var(--fs-12); }

/* Mappa */
.stMapCard{ position: relative; min-height: 360px; overflow: hidden; }
.stMapEmpty,
.stMapLoading{ display: grid; place-items: center; gap: 10px; min-height: 280px; color: var(--text-2); font-size: var(--fs-14); text-align: center; }
.stMapEmpty button{ height: 32px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); color: var(--text); font-size: var(--fs-13); font-weight: 500; }
.stMapPin span{ display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid #fff; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 600; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.leaflet-container{ font-family: var(--font-sans) !important; background: var(--surface-inset) !important; border-radius: var(--r-lg); }
/* Opaque overlapping tiles must not brighten their shared edges at fractional zoom. */
#statisticsView .leaflet-container img.leaflet-tile{ mix-blend-mode: normal; }
:root[data-theme="dark"] .leaflet-tile{ filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.7); }
:root[data-theme="dark"] .leaflet-control-attribution{ background: rgba(0, 0, 0, .55) !important; color: var(--text-2) !important; }
:root[data-theme="dark"] .leaflet-control-attribution a{ color: var(--text) !important; }
.leaflet-bar a{ background: var(--surface-raised) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-popup-content-wrapper,
.leaflet-popup-tip{ background: var(--surface-raised) !important; color: var(--text) !important; box-shadow: var(--shadow-pop) !important; }

/* Skeletons */
.stSkeleton{ flex: 1 1 auto; min-height: 180px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--bg-muted) 0, var(--bg-subtle) 60px, var(--bg-muted) 120px) var(--bg-muted); background-size: 480px 100%; animation: uiShimmer 1.3s linear infinite; }

/* Payroll detail dialog */
.stDetailDialog{
  width: min(720px, calc(100vw - 48px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 48px));
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-xl);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.stDetailDialog[open]{ display: flex; flex-direction: column; }
.stDialogHead{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  padding: 18px 16px 14px 24px;
  border-bottom: 1px solid var(--divider);
}
.stDialogHead > div{ min-width: 0; }
.stDialogHead h2{ margin: 0; color: var(--text); font-size: var(--fs-18); font-weight: 600; line-height: 1.35; }
.stDialogClose{
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  color: var(--text-2);
  line-height: 0;
}
.stDialogClose svg{ display: block; width: 18px; height: 18px; }
.stDialogClose:hover{ background: var(--bg-hover); color: var(--text); }
/* Both flex ancestors must shrink, otherwise the table grows beyond the dialog. */
.stDetailDialog > [data-detail-body]{ display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.stDialogSummary{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  padding: 18px 24px 16px;
  color: var(--text-2);
  font-size: var(--fs-14);
}
.stDialogSummary > span{ text-transform: capitalize; }
.stDialogSummary strong{ color: var(--text); font-size: var(--fs-20); line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stDetailNote{ flex: 0 0 auto; margin: 0; padding: 0 24px 16px; color: var(--text-3); font-size: var(--fs-12); line-height: 1.45; }
.stDetailScroller{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 0 24px 16px;
}
.stDetailScroller table{ width: 100%; table-layout: fixed; }
.stDetailScroller th{
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 0;
  background: var(--surface-raised);
  color: var(--text-3);
  box-shadow: inset 0 -1px 0 var(--divider);
  font-size: var(--fs-12);
  font-weight: 500;
  text-align: left;
}
.stDetailScroller td{ padding: 10px 0; border-bottom: 1px solid var(--divider); vertical-align: middle; color: var(--text); font-size: var(--fs-14); }
.stDetailScroller tr:last-child td{ border-bottom: 0; }
.stDetailScroller th:first-child,
.stDetailScroller td:first-child{ padding-right: 16px; }
.stDetailScroller th:last-child,
.stDetailScroller td:last-child{ width: 38%; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stDetailDialog .stPerson{ display: flex; align-items: center; gap: 12px; min-width: 0; }
.stDetailDialog .stPerson .stAvatar{ flex: 0 0 32px; }
.stDetailDialog .stPerson > span:last-child{ min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px){
  .stDetailDialog{ width: calc(100vw - 24px); max-height: calc(100dvh - 24px); }
  .stDialogHead{ padding: 14px 12px 12px 16px; }
  .stDialogSummary{ padding: 14px 16px; }
  .stDetailNote{ padding: 0 16px 12px; }
  .stDetailScroller{ padding: 0 16px 16px; }
  .stDetailScroller td{ font-size: var(--fs-13); }
  .stDetailScroller th:first-child,
  .stDetailScroller td:first-child{ padding-right: 10px; }
  .stDetailDialog .stPerson{ gap: 8px; }
}

@media (max-width: 1100px){ .stGrid{ grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px){ .stPeopleBody{ grid-template-columns: minmax(0, 1fr); justify-items: center; } .stLegend{ width: 100%; } }
.stMapCard{ grid-column: span 1; }
.stMapWrap{ position: relative; flex: 1 1 auto; min-height: 320px; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-inset); }
.stMap{ position: absolute; inset: 0; }
.stMapEmpty{ position: absolute; inset: 0; }
.stMapEmpty:empty{ display: none; }
.stMapShade{ display: none; }
.stMapPopup > div{ display: flex; align-items: center; gap: 10px; }
.stMapPopup strong{ display: block; color: var(--text); font-size: var(--fs-13); }
.stMapPopup small{ color: var(--text-2); font-size: var(--fs-12); }
.stScrollBottom::after,
.stScrollTop::before{ content: none; }
