:root {
  /* SARIAL — linguaggio visivo condiviso (landing · app · mobile premium, palette «premium» landing) */
  --sarial-deep: #050816;
  --sarial-navy: #0a0e14;
  --sarial-glow-cyan: rgba(56, 189, 248, 0.26);
  --sarial-glow-violet: rgba(129, 140, 248, 0.22);
  --sarial-glow-teal: rgba(45, 212, 191, 0.18);
  --sarial-glass-edge: rgba(129, 140, 248, 0.28);
  --bg: #eef3fb;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --ink: #12233f;
  --muted: #607089;
  --brand: #1758bb;
  --brand-2: #0e2f71;
  --ok: #1d8f57;
  --warn: #c88610;
  --danger: #d7384d;
  --shadow: 0 18px 44px rgba(17, 35, 68, 0.12);
  --radius: 20px;
  --dark-bg: #020617;
  --accent: #5eead4;
  --accent-2: #a78bfa;
  --accent-hot: #22d3ee;
  --text-muted: #94a3b8;
  /* Logo scudo Sarial (SVG): no currentColor — contrasto su dark/light e Safari iOS */
  --sarial-logo-shield: #0e2f71;
  --sarial-logo-check: #ffffff;
  --ui-font-display: Sora, Manrope, sans-serif;
  --ui-font-body: Manrope, sans-serif;
  --ui-radius-sm: 12px;
  --ui-radius-md: 18px;
  --ui-radius-lg: 22px;
  --ui-radius-xl: 26px;
  --ui-space-1: 0.35rem;
  --ui-space-2: 0.55rem;
  --ui-space-3: 0.8rem;
  --ui-space-4: 1rem;
  --ui-space-5: 1.25rem;
  --ui-space-6: 1.6rem;
  --ui-shadow-soft: 0 8px 24px rgba(2, 8, 23, 0.12);
  --ui-shadow-raised: 0 16px 40px rgba(2, 8, 23, 0.2);
  /* Dashboard mock (landing-preview): vetro + bloom indaco */
  --mock-shell-shadow:
    0 24px 56px rgba(2, 6, 23, 0.52),
    0 0 72px rgba(79, 70, 229, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --mock-widget-bg: linear-gradient(165deg, rgba(2, 6, 23, 0.52), rgba(15, 23, 42, 0.68));
  --mock-widget-border: rgba(56, 189, 248, 0.22);
  --mock-shell-border: rgba(129, 140, 248, 0.38);
}

.sarial-logo-svg {
  min-width: 1.5rem;
  min-height: 1.5rem;
  flex-shrink: 0;
  display: block;
  overflow: visible;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* SARIAL Icon Pack — SVG inline (navigazione, dashboard, export); colore = testo circostante */
.sarial-ico {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  color: inherit;
}
svg.sarial-ico {
  overflow: visible;
}

* { box-sizing: border-box; }
html {
  color-scheme: light dark;
}
html[data-theme="light"] {
  color-scheme: light;
  --sarial-logo-shield: #0e2f71;
  --sarial-logo-check: #ffffff;
}
html[data-theme="dark"] {
  color-scheme: dark;
  /* Come il logo ufficiale: scudo blu brand + spunta bianca (leggibile su UI scura) */
  --sarial-logo-shield: #1758bb;
  --sarial-logo-check: #ffffff;
}

html[data-theme="light"] body,
html:not([data-theme]) body {
  margin: 0;
  padding: 0;
  font-family: Manrope, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 120% 78% at 50% -28%, rgba(59, 130, 246, 0.18), transparent 58%),
    radial-gradient(circle at 6% 3%, rgba(16, 185, 129, 0.08), transparent 35%),
    radial-gradient(circle at 94% 18%, rgba(99, 102, 241, 0.1), transparent 38%),
    linear-gradient(180deg, #f7faff 0%, #eef4ff 45%, #e6efff 100%);
}

html[data-theme="dark"] body {
  margin: 0;
  padding: 0;
  font-family: Manrope, sans-serif;
  color: #e2e8f0;
  background:
    radial-gradient(ellipse 110% 85% at 50% -28%, rgba(129, 140, 248, 0.32), transparent 58%),
    radial-gradient(ellipse 70% 50% at 0% 20%, rgba(34, 211, 238, 0.12), transparent 50%),
    radial-gradient(ellipse 65% 45% at 100% 15%, rgba(232, 121, 249, 0.1), transparent 48%),
    radial-gradient(circle at 50% 120%, rgba(59, 130, 246, 0.14), transparent 55%),
    linear-gradient(175deg, #020617 0%, #0f172a 38%, #020617 100%);
}
button, input, select, textarea { font: inherit; }
a { color: var(--brand); text-decoration: none; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.85);
  outline-offset: 2px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  padding: 16px;
}
.sidebar {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%);
  border-radius: 22px;
  color: #fff;
  padding: 18px 14px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}
.brandblock {
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  margin-bottom: 12px;
}
.brandtitle { font-family: Sora, sans-serif; font-weight: 700; font-size: 1.12rem; }
.brandsub { opacity: 0.85; font-size: 0.86rem; }
.nav { display: flex; flex-direction: column; gap: 7px; overflow: auto; padding-right: 4px; }
.nav button {
  text-align: left;
  border: 0;
  background: rgba(255,255,255,0.07);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}
.nav button.active { background: rgba(255,255,255,0.2); }
.sidebar-footer { margin-top: auto; font-size: 0.75rem; opacity: 0.85; padding: 10px; }

.main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.topbar {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-title h1 { margin: 0; font-size: 1.15rem; }
.topbar-title p { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.badge {
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf2ff;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.78rem;
}

.btn {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), #1b72db);
  color: #fff;
  font-weight: 800;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(23, 88, 187, 0.25);
}
.btn.secondary { background: #e9eef8; color: var(--ink); box-shadow: none; }
.btn.danger { background: linear-gradient(135deg, #d7384d, #f34d64); }
.btn.small { padding: 7px 10px; font-size: 0.85rem; border-radius: 10px; }
.btn-glow {
  border: none;
  border-radius: var(--ui-radius-md);
  padding: 0.95rem 1.3rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #0d9488 0%, #1758bb 52%, #2563eb 100%);
  box-shadow: 0 12px 28px rgba(13, 148, 136, 0.35), 0 8px 24px rgba(23, 88, 187, 0.22);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(13, 148, 136, 0.42), 0 12px 32px rgba(37, 99, 235, 0.35);
}
html[data-theme="light"] .btn-glow {
  background: linear-gradient(135deg, #0f766e 0%, var(--brand) 48%, #2563eb 100%);
  box-shadow: 0 10px 22px rgba(23, 88, 187, 0.26), 0 6px 18px rgba(13, 148, 136, 0.18);
}

/* Secondario / outline: login, 2FA, coerente con landing .btn-ghost */
.btn-ghost {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  color: #dbe7fb;
  text-decoration: none;
  padding: 0.95rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.98rem;
  font-family: inherit;
  line-height: 1.25;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  box-sizing: border-box;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.42);
}
.btn-ghost.small {
  padding: 0.62rem 1.1rem;
  font-size: 0.88rem;
  border-radius: 10px;
}
.btn-ghost:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.65);
  outline-offset: 2px;
}

.view {
  background: transparent;
  display: grid;
  gap: 14px;
}
.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  overflow: hidden;
}
.panel h2 { margin: 0 0 12px; font-size: 1.08rem; }
.panel h3 { margin: 0 0 10px; font-size: 0.95rem; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }

.stat {
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(244,248,255,0.95));
  border: 1px solid #e8effc;
  border-radius: 16px;
  padding: 12px;
}
.stat .label { color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.stat .value { font-size: 1.7rem; font-weight: 800; margin-top: 3px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}
th, td { padding: 10px 12px; border-bottom: 1px solid #edf2fb; text-align: left; font-size: 0.9rem; vertical-align: top; }
th { background: #f2f6ff; color: #28496e; font-weight: 800; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
.table-wrap { max-height: 360px; overflow: auto; border-radius: 12px; border: 1px solid #e7eefc; }

.pill { border-radius: 999px; padding: 5px 9px; font-size: 0.76rem; font-weight: 800; display: inline-flex; gap: 6px; align-items: center; }
.pill.ok { background: #e7f7ef; color: var(--ok); }
.pill.warn { background: #fff4da; color: var(--warn); }
.pill.danger { background: #ffe4e8; color: var(--danger); }
.pill.info { background: #e6efff; color: var(--brand); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar h2 { margin: 0; }
.toolbar input, .toolbar select, .toolbar textarea,
.form-grid input, .form-grid select, .form-grid textarea {
  border: 1px solid #d7e3f7;
  background: #fff;
  border-radius: 11px;
  padding: 10px 12px;
  color: var(--ink);
}
.toolbar input, .toolbar select { min-width: 170px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: grid; gap: 6px; font-size: 0.82rem; font-weight: 700; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
}
.temp-card {
  background: linear-gradient(180deg, #fff, #f5f9ff);
  border: 1px solid #e6eefb;
  border-radius: 16px;
  padding: 12px;
}
.temp-card .name { font-weight: 800; }
.temp-card .t { font-size: 2rem; font-weight: 800; margin: 8px 0 10px; }
.temp-card .meta { color: var(--muted); font-size: 0.82rem; }
.temp-card.ok { border-left: 6px solid var(--ok); }
.temp-card.warn { border-left: 6px solid var(--warn); }
.temp-card.alarm { border-left: 6px solid var(--danger); }
.temp-card.offline { border-left: 6px solid #95a6bf; }

.chart {
  background: #fff;
  border: 1px solid #e6eefb;
  border-radius: 14px;
  padding: 8px;
}
.chart svg { width: 100%; height: 220px; display: block; }

.temp-chart-wrap { display: grid; gap: 12px; }
.temp-chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  padding: 4px 0;
}
.temp-chart-filter-label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--muted);
}
.temp-chart-select {
  min-width: min(100%, 280px);
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #dbe5f8;
  background: #fff;
  font-size: 0.95rem;
}

/* Shell tema scuro: il select storico grafo non deve restare “lastra bianca” */
[data-theme="dark"] .app-shell .temp-chart-select {
  border-color: rgba(148, 163, 184, 0.45);
  background-color: rgba(15, 23, 42, 0.94);
  color: #f1f5f9;
}
[data-theme="dark"] .app-shell .temp-chart-select:focus {
  border-color: rgba(96, 165, 250, 0.75);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
  outline: none;
}
[data-theme="dark"] .app-shell .temp-chart-select option {
  background: #0f172a;
  color: #f1f5f9;
}

/* Tablet/phone: stile coerente + frecce custom (Safari/iOS non forza tema chiaro sulla tendina nativa). */
@media (max-width: 1024px) {
  [data-theme="dark"] .app-shell .temp-chart-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.2rem;
    background-color: rgba(15, 23, 42, 0.94);
    background-image:
      linear-gradient(45deg, transparent 50%, #9fb7e8 50%),
      linear-gradient(135deg, #9fb7e8 50%, transparent 50%);
    background-position:
      calc(100% - 16px) calc(50% - 3px),
      calc(100% - 10px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
  }
  html.mobile-app-chrome [data-theme="dark"] .app-shell .temp-chart-select {
    font-size: 16px;
    min-height: 44px;
  }
}

[data-theme="dark"] .app-shell .chart.temp-chart {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.32);
}
.temp-chart-toolbar-hint { margin: 0; max-width: 56ch; font-size: 0.82rem; line-height: 1.35; }
.temp-chart-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.temp-chart-zoom-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  min-height: 2.1rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--shell-brand-fg, #0f172a);
  border: 1px solid var(--shell-glass-border, #dbe5f8);
  background: rgba(148, 163, 184, 0.12);
}
.temp-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 0 4px 4px;
  font-size: 0.82rem;
}
.temp-chart-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.temp-chart-legend__item i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.chart.temp-chart svg.temp-chart-svg,
.temp-chart-wrap .chart.temp-chart svg.temp-chart-svg {
  height: clamp(260px, 42vh, 440px);
  min-height: 260px;
}
.temp-chart-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 280px);
  gap: 10px;
  align-items: stretch;
}
.temp-chart-side {
  border: 1px solid var(--shell-glass-border, #dbe5f8);
  border-radius: 14px;
  padding: 12px;
  background: color-mix(in srgb, var(--shell-table-bg, #f8fbff) 80%, transparent);
}
.temp-chart-side__title {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.temp-chart-side__body {
  margin: 0;
  line-height: 1.45;
  font-size: 0.9rem;
}
.temp-chart-point {
  cursor: pointer;
}
.temp-chart--empty {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 16px;
}
@media (max-width: 640px) {
  .temp-chart-main {
    grid-template-columns: 1fr;
  }
  .temp-chart-zoom-controls {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  background: rgba(255,255,255,0.82);
  border-radius: 24px;
  box-shadow: 0 28px 50px rgba(14, 33, 68, 0.15);
  overflow: hidden;
}
.login-art {
  padding: 28px;
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.55), transparent 42%),
    radial-gradient(circle at 80% 20%, rgba(113,198,255,0.28), transparent 34%),
    linear-gradient(160deg, #184ea7, #102b66 58%, #0a1837);
  color: #fff;
  display: grid;
  align-content: space-between;
  min-height: 520px;
}
.login-art h1 { font-family: Sora, sans-serif; margin: 0; font-size: 2rem; line-height: 1.1; }
.login-art p { opacity: 0.9; max-width: 42ch; }
.feature-list { display: grid; gap: 8px; }
.feature-list div { background: rgba(255,255,255,0.09); border-radius: 12px; padding: 10px 12px; }

.login-form {
  padding: 28px;
  display: grid;
  align-content: center;
  gap: 12px;
}
.login-form h2 { margin: 0; font-size: 1.4rem; }
.login-form p { margin: 0 0 8px; color: var(--muted); }
.login-form label { display: grid; gap: 6px; font-weight: 700; font-size: 0.86rem; color: var(--muted); }
.login-form input {
  border: 1px solid #dbe5f8;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}
.error-box, .success-box {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
}
.error-box { background: #ffe8ec; color: #9b2034; }
.success-box { background: #e7f7ef; color: #1d8f57; }

.inline-list { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.84rem; }

.main-content { flex: 1; min-width: 0; }
.view-content { padding: 18px; }
.mobile-toggle {
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  margin-right: 10px;
  cursor: pointer;
}
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 999;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.login-page-wrap {
  background:
    radial-gradient(ellipse 110% 85% at 50% -28%, rgba(129, 140, 248, 0.32), transparent 58%),
    radial-gradient(ellipse 70% 50% at 0% 20%, rgba(34, 211, 238, 0.12), transparent 50%),
    radial-gradient(ellipse 65% 45% at 100% 15%, rgba(232, 121, 249, 0.1), transparent 48%),
    radial-gradient(circle at 50% 120%, rgba(59, 130, 246, 0.14), transparent 55%),
    linear-gradient(175deg, #020617 0%, #0f172a 38%, #020617 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 26px);
  font-family: var(--ui-font-body);
}
.login-container {
  width: 100%;
  max-width: 470px;
}
.glass-card {
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.82), rgba(15, 23, 42, 0.62));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(129, 140, 248, 0.38);
  border-radius: var(--ui-radius-lg);
  box-shadow:
    0 24px 56px rgba(2, 6, 23, 0.5),
    0 0 80px rgba(79, 70, 229, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.login-box {
  padding: clamp(1.2rem, 2.8vw, 1.8rem);
  color: #e2e8f0;
}
.login-header h2 {
  margin: 12px 0 6px;
  font-size: clamp(1.55rem, 4.8vw, 2rem);
  font-family: var(--ui-font-display);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.login-subtitle {
  color: #9fb0cc;
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.5;
}
.cyber-form { display: grid; gap: var(--ui-space-4); }
.input-group { display: grid; gap: var(--ui-space-2); }
.input-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.cyber-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.input-link {
  color: var(--accent-hot, #22d3ee);
  font-size: 0.76rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  font-weight: 760;
}
.cyber-form input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--ui-radius-sm);
  padding: 12px 13px;
  min-height: 46px;
  background: rgba(3, 12, 30, 0.62);
  color: #ecf2ff;
  font-size: 0.96rem;
  line-height: 1.35;
}
.cyber-form input::placeholder { color: #9caecb; }
.cyber-form input:focus {
  outline: none;
  border-color: rgba(94, 234, 212, 0.85);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.14);
}
.login-submit {
  width: 100%;
  min-height: 48px;
  padding: 0.98rem;
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.login-footer {
  margin-top: 1.1rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.back-btn { width: auto; min-width: 170px; }

/* Login 2FA: scelta Authenticator vs email */
.twofa-method-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.twofa-method-btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 10px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.25;
  min-height: 46px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.twofa-method-btn:hover {
  border-color: rgba(94, 234, 212, 0.4);
  color: #e2e8f0;
}
.twofa-method-btn.is-active {
  border-color: rgba(94, 234, 212, 0.55);
  background: rgba(45, 212, 191, 0.16);
  color: #ecfeff;
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.28);
}
.twofa-panel { margin-bottom: 4px; }
html[data-theme="light"] .twofa-method-btn {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.75);
  color: #475569;
}
html[data-theme="light"] .twofa-method-btn:hover {
  border-color: rgba(23, 88, 187, 0.35);
  color: #0f172a;
}
html[data-theme="light"] .twofa-method-btn.is-active {
  border-color: rgba(23, 88, 187, 0.45);
  background: rgba(23, 88, 187, 0.1);
  color: #0e2f71;
  box-shadow: 0 0 0 1px rgba(23, 88, 187, 0.15);
}

/* Schermata 2FA (e login cyber) su telefono: safe area, niente zoom iOS sugli input, layout leggibile */
@media (max-width: 520px) {
  .login-page-wrap {
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .login-container {
    max-width: 100%;
    width: 100%;
    padding-top: 2.5rem;
  }
  .login-page-wrap .login-aux-bar {
    position: fixed;
    top: max(8px, env(safe-area-inset-top, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    left: auto;
    z-index: 30;
  }
  .glass-card.login-box {
    padding: 1rem 0.9rem 1.15rem;
    border-radius: 16px;
    max-width: 100%;
    box-sizing: border-box;
  }
  .login-header h2 {
    font-size: clamp(1.28rem, 5.5vw, 1.65rem);
    line-height: 1.2;
  }
  .login-subtitle {
    font-size: 0.86rem;
    line-height: 1.5;
    margin-left: auto;
    margin-right: auto;
    max-width: 36ch;
  }
  .twofa-login-email {
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    max-width: 100%;
    line-height: 1.4;
  }
  .twofa-method-row {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }
  .twofa-method-btn {
    min-height: 48px;
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    font-size: 0.9rem;
  }
  .cyber-form input[type="text"],
  .cyber-form input[type="email"],
  .cyber-form input[type="password"] {
    font-size: 16px;
    min-height: 48px;
    box-sizing: border-box;
  }
  .login-submit.btn-glow {
    min-height: 48px;
    box-sizing: border-box;
  }
  .login-page-wrap .login-footer .back-btn {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }
  .login-page-wrap details summary {
    -webkit-tap-highlight-color: transparent;
  }
}

/* Form recupero password (login-shell): stesso ritmo del footer login cyber */
.login-shell .login-form .login-footer {
  margin-top: 1.25rem;
  padding-top: 0.25rem;
}

.landing-page .landing-hero__headline { word-break: normal; }
.landing-page .hero-actions:not(.landing-hero__actions) { flex-wrap: wrap; }

@media (max-width: 1100px) {
  .grid-4, .cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .login-card { grid-template-columns: 1fr; }
  .login-art { min-height: 260px; }
  .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .main-content { width: 100%; }
  .view-content { padding: 12px; }
  .shell .topbar { padding: 10px 12px; }
  .shell .topbar-actions { gap: 8px; }
  .mobile-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    transform: translateX(-100%);
    width: min(84vw, 310px) !important;
  }
  .sidebar.open { transform: translateX(0); }
}

@media (max-width: 768px) {
  .login-box { padding: 18px; }
  .login-shell { padding: 12px; }
  .login-page-wrap .btn,
  .login-page-wrap .btn-glow,
  .login-page-wrap .btn-main,
  .login-page-wrap .btn-ghost { width: 100%; justify-content: center; }
  .landing-page .landing-hero__copy {
    text-align: left;
  }
  .landing-page .hero-actions:not(.landing-hero__actions) {
    max-width: none;
  }
  .landing-page .hero-actions:not(.landing-hero__actions) .btn-main,
  .landing-page .hero-actions:not(.landing-hero__actions) .btn-ghost {
    /* Landing nuova: misure CTA gestite nello style di app-main.js */
    min-height: inherit;
  }
  .app-shell .toolbar > * { flex: 1 1 100%; }
  .app-shell .toolbar > h2 { flex-basis: 100%; }
  .landing-page .features:not(.features--landing) { padding-top: 2.5rem !important; }
}

/* ——— Theme switcher ——— */
.theme-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.35);
  gap: 2px;
  flex-shrink: 0;
}
html[data-theme="light"] .theme-toggle {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.theme-toggle--compact .theme-seg {
  min-width: 2.1rem;
  padding: 0.35rem 0.45rem;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-seg {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.42rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
html[data-theme="light"] .theme-seg {
  color: #475569;
}
.theme-seg:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
}
html[data-theme="light"] .theme-seg:hover {
  color: var(--ink);
  background: rgba(23, 88, 187, 0.08);
}
.theme-seg.is-active {
  background: rgba(45, 212, 191, 0.2);
  color: #ecfeff;
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.42);
}
html[data-theme="light"] .theme-seg.is-active {
  background: rgba(23, 88, 187, 0.15);
  color: var(--brand);
  box-shadow: 0 0 0 1px rgba(23, 88, 187, 0.22);
}

.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.login-shell,
.login-page-wrap {
  position: relative;
}
.login-aux-bar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
}
@media (max-width: 480px) {
  .login-aux-bar {
    top: 0.5rem;
    right: 0.5rem;
  }
  .theme-toggle--compact .theme-seg {
    min-width: 1.85rem;
    padding: 0.32rem 0.35rem;
    font-size: 0.85rem;
  }
}

.login-card--narrow {
  flex-direction: column;
  padding: 2rem;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.text-gradient {
  background: linear-gradient(115deg, #5eead4 0%, #38bdf8 38%, #a78bfa 72%, #e879f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ——— Landing light palette ——— */
html[data-theme="light"] .landing-page {
  background:
    radial-gradient(circle at 8% 4%, rgba(23, 88, 187, 0.12), transparent 40%),
    radial-gradient(circle at 92% 18%, rgba(0, 98, 255, 0.1), transparent 38%),
    linear-gradient(180deg, #f8fafc 0%, #eef2ff 45%, #f1f5f9 100%) !important;
  color: #0f172a !important;
}
html[data-theme="light"] .landing-brandmark__name--hero:not(.text-gradient) {
  color: #0f172a !important;
  text-shadow: 0 2px 28px rgba(23, 88, 187, 0.18) !important;
}
html[data-theme="light"] .landing-hero__bg {
  background:
    radial-gradient(ellipse 100% 70% at 50% -20%, rgba(23, 88, 187, 0.2), transparent 58%),
    radial-gradient(ellipse 55% 45% at 100% 35%, rgba(0, 98, 255, 0.14), transparent 52%),
    radial-gradient(ellipse 50% 42% at 0% 55%, rgba(14, 165, 233, 0.12), transparent 48%),
    radial-gradient(circle at 50% 100%, rgba(23, 88, 187, 0.06), transparent 42%) !important;
}
html[data-theme="light"] .landing-hero__vignette {
  background: radial-gradient(ellipse 95% 85% at 50% 40%, transparent 0%, rgba(248, 250, 252, 0.55) 70%, rgba(241, 245, 249, 0.92) 100%) !important;
}
html[data-theme="light"] .landing-brandmark__name:not(.text-gradient) {
  color: #0f172a !important;
  text-shadow: 0 2px 24px rgba(23, 88, 187, 0.12), 0 1px 0 rgba(255, 255, 255, 0.8) !important;
}
html[data-theme="light"] .landing-brandmark__product {
  color: #1758bb !important;
}
html[data-theme="light"] .landing-brandmark__product--hero {
  color: #1758bb !important;
}
html[data-theme="light"] .landing-brandmark__logo {
  filter: drop-shadow(0 10px 28px rgba(23, 88, 187, 0.25)) drop-shadow(0 4px 12px rgba(14, 165, 233, 0.12)) !important;
}
html[data-theme="light"] .landing-brandmark__logo--hero {
  filter: drop-shadow(0 10px 28px rgba(23, 88, 187, 0.25)) drop-shadow(0 4px 12px rgba(14, 165, 233, 0.12)) !important;
}
html[data-theme="light"] .landing-kicker {
  color: #1758bb !important;
  text-shadow: none !important;
}
html[data-theme="light"] .landing-band--soft {
  background: linear-gradient(180deg, transparent 0%, rgba(241, 245, 249, 0.9) 6%, rgba(241, 245, 249, 0.75) 94%, transparent 100%) !important;
  border-top-color: rgba(15, 23, 42, 0.06) !important;
  border-bottom-color: rgba(15, 23, 42, 0.05) !important;
}
html[data-theme="light"] .landing-band--deep {
  background: linear-gradient(180deg, rgba(238, 242, 255, 0.95) 0%, rgba(241, 245, 249, 0.88) 100%) !important;
  border-top-color: rgba(15, 23, 42, 0.06) !important;
  border-bottom-color: rgba(15, 23, 42, 0.05) !important;
}
html[data-theme="light"] .landing-hero__mesh {
  opacity: 0.25 !important;
}
html[data-theme="light"] .landing-hero__eyebrow {
  color: #475569 !important;
}
html[data-theme="light"] .landing-hero__headline {
  color: #0f172a !important;
}
html[data-theme="light"] .landing-hero__lead {
  color: #475569 !important;
}
html[data-theme="light"] .landing-hero .btn-ghost {
  color: #0f172a !important;
  border-color: rgba(23, 88, 187, 0.35) !important;
  background: rgba(255, 255, 255, 0.88) !important;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06) !important;
}
html[data-theme="light"] .landing-hero .btn-ghost:hover {
  background: rgba(255, 255, 255, 1) !important;
  border-color: rgba(23, 88, 187, 0.5) !important;
}
html[data-theme="light"] .landing-features__title {
  color: #0f172a !important;
}
html[data-theme="light"] .landing-features__lead {
  color: #64748b !important;
}
html[data-theme="light"] .feat-card {
  background: rgba(255, 255, 255, 0.92) !important;
  border-color: rgba(15, 23, 42, 0.08) !important;
}
html[data-theme="light"] .feat-card p {
  color: #475569 !important;
}
html[data-theme="light"] .feat-card h3 {
  color: #0f172a;
}
html[data-theme="light"] .landing-metric {
  background: rgba(255, 255, 255, 0.92) !important;
  border-color: rgba(15, 23, 42, 0.12) !important;
}
html[data-theme="light"] .landing-metric strong {
  background: none !important;
  -webkit-text-fill-color: #0e2f71 !important;
  color: #0e2f71 !important;
}
html[data-theme="light"] .landing-metric span {
  color: #475569;
}
html[data-theme="light"] .landing-section h2,
html[data-theme="light"] .landing-section-head h2 {
  color: #0f172a;
}
html[data-theme="light"] .landing-lead {
  color: #64748b !important;
}
html[data-theme="light"] .landing-cosa-item {
  background: rgba(255, 255, 255, 0.92) !important;
  border-color: rgba(15, 23, 42, 0.1) !important;
}
html[data-theme="light"] .landing-cosa-item h3 {
  color: #0f172a;
}
html[data-theme="light"] .landing-cosa-item p {
  color: #475569;
}
html[data-theme="light"] .landing-timeline li {
  background: rgba(255, 255, 255, 0.92) !important;
  border-color: rgba(15, 23, 42, 0.1) !important;
}
html[data-theme="light"] .landing-timeline-time {
  color: #1758bb !important;
}
html[data-theme="light"] .landing-timeline-body h3 {
  color: #0f172a;
}
html[data-theme="light"] .landing-timeline-body p {
  color: #475569;
}
html[data-theme="light"] .landing-audience-card {
  background: rgba(255, 255, 255, 0.92) !important;
  border-color: rgba(15, 23, 42, 0.1) !important;
}
html[data-theme="light"] .landing-audience-card h3 {
  color: #0f172a;
}
html[data-theme="light"] .landing-audience-card p {
  color: #475569;
}
html[data-theme="light"] .landing-trust-list {
  background: linear-gradient(135deg, rgba(23, 88, 187, 0.1), rgba(219, 234, 254, 0.65)) !important;
  border-color: rgba(23, 88, 187, 0.22) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 36px rgba(15, 23, 42, 0.06) !important;
}
html[data-theme="light"] .landing-trust-list li {
  color: #475569;
}
html[data-theme="light"] .landing-trust-list li::before {
  color: #1758bb !important;
}
html[data-theme="light"] .landing-trust-list strong {
  color: #0f172a;
}
html[data-theme="light"] .landing-metrics::before {
  background: linear-gradient(90deg, transparent, rgba(23, 88, 187, 0.35), transparent) !important;
}
html[data-theme="light"] .landing-faq-item summary::after {
  border-right-color: #94a3b8 !important;
  border-bottom-color: #94a3b8 !important;
}
html[data-theme="light"] .landing-footer a {
  color: #1758bb !important;
  border-bottom-color: transparent !important;
}
html[data-theme="light"] .landing-footer a:hover {
  color: #0e2f71 !important;
  border-bottom-color: rgba(23, 88, 187, 0.35) !important;
}
html[data-theme="light"] .landing-page ::selection {
  background: rgba(23, 88, 187, 0.2);
  color: #0f172a;
}
html[data-theme="light"] .landing-faq-item {
  background: rgba(255, 255, 255, 0.92) !important;
  border-color: rgba(15, 23, 42, 0.1) !important;
}
html[data-theme="light"] .landing-faq-item summary {
  color: #0f172a;
}
html[data-theme="light"] .landing-faq-item[open] summary {
  border-bottom-color: rgba(15, 23, 42, 0.08) !important;
}
html[data-theme="light"] .landing-faq-item p {
  color: #475569;
}
html[data-theme="light"] .landing-page .text-gradient {
  background: linear-gradient(92deg, #0e7490 0%, #1758bb 45%, #0e2f71 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}
/* Wordmark SARIAL hero (light): stesso linguaggio del logo — ciano → blu → viola/magenta, leggibile su fondo chiaro */
html[data-theme="light"] .landing-page .landing-hero__brandmark .landing-brandmark__name--hero.text-gradient {
  background: linear-gradient(115deg, #14b8a6 0%, #0ea5e9 34%, #6366f1 68%, #c026d3 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.92));
}
/* Scudo logo landing (light): blu medio come identity, coerente con dark */
html[data-theme="light"] .landing-page .sarial-logo-svg .sarial-logo-shield {
  fill: #1758bb !important;
}
html[data-theme="light"] .landing-page .sarial-logo-svg .sarial-logo-check {
  stroke: #ffffff !important;
}
html[data-theme="light"] .landing-page .badge-new {
  background: rgba(23, 88, 187, 0.12) !important;
  color: #0e2f71 !important;
  border-color: rgba(23, 88, 187, 0.35) !important;
}
html[data-theme="light"] .landing-footer {
  color: #64748b !important;
  border-top-color: rgba(15, 23, 42, 0.08) !important;
  background: rgba(248, 250, 252, 0.92) !important;
}
html[data-theme="light"] .landing-page .landing-footer__theme {
  border-bottom-color: rgba(15, 23, 42, 0.08) !important;
}
html[data-theme="light"] .landing-page .landing-footer__theme-label {
  color: #64748b !important;
}

.landing-page .landing-cookie-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.landing-page .landing-cookie-menu-btn__ico .sarial-ico {
  display: block;
}

.sidebar-cookie-prefs-btn,
.app-menu-account-cookie-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

html[data-theme="light"] .landing-page .btn-ghost,
html[data-theme="light"] .login-page-wrap .btn-ghost {
  color: #334155 !important;
  border-color: rgba(15, 23, 42, 0.15) !important;
  background: rgba(255, 255, 255, 0.65) !important;
}

/* ——— Login / forgot light ——— */
html[data-theme="light"] .login-page-wrap {
  background:
    radial-gradient(ellipse 120% 78% at 50% -28%, rgba(59, 130, 246, 0.2), transparent 58%),
    radial-gradient(circle at 6% 3%, rgba(16, 185, 129, 0.1), transparent 35%),
    radial-gradient(circle at 94% 18%, rgba(99, 102, 241, 0.12), transparent 38%),
    linear-gradient(180deg, #f7faff 0%, #eef4ff 45%, #e6efff 100%) !important;
}
html[data-theme="light"] .login-page-wrap .glass-card {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.97), rgba(239, 246, 255, 0.98)) !important;
  border-color: rgba(59, 130, 246, 0.22) !important;
  box-shadow: 0 22px 48px rgba(59, 130, 246, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9) !important;
}
html[data-theme="light"] .login-box {
  color: #0f172a !important;
}
html[data-theme="light"] .login-header h2 {
  color: #0f172a;
}
html[data-theme="light"] .login-subtitle {
  color: #64748b !important;
}
html[data-theme="light"] .cyber-form input {
  background: #fff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
html[data-theme="light"] .cyber-form input::placeholder {
  color: #94a3b8 !important;
}
html[data-theme="light"] .cyber-form input:focus {
  border-color: rgba(23, 88, 187, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(23, 88, 187, 0.12) !important;
}
html[data-theme="light"] .cyber-label {
  color: var(--brand) !important;
}
html[data-theme="light"] .input-link {
  color: #1d4ed8 !important;
}
html[data-theme="light"] .login-page-wrap .btn-ghost.small,
html[data-theme="light"] .landing-page .btn-ghost.small {
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--brand);
  background: rgba(255, 255, 255, 0.7);
}

html[data-theme="light"] .login-box details {
  color: #475569;
}
html[data-theme="light"] .login-box summary {
  color: var(--brand);
}
html[data-theme="light"] .login-shell {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  min-height: 100vh;
}
html[data-theme="light"] .login-card {
  background: #fff !important;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .login-form h2 {
  color: #0f172a;
}
html[data-theme="light"] .login-form p,
html[data-theme="light"] .login-form label {
  color: #475569 !important;
}
html[data-theme="light"] .login-form input {
  border-color: #cbd5e1;
  color: #0f172a;
}
html[data-theme="light"] .login-form a {
  color: var(--brand);
}

/* Alert e testi secondari: login / recupero / cambio password obbligatorio (dark) */
html[data-theme="dark"] .login-page-wrap .success-box {
  background: rgba(16, 185, 129, 0.14) !important;
  color: #a7f3d0 !important;
  border: 1px solid rgba(52, 211, 153, 0.35);
  box-shadow: none;
}
html[data-theme="dark"] .login-page-wrap .error-box {
  background: rgba(248, 113, 113, 0.12) !important;
  color: #fecaca !important;
  border: 1px solid rgba(248, 113, 113, 0.35);
  box-shadow: none;
}
html[data-theme="dark"] .login-box .muted {
  color: #94a3b8 !important;
}

html[data-theme="light"] .login-page-wrap .success-box {
  border: 1px solid rgba(22, 163, 74, 0.25);
}
html[data-theme="light"] .login-page-wrap .error-box {
  border: 1px solid rgba(190, 18, 60, 0.2);
}

.topbar-leading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-heading {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 780;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.topbar-user {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.005em;
}
.pill--tb {
  font-size: 0.7rem;
}

/* ——— App shell (dashboard): tema scuro ——— */
[data-theme="dark"] .app-shell {
  --shell-glass: linear-gradient(165deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.78));
  --shell-glass-border: var(--mock-shell-border, rgba(129, 140, 248, 0.38));
  --shell-table-bg: rgba(2, 6, 23, 0.42);
  --shell-table-head-bg: rgba(15, 23, 42, 0.94);
  --shell-table-head-color: #dbeafe;
  --shell-td-color: #f1f5f9;
  --shell-muted: #94a3c8;
  --shell-panel-title: #a5b4fc;
  --shell-stat-value: #fff;
  --shell-sidebar: linear-gradient(188deg, rgba(5, 8, 22, 0.98) 0%, rgba(15, 23, 42, 0.96) 48%, rgba(30, 27, 75, 0.94) 100%);
  --shell-sidebar-border: rgba(129, 140, 248, 0.34);
  --shell-topbar: rgba(15, 23, 42, 0.78);
  --shell-nav-active-bg: linear-gradient(135deg, rgba(56, 189, 248, 0.28), rgba(99, 102, 241, 0.26));
  --shell-nav-active-fg: #e0e7ff;
  --shell-nav-fg: #a9bbd6;
  --shell-brand-fg: #fff;
  --shell-subtle: rgba(241, 245, 249, 0.78);
}

[data-theme="light"] .app-shell {
  --shell-glass: linear-gradient(155deg, rgba(255, 255, 255, 0.97), rgba(239, 246, 255, 0.98));
  --shell-glass-border: rgba(59, 130, 246, 0.22);
  --shell-table-bg: #ffffff;
  --shell-table-head-bg: #e0ebff;
  --shell-table-head-color: #0f172a;
  --shell-td-color: #14233d;
  --shell-muted: #4b5d78;
  --shell-panel-title: #2f4bb8;
  --shell-stat-value: #0f172a;
  --shell-sidebar: linear-gradient(185deg, rgba(247, 250, 255, 0.98) 0%, rgba(236, 245, 255, 0.98) 100%);
  --shell-sidebar-border: rgba(59, 130, 246, 0.18);
  --shell-topbar: rgba(255, 255, 255, 0.92);
  --shell-nav-active-bg: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(16, 185, 129, 0.16));
  --shell-nav-active-fg: #183484;
  --shell-nav-fg: #31465f;
  --shell-brand-fg: #0f172a;
  --shell-subtle: #4f6380;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
  background:
    radial-gradient(ellipse 110% 85% at 50% -28%, rgba(129, 140, 248, 0.22), transparent 58%),
    radial-gradient(ellipse 70% 50% at 0% 18%, rgba(34, 211, 238, 0.1), transparent 50%),
    radial-gradient(ellipse 65% 45% at 100% 12%, rgba(232, 121, 249, 0.08), transparent 48%),
    radial-gradient(ellipse 80% 52% at 14% -12%, var(--sarial-glow-cyan), transparent 60%),
    radial-gradient(ellipse 72% 58% at 100% 0%, var(--sarial-glow-violet), transparent 62%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(15, 23, 42, 0.35), transparent 70%);
}

[data-theme="light"] .app-shell {
  background:
    radial-gradient(ellipse 120% 75% at 50% -26%, rgba(59, 130, 246, 0.14), transparent 58%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(99, 102, 241, 0.08), transparent 58%),
    radial-gradient(ellipse 55% 42% at 0% 15%, rgba(16, 185, 129, 0.06), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(59, 130, 246, 0.05), transparent 70%);
}

.app-shell .sidebar {
  width: 292px;
  flex-shrink: 0;
  background: var(--shell-sidebar);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-right: 1px solid var(--shell-sidebar-border);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--shell-sidebar-border) 35%, transparent), 0 28px 58px rgba(2, 8, 23, 0.28);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  transition: transform 0.3s ease;
  z-index: 1000;
}

/* Fallback browser (es. alcune build Windows/Firefox): no glass blur -> sfondi più solidi. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .app-shell .sidebar {
    background: rgba(5, 10, 24, 0.98);
  }
  [data-theme="light"] .app-shell .sidebar {
    background: #f8fafc;
  }
  .app-shell-topbar {
    background: rgba(5, 10, 24, 0.92);
  }
  [data-theme="light"] .app-shell-topbar {
    background: #ffffff;
  }
  .app-shell .panel {
    background: rgba(15, 23, 42, 0.9);
  }
  [data-theme="light"] .app-shell .panel {
    background: #ffffff;
  }
}

.app-shell-brandblock {
  padding: 2rem 1.5rem;
  border-bottom: 1px solid var(--shell-glass-border);
  display: flex;
  gap: 12px;
  align-items: center;
}

.app-shell-logo {
  color: var(--accent);
  display: flex;
  align-items: center;
}

.app-shell-brandtitle {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.5px;
  color: var(--shell-brand-fg) !important;
}

.app-shell-role {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.app-shell-nav {
  min-height: 0;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-shell-nav--main {
  flex: 1 1 0%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-account-wrap {
  flex-shrink: 0;
  border-top: 1px solid var(--shell-glass-border);
  padding-bottom: 0.25rem;
}

.sidebar-account-wrap .app-drawer-section-label {
  margin-top: 0.65rem;
}

.sidebar-account-wrap__extras {
  padding: 0 1rem 0.5rem;
}

.sidebar-account-panel {
  width: 100%;
  margin: 0;
}

.sidebar-account-panel > summary.nav-btn {
  list-style: none;
}

.sidebar-account-panel > summary::-webkit-details-marker {
  display: none;
}

.sidebar-account-panel > summary::marker {
  content: "";
}

.nav-btn--account-toggle {
  justify-content: space-between;
  align-items: center;
  font-weight: 680;
}

.nav-btn__lead {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}

.nav-btn__caret {
  flex-shrink: 0;
  width: 0.42rem;
  height: 0.42rem;
  margin-left: 0.35rem;
  margin-top: 0.28rem;
  border-right: 2px solid rgba(148, 163, 184, 0.82);
  border-bottom: 2px solid rgba(148, 163, 184, 0.82);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  opacity: 0.92;
}

.sidebar-account-panel[open] > summary .nav-btn__caret {
  transform: rotate(-135deg);
}

.sidebar-account-panel__body {
  padding: 0.35rem 0 0.35rem 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sidebar-account-panel__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-account-panel__block-title {
  margin: 0 0 0.35rem 0.15rem;
  padding: 0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--shell-muted);
}

.app-shell .nav-btn--nested {
  padding: 0.58rem 0.85rem;
  font-size: 0.88rem;
  border-radius: 11px;
}

.app-shell .nav-btn--nested .nav-btn__label {
  font-weight: 640;
}

.app-shell .nav-btn--cookie .nav-btn__label {
  font-weight: 600;
}

.app-menu-account-disclosure,
.app-menu-registers-disclosure {
  background: var(--shell-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--ui-radius-md);
  border: 1px solid var(--shell-glass-border);
  margin-bottom: clamp(0.8rem, 1.3vw, 1.2rem);
  box-shadow: 0 10px 30px rgba(2, 8, 23, 0.16);
  overflow: hidden;
}

.app-menu-account-summary,
.app-menu-registers-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  cursor: pointer;
  list-style: none;
  padding: 0.82rem 1rem;
  margin: 0;
  background: rgba(148, 163, 184, 0.07);
  border: none;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

.app-menu-account-disclosure[open] > .app-menu-account-summary,
.app-menu-registers-disclosure[open] > .app-menu-registers-summary {
  border-bottom-color: rgba(148, 163, 184, 0.18);
}

.app-menu-account-summary::-webkit-details-marker,
.app-menu-registers-summary::-webkit-details-marker {
  display: none;
}

.app-menu-registers-summary::marker {
  content: "";
}

.app-menu-account-summary__main {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.app-menu-account-summary__icon {
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-menu-account-summary__icon .sarial-ico {
  display: block;
}

.app-menu-account-summary__label {
  font-size: 1rem;
  font-weight: 760;
  letter-spacing: -0.015em;
  color: var(--shell-brand-fg);
  text-align: left;
}

.app-menu-account-summary__caret {
  flex-shrink: 0;
  width: 0.42rem;
  height: 0.42rem;
  border-right: 2px solid rgba(148, 163, 184, 0.85);
  border-bottom: 2px solid rgba(148, 163, 184, 0.85);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.app-menu-account-disclosure[open] > .app-menu-account-summary .app-menu-account-summary__caret,
.app-menu-registers-disclosure[open] > .app-menu-registers-summary .app-menu-account-summary__caret {
  transform: rotate(-135deg);
}

.app-menu-registers-inner {
  padding: clamp(0.65rem, 1.8vw, 0.9rem) clamp(0.85rem, 2vw, 1.05rem) clamp(0.85rem, 2vw, 1.05rem);
}

.app-menu-registers__hint {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  line-height: 1.4;
}

.app-menu-links--registers {
  gap: 0.38rem;
}

.app-menu-account-inner {
  padding: clamp(0.85rem, 2vw, 1.05rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.app-menu-account-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.app-menu-account-stack__block .sidebar-account-panel__block-title {
  margin-bottom: 0.45rem;
}

.app-shell .nav-btn {
  display: flex;
  align-items: flex-start;
  width: 100%;
  padding: 0.72rem 1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.35;
  text-align: left;
  transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease, transform 0.18s ease;
  background: color-mix(in srgb, var(--shell-nav-fg) 6%, transparent);
  color: var(--shell-nav-fg);
  font-weight: 500;
  border-left: 3px solid transparent;
  font-family: inherit;
}

.app-shell .nav-btn__icon {
  width: 1.2rem;
  min-width: 1.2rem;
  text-align: center;
  margin-right: 0.5rem;
  margin-top: 0.1em;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-shell .nav-btn__icon .sarial-ico {
  display: block;
}

.app-shell .nav-btn__label {
  min-width: 0;
  line-height: 1.38;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.app-shell .nav-btn:hover {
  background: color-mix(in srgb, var(--shell-nav-fg) 14%, transparent);
  color: var(--shell-brand-fg);
  transform: translateX(2px);
}

[data-theme="dark"] .app-shell .nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.app-shell .nav-btn.active {
  background: var(--shell-nav-active-bg);
  color: var(--shell-nav-active-fg);
  font-weight: 800;
  border-left-color: var(--shell-nav-active-fg);
  box-shadow: 0 8px 22px rgba(2, 8, 23, 0.18);
}

.app-shell-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--shell-glass-border);
  font-size: 0.75rem;
  color: var(--shell-muted);
}

/* Sidebar: riepilogo spazio documenti (tenant) */
.app-shell .sidebar-storage {
  margin: 10px 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--shell-glass-border);
  background: var(--shell-glass);
  --sidebar-storage-pct: 0%;
}

.app-shell .sidebar-storage__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--shell-muted);
  margin-bottom: 8px;
}

.app-shell .sidebar-storage__track {
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  overflow: hidden;
  margin-bottom: 8px;
}

.app-shell .sidebar-storage__fill {
  height: 100%;
  width: var(--sidebar-storage-pct);
  max-width: 100%;
  background: linear-gradient(90deg, var(--brand, #1758bb), var(--brand-2, #093a7b));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.app-shell .sidebar-storage__meta {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--shell-muted);
}

.app-shell .sidebar-storage__meta strong {
  color: var(--shell-panel-title);
  font-weight: 700;
}

.app-shell .sidebar-storage__btn {
  width: 100%;
  margin-top: 10px;
  padding: 7px 10px;
  font-size: 0.8rem;
  box-sizing: border-box;
}

.app-shell-main {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.app-shell-topbar {
  background: var(--shell-topbar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--shell-glass-border);
  padding: 0.85rem clamp(1rem, 2.5vw, 2.25rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  min-height: 3.25rem;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 900;
}

[data-theme="light"] .app-shell-topbar {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .app-shell-topbar {
  background: rgba(15, 23, 42, 0.82);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  box-shadow:
    0 12px 40px rgba(2, 8, 23, 0.45),
    inset 0 -1px 0 rgba(148, 163, 184, 0.06);
}

.app-shell .topbar-leading {
  flex: 1;
  min-width: 0;
  align-items: center;
}

.app-shell .topbar-title {
  min-width: 0;
  flex: 1;
}

.app-shell .topbar-heading {
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.app-shell .topbar-user {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
  word-break: break-word;
}

[data-theme="dark"] .topbar-heading {
  color: #e2e8f0;
}
[data-theme="light"] .topbar-heading {
  color: var(--ink);
}
[data-theme="dark"] .topbar-user {
  color: #94a3b8;
}
[data-theme="light"] .topbar-user {
  color: #475569;
}

[data-theme="light"] .app-shell-logo {
  color: var(--brand);
}

[data-theme="light"] .app-shell-role {
  color: var(--brand-2);
}

[data-theme="light"] .app-shell .panel {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07), 0 18px 34px rgba(59, 130, 246, 0.08);
}

[data-theme="light"] .app-shell .mobile-toggle {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] .app-shell .quick-action-card {
  background: linear-gradient(155deg, #ffffff, #f0f7ff);
  border-color: rgba(59, 130, 246, 0.2);
}

[data-theme="light"] .app-shell .quick-action-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 14px 30px rgba(59, 130, 246, 0.16);
}

[data-theme="light"] .app-shell .admin-dash-hero {
  background: linear-gradient(130deg, rgba(59, 130, 246, 0.18), rgba(16, 185, 129, 0.14), rgba(226, 232, 240, 0.95));
  border-color: rgba(59, 130, 246, 0.25);
}

[data-theme="light"] .app-shell .admin-dash-hero-metrics strong {
  color: #0e2f71;
}

[data-theme="light"] .app-shell .mono {
  color: #0f172a;
  font-weight: 600;
}

[data-theme="light"] .app-shell .temp-card.danger .t {
  color: #b91c1c;
}

/* Light mode: pack SARIAL — contrasto icone (stroke currentColor) e UI affini */
[data-theme="light"] .app-shell .nav-btn__icon {
  opacity: 1;
}

[data-theme="light"] .app-shell .quick-action-icon {
  color: var(--brand);
  opacity: 1;
}

[data-theme="light"] .app-shell .quick-action-card:hover .quick-action-icon {
  color: var(--brand-2);
}

[data-theme="light"] .app-menu-link__icon {
  opacity: 1;
  color: var(--brand);
}

[data-theme="light"] .app-menu-link.is-active .app-menu-link__icon {
  color: inherit;
}

[data-theme="light"] .app-menu-account-summary__icon .sarial-ico {
  color: var(--brand);
}

[data-theme="light"] .empty-state {
  border-color: rgba(59, 130, 246, 0.22);
  background: rgba(248, 250, 252, 0.92);
}

[data-theme="light"] .empty-state__icon {
  color: var(--brand);
  opacity: 1;
}

[data-theme="light"] html.mobile-app-chrome .app-bottom-nav__icon {
  opacity: 1;
}

[data-theme="light"] html.mobile-app-chrome .app-bottom-nav__btn:not(.is-active) {
  color: #475569;
}

[data-theme="light"] .app-shell .dash-mob-icon--temp .sarial-ico {
  color: #be123c;
}

[data-theme="light"] .app-shell .dash-mob-icon--hum .sarial-ico {
  color: #1d4ed8;
}

[data-theme="light"] .app-shell .dash-mob-icon--warn .sarial-ico {
  color: #b45309;
}

[data-theme="light"] .app-shell .dash-mob-icon--lot .sarial-ico {
  color: #7e22ce;
}

[data-theme="light"] .app-shell .dash-mob-qbtn span[aria-hidden="true"] .sarial-ico {
  color: var(--brand);
}

[data-theme="light"] .pill--tb.danger,
[data-theme="light"] .app-shell .topbar-actions .pill.danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid rgba(185, 28, 28, 0.35);
}

html[data-theme="light"] .app-dialog-card h3 {
  color: #0f172a;
}

html[data-theme="light"] .app-dialog-message {
  color: #475569;
}

html[data-theme="light"] .dialog-label {
  color: #334155;
}

.app-shell .topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.app-shell-topbar {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--shell-glass-border);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--shell-topbar) 90%, transparent) 0%, color-mix(in srgb, var(--shell-topbar) 82%, transparent) 100%);
}

.app-shell-view,
.app-shell .sidebar,
.app-shell .table-wrap {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--shell-muted) 36%, transparent) transparent;
}

.app-shell-view::-webkit-scrollbar,
.app-shell .sidebar::-webkit-scrollbar,
.app-shell .table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.app-shell-view::-webkit-scrollbar-thumb,
.app-shell .sidebar::-webkit-scrollbar-thumb,
.app-shell .table-wrap::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--shell-muted) 36%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

@media (max-width: 380px) {
  .app-shell .topbar-actions {
    flex-wrap: wrap;
    max-width: 100%;
    justify-content: flex-end;
  }
  /* PWA/mobile: una sola riga come header nativo (ref. Sarial). */
  html.mobile-app-chrome .app-shell .topbar-actions {
    flex-wrap: nowrap;
    max-width: none;
  }
}

.app-shell .topbar-actions .topbar-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}
.app-shell .topbar-actions .topbar-btn-icon {
  font-size: 1.05em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-shell .topbar-actions .pill--tb {
  max-width: min(46vw, 11rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell .topbar-actions .pill--tb.danger {
  max-width: min(52vw, 13rem);
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.btn-inline-ico {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 0.25rem;
}

.app-shell-view {
  padding: 1.25rem;
  min-width: 0;
  min-height: 0;
  flex: 1 1 0%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: auto;
}

/* Desktop/laptop: shell più “pro app” con spaziature e densità più curate */
@media (min-width: 1025px) {
  .app-shell-main {
    padding: 0.45rem 0.45rem 0.95rem;
  }

  .app-shell-view {
    padding: 1.15rem 1.35rem;
  }

  .app-shell .panel {
    border-radius: 20px;
    padding: 1.2rem 1.25rem;
    border-color: rgba(148, 163, 184, 0.2);
    box-shadow: 0 12px 34px rgba(2, 8, 23, 0.06);
  }

  .app-shell .toolbar .btn,
  .app-shell .toolbar .btn.small {
    min-height: 2.65rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .app-shell .table-wrap {
    border-radius: 14px;
    overflow: auto;
  }
}

/* Tablet e laptop piccoli: topbar più elastica, senza tagli sui comandi */
@media (max-width: 1200px) {
  .app-shell-topbar {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    gap: 8px;
  }
  .app-shell .topbar-actions {
    gap: 6px;
    min-width: 0;
  }
  .app-shell .topbar-actions .pill--tb {
    max-width: 10.5rem;
  }
  .app-shell .topbar-actions .topbar-logout-btn {
    min-height: 2.35rem;
    padding: 0.42rem 0.68rem;
  }
}

/* Tablet hardening: evita clipping a destra, consenti scroll orizzontale dove serve. */
@media (min-width: 768px) and (max-width: 1180px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }
  .app-shell,
  .app-shell-main,
  .app-shell-view {
    width: 100%;
    max-width: 100%;
  }
  .app-shell-view {
    overflow-x: auto;
    padding-left: clamp(0.75rem, 1.8vw, 1.05rem);
    padding-right: clamp(0.75rem, 1.8vw, 1.05rem);
  }
  .app-shell .panel,
  .app-shell .view-card,
  .app-shell .view-table-wrap,
  .app-shell .table-wrap {
    max-width: 100%;
  }
  .app-shell .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .app-shell .toolbar {
    flex-wrap: wrap;
    min-width: 0;
  }
  .app-shell .toolbar > *,
  .app-shell .toolbar .toolbar-cluster > * {
    min-width: 0;
  }
}

/* Shell: panels, stats, tables (override global app.css per tema) */
.app-shell .panel {
  background: var(--shell-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--ui-radius-md);
  padding: clamp(0.95rem, 1.55vw, 1.35rem);
  border: 1px solid var(--shell-glass-border);
  margin-bottom: clamp(0.8rem, 1.3vw, 1.2rem);
  box-shadow: 0 14px 38px rgba(2, 8, 23, 0.18);
  /* Il .panel globale usa overflow:hidden e taglia titoli/testi lunghi (lotti, admin). */
  overflow-x: auto;
  overflow-y: visible;
  min-width: 0;
}

.app-shell .btn,
.app-shell .nav-btn {
  transition: transform 0.18s ease, box-shadow 0.22s ease, filter 0.2s ease, border-color 0.2s ease;
}

.app-shell .btn:hover,
.app-shell .nav-btn:hover {
  transform: translateY(-1px);
}

.app-shell .btn:active,
.app-shell .nav-btn:active {
  transform: translateY(0);
}

.app-shell .panel input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.app-shell .panel select,
.app-shell .panel textarea {
  transition: border-color 0.18s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.app-shell .panel input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
.app-shell .panel select:focus,
.app-shell .panel textarea:focus {
  border-color: color-mix(in srgb, var(--brand) 62%, #93c5fd);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
  outline: none;
}

.app-shell .panel h2 {
  font-size: clamp(1.04rem, 1.2vw, 1.14rem);
  font-weight: 800;
  font-family: var(--ui-font-display);
  color: var(--shell-panel-title);
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--shell-glass-border);
  padding-bottom: 0.75rem;
  letter-spacing: -0.015em;
}

.app-shell .warehouse-platform-central-panel {
  border-color: color-mix(in srgb, #f59e0b 58%, var(--shell-glass-border));
  background: color-mix(in srgb, #f59e0b 9%, var(--shell-glass));
}

html[data-theme="dark"] .app-shell .warehouse-platform-central-panel {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
}

.app-shell .grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.app-shell .grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.app-shell .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--shell-glass);
  border: 1px solid var(--shell-glass-border);
  border-radius: var(--ui-radius-md);
  padding: var(--ui-space-6);
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 22px rgba(2, 8, 23, 0.14);
}

.app-shell .stat:hover {
  transform: translateY(-3px);
  border-color: rgba(45, 212, 191, 0.42);
}

[data-theme="light"] .app-shell .stat:hover {
  border-color: rgba(23, 88, 187, 0.35);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .app-shell .stat {
  background: var(--mock-widget-bg);
  border-color: var(--mock-widget-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 32px rgba(2, 8, 23, 0.42),
    0 0 48px rgba(79, 70, 229, 0.08);
}

[data-theme="dark"] .app-shell .stat:hover {
  border-color: rgba(45, 212, 191, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 14px 40px rgba(2, 8, 23, 0.5),
    0 0 56px rgba(79, 70, 229, 0.14);
}

.app-shell .stat .label {
  max-width: 100%;
  color: var(--shell-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.app-shell .stat .value {
  font-size: clamp(1.85rem, 2.4vw, 2.3rem);
  font-weight: 800;
  color: var(--shell-stat-value);
  font-family: var(--ui-font-display);
  line-height: 1.15;
  text-align: center;
}

.app-shell .toolbar {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  gap: var(--ui-space-3);
}

.app-shell .toolbar h2 {
  min-width: 0;
  flex: 1 1 auto;
}

/* Toolbar lotti/temperature: gruppo pulsanti senza una riga per bottone su mobile */
.app-shell .toolbar .toolbar-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-2);
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}
.app-shell .toolbar--lots,
.app-shell .toolbar--temps {
  align-items: center;
}
@media (max-width: 768px) {
  .app-shell .toolbar--lots .toolbar-cluster--lots,
  .app-shell .toolbar--temps .toolbar-cluster--temps {
    flex: 1 1 100%;
    justify-content: stretch;
  }
  .app-shell .toolbar-cluster--lots .btn,
  .app-shell .toolbar-cluster--temps .btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    justify-content: center;
    box-sizing: border-box;
  }
}

/* Export storico (lotti / temperature): date e azioni ordinate su stretto e desktop */
.app-shell .hist-export-panel .hist-export-lead {
  margin: 0 0 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  max-width: none;
}
.app-shell .hist-export-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px 14px;
  margin-bottom: 12px;
  max-width: none;
  box-sizing: border-box;
}
.app-shell .hist-export-dates label {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--shell-muted);
}

@media (min-width: 769px) {
  .app-shell .hist-export-dates {
    max-width: min(26rem, 100%);
  }
}
.app-shell .hist-export-label {
  display: block;
}
.app-shell .hist-export-dates input[type="date"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--shell-glass-border);
  background: var(--shell-table-bg);
  color: var(--shell-td-color);
  font-size: 0.95rem;
  line-height: 1.25;
  text-align: left;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
}
.app-shell .hist-export-dates input[type="date"]::-webkit-datetime-edit {
  color: inherit;
  padding: 0;
}
.app-shell .hist-export-dates input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.92;
  cursor: pointer;
  margin-left: 8px;
}
.app-shell .hist-export-dates input[type="date"]::-webkit-clear-button,
.app-shell .hist-export-dates input[type="date"]::-webkit-inner-spin-button {
  display: none;
}
[data-theme="light"] .app-shell .hist-export-dates input[type="date"] {
  background: #fff;
  color: var(--ink);
  border-color: #cbd5e1;
  color-scheme: light;
}
[data-theme="dark"] .app-shell .hist-export-dates input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.88) saturate(0.1) brightness(1.2);
}
[data-theme="light"] .app-shell .hist-export-dates input[type="date"]::-webkit-calendar-picker-indicator {
  filter: none;
}
.app-shell .hist-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  max-width: none;
}
.app-shell .hist-export-actions .btn.small {
  flex: 0 1 auto;
  width: auto;
  min-width: min(13rem, 100%);
  justify-content: center;
  text-align: center;
  gap: 6px;
}
.app-shell .temps-filter-head {
  margin: 0 0 6px;
}
.app-shell .temps-filter-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--shell-panel-title, #0f172a);
}
.app-shell .temps-filter-help {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.42;
  color: var(--muted);
  max-width: 72ch;
}
@media (max-width: 640px) {
  .app-shell .hist-export-dates {
    grid-template-columns: 1fr;
    max-width: none;
  }
  .app-shell .hist-export-dates input[type="date"] {
    font-size: 16px;
    min-height: 44px;
  }
  .app-shell .hist-export-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-width: none;
  }
  .app-shell .hist-export-actions--temps {
    grid-template-columns: 1fr 1fr;
  }
  .app-shell .hist-export-actions .btn.small {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 768px) {
  /* Lotti: usa meglio lo spazio, con CTA primaria piena e export distribuiti. */
  .app-shell .toolbar-cluster--lots #addLotBtn {
    flex: 1 1 100%;
    min-height: 46px;
  }

  .app-shell .toolbar-cluster--lots .btn.secondary.small {
    flex: 1 1 calc(33.333% - 6px);
  }
}

@media (max-width: 520px) {
  .app-shell .toolbar-cluster--lots .btn.secondary.small {
    flex: 1 1 calc(50% - 4px);
  }
}
@media (max-width: 380px) {
  .app-shell .hist-export-actions:not(.hist-export-actions--lots) {
    grid-template-columns: 1fr;
  }
  .app-shell .hist-export-actions--lots {
    grid-template-columns: 1fr;
  }
}

/* Dashboard ristorante: colonna numeri / pill centrata */
.app-shell .dash-priority-table th:nth-child(2),
.app-shell .dash-priority-table td:nth-child(2) {
  text-align: center;
}
.app-shell .dash-priority-table th:nth-child(3),
.app-shell .dash-priority-table td:nth-child(3) {
  text-align: center;
}

.app-shell .table-wrap {
  overflow: auto;
  border: 1px solid var(--shell-glass-border);
  border-radius: var(--ui-radius-md);
  background: var(--shell-table-bg);
  -webkit-overflow-scrolling: touch;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.app-shell table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: transparent !important;
}

.app-shell th {
  text-align: left;
  padding: 0.92rem 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--shell-glass-border);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--shell-table-head-bg) !important;
  color: var(--shell-table-head-color) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.app-shell .table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--shell-glass-border) 70%, transparent);
}

.app-shell td {
  padding: 0.92rem 1rem;
  border-bottom: 1px solid var(--shell-glass-border);
  color: var(--shell-td-color) !important;
  vertical-align: middle;
  background: transparent !important;
}

.app-shell tbody tr td {
  transition: background-color 0.2s ease;
}

.app-shell tbody tr:hover td {
  background: color-mix(in srgb, var(--shell-nav-active-bg) 40%, transparent) !important;
}

.app-shell tr:last-child td {
  border-bottom: none;
}

[data-theme="dark"] .app-shell tbody tr:hover td {
  background: rgba(255, 255, 255, 0.04) !important;
}

.app-shell .muted {
  color: var(--shell-muted) !important;
  font-weight: 600;
}

.app-shell .pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-block;
  white-space: nowrap;
  border: 1px solid transparent;
}

[data-theme="dark"] .app-shell .pill.ok {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}

[data-theme="light"] .app-shell .pill.ok {
  background: #dcfce7;
  color: #166534;
}

[data-theme="dark"] .app-shell .pill.warn {
  background: rgba(234, 179, 8, 0.15);
  color: #fde047;
  border-color: rgba(234, 179, 8, 0.35);
}

[data-theme="light"] .app-shell .pill.warn {
  background: #fff4da;
  color: #a16207;
}

[data-theme="dark"] .app-shell .pill.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

[data-theme="light"] .app-shell .pill.danger {
  background: #ffe4e8;
  color: #b91c1c;
}

.app-shell .btn {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff;
  border: none;
  padding: clamp(0.5rem, 0.25vw + 0.44rem, 0.7rem) clamp(0.9rem, 0.6vw + 0.78rem, 1.28rem);
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  font-size: clamp(0.84rem, 0.18vw + 0.81rem, 0.94rem);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(23, 88, 187, 0.25);
  min-height: clamp(2.45rem, 0.55vw + 2.3rem, 2.8rem);
  box-sizing: border-box;
  line-height: 1.1;
  white-space: nowrap;
}

.app-shell .btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.app-shell .btn.secondary {
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid var(--shell-glass-border);
  color: var(--shell-brand-fg);
  box-shadow: none;
}

[data-theme="dark"] .app-shell .btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

[data-theme="light"] .app-shell .btn.secondary {
  background: #e8edf4;
  color: #0f172a;
  border-color: #cbd5e1;
}

.app-shell .btn.secondary:hover {
  border-color: var(--brand);
}

.app-shell .btn.small {
  min-height: clamp(2.2rem, 0.35vw + 2.1rem, 2.45rem);
  padding: clamp(0.34rem, 0.18vw + 0.3rem, 0.48rem) clamp(0.68rem, 0.35vw + 0.6rem, 0.9rem);
  font-size: clamp(0.78rem, 0.14vw + 0.75rem, 0.87rem);
}

/* Tabelle e azioni compatte: evita pulsanti “mattoni” alti 2.75rem */
.app-shell table .btn,
.app-shell .data-table .btn {
  min-height: clamp(2rem, 0.25vw + 1.95rem, 2.2rem);
  padding: clamp(0.3rem, 0.14vw + 0.28rem, 0.42rem) clamp(0.62rem, 0.3vw + 0.56rem, 0.82rem);
  font-size: clamp(0.76rem, 0.12vw + 0.74rem, 0.84rem);
}

.app-shell .btn.danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}

.app-shell .form-grid label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--shell-muted);
  margin-bottom: 0.35rem;
}

.app-shell .form-grid input,
.app-shell .form-grid select,
.app-shell .form-grid textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--shell-glass-border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--shell-td-color);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

/* Dropdown in dark mode: forza popup/voce leggibili anche su Safari/iOS. */
.app-shell .form-grid select,
.app-shell .toolbar select {
  color-scheme: dark;
  -webkit-text-fill-color: currentColor;
}

[data-theme="light"] .app-shell .form-grid input,
[data-theme="light"] .app-shell .form-grid select,
[data-theme="light"] .app-shell .form-grid textarea {
  background: #fff;
  color: var(--ink);
  border-color: #cbd5e1;
}

[data-theme="light"] .app-shell .form-grid select,
[data-theme="light"] .app-shell .toolbar select {
  color-scheme: light;
}

.app-shell .form-grid input:focus,
.app-shell .form-grid select:focus,
.app-shell .form-grid textarea:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(23, 88, 187, 0.15);
}

[data-theme="dark"] .app-shell .form-grid input:focus,
[data-theme="dark"] .app-shell .form-grid select:focus,
[data-theme="dark"] .app-shell .form-grid textarea:focus {
  box-shadow: 0 0 0 3px rgba(0, 242, 255, 0.12);
}

/* Magazzino: riquadro «Aggiungi articolo» — variabili shell (evita sfondo bianco / etichette illeggibili in dark) */
.app-shell .wh-item-form-box {
  margin: 12px 0;
  padding: 12px;
  border-radius: var(--ui-radius-sm, 12px);
  border: 1px solid var(--shell-glass-border);
  background: var(--shell-glass);
}

/* Onboarding tenant: palette + selettore colore (primario / secondario) */
.app-shell .onboard-color-field {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  align-self: start;
}

.app-shell .onboard-color-field__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--shell-muted);
}

.app-shell .onboard-color-field__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 1rem;
}

.app-shell .onboard-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: 100%;
}

.app-shell .onboard-swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid var(--shell-glass-border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.app-shell .onboard-swatch:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.25);
}

.app-shell .onboard-swatch:focus-visible {
  outline: 2px solid var(--brand, #1758bb);
  outline-offset: 2px;
}

.app-shell .onboard-color-custom {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.app-shell .onboard-color-native-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.app-shell .onboard-color-native-hint {
  font-size: 0.72rem;
}

.app-shell .onboard-color-native {
  width: 52px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--shell-glass-border);
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  box-sizing: border-box;
}

.app-shell .onboard-color-native::-webkit-color-swatch-wrapper {
  padding: 0;
}

.app-shell .onboard-color-native::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

.app-shell .onboard-color-hex {
  font-size: 0.78rem;
  color: var(--shell-muted);
}

@media (max-width: 640px) {
  .app-shell .onboard-color-field__row {
    flex-direction: column;
    align-items: stretch;
  }
}

.app-shell .form-grid select option,
.app-shell .toolbar select option {
  background: #0b152c;
  color: #e2e8f0;
}

.app-shell .form-grid select option:checked,
.app-shell .toolbar select option:checked {
  background: #1f2f57;
  color: #f8fafc;
}

/* Desktop dark-mode: migliora leggibilità menu a tendina senza toccare mobile. */
@media (min-width: 1025px) {
  [data-theme="dark"] .app-shell .form-grid select,
  [data-theme="dark"] .app-shell .toolbar select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #0f1b33;
    border-color: rgba(148, 163, 184, 0.4);
    color: #eaf2ff;
    padding-right: 2.3rem;
    background-image:
      linear-gradient(45deg, transparent 50%, #9fb7e8 50%),
      linear-gradient(135deg, #9fb7e8 50%, transparent 50%);
    background-position:
      calc(100% - 16px) calc(50% - 3px),
      calc(100% - 10px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  }

  [data-theme="dark"] .app-shell .form-grid select:hover,
  [data-theme="dark"] .app-shell .toolbar select:hover {
    border-color: rgba(96, 165, 250, 0.68);
    background-color: #12223f;
  }

  [data-theme="dark"] .app-shell .form-grid select:focus,
  [data-theme="dark"] .app-shell .toolbar select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
  }
}

[data-theme="light"] .app-shell .form-grid select option,
[data-theme="light"] .app-shell .toolbar select option {
  background: #fff;
  color: #0f172a;
}

[data-theme="light"] .app-shell .form-grid select option:checked,
[data-theme="light"] .app-shell .toolbar select option:checked {
  background: #dbeafe;
  color: #0e2f71;
}

.app-shell .toolbar input,
.app-shell .toolbar select,
.app-shell .toolbar textarea {
  border: 1px solid var(--shell-glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--shell-td-color);
  border-radius: 11px;
  padding: 10px 12px;
}

[data-theme="light"] .app-shell .toolbar input,
[data-theme="light"] .app-shell .toolbar select,
[data-theme="light"] .app-shell .toolbar textarea {
  background: #fff;
  color: var(--ink);
  border-color: #cbd5e1;
}

.app-shell .hint-banner {
  background: rgba(255, 205, 86, 0.12);
  border: 1px solid rgba(255, 205, 86, 0.45);
  padding: 10px;
  border-radius: 10px;
  color: #fde68a;
}

[data-theme="light"] .app-shell .hint-banner {
  background: #fef9c3;
  border-color: #eab308;
  color: #713f12;
}

.app-shell .cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 380px));
  gap: 1rem;
  justify-content: start;
}

.app-shell .temp-card {
  background: var(--shell-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--shell-glass-border);
  border-radius: 16px;
  padding: 1.5rem;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.app-shell .temp-card:hover {
  transform: translateY(-4px);
  border-color: var(--brand);
}

[data-theme="dark"] .app-shell .temp-card {
  background: var(--mock-widget-bg);
  border-color: var(--mock-widget-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 12px 36px rgba(2, 8, 23, 0.42),
    0 0 48px rgba(79, 70, 229, 0.09);
}

[data-theme="dark"] .app-shell .temp-card:hover {
  border-color: rgba(45, 212, 191, 0.35);
  box-shadow:
    0 16px 44px rgba(2, 8, 23, 0.48),
    0 0 56px rgba(79, 70, 229, 0.12);
}

.app-shell .temp-card .name {
  font-weight: 700;
  color: var(--shell-brand-fg);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.app-shell .temp-card .t {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.03em;
  margin: 0.5rem 0;
  line-height: 1;
  font-family: Sora, sans-serif;
}

.app-shell .temp-card.danger .t {
  color: #f87171;
}

.app-shell .temp-card .meta {
  font-size: 0.8rem;
  color: var(--shell-muted);
}

.app-shell .chart {
  background: var(--shell-table-bg);
  border: 1px solid var(--shell-glass-border);
  border-radius: 14px;
  padding: 8px;
}

[data-theme="dark"] .app-shell .chart {
  background: rgba(2, 6, 23, 0.48);
  border-color: rgba(56, 189, 248, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.app-shell .mobile-toggle {
  display: none;
  flex-shrink: 0;
  border: 1px solid var(--shell-glass-border);
  background: rgba(148, 163, 184, 0.12);
  color: var(--shell-brand-fg);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.app-shell .mobile-toggle .sarial-ico {
  display: block;
}

[data-theme="dark"] .app-shell .mobile-toggle {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

@media (max-width: 1024px) {
  .app-shell .mobile-toggle {
    display: inline-flex;
  }
}

html[data-theme="dark"]:has(.app-shell) body {
  background: #050a18;
  color: #e2e8f0;
}

html[data-theme="light"]:has(.app-shell) body {
  background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
  color: #0f172a;
}

/* ——— Admin dashboard ——— */
.app-shell .admin-dash-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 0.25rem;
  border: 1px solid var(--shell-glass-border);
  background: linear-gradient(135deg, rgba(23, 88, 187, 0.12), rgba(0, 242, 255, 0.06));
}

[data-theme="dark"] .app-shell .admin-dash-hero {
  background: linear-gradient(125deg, rgba(0, 98, 255, 0.18), rgba(5, 10, 24, 0.4));
}

.app-shell .admin-dash-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--shell-muted);
}

.app-shell .admin-dash-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--shell-brand-fg);
  font-family: Sora, sans-serif;
}

.app-shell .admin-dash-lead {
  margin: 0;
  max-width: 52ch;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--shell-muted);
}

.app-shell .admin-dash-hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.app-shell .admin-dash-hero-metrics > div {
  min-width: 5.5rem;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  background: var(--shell-glass);
  border: 1px solid var(--shell-glass-border);
  text-align: center;
}

.app-shell .admin-dash-hero-metrics strong {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  font-family: Sora, sans-serif;
  color: var(--shell-panel-title);
}

.app-shell .admin-dash-hero-metrics span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--shell-muted);
}

/* ——— Dashboard layout unificato (admin + tenant) ——— */
.app-shell .dash-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 1600px;
  width: 100%;
  margin-inline: auto;
}

.app-shell .dash-hero {
  margin-bottom: 0;
  border: 1px solid var(--shell-glass-border);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(23, 88, 187, 0.12), rgba(0, 242, 255, 0.06));
}

[data-theme="dark"] .app-shell .dash-hero {
  background: linear-gradient(125deg, rgba(0, 98, 255, 0.18), rgba(5, 10, 24, 0.4));
}

.app-shell .dash-hero--tenant {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(23, 88, 187, 0.08));
}

[data-theme="dark"] .app-shell .dash-hero--tenant {
  background: linear-gradient(125deg, rgba(16, 185, 129, 0.14), rgba(0, 98, 255, 0.12));
}

.app-shell .dash-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem 1.5rem;
  align-items: end;
}

.app-shell .dash-hero__grid--tenant {
  align-items: start;
}

@media (min-width: 900px) {
  .app-shell .dash-hero__grid--tenant {
    align-items: end;
  }
}

.app-shell .dash-hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

.app-shell .dash-hero-metrics--hero {
  justify-content: flex-end;
}

.app-shell .dash-hero-metric {
  min-width: 5.25rem;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  background: var(--shell-glass);
  border: 1px solid var(--shell-glass-border);
  text-align: center;
}

.app-shell .dash-hero-metric strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  font-family: Sora, sans-serif;
  color: var(--shell-panel-title);
  line-height: 1.15;
}

.app-shell .dash-hero-metric span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--shell-muted);
  margin-top: 0.15rem;
}

.app-shell .dash-hero-metric--alert {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

.app-shell .dash-hero-metric--warn {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.08);
}

/* Admin dashboard hero: evita colonna `auto` che comprime il testo con 6 KPI */
.app-shell .dash-hero__grid--admin {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.app-shell .dash-hero__grid--admin .dash-hero__intro {
  max-width: 42rem;
}

.app-shell .dash-hero__grid--admin .admin-dash-hero-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr));
  gap: 0.55rem;
  width: 100%;
  justify-content: stretch;
}

.app-shell .dash-hero__grid--admin .admin-dash-hero-metrics .dash-hero-metric {
  min-width: 0;
}

@media (min-width: 720px) {
  .app-shell .dash-hero__grid--admin .admin-dash-hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .app-shell .dash-hero__grid--admin {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    align-items: center;
    gap: 1rem 1.35rem;
  }

  .app-shell .dash-hero__grid--admin .admin-dash-hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.app-shell .admin-global-search-input {
  width: 100%;
  max-width: 36rem;
}

.app-shell .admin-search-out {
  margin-top: 0.65rem;
}

.app-shell .admin-search-group {
  margin-top: 0.85rem;
}

.app-shell .admin-search-group:first-child {
  margin-top: 0.25rem;
}

.app-shell .admin-search-group__title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.35rem;
  color: var(--shell-muted);
  font-weight: 800;
}

.app-shell .admin-search-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.app-shell .admin-search-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--shell-glass-border);
}

.app-shell .admin-search-list__row:last-child {
  border-bottom: none;
}

.app-shell .admin-posture-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.app-shell .admin-posture-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.65rem;
  line-height: 1.4;
}

.app-shell .dash-section-head {
  margin-bottom: 1rem;
}

.app-shell .dash-section-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--shell-brand-fg);
  font-family: Sora, sans-serif;
}

.app-shell .dash-section-lead {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.app-shell .dash-section--pulse h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--shell-brand-fg);
  font-family: Sora, sans-serif;
}

.app-shell .dash-group-title {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--shell-muted);
}

.app-shell .panel.dash-section .dash-group-title:first-child {
  margin-top: 0;
}

.app-shell .dash-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.app-shell .dash-stat-grid--dense {
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
}

.app-shell .stat.dash-stat {
  padding: 1rem 0.85rem;
  align-items: center;
}

.app-shell .stat.dash-stat .value {
  font-size: 1.65rem;
}

.app-shell .stat.dash-stat--brand {
  border-color: rgba(23, 88, 187, 0.35);
  background: linear-gradient(180deg, rgba(23, 88, 187, 0.1), var(--shell-glass));
}

.app-shell .stat.dash-stat--ok {
  border-color: rgba(16, 185, 129, 0.28);
}

.app-shell .stat.dash-stat--warn {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.06);
}

.app-shell .stat.dash-stat--danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

.app-shell .dash-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  gap: 1.25rem;
  align-items: stretch;
}

.app-shell .dash-pulse-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.app-shell .dash-pulse-row .stat.dash-stat .value {
  font-size: 1.45rem;
}

.app-shell .dash-footer-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.app-shell .dash-table-wrap {
  margin-top: 0.5rem;
}

.app-shell .dash-role-pill-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
}

.app-shell .dash-kicker-inline {
  margin: 0;
}

.app-shell .dash-priority-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.app-shell .dash-priority-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--shell-glass-border);
  background: var(--shell-glass);
}

.app-shell .dash-priority-card--ok {
  border-color: rgba(16, 185, 129, 0.28);
}

.app-shell .dash-priority-card--warn {
  border-color: rgba(245, 158, 11, 0.42);
  background: rgba(245, 158, 11, 0.06);
}

.app-shell .dash-priority-card__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.app-shell .dash-priority-card__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--shell-muted);
}

.app-shell .dash-priority-card__value {
  font-size: 1.45rem;
  font-weight: 800;
  font-family: Sora, sans-serif;
  color: var(--shell-stat-value);
}

@media (min-width: 720px) {
  .app-shell .dash-priority-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .app-shell .dash-priority-card {
    flex-direction: column;
    align-items: stretch;
  }

  .app-shell .dash-priority-card__btn {
    width: 100%;
    margin-top: 0.25rem;
  }
}

.app-shell .dash-lotti-priority {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

@media (min-width: 720px) {
  .app-shell .dash-lotti-priority {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

/* Tenant cockpit desktop: schede Panoramica / Temperature / Lotti */
.app-shell .dash-cockpit-toolbar {
  margin-bottom: 0.75rem;
}

.app-shell .dash-cockpit-tabs {
  flex-wrap: wrap;
}

.app-shell .dash-haccp-bar {
  margin-bottom: 0.75rem;
}

.app-shell .dash-haccp-bar__track {
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  overflow: hidden;
}

.app-shell .dash-haccp-bar__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #38bdf8);
  transition: width 0.35s ease;
}

.app-shell .dash-haccp-bar__label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.app-shell .dash-cockpit-kpis {
  margin-bottom: 1rem;
}

.app-shell .dash-cockpit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1099px) {
  .app-shell .dash-cockpit-grid {
    grid-template-columns: 1fr;
  }
}

.app-shell .dash-cockpit-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.app-shell .dash-fridge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.65rem;
}

.app-shell .dash-fridge-grid--wide {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.app-shell .dash-fridge-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--shell-glass-border);
  background: var(--shell-glass);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.app-shell .dash-fridge-card:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.45);
}

.app-shell .dash-fridge-card--ok {
  border-color: rgba(16, 185, 129, 0.35);
}

.app-shell .dash-fridge-card--warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.05);
}

.app-shell .dash-fridge-card--alarm {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.06);
}

.app-shell .dash-fridge-card--offline {
  border-color: rgba(148, 163, 184, 0.5);
  opacity: 0.92;
}

.app-shell .dash-fridge-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.app-shell .dash-fridge-card__name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
}

.app-shell .dash-fridge-card__badge {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
}

.app-shell .dash-fridge-card--alarm .dash-fridge-card__badge {
  background: rgba(248, 113, 113, 0.25);
}

.app-shell .dash-fridge-card--warning .dash-fridge-card__badge {
  background: rgba(245, 158, 11, 0.28);
}

.app-shell .dash-fridge-card__mid {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.app-shell .dash-fridge-card__temp {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: Sora, sans-serif;
}

.app-shell .dash-fridge-card__ago {
  font-size: 0.78rem;
}

.app-shell .dash-fridge-card__range {
  font-size: 0.78rem;
  margin: 0;
}

.app-shell .dash-fridge-card__spark {
  margin-top: 0.15rem;
}

.app-shell .dash-spark {
  display: block;
  width: 100%;
  max-width: 128px;
  color: #38bdf8;
}

.app-shell .dash-spark--alarm {
  color: #f87171;
}

.app-shell .dash-spark--warning {
  color: #fbbf24;
}

.app-shell .dash-spark--offline {
  color: #94a3b8;
}

.app-shell .dash-spark--ok {
  color: #38bdf8;
}

.app-shell .dash-hour-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding-top: 0.25rem;
}

.app-shell .dash-hour-chart--wide {
  height: 140px;
}

.app-shell .dash-hour-slot {
  flex: 1;
  min-width: 0;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.85), rgba(14, 165, 233, 0.35));
  height: var(--slot-h, 40%);
  align-self: flex-end;
}

.app-shell .dash-hour-slot--empty {
  height: 12%;
  background: rgba(148, 163, 184, 0.15);
}

.app-shell .dash-chart-card__title {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.app-shell .dash-cockpit-aside {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.app-shell .dash-desk-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.app-shell .dash-desk-feed-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(148, 163, 184, 0.08);
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.app-shell .dash-desk-feed-row:hover {
  border-color: rgba(56, 189, 248, 0.35);
}

.app-shell .dash-desk-feed-title {
  font-size: 0.86rem;
  min-width: 0;
}

.app-shell .dash-desk-feed-meta {
  font-size: 0.75rem;
  color: var(--shell-muted);
  flex-shrink: 0;
}

.app-shell .dash-cockpit-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--shell-glass-border);
  font-size: 0.85rem;
}

/* Tenant dashboard: vista mobile “premium” vs layout desktop (wrapper .dash-desktop-only) */
.app-shell .dash-desktop-only {
  display: contents;
}
.app-shell .dash-mobile-premium {
  display: none;
}
@media (max-width: 719px) {
  .app-shell .dash-mobile-premium {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  .app-shell .dash-desktop-only {
    display: none !important;
  }
}
html.mobile-app-chrome .app-shell .dash-mobile-premium {
  display: flex;
  flex-direction: column;
  width: 100%;
}
html.mobile-app-chrome .app-shell .dash-desktop-only {
  display: none !important;
}

/* Dashboard ristoratore: layout mobile “SARIAL” (hero, KPI, feed allarmi/lotti) */
.app-shell .dash-mobile-premium {
  box-sizing: border-box;
  padding: 0.15rem 0 1rem;
  gap: 0.85rem;
}
.app-shell .dash-mob-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.15rem 0.5rem;
}

.app-shell .dash-mob-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--shell-muted);
}

.app-shell .dash-mob-title {
  margin: 0;
  font-family: var(--ui-font-display, Sora, sans-serif);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--shell-brand-fg);
}

.app-shell .dash-mob-lead {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--shell-muted);
}

.app-shell .dash-mob-shield {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #38bdf8;
  background: linear-gradient(165deg, rgba(56, 189, 248, 0.14), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.12),
    0 12px 32px rgba(56, 189, 248, 0.18);
}

.app-shell .dash-mob-stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.app-shell .dash-mob-stat {
  border: 0;
  border-radius: var(--ui-radius-sm, 12px);
  padding: 0.55rem 0.35rem;
  min-height: 4.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  text-align: center;
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.app-shell .dash-mob-stat:active {
  transform: scale(0.98);
}

.app-shell .dash-mob-stat strong {
  font-family: var(--ui-font-display, Sora, sans-serif);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

.app-shell .dash-mob-stat span {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.92;
}

.app-shell .dash-mob-stat--static {
  cursor: default;
}

.app-shell .dash-mob-stat--blue {
  color: #e0f2fe;
  background: linear-gradient(165deg, rgba(59, 130, 246, 0.35), rgba(14, 165, 233, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.42);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.16);
}

.app-shell .dash-mob-stat--red {
  color: #ffe4e6;
  background: linear-gradient(165deg, rgba(244, 63, 94, 0.42), rgba(190, 18, 60, 0.15));
  border: 1px solid rgba(251, 113, 133, 0.45);
  box-shadow: 0 8px 22px rgba(225, 29, 72, 0.18);
}

.app-shell .dash-mob-stat--amber {
  color: #fffbeb;
  background: linear-gradient(165deg, rgba(245, 158, 11, 0.4), rgba(217, 119, 6, 0.14));
  border: 1px solid rgba(251, 191, 36, 0.42);
  box-shadow: 0 8px 22px rgba(245, 158, 11, 0.15);
}

.app-shell .dash-mob-card {
  border-radius: var(--ui-radius-md, 16px);
  padding: 0.65rem 0.65rem 0.45rem;
  background: var(--shell-glass);
  border: 1px solid var(--shell-glass-border);
  box-shadow: var(--ui-shadow-soft);
}

.app-shell .dash-mob-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.app-shell .dash-mob-card-head h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--shell-panel-title);
}

.app-shell .dash-mob-link {
  border: 0;
  background: transparent;
  padding: 0.15rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
  cursor: pointer;
  font: inherit;
}

.app-shell .dash-mob-feed {
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-shell .dash-mob-feed li + li {
  margin-top: 0.15rem;
}

.app-shell .dash-mob-feed-empty {
  padding: 0.65rem 0.35rem;
  font-size: 0.82rem;
}

.app-shell .dash-mob-feed-row {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.35rem;
  border-radius: 12px;
  border: 0;
  background: color-mix(in srgb, var(--shell-table-bg, rgba(15, 23, 42, 0.5)) 88%, transparent);
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.app-shell .dash-mob-feed-row:active {
  filter: brightness(1.06);
}

.app-shell .dash-mob-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.app-shell .dash-mob-icon--temp {
  background: rgba(244, 63, 94, 0.18);
  border: 1px solid rgba(251, 113, 133, 0.35);
}

.app-shell .dash-mob-icon--hum {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(96, 165, 250, 0.38);
}

.app-shell .dash-mob-icon--warn {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.38);
}

.app-shell .dash-mob-icon--lot {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(192, 132, 252, 0.35);
}

.app-shell .dash-mob-icon .sarial-ico {
  display: block;
}

.app-shell .dash-mob-feed-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.app-shell .dash-mob-feed-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--shell-td-color);
}

.app-shell .dash-mob-feed-sub {
  font-size: 0.69rem;
  color: var(--shell-muted);
}

.app-shell .dash-mob-feed-meta {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--shell-muted);
  white-space: nowrap;
}

.app-shell .dash-mob-feed-badge {
  font-size: 0.62rem;
  font-weight: 800;
  color: #fbbf24;
  white-space: nowrap;
}

.app-shell .dash-mob-quick-title {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--shell-panel-title);
}

.app-shell .dash-mob-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.app-shell .dash-mob-qbtn {
  border-radius: 14px;
  border: 1px solid var(--shell-glass-border);
  padding: 0.55rem 0.45rem;
  background: color-mix(in srgb, var(--shell-table-bg, #0f172a) 75%, transparent);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  color: var(--shell-td-color);
  font: inherit;
}

.app-shell .dash-mob-qbtn span[aria-hidden="true"] {
  font-size: 1.25rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-shell .dash-mob-qbtn span[aria-hidden="true"] .sarial-ico {
  display: block;
}

.app-shell .dash-mob-qbtn:active {
  transform: scale(0.98);
}

/* Desktop tenant: hero + cockpit a tutta larghezza */
@media (min-width: 900px) {
  .app-shell .dash-page--tenant {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 1.25rem;
    row-gap: 1.25rem;
    align-items: start;
  }

  .app-shell .dash-page--tenant .dash-desktop-only > section:nth-child(1) {
    grid-column: 1 / -1;
  }

  .app-shell .dash-page--tenant .dash-desktop-only > section:nth-child(2) {
    grid-column: 1 / -1;
  }
}

/* Layout esplicito dashboard tenant (cockpit sotto la hero) */
@media (min-width: 900px) {
  .app-shell .dash-page--tenant .dash-desktop-only .dash-hero {
    grid-column: 1 / -1;
  }
  .app-shell .dash-page--tenant .dash-desktop-only .dash-tenant-cockpit {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1000px) {
  .app-shell .dash-page--admin {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
  }
  .app-shell .dash-page--admin > .dash-hero {
    grid-column: 1 / -1;
  }
  .app-shell .dash-page--admin > .dash-admin-search {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .app-shell .dash-page--admin > .dash-admin-quick {
    grid-column: 1 / -1;
    grid-row: 3;
  }
  .app-shell .dash-page--admin > .dash-admin-infra {
    grid-column: 1;
    grid-row: 4;
  }
  .app-shell .dash-page--admin > .dash-admin-people {
    grid-column: 2;
    grid-row: 4;
  }
  .app-shell .dash-page--admin > .dash-admin-opslive {
    grid-column: 1 / -1;
    grid-row: 5;
  }
  .app-shell .dash-page--admin > .dash-admin-posture {
    grid-column: 1 / -1;
    grid-row: 6;
  }
  .app-shell .dash-page--admin > .dash-admin-split {
    grid-column: 1 / -1;
    grid-row: 7;
  }
}

@media (max-width: 999px) {
  .app-shell .dash-page--admin,
  .app-shell .dash-page--tenant {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
}

/* === Dashboard redesign drastico (admin + ristoratore) === */
.app-shell .dash-page--tenant,
.app-shell .dash-page--admin {
  gap: 1rem;
}

.app-shell .dash-section,
.app-shell .dash-hero {
  padding: 1rem 1.05rem;
}

.app-shell .dash-stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.app-shell .quick-actions-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
}

.app-shell .quick-action-card {
  min-height: 88px;
  justify-content: center;
}

.app-shell .dash-hero__grid {
  gap: 0.9rem 1rem;
}

@media (min-width: 1100px) {
  .app-shell .dash-page--tenant {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-areas:
      "hero hero"
      "cockpit cockpit";
    gap: 1rem;
    align-items: start;
  }
  .app-shell .dash-page--tenant .dash-desktop-only .dash-hero {
    grid-area: hero;
  }
  .app-shell .dash-page--tenant .dash-desktop-only .dash-tenant-cockpit {
    grid-area: cockpit;
  }

  .app-shell .dash-page--admin {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-areas:
      "hero hero"
      "search search"
      "quick quick"
      "infra people"
      "opslive opslive"
      "posture posture"
      "split split";
    gap: 1rem;
    align-items: start;
  }
  .app-shell .dash-page--admin > .dash-hero {
    grid-area: hero;
  }
  .app-shell .dash-page--admin > .dash-admin-search {
    grid-area: search;
  }
  .app-shell .dash-page--admin > .dash-admin-quick {
    grid-area: quick;
  }
  .app-shell .dash-page--admin > .dash-admin-infra {
    grid-area: infra;
  }
  .app-shell .dash-page--admin > .dash-admin-people {
    grid-area: people;
  }
  .app-shell .dash-page--admin > .dash-admin-opslive {
    grid-area: opslive;
  }
  .app-shell .dash-page--admin > .dash-admin-posture {
    grid-area: posture;
  }
  .app-shell .dash-page--admin > .dash-admin-split {
    grid-area: split;
  }
}

@media (max-width: 1099px) {
  /* Solo tenant in colonna: admin tra 1000–1099 usa la griglia definita sopra (min-width: 1000px). */
  .app-shell .dash-page--tenant {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
  }
  .app-shell .dash-page--admin {
    gap: 0.9rem;
  }
  .app-shell .dash-hero-metrics--hero {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 0.45rem;
  }
  .app-shell .dash-hero-metric {
    min-width: 0;
    padding: 0.5rem 0.4rem;
  }
  .app-shell .dash-hero-metric strong {
    font-size: 1.06rem;
  }
  .app-shell .dash-hero-metric span {
    font-size: 0.6rem;
  }
  .app-shell .quick-actions-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .app-shell .dash-stat-grid,
  .app-shell .dash-stat-grid--dense {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell .dash-hero__grid {
    grid-template-columns: 1fr;
  }

  .app-shell .dash-hero-metrics--hero {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    width: 100%;
    justify-content: stretch;
  }

  .app-shell .dash-hero-metrics {
    justify-content: stretch;
    width: 100%;
  }

  .app-shell .dash-hero-metric {
    min-width: 0;
    padding: 0.55rem 0.45rem;
  }

  .app-shell .dash-hero-metric strong {
    font-size: 1.12rem;
  }

  .app-shell .dash-hero-metric span {
    font-size: 0.62rem;
  }

  .app-shell .dash-split {
    grid-template-columns: 1fr;
  }

  .app-shell .dash-pulse-row {
    grid-template-columns: 1fr;
  }
  .app-shell .quick-actions-grid {
    grid-template-columns: 1fr;
  }
  .app-shell .dash-stat-grid,
  .app-shell .dash-stat-grid--dense {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.app-shell .quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.75rem;
}

.app-shell .quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border-radius: var(--ui-radius-md);
  border: 1px solid var(--shell-glass-border);
  background: rgba(148, 163, 184, 0.06);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  color: inherit;
}

[data-theme="dark"] .app-shell .quick-action-card {
  background: var(--mock-widget-bg);
  border-color: var(--mock-widget-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 28px rgba(2, 8, 23, 0.4),
    0 0 40px rgba(79, 70, 229, 0.08);
}

.app-shell .quick-action-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
}

[data-theme="dark"] .app-shell .quick-action-card:hover {
  border-color: rgba(45, 212, 191, 0.38);
  box-shadow:
    0 16px 44px rgba(2, 8, 23, 0.52),
    0 0 56px rgba(79, 70, 229, 0.14),
    0 0 0 1px rgba(56, 189, 248, 0.12);
}

.app-shell .quick-action-icon {
  font-size: 1.35rem;
  line-height: 1;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-shell .quick-action-icon .sarial-ico {
  display: block;
}

.app-shell .quick-action-label {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--shell-brand-fg);
}

.app-shell .quick-action-hint {
  font-size: 0.78rem;
  color: var(--shell-muted);
  line-height: 1.35;
}

.app-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, 0.68);
  display: grid;
  place-items: center;
  z-index: 3000;
  padding: 16px;
}

.app-dialog-card {
  width: min(100%, 480px);
  border-radius: 16px;
  border: 1px solid var(--shell-glass-border, rgba(148, 163, 184, 0.32));
  background: var(--panel, rgba(255, 255, 255, 0.92));
  box-shadow: 0 20px 48px rgba(2, 8, 23, 0.35);
  padding: 16px;
}

html[data-theme="dark"] .app-dialog-card {
  background: #0b1224;
  border-color: rgba(148, 163, 184, 0.26);
}

.app-dialog-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.app-dialog-message {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

html[data-theme="dark"] .app-dialog-message {
  color: #94a3b8;
}

.app-dialog-form {
  display: grid;
  gap: 10px;
}

.dialog-label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.dialog-input {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  border-radius: 10px;
  padding: 10px 12px;
}

.field-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.field-error-text {
  margin-top: 2px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #b91c1c;
  font-weight: 700;
}

html[data-theme="dark"] .dialog-input {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.75);
  color: #e2e8f0;
}

html[data-theme="dark"] .field-error {
  border-color: #f87171 !important;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.2);
}

html[data-theme="dark"] .field-error-text {
  color: #fecaca;
}

.app-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
}

.admin-pwd-actions,
.admin-actions-wrap {
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* Riduce blur compositing su tablet/mobile (meno lag su Safari iOS / GPU integrate) */
@media (max-width: 900px) {
  .app-shell .sidebar {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  .app-shell-topbar {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .app-shell .panel {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell .sidebar {
    transition: none;
  }
}

/* Superficie UI: testo non selezionabile (sorgente/non estrazione rapida). Eccezioni: campi e messaggi di sistema. */
#app {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#app input,
#app textarea,
#app select,
#app [contenteditable="true"],
#app .allow-copy,
#app .error-box,
#app .success-box,
#app .app-dialog-message {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.hccp-toast,
.hccp-toast-zone {
  -webkit-user-select: text;
  user-select: text;
}

/* Toast */
.hccp-toast-zone {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, 92vw);
  pointer-events: none;
}
.hccp-toast {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.35;
  box-shadow: 0 10px 36px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: auto;
}
.hccp-toast--in { opacity: 1; transform: translateY(0); }
.hccp-toast--out { opacity: 0; transform: translateY(6px); }
.hccp-toast--success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.hccp-toast--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.hccp-toast--info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
html[data-theme="dark"] .hccp-toast--success {
  background: rgba(6, 95, 70, 0.35);
  color: #d1fae5;
  border-color: rgba(16, 185, 129, 0.45);
}
html[data-theme="dark"] .hccp-toast--error {
  background: rgba(127, 29, 29, 0.4);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.45);
}
html[data-theme="dark"] .hccp-toast--info {
  background: rgba(30, 64, 175, 0.35);
  color: #dbeafe;
  border-color: rgba(96, 165, 250, 0.45);
}

/* Lotti: progress bar upload */
.lots-upload-track {
  height: 8px;
  border-radius: 6px;
  background: rgba(23, 88, 187, 0.15);
  overflow: hidden;
}
.lots-upload-bar {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width 0.12s ease-out;
}
.lots-filter.inner-panel {
  padding: 12px 14px;
  background: rgba(23, 88, 187, 0.06);
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

/* Export storico lotti/temperature: stessa “card” interna dei filtri lotti */
.app-shell .panel.inner-panel.hist-export-panel {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(23, 88, 187, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 22px rgba(2, 8, 23, 0.06);
}

html[data-theme="dark"] .app-shell .panel.inner-panel.hist-export-panel {
  background: rgba(23, 88, 187, 0.12);
  border-color: rgba(226, 232, 240, 0.12);
}
.app-shell .lots-filter-form .lots-filter-head {
  margin: 0 0 10px;
}
.app-shell .lots-filter-form .lots-filter-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--shell-panel-title, #0f172a);
}
.app-shell .lots-filter-form .lots-filter-help {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.42;
  color: var(--muted);
  max-width: 72ch;
}
.app-shell .lots-filter-form .lots-filter-tip {
  margin: 8px 0 0;
  font-size: 0.8rem;
}
html[data-theme="dark"] .lots-filter.inner-panel {
  background: rgba(23, 88, 187, 0.12);
  border-color: rgba(226, 232, 240, 0.12);
}

/* Desktop dark-mode: migliora leggibilità filtri/esportazione lotti */
@media (min-width: 1025px) {
  [data-theme="dark"] .app-shell .hist-export-dates input[type="date"],
  [data-theme="dark"] .app-shell .lots-filter-form input[type="date"],
  [data-theme="dark"] .app-shell .lots-filter-form input[type="search"],
  [data-theme="dark"] .app-shell .lots-filter-form select {
    background-color: #0f1b33;
    border-color: rgba(148, 163, 184, 0.42);
    color: #eaf2ff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  }

  [data-theme="dark"] .app-shell .lots-filter-form input[type="search"]::placeholder {
    color: rgba(191, 219, 254, 0.72);
  }

  [data-theme="dark"] .app-shell .lots-filter-form input[type="date"]:hover,
  [data-theme="dark"] .app-shell .lots-filter-form input[type="search"]:hover,
  [data-theme="dark"] .app-shell .lots-filter-form select:hover,
  [data-theme="dark"] .app-shell .hist-export-dates input[type="date"]:hover {
    border-color: rgba(96, 165, 250, 0.68);
    background-color: #12223f;
  }

  [data-theme="dark"] .app-shell .lots-filter-form input[type="date"]:focus,
  [data-theme="dark"] .app-shell .lots-filter-form input[type="search"]:focus,
  [data-theme="dark"] .app-shell .lots-filter-form select:focus,
  [data-theme="dark"] .app-shell .hist-export-dates input[type="date"]:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
  }

  [data-theme="dark"] .app-shell .lots-filter-form select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.3rem;
    background-image:
      linear-gradient(45deg, transparent 50%, #9fb7e8 50%),
      linear-gradient(135deg, #9fb7e8 50%, transparent 50%);
    background-position:
      calc(100% - 16px) calc(50% - 3px),
      calc(100% - 10px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
  }
}

/* Lotti: pannello filtri — layout dedicato (mese su una riga, griglia compatta su desktop) */
.app-shell .lots-filter-form .lots-filter-grid {
  display: grid;
  gap: 0.75rem 1rem;
  grid-template-columns: 1fr;
  align-items: end;
}
.app-shell .lots-filter-form .lots-filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  min-width: 0;
}
.app-shell .lots-filter-form label.lots-filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}
.app-shell .lots-filter-form .lots-filter-kicker {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.2;
}
.app-shell .lots-filter-form .lots-month-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  max-width: 22rem;
}
.app-shell .lots-filter-form .lots-month-btn {
  flex: 0 0 auto;
  min-width: 2.35rem;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}
.app-shell .lots-filter-form .lots-month-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}
.app-shell .lots-filter-form .lots-day-nav {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}
.app-shell .lots-filter-form .lots-day-nav input[type="date"] {
  flex: 1 1 auto;
  min-width: 0;
}
.app-shell .lots-filter-form .lots-day-nav button {
  flex: 0 0 auto;
}
.app-shell .lots-filter-form .lots-filter-field--search input[type="search"] {
  width: 100%;
  max-width: 36rem;
}
.app-shell .lots-filter-form .lots-filter-field--actions {
  padding-top: 0.15rem;
}
.app-shell .lots-filter-form .lots-filter-field--actions .lots-filter-submit {
  width: 100%;
  max-width: 16rem;
}

@media (min-width: 420px) {
  .app-shell .lots-filter-form .lots-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .app-shell .lots-filter-form .lots-filter-field--month,
  .app-shell .lots-filter-form .lots-filter-field--mode,
  .app-shell .lots-filter-form .lots-filter-field--day,
  .app-shell .lots-filter-form .lots-filter-field--search,
  .app-shell .lots-filter-form .lots-filter-field--actions {
    grid-column: 1 / -1;
  }
  .app-shell .lots-filter-form .lots-filter-field--actions {
    justify-self: start;
  }
  .app-shell .lots-filter-form .lots-month-nav {
    max-width: none;
  }
}

@media (min-width: 768px) {
  /* Desktop/tablet: due righe chiare — niente “mese” che occupa due righe (evita pulsante Apply centrato in verticale). */
  .app-shell .lots-filter-form .lots-filter-grid {
    grid-template-columns: minmax(9rem, 11rem) minmax(11rem, 13rem) minmax(14rem, 1fr) minmax(10rem, 12rem);
    grid-template-rows: auto auto;
    column-gap: 1rem;
    row-gap: 0.75rem;
    align-items: end;
  }
  .app-shell .lots-filter-form .lots-filter-field--mode {
    grid-column: 1;
    grid-row: 1;
  }
  .app-shell .lots-filter-form .lots-filter-field--day {
    grid-column: 2;
    grid-row: 1;
  }
  .app-shell .lots-filter-form .lots-filter-field--search {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
  }
  .app-shell .lots-filter-form .lots-filter-field--actions {
    grid-column: 4;
    grid-row: 1;
    padding-top: 0;
    justify-self: end;
    align-self: end;
  }
  .app-shell .lots-filter-form .lots-filter-field--actions .lots-filter-submit {
    width: auto;
    min-width: 9.5rem;
    max-width: none;
  }
  .app-shell .lots-filter-form .lots-filter-field--month {
    grid-column: 1 / span 2;
    grid-row: 2;
    justify-self: stretch;
  }
  .app-shell .lots-filter-form .lots-filter-field--filter {
    grid-column: 3;
    grid-row: 2;
    max-width: 18rem;
    justify-self: start;
  }
  .app-shell .lots-filter-form .lots-filter-field--limit {
    grid-column: 4;
    grid-row: 2;
    max-width: 12rem;
    justify-self: end;
  }
}

.app-shell .lots-month-row td {
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--shell-panel-title, #1e3a8a);
  background: color-mix(in srgb, var(--shell-table-head-bg, #e0ebff) 55%, transparent);
}
.app-shell .lots-month-badge {
  display: inline-block;
  margin-right: 0.55rem;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  color: #1e3a8a;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.26);
}
html[data-theme="dark"] .app-shell .lots-month-badge {
  color: #93c5fd;
  background: rgba(30, 64, 175, 0.3);
  border-color: rgba(96, 165, 250, 0.35);
}

/* Accessibilità: focus visibile su controlli custom */
.app-shell .btn:focus-visible,
.app-shell [data-set-theme]:focus-visible,
.landing-page .btn-glow:focus-visible,
.landing-page .btn-main:focus-visible,
.login-page-wrap .btn-ghost:focus-visible,
.login-page-wrap .btn-glow:focus-visible {
  outline: 2px solid rgba(0, 242, 255, 0.85);
  outline-offset: 2px;
}

/* ——— Chrome “app” mobile (viewport stretto): tab bar, safe area, scroll area ——— */
.app-bottom-nav {
  display: none;
}

.cookie-consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  padding: 10px;
  box-sizing: border-box;
}
.cookie-consent-banner__inner {
  max-width: 980px;
  margin: 0 auto;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.cookie-consent-banner__title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
}
.cookie-consent-banner__text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
}
.cookie-consent-banner__links {
  margin: 6px 0 0;
  font-size: 0.8rem;
}
.cookie-consent-banner__links a {
  color: #93c5fd;
}
.cookie-consent-banner__actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.cookie-prefs-btn {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 1180;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.86);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}
.cookie-prefs-btn--icon {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  justify-content: center;
  align-items: center;
  padding: 0;
  display: inline-flex;
  font-size: 1.02rem;
}
.cookie-prefs-btn__emoji {
  display: inline-flex;
  line-height: 1;
  transform: translateY(-0.5px);
}
.landing-cookie-menu-btn {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.28);
  color: inherit;
  border-radius: 999px;
  padding: 0.15rem 0.58rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.landing-cookie-menu-btn:hover {
  border-color: rgba(125, 211, 252, 0.55);
  background: rgba(15, 23, 42, 0.42);
}
html[data-theme="light"] .cookie-consent-banner__inner {
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.13);
}
html[data-theme="light"] .cookie-consent-banner__links a {
  color: #1d4ed8;
}
html[data-theme="light"] .cookie-prefs-btn {
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.2);
}
html[data-theme="light"] .landing-cookie-menu-btn {
  background: rgba(241, 245, 249, 0.88);
  border-color: rgba(15, 23, 42, 0.18);
}
@media (max-width: 640px) {
  .cookie-consent-banner__actions {
    justify-content: stretch;
  }
  .cookie-consent-banner__actions .btn {
    flex: 1 1 0;
  }
}

html.mobile-app-chrome {
  /* Evita zoom indesiderato su focus iOS */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

html.mobile-app-chrome .app-shell {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

html.mobile-app-chrome .login-shell,
html.mobile-app-chrome .login-page-wrap {
  padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
  padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

html.mobile-app-chrome .landing-page .landing-hero__brandmark {
  padding-left: max(0, env(safe-area-inset-left, 0px));
  padding-right: max(0, env(safe-area-inset-right, 0px));
}

html.mobile-app-chrome .app-shell-topbar {
  /* Safe area status bar / Dynamic Island (viewport-fit=cover); constant() = iOS 11.2–11.4 */
  padding-top: calc(1.05rem + constant(safe-area-inset-top, 0px));
  padding-top: calc(1.05rem + env(safe-area-inset-top, 0px));
  padding-left: max(0.8rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.8rem, env(safe-area-inset-right, 0px));
  padding-bottom: 0.65rem;
  min-height: calc(3.25rem + constant(safe-area-inset-top, 0px));
  min-height: calc(3.25rem + env(safe-area-inset-top, 0px));
  align-items: center;
}

/* Tema chiaro: fascia superiore come ref. Sarial (bianco/grigio chiaro, bordo leggero). */
html[data-theme="light"].mobile-app-chrome .app-shell-topbar {
  background: rgba(248, 250, 252, 0.97);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

html.mobile-app-chrome .app-shell .sidebar {
  height: 100svh !important;
  height: 100dvh !important;
  max-height: 100svh;
  max-height: 100dvh;
  padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  width: min(88vw, 320px) !important;
  max-width: 100%;
}

/* Drawer: colonna fissa in altezza, solo l’elenco voci scrolla (min-height:auto rompeva il touch su mobile) */
html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  min-height: 0 !important;
}

html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer .sidebar-drawer-handle,
html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer .app-shell-brandblock,
html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer .app-drawer-section-label,
html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer .sidebar-storage,
html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer .sidebar-account-wrap,
html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer .sidebar-registers-wrap,
html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer .app-shell-footer {
  flex-shrink: 0;
}

html.mobile-app-chrome .topbar-heading {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

html.mobile-app-chrome .topbar-user {
  font-size: 0.72rem;
  opacity: 0.88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56vw;
}

html.mobile-app-chrome .topbar-actions .pill--tb.info,
html.mobile-app-chrome .topbar-actions .pill--tb.warn {
  display: none;
}

html.mobile-app-chrome .topbar-logout-text {
  display: none;
}

html.mobile-app-chrome .topbar-actions .topbar-logout-btn {
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.55rem;
  justify-content: center;
}

html.mobile-app-chrome .app-shell-main {
  min-height: 0;
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  /* Spazio barra gestito dalla view scrollabile, non qui. */
  padding-bottom: 0;
}

html.mobile-app-chrome .app-shell-view {
  /* flex-basis 0% + min-height 0: fondamentale su iOS/Android per lo scroll nel flex column */
  flex: 1 1 0%;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: auto;
  touch-action: pan-y;
  /* Riserva spazio per barra fissa + safe-area direttamente nel contenuto scrollabile. */
  padding: 0.75rem 0.85rem calc(4.6rem + env(safe-area-inset-bottom, 0px));
  position: relative;
}

html.mobile-app-chrome .app-shell-view .panel {
  scroll-margin-top: calc(4.2rem + env(safe-area-inset-top, 0px));
}

/* .view usa display:grid: su mobile può interferire con l’altezza dello scroll container */
html.mobile-app-chrome .app-shell-main > .app-shell-view.view {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

html.mobile-app-chrome .app-shell .panel {
  /* Vista "pagina unica": meno card annidate, contenuto più continuo e leggibile. */
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0.35rem 0.1rem;
  margin-bottom: 0.85rem;
  overflow: visible;
}

html.mobile-app-chrome .app-shell .panel h2 {
  font-size: 1rem;
  line-height: 1.3;
  margin-bottom: 0.65rem;
  padding-bottom: 0.35rem;
}

/* Mobile app: solo tab bar in basso per il Menu completo. */
html.mobile-app-chrome .app-shell .mobile-toggle {
  display: none !important;
}

html.mobile-app-chrome .app-bottom-nav {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 960;
  justify-content: space-around;
  align-items: stretch;
  gap: 2px;
  /* Home indicator: il padding-bottom include la safe area; lo sfondo copre fino al bordo fisico */
  padding: 6px max(6px, env(safe-area-inset-right, 0px)) max(10px, calc(6px + env(safe-area-inset-bottom, 0px)))
    max(6px, env(safe-area-inset-left, 0px));
  margin: 0;
  box-sizing: border-box;
  background: linear-gradient(180deg, color-mix(in srgb, var(--shell-topbar) 90%, transparent), color-mix(in srgb, var(--shell-topbar) 96%, #000 4%));
  border-top: 1px solid color-mix(in srgb, var(--shell-glass-border) 80%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -14px 36px rgba(2, 8, 23, 0.2);
}

html[data-theme="dark"].mobile-app-chrome .app-bottom-nav {
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.45);
}

html.mobile-app-chrome .app-bottom-nav__btn {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  margin: 0;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--shell-muted);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}
html.mobile-app-chrome .app-bottom-nav__btn:active {
  transform: translateY(1px) scale(0.98);
}

html.mobile-app-chrome .app-bottom-nav__icon {
  font-size: 1.28rem;
  line-height: 1;
  opacity: 0.92;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
html.mobile-app-chrome .app-bottom-nav__icon .sarial-ico {
  display: block;
}

html.mobile-app-chrome .app-bottom-nav__label {
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 0 1px;
  font-size: clamp(0.68rem, 2.9vw, 0.78rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0;
  text-align: center;
  overflow-wrap: anywhere;
  hyphens: auto;
  -webkit-hyphens: auto;
}

html.mobile-app-chrome .app-bottom-nav__btn.is-active {
  color: var(--shell-nav-active-fg);
  background: var(--shell-nav-active-bg);
}

html.mobile-app-chrome .app-bottom-nav__btn--profile .app-bottom-nav__icon {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

html.mobile-app-chrome .hccp-toast-zone {
  bottom: calc(5.1rem + env(safe-area-inset-bottom, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
}

/* App mobile: altezza viewport + colonna flex così .app-shell-view può scrollare (evita “bloccato”) */
@supports selector(body:has(*)) {
  html.mobile-app-chrome body:has(#app .app-shell) {
    min-height: 100dvh;
    min-height: -webkit-fill-available;
  }
  /* Senza web-frame: fallback scroll su body se il flex interno non vincola l’altezza */
  html.mobile-app-chrome:not(.mobile-app-web-frame) body:has(#app .app-shell) {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  html.mobile-app-chrome #app:has(.app-shell) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
  }
}

html.mobile-app-chrome .app-shell.app-shell--mobile-chrome {
  flex: 1 1 0%;
  min-height: 0;
  max-height: none;
  display: flex;
  min-width: 0;
}

html.mobile-app-chrome .sidebar-overlay {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(2, 8, 23, 0.62);
}

html[data-theme="light"].mobile-app-chrome .sidebar-overlay {
  background: rgba(15, 23, 42, 0.45);
}

.sidebar-drawer-handle {
  display: none;
}

html.mobile-app-chrome .sidebar-drawer-handle {
  display: block;
  width: 40px;
  height: 5px;
  border-radius: 5px;
  background: var(--shell-muted);
  opacity: 0.45;
  margin: 0 auto 10px;
  flex-shrink: 0;
}

html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer {
  border-radius: 0 22px 22px 0;
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.38);
}

html[data-theme="light"].mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer {
  box-shadow: 12px 0 36px rgba(15, 23, 42, 0.14);
}

/* Dialog = bottom sheet (stesso contenuto della modale web) */
html.mobile-app-chrome .app-dialog-overlay--sheet {
  align-items: flex-end;
  justify-content: stretch;
  padding: 0;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.mobile-app-chrome .app-dialog-overlay--sheet .app-dialog-card {
  width: 100%;
  max-width: none;
  border-radius: 22px 22px 0 0;
  margin: 0;
  max-height: min(88dvh, 640px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 22px;
  box-sizing: border-box;
}

html.mobile-app-chrome .app-dialog-overlay--sheet .app-dialog-card h3 {
  font-size: 1.1rem;
  padding-right: 8px;
}

html.mobile-app-chrome .app-dialog-overlay--sheet .dialog-input {
  font-size: 16px;
  min-height: 48px;
}

html.mobile-app-chrome .app-dialog-overlay--sheet .app-dialog-actions {
  flex-direction: column-reverse;
  align-items: stretch;
  gap: 10px;
  margin-top: 12px;
}

html.mobile-app-chrome .app-dialog-overlay--sheet .app-dialog-actions .btn {
  width: 100%;
  justify-content: center;
  min-height: 48px;
}

/* Tabelle: scroll orizzontale; altezza libera così la pagina scrolla tutta (no “gabbia” illeggibile) */
html.mobile-app-chrome .app-shell .table-wrap {
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

html.mobile-app-chrome .app-shell .table-wrap table {
  min-width: 460px;
}

html.mobile-app-chrome .app-shell th,
html.mobile-app-chrome .app-shell td {
  padding: 0.75rem 0.65rem;
  font-size: 0.86rem;
}

html.mobile-app-chrome .app-shell .toolbar {
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
  min-width: 0;
}

html.mobile-app-chrome .app-shell .toolbar h2 {
  font-size: 1.02rem;
  line-height: 1.3;
  flex: 1 1 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

html.mobile-app-chrome .app-shell .toolbar input,
html.mobile-app-chrome .app-shell .toolbar select,
html.mobile-app-chrome .app-shell .toolbar textarea {
  width: 100%;
  min-width: 0 !important;
  font-size: 16px;
  min-height: 46px;
  box-sizing: border-box;
}

html.mobile-app-chrome .app-shell .toolbar .btn,
html.mobile-app-chrome .app-shell .toolbar .btn.small {
  min-height: 46px;
  padding-left: 14px;
  padding-right: 14px;
}

/* Mobile app polish (admin + ristoratore): layout lineare, touch-friendly, niente micro-elementi */
html.mobile-app-chrome .app-shell-view .btn,
html.mobile-app-chrome .app-shell-view .btn.small {
  min-height: 46px;
}

html.mobile-app-chrome .app-shell .form-grid {
  grid-template-columns: 1fr !important;
  gap: 10px;
}

html.mobile-app-chrome .app-shell .form-grid .full {
  grid-column: 1 / -1;
}

html.mobile-app-chrome .app-shell .toolbar .toolbar-cluster {
  width: 100%;
  justify-content: stretch;
}

html.mobile-app-chrome .app-shell .toolbar .toolbar-cluster .btn,
html.mobile-app-chrome .app-shell .toolbar .toolbar-cluster .btn.small {
  flex: 1 1 100%;
  min-width: 0;
  justify-content: center;
}

html.mobile-app-chrome .app-shell .grid-4 {
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

html.mobile-app-chrome .app-shell .grid-2 {
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

html.mobile-app-chrome .app-shell .quick-actions-grid {
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Tablet mobile-web-app (iPad / Android tablet): layout dedicato, non “telefono ingrandito”. */
@media (min-width: 769px) and (max-width: 1024px) {
  html.mobile-app-chrome .app-shell-main {
    padding-bottom: 0;
  }

  html.mobile-app-chrome .app-shell-view {
    padding: 1rem 1.05rem calc(4.8rem + env(safe-area-inset-bottom, 0px));
  }

  html.mobile-app-chrome .app-shell .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
  }

  html.mobile-app-chrome .app-shell .quick-actions-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
  }

  html.mobile-app-chrome .app-shell .toolbar .toolbar-cluster .btn,
  html.mobile-app-chrome .app-shell .toolbar .toolbar-cluster .btn.small {
    flex: 1 1 calc(50% - 6px);
  }

  html.mobile-app-chrome .app-shell .table-wrap table {
    min-width: 620px;
  }

  html.mobile-app-chrome .app-bottom-nav__btn {
    padding: 9px 8px;
  }

  html.mobile-app-chrome .app-bottom-nav__label {
    font-size: 0.8rem;
  }
}

html.mobile-app-chrome .app-shell .quick-action-card {
  min-height: 52px;
  padding: 1rem 1rem;
  border-radius: 16px;
}

html.mobile-app-chrome .app-shell .quick-action-card:active {
  transform: scale(0.99);
  opacity: 0.95;
}

html.mobile-app-chrome .app-shell .quick-action-label {
  white-space: normal;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

html.mobile-app-chrome .app-shell .quick-action-hint {
  white-space: normal;
  overflow-wrap: anywhere;
}

html.mobile-app-chrome .app-shell .nav-btn {
  align-items: flex-start;
  min-height: 48px;
  padding: 0.78rem 0.85rem;
  border-radius: 14px;
  font-size: 1rem;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}

html.mobile-app-chrome .app-shell .nav-btn__icon {
  margin-top: 0.12em;
}

html.mobile-app-chrome .app-shell .nav-btn__label {
  line-height: 1.38;
}

/* ========== Web app mobile (sessione attiva): un solo scroll in .app-shell-view (evita iOS che non scrolla) ========== */
html.mobile-app-web-frame {
  height: 100%;
  min-height: calc(var(--app-vh, 1vh) * 100);
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
}

html.mobile-app-web-frame body {
  overflow: hidden;
  margin: 0;
  height: 100%;
  min-height: calc(var(--app-vh, 1vh) * 100);
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  /* none su body può rendere “morto” lo scroll annidato su alcuni WebKit */
  overscroll-behavior-y: auto;
}

html.mobile-app-web-frame #app {
  height: 100%;
  min-height: 0;
  min-height: calc(var(--app-vh, 1vh) * 100);
  max-height: calc(var(--app-vh, 1vh) * 100);
  max-height: 100dvh;
  max-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: visible;
}

html.mobile-app-chrome.mobile-app-web-frame body:has(#app .app-shell) {
  display: flex;
  flex-direction: column;
}

html.mobile-app-web-frame .app-shell.app-shell--mobile-chrome {
  flex: 1 1 0%;
  min-height: 0;
  max-height: calc(var(--app-vh, 1vh) * 100);
  max-height: 100dvh;
  max-height: -webkit-fill-available;
  height: 100%;
  /*
   * overflow:hidden sui contenitori avo rompe position:fixed su iOS/WebKit: la tab bar resta “sospesa”
   * sopra un vuoto sotto il display. Scroll e clip restano su .app-shell-view.
   */
  overflow-x: hidden;
  overflow-y: visible;
}

html.mobile-app-chrome.mobile-app-web-frame .app-shell-main {
  overflow-x: hidden;
  overflow-y: visible;
  min-height: 0;
}

/* Più specifico di body:has(...) / #app:has(...) sotto: forza blocco scroll sul body quando sessione attiva */
html.mobile-app-chrome.mobile-app-web-frame body:has(#app .app-shell) {
  overflow: hidden;
  height: 100%;
  min-height: calc(var(--app-vh, 1vh) * 100);
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

html.mobile-app-chrome.mobile-app-web-frame #app:has(.app-shell) {
  flex: 1 1 0%;
  min-height: 0;
  height: auto;
  max-height: calc(var(--app-vh, 1vh) * 100);
  max-height: 100dvh;
  max-height: -webkit-fill-available;
  overflow-x: hidden;
  overflow-y: visible;
}

/* Telefono stretto: evita header schiacciato e rende i tab più leggibili */
@media (max-width: 420px) {
  html.mobile-app-chrome .app-shell-topbar {
    gap: 6px;
    padding-left: max(0.6rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.6rem, env(safe-area-inset-right, 0px));
  }
  html.mobile-app-chrome .topbar-heading {
    font-size: 1.08rem;
  }
  html.mobile-app-chrome .topbar-user {
    max-width: 100%;
  }
  html.mobile-app-chrome .app-bottom-nav__icon {
    font-size: 1.2rem;
  }
  html.mobile-app-chrome .app-bottom-nav__btn {
    font-size: 0.7rem;
    line-height: 1.2;
    padding-left: 2px;
    padding-right: 2px;
  }
  html.mobile-app-chrome .app-bottom-nav__label {
    font-size: clamp(0.66rem, 3.1vw, 0.74rem);
    line-height: 1.15;
  }
}

@media (max-width: 640px) {
  /*
   * Una sola riga: titolo + azioni come su tablet/desktop (evita due “fasce” sotto la status bar).
   * width:100% su leading+actions forzava il wrap e sembrava un header doppio / “sballato”.
   */
  html.mobile-app-chrome .app-shell-topbar .topbar-actions {
    gap: 6px;
  }

  html.mobile-app-chrome .app-shell-topbar .theme-toggle--compact .theme-seg {
    min-width: 1.86rem;
    padding: 0.32rem 0.36rem;
    font-size: 0.82rem;
  }
}

/* Drawer: intestazione sezioni + brand più compatto */
.app-drawer-section-label {
  margin: 0.35rem 1rem 0.2rem;
  padding: 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.35;
  color: var(--shell-muted);
}

.app-drawer-section-label--nav-sub {
  margin-top: 0.55rem;
  margin-bottom: 0.05rem;
}

.sidebar-registers-wrap {
  width: 100%;
  flex-shrink: 0;
  margin-top: 0.2rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--shell-glass-border);
}

.sidebar-registers-wrap .sidebar-registers-panel > summary {
  border-radius: 12px;
}

.app-menu-section__title--sub {
  margin: 0.55rem 0 0.3rem;
  font-size: 0.68rem;
}

.app-menu-link.app-menu-link--nested {
  min-height: 2.85rem;
  padding: 0.62rem 0.85rem 0.62rem 1.15rem;
  font-size: 0.94rem;
  border-radius: 12px;
}

html.mobile-app-chrome .app-menu-link.app-menu-link--nested {
  min-height: 3rem;
  padding: 0.68rem 0.95rem 0.68rem 1.2rem;
}

html.mobile-app-chrome .app-shell-brandblock {
  padding: 1rem 1.15rem;
}

html.mobile-app-chrome .app-shell-nav--main {
  padding-top: 0.35rem;
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior-y: contain !important;
  touch-action: pan-y !important;
}

/* Topbar: titolo che non va in conflitto con azioni compatte */
html.mobile-app-chrome .app-shell-topbar {
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
}

html.mobile-app-chrome .app-shell-topbar .topbar-leading {
  flex: 1;
  min-width: 0;
}

html.mobile-app-chrome .app-shell-topbar .topbar-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

html.mobile-app-chrome .app-shell-topbar .theme-toggle--compact {
  padding: 2px;
  gap: 1px;
}

html.mobile-app-chrome .app-shell-topbar .theme-toggle--compact .theme-seg {
  min-width: 1.72rem;
  padding: 0.28rem 0.32rem;
  font-size: 0.78rem;
}

/* Touch: meno zoom doppio tap su controlli principali */
html.mobile-app-chrome .app-shell .btn,
html.mobile-app-chrome .app-shell .nav-btn,
html.mobile-app-chrome .app-bottom-nav__btn {
  touch-action: manipulation;
}

/* Dashboard admin: metriche a griglia 2 colonne su telefono */
html.mobile-app-chrome .app-shell .admin-dash-hero {
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
}

html.mobile-app-chrome .app-shell .admin-dash-hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

html.mobile-app-chrome .app-shell .admin-dash-hero-metrics > div {
  min-width: 0;
  padding: 0.55rem 0.65rem;
}

html.mobile-app-chrome .app-shell .admin-dash-hero-metrics strong {
  font-size: 1.25rem;
}

/* Dashboard nuova: hero e metriche compatte */
html.mobile-app-chrome .app-shell .dash-hero__grid {
  grid-template-columns: 1fr;
}

html.mobile-app-chrome .app-shell .dash-hero-metrics--hero {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

html.mobile-app-chrome .app-shell .dash-hero-metric {
  min-width: 0;
  padding: 0.5rem 0.4rem;
}

html.mobile-app-chrome .app-shell .dash-hero-metric strong {
  font-size: 1.18rem;
}

/* Moduli e filtri nel contenuto: evita zoom iOS su focus */
html.mobile-app-chrome .app-shell-view .panel input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
html.mobile-app-chrome .app-shell-view .panel select,
html.mobile-app-chrome .app-shell-view .panel textarea {
  font-size: 16px;
}

/* Z-index: drawer sopra tab bar */
html.mobile-app-chrome .sidebar-overlay {
  z-index: 980;
}

html.mobile-app-chrome .app-shell .sidebar.sidebar--app-drawer {
  z-index: 1000;
}

html.mobile-app-chrome .app-bottom-nav {
  z-index: 970;
}

/* Vista “Menu” (mobile): elenco sezioni, non drawer */
.app-menu-page {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 0.25rem;
}

.app-menu-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.app-menu-section__title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.35;
  color: var(--shell-muted);
}

.app-menu-section__title--ops {
  margin: 0.15rem 0 0;
}

.app-menu-account__extras {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.15rem;
}

.app-menu-user {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.app-menu-avatar {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, var(--brand, #1758bb), var(--brand-2, #093a7b));
  box-shadow: 0 4px 14px rgba(2, 8, 23, 0.2);
}

.app-menu-user__text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.app-menu-user__text strong {
  font-size: 1.05rem;
  color: var(--shell-panel-title, #f1f5f9);
}

.app-menu-hint {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.app-menu-links {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.app-menu-account {
  display: grid;
  gap: 0.45rem;
}

.app-menu-account__title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--shell-panel-title, #f1f5f9);
}

.app-menu-account__hint {
  margin: 0;
  font-size: 0.82rem;
}

.app-menu-account__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.email-change-panel {
  border-style: dashed;
}

.email-change-panel .success-box,
.email-change-panel .error-box {
  margin: 0 0 8px;
}

.app-menu-link {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  gap: 0.75rem;
  min-height: 3.15rem;
  padding: 0.75rem 1rem;
  margin: 0;
  border: 1px solid var(--shell-glass-border, rgba(148, 163, 184, 0.22));
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--shell-brand-fg, #e2e8f0);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.app-menu-link__main {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 0;
}

.app-menu-link__label {
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.app-menu-link__icon {
  width: 1.2rem;
  min-width: 1.2rem;
  margin-top: 0.1em;
  text-align: center;
  opacity: 0.95;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-menu-link__icon .sarial-ico {
  display: block;
}

.app-menu-link:hover {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(94, 234, 212, 0.35);
}

.app-menu-link.is-active {
  border-color: rgba(94, 234, 212, 0.5);
  background: var(--shell-nav-active-bg, rgba(94, 234, 212, 0.12));
  color: var(--shell-nav-active-fg, #5eead4);
}

.app-menu-link__chev {
  flex-shrink: 0;
  opacity: 0.55;
  font-size: 1.1rem;
  line-height: 1;
}

[data-theme="light"] .app-menu-link {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] .app-menu-link:hover {
  background: #e8edf4;
}

[data-theme="light"] .app-menu-link.is-active {
  background: rgba(23, 88, 187, 0.1);
  color: #1758bb;
  border-color: rgba(23, 88, 187, 0.35);
}

html.mobile-app-chrome .app-menu-link {
  min-height: 3.35rem;
  padding: 0.82rem 1.05rem;
  font-size: 1.02rem;
  border-radius: 16px;
}

html.mobile-app-chrome .app-menu-link__chev {
  margin-top: 0.08em;
}

/* ========== Final Design Pass (landing + auth + app shell) ========== */

.app-shell .panel,
.app-shell .stat,
.app-shell .temp-card,
.app-shell .quick-action-card,
.app-shell .table-wrap,
.app-dialog-card {
  border-radius: var(--ui-radius-md);
}

.app-shell .panel {
  box-shadow: 0 14px 34px rgba(2, 8, 23, 0.16);
}

[data-theme="dark"] .app-shell .panel {
  box-shadow: var(--mock-shell-shadow);
}

.app-shell-topbar {
  border-bottom-color: color-mix(in srgb, var(--shell-glass-border) 82%, transparent);
}

.app-shell .nav-btn {
  border-radius: 12px;
}

.app-shell .nav-btn__label {
  font-weight: 650;
}

.app-shell .nav-btn.active .nav-btn__label {
  font-weight: 780;
}

.app-shell .toolbar .btn,
.app-shell .toolbar .btn.small {
  min-height: clamp(2.35rem, 0.5vw + 2.2rem, 2.7rem);
  border-radius: 12px;
}

.app-shell .table-wrap {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 24px rgba(2, 8, 23, 0.08);
}

.app-shell th {
  font-weight: 780;
  letter-spacing: 0.09em;
}

.app-shell td {
  line-height: 1.45;
}

/* Micro-consistenza tipografica per schermate dense (liste/tabelle/toolbar). */
.app-shell .panel h2,
.app-shell .panel h3 {
  letter-spacing: -0.012em;
  line-height: 1.24;
}

.app-shell .toolbar h2 {
  letter-spacing: -0.014em;
}

.app-shell th {
  font-size: clamp(0.68rem, 0.35vw + 0.63rem, 0.74rem);
  letter-spacing: 0.085em;
}

.app-shell td {
  font-size: clamp(0.86rem, 0.18vw + 0.83rem, 0.92rem);
  line-height: 1.42;
}

.app-shell .pill {
  letter-spacing: 0.012em;
  line-height: 1.25;
}

.app-shell .toolbar .btn.small,
.app-shell table .btn,
.app-shell .data-table .btn {
  font-size: clamp(0.78rem, 0.15vw + 0.76rem, 0.85rem);
  letter-spacing: 0.008em;
}

@media (max-width: 768px) {
  .app-shell .btn {
    min-height: 2.75rem;
    padding: 0.62rem 1rem;
    font-size: 0.91rem;
  }

  .app-shell .btn.small {
    min-height: 2.55rem;
    padding: 0.48rem 0.86rem;
    font-size: 0.84rem;
  }

  .app-shell td {
    font-size: clamp(0.84rem, 0.6vw + 0.79rem, 0.9rem);
    line-height: 1.4;
  }

  .app-shell th {
    letter-spacing: 0.07em;
  }
}

html[data-theme="light"] .app-shell .panel,
html[data-theme="light"] .app-shell .stat,
html[data-theme="light"] .app-shell .temp-card,
html[data-theme="light"] .app-shell .quick-action-card,
html[data-theme="light"] .app-shell .table-wrap {
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.09);
}

.login-page-wrap .glass-card.login-box {
  border-radius: 20px;
}

.login-page-wrap .login-header h2 {
  letter-spacing: -0.025em;
}

.login-page-wrap .cyber-form input,
.login-page-wrap .cyber-form select,
.login-page-wrap .cyber-form textarea {
  border-radius: 12px;
  min-height: 46px;
}

.login-page-wrap .login-submit {
  border-radius: 12px;
}

.landing-page .landing-hero__copy {
  gap: 0.92rem;
}

.landing-page .landing-hero__actions.hero-actions {
  gap: 0.7rem 0.9rem;
}

.landing-page .landing-hero__actions.hero-actions .btn-main,
.landing-page .landing-hero__actions.hero-actions .btn-ghost {
  min-height: 3.3rem;
  border-radius: 999px;
}

@media (max-width: 768px) {
  .landing-page .landing-hero__actions.hero-actions .btn-main,
  .landing-page .landing-hero__actions.hero-actions .btn-ghost {
    min-height: 3.22rem;
    font-size: 1rem;
    padding: 0.82rem 1.08rem;
  }
}

/* Support tickets: tag chips */
.app-shell .support-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.app-shell .support-tag-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.app-shell .support-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.56rem;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.app-shell .support-tag--compact {
  font-size: 0.69rem;
  padding: 0.14rem 0.48rem;
}
html[data-theme="dark"] .app-shell .support-tag {
  color: #93c5fd;
  background: rgba(30, 64, 175, 0.28);
  border-color: rgba(96, 165, 250, 0.32);
}
html[data-theme="light"] .app-shell .support-tag {
  color: #1e3a8a;
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.28);
}

/* Dashboard final: responsive stabile desktop / tablet / telefono */
.app-shell .dash-page {
  max-width: 1600px;
  width: 100%;
}

@media (min-width: 1280px) {
  .app-shell .dash-page--admin {
    display: grid !important;
    grid-template-columns: 1.25fr 1fr !important;
    grid-template-areas:
      "hero hero"
      "search search"
      "quick quick"
      "infra people"
      "opslive opslive"
      "posture posture"
      "split split" !important;
    gap: 1rem !important;
  }
  .app-shell .dash-page--tenant {
    display: grid !important;
    grid-template-columns: 1.15fr 1fr !important;
    grid-template-areas:
      "hero hero"
      "cockpit cockpit" !important;
    gap: 1rem !important;
  }
}

@media (min-width: 768px) and (max-width: 1279px) {
  /* Tenant: colonna su tablet. Admin: NON forzare flex qui — rompe la griglia 1100px (1024–1279 è molto comune). */
  .app-shell .dash-page--tenant {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.9rem !important;
  }
  .app-shell .quick-actions-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .app-shell .dash-stat-grid,
  .app-shell .dash-stat-grid--dense {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 767px) {
  .app-shell .dash-page--admin,
  .app-shell .dash-page--tenant {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.8rem !important;
  }
  .app-shell .dash-section,
  .app-shell .dash-hero {
    padding: 0.82rem 0.86rem !important;
  }
  .app-shell .quick-actions-grid {
    grid-template-columns: 1fr !important;
  }
  .app-shell .dash-stat-grid,
  .app-shell .dash-stat-grid--dense {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.55rem !important;
  }
  .app-shell .dash-hero-metrics--hero {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: 100% !important;
    gap: 0.45rem !important;
  }
  .app-shell .dash-hero-metric {
    min-width: 0 !important;
    padding: 0.48rem 0.4rem !important;
  }
  .app-shell .dash-hero-metric strong {
    font-size: 1rem !important;
  }
  .app-shell .dash-hero-metric span {
    font-size: 0.58rem !important;
  }
}

/* Responsive hardening globale: layout fluido su tutti i dispositivi */
.app-shell,
.app-shell-main,
.app-shell-view,
.app-shell .panel,
.app-shell .toolbar,
.app-shell .table-wrap {
  max-width: 100%;
}

.app-shell .toolbar > *,
.app-shell .toolbar .toolbar-cluster > * {
  min-width: 0;
}

.app-shell .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.app-shell img,
.app-shell svg,
.app-shell canvas {
  max-width: 100%;
  height: auto;
}

.app-shell .table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.app-shell .table-wrap table {
  width: 100%;
}

@media (max-width: 820px) {
  .app-shell-topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .app-shell .topbar-leading,
  .app-shell .topbar-actions {
    width: 100%;
  }

  .app-shell .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /*
   * App mobile / “Aggiungi a Home”: stesso header a una riga del mock (titolo | tema · esci).
   * Senza questo, width:100% su leading+actions duplica la fascia sotto i 820px.
   */
  html.mobile-app-chrome .app-shell-topbar {
    flex-wrap: nowrap;
    align-items: center;
  }
  html.mobile-app-chrome .app-shell-topbar .topbar-leading,
  html.mobile-app-chrome .app-shell-topbar .topbar-actions {
    width: auto;
    max-width: none;
  }
  html.mobile-app-chrome .app-shell-topbar .topbar-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .app-shell .panel {
    padding: clamp(0.86rem, 2.2vw, 1.1rem);
  }

  .app-shell .toolbar .toolbar-cluster {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .app-shell-view {
    padding: 0.8rem 0.72rem;
  }

  .app-shell .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .app-shell .toolbar > h2 {
    width: 100%;
  }

  .app-shell .toolbar > .toolbar-cluster {
    width: 100%;
  }

  .app-shell .toolbar > .btn,
  .app-shell .toolbar > button[class*="btn"] {
    width: 100%;
    justify-content: center;
  }

  .app-shell .toolbar > span.muted {
    width: 100%;
  }

  .app-shell .toolbar input,
  .app-shell .toolbar select,
  .app-shell .toolbar textarea {
    min-width: 0;
    max-width: 100%;
  }

  /* Tabella larga → scroll orizzontale nel contenitore. Esclusa righe bolle (layout card). */
  .app-shell .table-wrap:not(.commercial-sales-lines) table {
    min-width: 560px;
  }
}

@media (max-width: 520px) {
  .app-shell .toolbar-cluster .btn,
  .app-shell .toolbar-cluster .btn.small {
    white-space: normal;
    line-height: 1.2;
    text-align: center;
  }
}

/* ========================================================================== */
/* 20260420 RADICAL UI REFRESH — desktop/tablet/mobile unified design system */
/* ========================================================================== */
:root {
  --ui-radius-card: 22px;
  --ui-radius-panel: 18px;
  --ui-elev-1: 0 10px 30px rgba(15, 23, 42, 0.1);
  --ui-elev-2: 0 22px 60px rgba(15, 23, 42, 0.16);
  --ui-border-soft: rgba(148, 163, 184, 0.24);
}

html[data-theme="light"] body {
  background:
    radial-gradient(1200px 480px at 8% -10%, rgba(56, 189, 248, 0.2), transparent 64%),
    radial-gradient(1100px 520px at 100% 0%, rgba(99, 102, 241, 0.15), transparent 58%),
    linear-gradient(180deg, #f7faff 0%, #eef3fb 52%, #e8effa 100%);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(1200px 540px at 6% -12%, rgba(14, 47, 113, 0.55), transparent 62%),
    radial-gradient(1200px 520px at 100% -10%, rgba(30, 64, 175, 0.26), transparent 58%),
    #050a18;
}

.panel,
.app-shell .panel {
  border: 1px solid var(--ui-border-soft);
  border-radius: var(--ui-radius-card);
  box-shadow: var(--ui-elev-1);
}

.topbar,
.app-shell-topbar {
  border: 1px solid var(--ui-border-soft);
  box-shadow: var(--ui-elev-1);
  border-radius: calc(var(--ui-radius-card) + 2px);
}

.app-shell .table-wrap {
  border-radius: var(--ui-radius-panel);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}

.app-shell table th {
  letter-spacing: 0.02em;
  font-size: 0.79rem;
  text-transform: uppercase;
}

.app-shell table td {
  font-size: 0.9rem;
  line-height: 1.42;
}

.btn,
.btn-glow,
.btn-ghost {
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn:hover,
.btn-glow:hover,
.btn-ghost:hover {
  transform: translateY(-1px);
}

.landing-page {
  --landing-max: 1180px;
  color: #e2e8f0;
}

.landing-page .landing-nav,
.landing-page .landing-hero__inner,
.landing-page .landing-section,
.landing-page .landing-footer__inner {
  width: min(var(--landing-max), calc(100% - 2rem));
  margin-left: auto;
  margin-right: auto;
}

/* Tipografia e layout hero: definiti nello <style> della landing (app-main.js).
   Non duplicare qui .landing-hero__headline / .landing-hero__lead: hanno specificità
   più alta e rompevano geometria e breakpoint su mobile/desktop. */

.landing-page .hero-actions:not(.landing-hero__actions) {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.landing-page .hero-actions:not(.landing-hero__actions) .btn-main,
.landing-page .hero-actions:not(.landing-hero__actions) .btn-ghost {
  min-height: 2.9rem;
  border-radius: 13px;
}

.landing-page .landing-cosa-item,
.landing-page .landing-audience-card,
.landing-page .landing-metric {
  border-radius: var(--ui-radius-card);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: var(--ui-elev-2);
}

/* FAQ: radius e bordo gestiti nello <style> della landing (pill + stato [open]). */

.landing-page .landing-section h2,
.landing-page .landing-section-head h2 {
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  letter-spacing: -0.015em;
}

@media (max-width: 1080px) {
  .landing-page .landing-hero__copy {
    max-width: 100%;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    padding: 0.72rem;
  }
  .sidebar {
    position: static;
    height: auto;
    border-radius: 18px;
  }
  .main {
    gap: 0.85rem;
  }
  .cards,
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .landing-page .landing-nav,
  .landing-page .landing-hero__inner,
  .landing-page .landing-section,
  .landing-page .landing-footer__inner {
    width: calc(100% - 1.2rem);
  }
  .landing-page .hero-actions:not(.landing-hero__actions) .btn-main,
  .landing-page .hero-actions:not(.landing-hero__actions) .btn-ghost {
    width: 100%;
    justify-content: center;
  }
  .panel,
  .app-shell .panel {
    border-radius: 16px;
  }
  .app-shell .table-wrap table {
    min-width: 640px;
  }
}

/* Empty states (liste, dashboard, archivio) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
  padding: 1.25rem 1rem;
  border-radius: var(--ui-radius-md, 16px);
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: rgba(148, 163, 184, 0.06);
}
.empty-state--compact {
  padding: 0.85rem 0.65rem;
  gap: 0.2rem;
  border-radius: var(--ui-radius-sm, 12px);
}
.empty-state__icon {
  font-size: 1.35rem;
  line-height: 1;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.empty-state__icon .sarial-ico {
  width: 2.5rem;
  height: 2.5rem;
}
.empty-state--compact .empty-state__icon .sarial-ico {
  width: 1.25rem;
  height: 1.25rem;
}
.empty-state__title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink, #12233f);
}
html[data-theme="dark"] .empty-state__title {
  color: #e2e8f0;
}
.empty-state__hint {
  margin: 0;
  max-width: 28rem;
  font-size: 0.82rem;
  line-height: 1.35;
}
.table-empty-cell {
  padding: 0.75rem 0.5rem !important;
  vertical-align: middle;
}
.table-empty-cell .empty-state {
  border: none;
  background: transparent;
  padding: 0.5rem 0.35rem;
}
.table-empty-cell .empty-state--compact {
  padding: 0.35rem 0.25rem;
}

/* ——— Magazzino (admin): layout moderno ——— */
:is(.view-page,.wh-view) {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  /* Limite “tipo brochure” utile fuori dall’app; dentro la shell la colonna è già contenuta dalla sidebar */
  max-width: min(1180px, 100%);
  width: 100%;
  box-sizing: border-box;
}

/* Desktop: la vista usa tutta la larghezza della colonna contenuti (evita fascia stretta ~1180px con molte colonne) */
.app-shell .app-shell-view > :is(.view-page, .wh-view) {
  max-width: none;
  width: 100%;
  min-width: 0; /* consente scroll orizzontale ai figli in flex / overflow */
}

:is(.view-hero,.wh-hero) {
  position: relative;
  overflow: hidden;
  border-radius: var(--ui-radius-xl, 24px);
  padding: 1.35rem 1.35rem 1.25rem;
  background:
    linear-gradient(135deg, rgba(23, 88, 187, 0.14) 0%, rgba(0, 242, 255, 0.06) 42%, rgba(255, 255, 255, 0.65) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(237, 242, 255, 0.88) 100%);
  border: 1px solid rgba(23, 88, 187, 0.14);
  box-shadow: var(--ui-shadow-soft);
}
:is(.view-hero,.wh-hero)::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 18% 22%, rgba(0, 242, 255, 0.18) 0%, transparent 42%),
    radial-gradient(circle at 88% 8%, rgba(23, 88, 187, 0.12) 0%, transparent 38%);
  pointer-events: none;
}
:is(.view-hero,.wh-hero) > * {
  position: relative;
  z-index: 1;
}
:is(.view-hero__grid,.wh-hero__grid) {
  display: grid;
  gap: 1.15rem;
  align-items: start;
  grid-template-columns: 1fr auto;
}
@media (max-width: 820px) {
  :is(.view-hero__grid,.wh-hero__grid) {
    grid-template-columns: 1fr;
  }
}
:is(.view-hero__eyebrow,.wh-hero__eyebrow) {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  opacity: 0.92;
}
:is(.view-hero__title,.wh-hero__title) {
  margin: 0;
  font-family: var(--ui-font-display);
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
}
:is(.view-hero__lead,.wh-hero__lead) {
  margin: 0.45rem 0 0;
  max-width: 38rem;
  font-size: 0.92rem;
  line-height: 1.55;
}
:is(.view-hero__controls,.wh-hero__controls) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  justify-content: flex-end;
}
:is(.view-field-label,.wh-field-label) {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
:is(.view-select,.wh-select) {
  min-width: min(22rem, 88vw);
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(23, 88, 187, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: 0 4px 14px rgba(17, 35, 68, 0.06);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
:is(.view-select,.wh-select):hover {
  border-color: rgba(23, 88, 187, 0.35);
}
:is(.view-select,.wh-select):focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 88, 187, 0.2);
}

:is(.view-kpi-strip,.wh-kpi-strip) {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}
@media (max-width: 900px) {
  :is(.view-kpi-strip,.wh-kpi-strip) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
:is(.view-kpi,.wh-kpi) {
  border-radius: var(--ui-radius-md, 16px);
  padding: 0.85rem 1rem;
  background: var(--panel-strong);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 6px 18px rgba(2, 8, 23, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
:is(.view-kpi__value,.wh-kpi__value) {
  font-family: var(--ui-font-display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--brand);
}
:is(.view-kpi__label,.wh-kpi__label) {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

:is(.view-callout,.wh-callout) {
  border-radius: var(--ui-radius-md, 16px);
  padding: 0.85rem 1rem;
  line-height: 1.55;
  font-size: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.72);
}
:is(.view-callout--accent-warn,.wh-callout--hub) {
  border-color: rgba(200, 134, 16, 0.35);
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.95), rgba(255, 255, 255, 0.88));
}
:is(.view-callout--accent-ok,.wh-callout--tenant) {
  border-color: rgba(29, 143, 87, 0.28);
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.85), rgba(255, 255, 255, 0.92));
}
:is(.view-active-pill,.wh-active-dep) {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  font-size: 0.88rem;
  line-height: 1.45;
  border: 1px dashed rgba(23, 88, 187, 0.35);
  background: rgba(237, 242, 255, 0.65);
  max-width: 52rem;
}

:is(.view-card,.wh-card) {
  border-radius: var(--ui-radius-lg, 20px) !important;
  border: 1px solid rgba(148, 163, 184, 0.22) !important;
  box-shadow: 0 10px 28px rgba(2, 8, 23, 0.06);
  background: rgba(255, 255, 255, 0.94) !important;
}
:is(.view-card--muted,.wh-card--muted) {
  background: rgba(248, 250, 252, 0.95) !important;
}
:is(.view-platform-scope,.wh-platform-scope).panel {
  padding: 1.15rem 1.2rem !important;
}
:is(.view-platform-scope,.wh-platform-scope) .toolbar h2 {
  font-family: var(--ui-font-display);
  letter-spacing: -0.02em;
}

:is(.view-panel-accent,.wh-logistics).panel {
  padding: 1.1rem 1.15rem !important;
  border-radius: var(--ui-radius-lg, 20px) !important;
  border: 1px solid rgba(16, 185, 129, 0.28) !important;
  background:
    linear-gradient(145deg, rgba(16, 185, 129, 0.07) 0%, rgba(255, 255, 255, 0.92) 52%) !important;
  box-shadow: 0 12px 32px rgba(16, 185, 129, 0.08);
}
:is(.view-panel-accent,.wh-logistics) h3 {
  font-family: var(--ui-font-display);
  font-size: 1.08rem;
  margin: 0 0 0.35rem !important;
}
:is(.view-split-grid,.wh-logistics-grid) {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
:is(.view-split-card,.wh-logistics-card) {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--ui-radius-md, 16px);
  padding: 1rem 1rem 0.85rem;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 18px rgba(2, 8, 23, 0.05);
}
:is(.view-split-card,.wh-logistics-card) h4 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}

:is(.view-section-head,.wh-section-head) {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.35rem 0 0.65rem;
}
:is(.view-section-head,.wh-section-head) h3 {
  margin: 0;
  font-family: var(--ui-font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
:is(.view-section-head,.wh-section-head) .muted {
  font-size: 0.86rem;
}

:is(.view-accordion,.wh-cat-block).panel {
  border-radius: var(--ui-radius-lg, 20px) !important;
  border-left: 4px solid var(--brand) !important;
  padding: 0.85rem 1rem 1rem !important;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 249, 255, 0.92)) !important;
}
:is(.view-accordion,.wh-cat-block) > summary {
  font-family: var(--ui-font-display);
  font-size: 1.02rem;
  padding: 0.35rem 0 0.25rem 1.6rem;
  position: relative;
  list-style: none;
}
:is(.view-accordion,.wh-cat-block) > summary::-webkit-details-marker {
  display: none;
}
:is(.view-accordion,.wh-cat-block) > summary::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transition: transform 0.2s ease;
}
:is(.view-accordion,.wh-cat-block)[open] > summary::before {
  transform: translateY(-50%) rotate(45deg);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
:is(.view-table-wrap,.wh-table-wrap) {
  margin-top: 0.65rem;
  border-radius: var(--ui-radius-md, 16px);
  /* Auto su X: su mobile le tabelle larghe scrollano (overflow:hidden tagliava tutto) */
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
:is(.view-table-wrap,.wh-table-wrap) .table-wrap {
  margin: 0;
}
:is(.view-table-wrap,.wh-table-wrap) table {
  margin: 0;
}
:is(.view-table-wrap,.wh-table-wrap) thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(237, 242, 255, 0.95), rgba(230, 237, 252, 0.88));
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  padding: 0.65rem 0.75rem;
}
:is(.view-table-wrap,.wh-table-wrap) tbody td {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
:is(.view-table-wrap,.wh-table-wrap) tbody tr:last-child td {
  border-bottom: none;
}
:is(.view-table-wrap,.wh-table-wrap) tbody tr:hover td {
  background: rgba(23, 88, 187, 0.04);
}

/* Vendite & bolle — righe bolla: niente scroll orizzontale su mobile (card impilate) */
@media (max-width: 640px) {
  .commercial-sales-lines {
    overflow-x: visible;
  }
  .commercial-sales-lines__table {
    min-width: 0 !important;
    width: 100%;
  }
  .commercial-sales-lines__table thead {
    display: none;
  }
  .commercial-sales-lines__table tbody tr {
    display: block;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.6rem;
    border-radius: var(--ui-radius-sm, 12px);
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: var(--panel, rgba(255, 255, 255, 0.88));
    box-shadow: var(--ui-shadow-soft, 0 8px 24px rgba(2, 8, 23, 0.12));
  }
  .commercial-sales-lines__table tbody tr:hover td {
    background: transparent;
  }
  html[data-theme="dark"] .commercial-sales-lines__table tbody tr {
    background: rgba(15, 23, 42, 0.72);
    border-color: rgba(148, 163, 184, 0.24);
  }
  .commercial-sales-lines__table tbody td {
    display: block;
    width: 100% !important;
    max-width: 100%;
    padding: 0.45rem 0;
    border-bottom: none !important;
    vertical-align: top;
  }
  .commercial-sales-lines__table tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.3rem;
  }
  .commercial-sales-lines__table tbody td input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .commercial-sales-lines__table tbody td.commercial-line-actions {
    padding-top: 0.55rem;
    margin-top: 0.35rem;
    border-top: 1px solid rgba(148, 163, 184, 0.22) !important;
  }
  .commercial-sales-lines__table tbody td.commercial-line-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

:is(.view-pill,.wh-stock-pill) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.88rem;
  background: rgba(23, 88, 187, 0.1);
  color: var(--brand-2);
}

:is(.view-row-actions,.wh-row-actions) {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

:is(.view-collapsible,.wh-collapsible).panel {
  border-radius: var(--ui-radius-lg, 20px) !important;
}
:is(.view-collapsible,.wh-collapsible) > summary {
  font-family: var(--ui-font-display);
  font-weight: 800;
  padding: 0.35rem 0;
}

:is(.view-empty-hint,.wh-empty-cats) {
  border-radius: var(--ui-radius-md, 16px);
  padding: 1.25rem 1rem;
  text-align: center;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: rgba(148, 163, 184, 0.06);
}

.wh-app {
  gap: 1rem;
}

.wh-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.35rem;
  border-radius: var(--ui-radius-lg, 20px);
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
}
.wh-tabs.wh-tabs--sub {
  width: 100%;
  max-width: 100%;
  margin-top: 0.15rem;
}
.wh-tabs.wh-tabs--sub .wh-tab {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 0.76rem;
  padding: 0.5rem 0.65rem;
}
@media (max-width: 640px) {
  .wh-tabs.wh-tabs--sub {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
  }
  .wh-tabs.wh-tabs--sub .wh-tab {
    flex: 0 0 auto;
  }
}

.wh-ops-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.wh-ops-context {
  margin: 0;
}
.wh-sub-panel[hidden] {
  display: none !important;
}

.wh-dep-row--active td {
  background: rgba(23, 88, 187, 0.06);
}
.wh-pill-mini {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(23, 88, 187, 0.12);
  color: var(--brand-2);
}
.wh-mov-pos {
  color: #15803d;
  font-weight: 800;
}
.wh-mov-neg {
  color: #b91c1c;
  font-weight: 800;
}
html[data-theme="dark"] .wh-mov-pos {
  color: #4ade80;
}
html[data-theme="dark"] .wh-mov-neg {
  color: #fca5a5;
}
html[data-theme="dark"] .wh-dep-row--active td {
  background: rgba(23, 88, 187, 0.14);
}
html[data-theme="dark"] .wh-pill-mini {
  background: rgba(23, 88, 187, 0.28);
  color: #bae6fd;
}
.wh-tab {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.55rem 1rem;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.wh-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}
.wh-tab.is-active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 18px rgba(23, 88, 187, 0.12);
}
.wh-tab-panel[hidden] {
  display: none !important;
}
.ui-tab-panel[hidden] {
  display: none !important;
}

.wh-catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin: 0.35rem 0 0.25rem;
}
.wh-field-label.wh-field-label--grow {
  flex: 1 1 18rem;
  min-width: min(22rem, 100%);
}
.wh-input-search {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(23, 88, 187, 0.18);
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.wh-input-search:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 88, 187, 0.18);
}
.wh-transfer-btn {
  padding: 0.65rem 1rem !important;
  border-radius: 14px !important;
  font-weight: 800 !important;
  align-self: flex-end;
}

.wh-platform-scope-head {
  margin: 0 0 14px;
}
.wh-platform-scope-title {
  margin: 0 0 6px;
  font-family: var(--ui-font-display);
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.wh-platform-scope-lead {
  margin: 0;
  max-width: 46rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

html[data-theme="dark"] :is(.view-hero,.wh-hero) {
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.14) 0%, rgba(99, 102, 241, 0.09) 42%, rgba(15, 23, 42, 0.94) 100%);
  border-color: rgba(56, 189, 248, 0.22);
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.38),
    0 0 0 1px rgba(56, 189, 248, 0.09),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
html[data-theme="dark"] :is(.view-hero__title,.wh-hero__title) {
  color: #f1f5f9;
}
html[data-theme="dark"] :is(.view-select,.wh-select) {
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.28);
}
html[data-theme="dark"] :is(.view-kpi,.wh-kpi) {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.22);
}
html[data-theme="dark"] :is(.view-kpi__value,.wh-kpi__value) {
  color: #7dd3fc;
}
html[data-theme="dark"] :is(.view-callout,.wh-callout) {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
}
html[data-theme="dark"] :is(.view-callout--accent-warn,.wh-callout--hub) {
  background: linear-gradient(135deg, rgba(120, 53, 15, 0.35), rgba(15, 23, 42, 0.85));
  border-color: rgba(251, 191, 36, 0.25);
}
html[data-theme="dark"] :is(.view-callout--accent-ok,.wh-callout--tenant) {
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.35), rgba(15, 23, 42, 0.88));
  border-color: rgba(52, 211, 153, 0.22);
}
html[data-theme="dark"] :is(.view-active-pill,.wh-active-dep) {
  background: rgba(23, 88, 187, 0.18);
  border-color: rgba(125, 211, 252, 0.28);
  color: #e2e8f0;
}
html[data-theme="dark"] :is(.view-card,.wh-card) {
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.78)) !important;
  border-color: rgba(129, 140, 248, 0.28) !important;
  box-shadow:
    0 20px 48px rgba(2, 6, 23, 0.48),
    0 0 64px rgba(79, 70, 229, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}
html[data-theme="dark"] :is(.view-panel-accent,.wh-logistics).panel {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.12), rgba(15, 23, 42, 0.92)) !important;
}
html[data-theme="dark"] :is(.view-split-card,.wh-logistics-card) {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(148, 163, 184, 0.2);
}
html[data-theme="dark"] :is(.view-accordion,.wh-cat-block).panel {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.78)) !important;
}
html[data-theme="dark"] :is(.view-table-wrap,.wh-table-wrap) thead th {
  background: rgba(30, 41, 59, 0.95);
  color: #94a3b8;
}
html[data-theme="dark"] :is(.view-table-wrap,.wh-table-wrap) tbody tr:hover td {
  background: rgba(23, 88, 187, 0.12);
}
html[data-theme="dark"] :is(.view-pill,.wh-stock-pill) {
  background: rgba(23, 88, 187, 0.28);
  color: #bae6fd;
}
html[data-theme="dark"] :is(.view-empty-hint,.wh-empty-cats) {
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.5);
}

html[data-theme="dark"] .wh-tabs {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.22);
}
html[data-theme="dark"] .wh-tab:hover {
  background: rgba(30, 41, 59, 0.85);
  color: #e2e8f0;
}
html[data-theme="dark"] .wh-tab.is-active {
  background: rgba(30, 41, 59, 0.98);
  color: #f1f5f9;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .wh-input-search {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
}
html[data-theme="dark"] .wh-platform-scope-title {
  color: #f1f5f9;
}

/* ——— Dark mode: messaggi di stato, hero lead, schede secondarie (evita “lastre” chiare) ——— */
html[data-theme="dark"] .app-shell .error-box {
  background: rgba(127, 29, 29, 0.42);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.42);
}
html[data-theme="dark"] .app-shell .success-box {
  background: rgba(6, 95, 70, 0.38);
  color: #d1fae5;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

html[data-theme="dark"] :is(.view-hero__lead, .wh-hero__lead) {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] :is(.view-card--muted, .wh-card--muted) {
  background: rgba(15, 23, 42, 0.55) !important;
  border-color: rgba(148, 163, 184, 0.18) !important;
}

html[data-theme="dark"] :is(.view-table-wrap, .wh-table-wrap) {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Dispositivi IoT: callout info / warning (prima inline #f0f9ff / #fffbeb) */
.app-shell .device-panel--info {
  border-color: #7dd3fc !important;
  background: #f0f9ff !important;
}
html[data-theme="dark"] .app-shell .device-panel--info {
  border-color: rgba(125, 211, 252, 0.45) !important;
  background: rgba(12, 74, 110, 0.42) !important;
}
.app-shell .device-panel--warn {
  border-color: #f59e0b !important;
  background: #fffbeb !important;
}
html[data-theme="dark"] .app-shell .device-panel--warn {
  border-color: rgba(245, 158, 11, 0.55) !important;
  background: rgba(120, 53, 15, 0.48) !important;
}

/* SARIAL — rifinitura schermate: toolbar, tabelle, CTA (mock premium) */
html[data-theme="dark"] .app-shell .panel > .toolbar:first-child,
html[data-theme="dark"] .app-shell .view-card > .toolbar:first-child {
  padding: 0.62rem 0.78rem;
  margin-bottom: 1rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.08), rgba(15, 23, 42, 0.45));
  border: 1px solid rgba(56, 189, 248, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .app-shell .table-wrap {
  border-color: rgba(56, 189, 248, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 16px 44px rgba(2, 8, 23, 0.45),
    0 0 0 1px rgba(56, 189, 248, 0.08),
    0 0 48px rgba(79, 70, 229, 0.06);
}

html[data-theme="dark"] .app-shell th {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.9)) !important;
  box-shadow: 0 1px 0 rgba(56, 189, 248, 0.08);
}

html[data-theme="dark"] .app-shell .btn:hover {
  box-shadow: 0 8px 28px rgba(56, 189, 248, 0.22);
}

html[data-theme="dark"] .app-shell .form-grid input:focus,
html[data-theme="dark"] .app-shell .form-grid select:focus,
html[data-theme="dark"] .app-shell .form-grid textarea:focus {
  border-color: rgba(56, 189, 248, 0.45) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15) !important;
}

/* Firma: anteprima salvata (il canvas del modal resta bianco per contrasto tratto) */
.app-shell .signature-preview-box {
  background: #fff;
}
html[data-theme="dark"] .app-shell .signature-preview-box {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.35) !important;
}

/* Griglia KPI pagine compliance / controlli critici (coerenza con dashboard) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 0.75rem;
}
