/* GROOT - foglio di stile unico. Token dal design handoff (docs/site-redesign).
   data-theme su <html> viene impostato da uno script inline in <head>, prima del primo disegno. */

:root,
[data-theme="light"] {
  --bg: #F8F7F2;
  --surface: #FFFFFF;
  --ink: #2F3437;
  --muted: #5C6166;
  --line: #E2DDD1;
  --ph: #ECE8DD;
  --grid: #E2DDD1;
  --accent: #2E7D32;
  --accent-hover: #1B5E20;
  --accent-active: #144617;
  --tint: #C8E6C9;
  --tint-ink: #1B5E20;
  --on-accent: #FFFFFF;
  --danger: #C62828;
  --shadow-modal: 0 24px 60px rgba(47, 52, 55, .22);
  --scrim: rgba(20, 22, 23, .55);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #1A1D1F;
  --surface: #222628;
  --ink: #EEEBE3;
  --muted: #A7ABAE;
  --line: #363B3F;
  --ph: #2C3134;
  --grid: #3A3F43;
  --accent: #6CC070;
  --accent-hover: #8FD493;
  --accent-active: #A9E0AC;
  --tint: #1F3A23;
  --tint-ink: #B9E4BB;
  --on-accent: #0F2412;
  --danger: #FF6B5E;
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, .55);
  --scrim: rgba(20, 22, 23, .55);
  color-scheme: dark;
}

:root {
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --page-x: 80px;
  --section-gap: 104px;
  --app-section-gap: 64px;
  --tap: 44px;
}

@media (max-width: 1100px) {
  :root { --page-x: 40px; }
}

@media (max-width: 767px) {
  :root {
    --page-x: 20px;
    --section-gap: 56px;
    --app-section-gap: 40px;
  }
}

/* ---------- Base ---------- */

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

/* Il CSS d'autore (display:grid/flex) vincerebbe sulla regola [hidden] del browser. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
  margin: 0;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--tint-ink);
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  flex: none;
  display: block;
}

.num {
  font-variant-numeric: tabular-nums;
}

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

.muted {
  color: var(--muted);
}

/* ---------- Pulsanti ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease-out, color 120ms ease-out, border-color 120ms ease-out;
}

.btn:hover {
  text-decoration: none;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}

.btn--primary:active {
  background: var(--accent-active);
  border-color: var(--accent-active);
}

.btn--secondary {
  border-color: var(--ink);
  color: var(--ink);
}

.btn--secondary:hover {
  background: var(--tint);
  color: var(--ink);
}

.btn--ghost {
  color: var(--ink);
}

.btn--ghost:hover {
  background: var(--ph);
  color: var(--ink);
}

.btn--ok,
.btn--ok:hover {
  background: var(--tint);
  border-color: var(--tint);
  color: var(--tint-ink);
}

.btn--error,
.btn--error:hover {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn--busy,
.btn:disabled {
  background: var(--ph);
  border-color: var(--ph);
  color: var(--muted);
  cursor: progress;
}

.btn--ok:disabled {
  background: var(--tint);
  border-color: var(--tint);
  color: var(--tint-ink);
  cursor: default;
}

.btn--icon {
  width: 44px;
  padding: 0;
}

.label-short {
  display: none;
}

/* ---------- Barra superiore ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px var(--page-x);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.logo:hover {
  color: var(--ink);
  text-decoration: none;
}

.logo .icon {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-switch {
  display: inline-flex;
  border: 1px solid var(--line);
}

.theme-switch__opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.theme-switch__opt + .theme-switch__opt {
  border-left: 1px solid var(--line);
}

.theme-switch__opt.is-active {
  background: var(--tint);
  color: var(--tint-ink);
}

/* ---------- Titoli e linea verde ---------- */

.rule {
  display: block;
  width: 64px;
  height: 4px;
  margin-top: 16px;
  background: var(--accent);
}

.section-title {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.015em;
}

.section-title::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  margin-top: 16px;
  background: var(--accent);
}

.subsection-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.subsection-title::after {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  margin-top: 10px;
  background: var(--accent);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

/* ---------- Riquadri ---------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.card--tint {
  background: var(--tint);
  border-color: var(--tint);
}

.card--tint .metric__label,
.card--tint .metric .icon,
.card--tint .big-stat__label,
.card--tint .card-head__meta {
  color: var(--tint-ink);
}

.card--highlight {
  border: 1.5px solid var(--accent);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.card-head__meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.divider {
  height: 1px;
  background: var(--line);
}

.card-label {
  font-size: 15px;
  font-weight: 700;
}

/* ---------- Pillola di stato ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.pill--on {
  background: var(--tint);
  color: var(--tint-ink);
}

.pill--on::before {
  background: var(--accent);
}

.pill--off {
  border: 1px solid var(--line);
  color: var(--muted);
}

.pill--off::before {
  border: 1.5px solid currentColor;
}

.line-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
}

/* ---------- Metriche ---------- */

.metrics {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric .icon {
  color: var(--muted);
}

.metric__label {
  flex: 1;
  font-size: 15px;
  color: var(--muted);
}

.metric__value {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.metric--danger .icon,
.metric--danger .metric__value {
  color: var(--danger);
}

.badge-low {
  padding: 2px 6px;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.big-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 20px;
}

.big-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.big-stat__label {
  font-size: 14px;
  color: var(--muted);
}

.big-stat__value {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: var(--accent);
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.big-stat__unit {
  font-size: 22px;
  letter-spacing: 0;
}

.big-stat__value--ink {
  color: var(--ink);
}

.big-stat--danger .big-stat__value {
  color: var(--danger);
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.live-indicator::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--tint);
}

/* ---------- Foto ---------- */

.photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--ph);
}

/* ---------- Stati: vuoto, errore, non autorizzato, caricamento ---------- */

.empty-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  border: 1px dashed var(--line);
  text-align: center;
}

.empty-box .icon {
  color: var(--accent);
}

.empty-box__title {
  font-size: 17px;
  font-weight: 700;
}

.empty-box__text {
  font-size: 14px;
  color: var(--muted);
}

.state-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  max-width: 720px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.state-box__icon {
  color: var(--accent);
}

.state-box--error .state-box__icon {
  color: var(--danger);
}

.state-box__title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.state-box__text {
  font-size: 17px;
  color: var(--muted);
}

.loading {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.loading__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(var(--skeleton-cols, 3), 1fr);
  gap: 24px;
}

.skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.skeleton span {
  display: block;
  height: 14px;
  background: var(--ph);
  animation: pulsazione 1.2s ease-in-out infinite;
}

.skeleton span:first-child {
  width: 45%;
  height: 22px;
}

.skeleton span:nth-child(2) {
  width: 85%;
}

.skeleton span:nth-child(3) {
  width: 70%;
}

.skeleton span:nth-child(4) {
  height: 72px;
}

@keyframes pulsazione {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton span {
    animation: none;
  }
}

/* ---------- Pagina pubblica ---------- */

.public-main {
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
  padding: 80px var(--page-x) var(--section-gap);
}

.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 72px;
  align-items: center;
}

.hero__display {
  font-size: 132px;
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.hero__sub {
  margin-top: 24px;
  font-size: 52px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.hero .rule {
  width: 96px;
  margin-top: 28px;
}

.hero__lead {
  margin-top: 28px;
  max-width: 34em;
  font-size: 20px;
  line-height: 1.5;
  color: var(--muted);
}

.hero__photo {
  height: 440px;
  margin: 0;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.problem-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.problem {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
}

.problem .icon {
  color: var(--accent);
}

.levels {
  display: grid;
  grid-template-columns: 1fr 48px 1fr 48px 1fr;
  align-items: stretch;
}

.level {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.level__photos {
  display: grid;
  grid-template-columns: repeat(var(--photo-cols, 1), 1fr);
  grid-template-rows: 150px;
  gap: 12px;
}

.level__photos .photo {
  height: 150px;
  min-width: 0;
}

.level__cloud {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
  border: 1px dashed var(--line);
  color: var(--accent);
}

.level__num {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.level__title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.level__text {
  font-size: 16px;
  color: var(--muted);
}

.level-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.distinct-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.distinct {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 32px 36px;
  background: var(--tint);
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
}

.distinct__num {
  font-size: 14px;
  color: var(--tint-ink);
}

.distinct .icon {
  color: var(--tint-ink);
}

.numbers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 24px;
}

.number {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.number__value {
  color: var(--accent);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.number__label {
  font-size: 14px;
  color: var(--muted);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  font-size: 19px;
  line-height: 1.4;
}

.step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 700;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px var(--page-x);
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}

.site-footer__left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.site-footer__left .icon {
  color: var(--accent);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.link-button:hover {
  color: var(--tint-ink);
  text-decoration: underline;
}

/* Sezione contatti */

.contact {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 48px;
  background: var(--tint);
}

.contact .section-title::after {
  background: var(--tint-ink);
}

.contact__text {
  max-width: 44em;
  margin-top: 24px;
  font-size: 19px;
  line-height: 1.5;
}

.contact__cta {
  flex: none;
}

.site-footer__links {
  display: inline-flex;
  align-items: center;
  gap: 24px;
  font-weight: 700;
}

/* ---------- Area riservata ---------- */

.tabs {
  display: flex;
  gap: 8px;
  padding: 0 var(--page-x);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
}

.tab:hover {
  color: var(--ink);
  text-decoration: none;
}

.tab--active {
  border-bottom-color: var(--accent);
  color: var(--ink);
  font-weight: 700;
}

.tab--active .icon {
  color: var(--accent);
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: var(--app-section-gap);
  padding: 48px var(--page-x) 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.page-title::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  margin-top: 16px;
  background: var(--accent);
}

.page-meta {
  font-size: 16px;
  color: var(--muted);
}

.app-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.content {
  display: flex;
  flex-direction: column;
  gap: var(--app-section-gap);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* Elenco erogazioni di oggi */

.eroga-list {
  display: flex;
  flex-direction: column;
}

.eroga-row {
  display: grid;
  grid-template-columns: 86px 52px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}

.eroga-row__time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.eroga-row__litri {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart__label {
  font-size: 14px;
  color: var(--muted);
}

.chart__canvas {
  position: relative;
  height: 140px;
}

.chart__canvas--tall {
  height: 200px;
}

/* Tabella comandi (desktop) e lista (mobile) */

.cmd-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
}

.cmd-table {
  width: 100%;
  border-collapse: collapse;
}

.cmd-table th {
  padding: 14px 20px;
  border-bottom: 1.5px solid var(--ink);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.cmd-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}

.cmd-table tbody tr:last-child td {
  border-bottom: 0;
}

.cmd-table tbody tr:hover {
  background: var(--bg);
}

.cmd-table td:first-child {
  font-variant-numeric: tabular-nums;
}

.esito {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.esito--ok {
  color: var(--accent);
}

.esito--ko {
  color: var(--danger);
}

.cmd-list {
  display: none;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cmd-list li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.cmd-list__top {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.cmd-list__top .esito {
  margin-left: auto;
}

.cmd-list__sub {
  font-size: 14px;
  color: var(--muted);
}

/* Controlli */

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.control-row__name {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 18px;
  font-weight: 700;
}

.control-row__error {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 400;
}

.control-row__buttons {
  display: flex;
  gap: 10px;
}

.control-row__buttons .btn {
  min-width: 112px;
}

/* Sensori */

.sensor-card {
  padding: 36px 40px;
  gap: 28px;
}

.sensor-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

/* Storico */

.total-card {
  gap: 8px;
}

.total-card__label {
  font-size: 15px;
  color: var(--muted);
}

.total-card__value {
  color: var(--accent);
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.total-card__unit {
  margin-left: 4px;
  font-size: 28px;
  letter-spacing: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chart__caption {
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Finestra modale ---------- */

.modal {
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow-modal);
}

.modal::backdrop {
  background: var(--scrim);
}

.modal__body {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px 36px;
}

.modal__handle {
  display: none;
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal__title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.modal__close {
  width: 44px;
  height: 44px;
  margin: -8px -12px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal__close:hover {
  background: var(--ph);
  color: var(--ink);
}

.modal__steps {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.modal__steps span {
  width: 28px;
  height: 4px;
  background: var(--line);
}

.modal__steps span.is-done {
  background: var(--accent);
}

.modal__steps em {
  margin-left: 8px;
  font-style: normal;
}

.modal__text {
  font-size: 20px;
  line-height: 1.45;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 15px;
  font-weight: 700;
}

.field input {
  height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--muted);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.field__help {
  font-size: 14px;
  color: var(--muted);
}

.field--error input,
.field--error input:focus-visible {
  border: 2px solid var(--danger);
  outline-color: var(--danger);
}

.field--error .field__help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--danger);
}

/* ---------- Tablet ---------- */

@media (max-width: 1100px) {
  .hero__display { font-size: 104px; }
  .hero__sub { font-size: 42px; }
  .live-grid,
  .grid-3,
  .problem-grid,
  .steps { grid-template-columns: repeat(2, 1fr); }
  .numbers { grid-template-columns: repeat(3, 1fr); }
  .levels {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .level-arrow { transform: rotate(90deg); height: 36px; }
  .sensor-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
  .topbar { padding-top: 14px; padding-bottom: 14px; }
  .logo { font-size: 20px; }
  .topbar-actions { gap: 8px; }
  .label-long { display: none; }
  .label-short { display: inline; }
  .topbar .btn--hide-mobile { display: none; }
  .btn--logout { width: 44px; padding: 0; }

  .section-title { font-size: 28px; }
  .section-title::after { width: 48px; margin-top: 12px; }
  .subsection-title { font-size: 20px; }
  .section-head { margin-bottom: 24px; }

  .public-main { padding-top: 40px; }
  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .hero__display { font-size: 72px; }
  .hero__sub { margin-top: 16px; font-size: 30px; }
  .hero .rule { width: 64px; margin-top: 20px; }
  .hero__lead { margin-top: 20px; font-size: 17px; }
  .hero__photo { height: 240px; }

  .live-grid,
  .grid-2,
  .grid-3,
  .distinct-grid,
  .steps { grid-template-columns: 1fr; gap: 16px; }

  .problem-grid { grid-template-columns: 1fr; gap: 0; }
  .problem {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 18px 0;
    font-size: 18px;
  }

  .distinct { padding: 22px 20px; font-size: 20px; }
  .numbers { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .number:first-child { grid-column: 1 / -1; }
  .number__value { font-size: 32px; }
  .step { font-size: 17px; }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .contact {
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
    padding: 28px 20px;
  }
  .contact__text { margin-top: 16px; font-size: 17px; }

  .card-title { font-size: 20px; }
  .big-stat__value { font-size: 36px; }
  .big-stat__unit { font-size: 18px; }

  /* Navigazione area riservata: barra fissa in basso */
  .tabs {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20;
    gap: 0;
    padding: 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: var(--surface);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    height: 68px;
    border-bottom: 0;
    border-top: 3px solid transparent;
    font-size: 13px;
  }
  .tab .icon { width: 22px; height: 22px; }
  .tab--active {
    border-top-color: var(--accent);
    color: var(--accent);
  }

  .app-main { padding: 24px var(--page-x) calc(40px + 68px); }
  .page-title { font-size: 32px; }
  .page-title::after { width: 48px; margin-top: 12px; }
  .page-meta { font-size: 15px; }

  .eroga-row { grid-template-columns: 76px 44px 1fr; }

  .cmd-table-wrap { display: none; }
  .cmd-list { display: block; }

  .control-row {
    flex-direction: column;
    align-items: stretch;
    padding: 20px;
  }
  .control-row__buttons .btn {
    flex: 1;
    min-width: 0;
    padding: 0 8px;
  }

  .sensor-card { padding: 24px 20px; }
  .total-card__value { font-size: 48px; }
  .total-card__unit { font-size: 22px; }
  .chart__canvas--tall { height: 160px; }

  .state-box { padding: 24px 20px; }
  .state-box__title { font-size: 22px; }

  .skeleton-grid { grid-template-columns: 1fr; }

  /* Modale come foglio dal basso */
  .modal {
    width: 100%;
    max-height: 92vh;
    margin: auto 0 0 0;
  }
  .modal__body { padding: 12px 20px 24px; }
  .modal__handle {
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto 8px;
    background: var(--line);
  }
  .modal__title { font-size: 22px; }
  .modal__actions { flex-direction: column-reverse; }
  .modal__actions .btn { width: 100%; }
}
