/* Base: reset, tipografia Helvetica Neue (DIRECTION §3), layout app, utilità */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.4;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0.5em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Probe CSS lvh (legge 6): --vh-l letto da JS via getComputedStyle, mai window.innerHeight */
.vh-probe { position: fixed; top: 0; left: 0; width: 0; height: 100lvh; visibility: hidden; pointer-events: none; }

/* Layout app: una colonna, cornice su desktop */
#app {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
}
.stage { position: absolute; inset: 0; overflow: hidden; }
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  will-change: transform, opacity;
  overflow: hidden;
}
.screen__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 0 var(--gutter) var(--tabbar-space);
  padding-left: max(var(--gutter), var(--safe-left));
  padding-right: max(var(--gutter), var(--safe-right));
  scrollbar-width: none;
}
.screen__scroll::-webkit-scrollbar { display: none; }
.screen--notab .screen__scroll { padding-bottom: calc(1.5em + var(--safe-bottom)); }
.screen--ink { background: var(--ink); color: var(--ink-fg); }
.screen[aria-hidden="true"] { pointer-events: none; }

@media (min-width: 992px) {
  body { background: #E4E4E1; }
  html[data-theme-status="dark"] body { background: #000; }
  #app {
    max-width: 30em;
    height: calc(100svh - 4em);
    min-height: 0;
    margin: 2em auto;
    border-radius: 3em;
    box-shadow: 0 30px 80px rgba(0,0,0,.25);
    overflow: hidden;
  }
}

/* Tipografia — scala em (DIRECTION §3) */
.t-hero { font-size: 3.5em; font-weight: 300; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.t-kpi { font-size: 2.5em; font-weight: 300; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.t-large { font-size: 2em; font-weight: 300; line-height: 1.1; letter-spacing: -0.015em; }
.t-1 { font-size: 1.5em; font-weight: 300; line-height: 1.15; }
.t-2 { font-size: 1.25em; font-weight: 400; line-height: 1.2; }
.t-3 { font-size: 1.0625em; font-weight: 500; line-height: 1.25; }
.t-card { font-size: 0.9375em; font-weight: 400; line-height: 1.3; }
.t-body { font-size: 1em; }
.t-label { font-size: 0.75em; color: var(--muted); letter-spacing: 0.01em; }
.t-caption { font-size: 0.6875em; color: var(--muted-2); letter-spacing: 0.01em; }
.t-mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.accent-text { color: var(--accent-text); }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
.w500 { font-weight: 500; }
.w300 { font-weight: 300; }

/* Spaziatura */
.stack > * + * { margin-top: 0.75em; }
.stack-lg > * + * { margin-top: 1.25em; }
.row-flex { display: flex; align-items: center; gap: 0.5em; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 0.75em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625em; }
.mt-1 { margin-top: 1em; } .mt-2 { margin-top: 1.5em; } .mt-3 { margin-top: 2em; }
.mb-1 { margin-bottom: 1em; }
.hr-dash { border: 0; border-top: 1px dashed var(--line); margin: 0.75em 0; }
.hidden { display: none !important; }

/* Icone */
.icon { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 1em; height: 1em; }
.icon--lg { width: 1.5em; height: 1.5em; }
.icon--fill { fill: currentColor; stroke: none; }

/* Reduced motion: tutto in crossfade (DIRECTION §5) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.15s !important; scroll-behavior: auto !important; }
}
html[data-reduce-motion="true"] *, html[data-reduce-motion="true"] *::before, html[data-reduce-motion="true"] *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.15s !important; }
html[data-large-text="true"] { --size-font: calc(var(--size-container) / (var(--size-container-ideal) / var(--size-unit)) * 1.15); }
