/* Reset, tipografia e struttura della pagina */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh);
  min-height: 100dvh;
}

h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 600; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
p { margin: 0; }

a { color: var(--link); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.95em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 40px; height: 40px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }

.skip-link {
  position: absolute; left: var(--sp-4); top: -100px; z-index: var(--z-toast);
  background: var(--surface); color: var(--text); padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
}
.skip-link:focus { top: var(--sp-2); }

/* ---------- struttura: sidebar ≥768px, barra in basso sotto ---------- */

.shell { display: block; }

.sidebar { display: none; }

.main-col { min-width: 0; }

.main {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--bottomnav-h) + var(--sp-5) + env(safe-area-inset-bottom));
}

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-nav);
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-muted); text-decoration: none; font-size: var(--fs-xs); font-weight: 500;
  min-height: 48px;
}
.bottom-link[aria-current="page"] { color: var(--link); font-weight: 600; box-shadow: inset 0 3px 0 var(--primary); }

.demo-banner {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-2) var(--sp-4);
  background: var(--warn-bg); color: var(--warn-text);
  border-bottom: 1px solid var(--warn-border);
  font-size: var(--fs-sm);
}
.demo-line { display: flex; align-items: flex-start; gap: var(--sp-2); }
.demo-line .icon { margin-top: 3px; }

.bare-main { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-4); }

@media (min-width: 768px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }

  .sidebar {
    display: flex; flex-direction: column; gap: var(--sp-4);
    position: sticky; top: 0; height: 100dvh;
    padding: var(--sp-4) var(--sp-3);
    background: var(--surface); border-right: 1px solid var(--border);
  }
  .brand { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); font-weight: 700; line-height: 1.2; color: var(--link); }
  .brand span { color: var(--text); font-size: var(--fs-sm); }
  .nav { display: flex; flex-direction: column; gap: var(--sp-1); }
  .logout { margin-top: auto; }

  .nav-link {
    display: flex; align-items: center; gap: var(--sp-3); width: 100%;
    min-height: var(--control-h); padding: 0 var(--sp-3);
    border: 0; border-radius: var(--radius-sm); background: none;
    color: var(--text-muted); font: inherit; font-size: var(--fs-sm); font-weight: 500;
    text-decoration: none; cursor: pointer; text-align: left;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  }
  .nav-link:hover { background: var(--surface-2); color: var(--text); }
  .nav-link[aria-current="page"] { background: var(--row-selected); color: var(--text); font-weight: 600; }

  .bottom-nav { display: none; }
  .main { padding: var(--sp-5) var(--sp-5) var(--sp-6); }
}

@media (min-width: 1024px) {
  .main { padding: var(--sp-6) var(--sp-6) var(--sp-6); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
