:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --ok: #3fb950;
  --warn: #d29922;
  --crit: #f85149;
  --accent: #58a6ff;
  --violet: #a371f7;
  /* Titoli sezioni nella risposta AI (testo **…**) e heading pannello */
  --ai-title: #6ecbff;
  --touch-min: 44px;
  --radius: 10px;
  /* Spazio riservato alla tab bar fissa (altezza pulsanti + safe area) */
  --bottom-tab-pad: calc(4rem + env(safe-area-inset-bottom, 0px));
}

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

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

.show-below-sm {
  display: none;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

header,
.app-header {
  position: relative;
  padding: max(0.75rem, env(safe-area-inset-top, 0.75rem)) 1rem 0.85rem;
  padding-right: max(3.25rem, calc(1rem + env(safe-area-inset-right, 0px)));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  text-align: center;
}

.header-view-toggle {
  position: absolute;
  right: max(0.55rem, env(safe-area-inset-right, 0px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  min-width: 2.35rem;
  min-height: 2rem;
  padding: 0.28rem 0.5rem;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b949e;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(139, 148, 158, 0.35);
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.header-view-toggle:hover {
  color: #c9d1d9;
  border-color: rgba(139, 148, 158, 0.55);
}

.header-view-toggle[aria-pressed="true"] {
  color: #e6edf3;
  border-color: rgba(110, 143, 255, 0.55);
  background: rgba(88, 166, 255, 0.12);
}

.header-view-toggle__label {
  display: block;
  line-height: 1;
}

.app-header--cloud .header-view-toggle {
  display: none;
}

header h1,
.app-header__title {
  margin: 0;
  font-size: clamp(1.05rem, 4vw, 1.25rem);
  font-weight: 600;
}

.header-title-panel,
.header-title-unit {
  display: block;
  width: 100%;
  text-align: center;
}

.header-cloud {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0 0.15rem;
}

.header-cloud__brand {
  font-size: clamp(1.05rem, 4.2vw, 1.28rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}

.header-cloud__account {
  font-size: clamp(0.76rem, 2.8vw, 0.86rem);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.app-header--cloud .app-header__title {
  display: none !important;
}

.app-header--unit .header-cloud,
.app-header--unit .header-title-panel,
.app-header--panel .header-cloud,
.app-header--panel .header-title-unit {
  display: none !important;
}

.app-header--panel .header-title-panel {
  display: block !important;
  font-size: clamp(0.92rem, 3.6vw, 1.15rem);
  line-height: 1.3;
}

.header-desc {
  margin: 0;
  font-size: clamp(0.8rem, 3.2vw, 0.9rem);
  color: var(--muted);
  max-width: 42rem;
}

.header-desc__hint {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.88em;
  color: var(--muted);
  font-weight: 400;
}

.header-desc__hint code {
  font-size: 0.92em;
  padding: 0.05em 0.28em;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
}

body.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: var(--bottom-tab-pad);
}

main.main-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  padding: 0.75rem max(0.75rem, env(safe-area-inset-left)) 0 max(0.75rem, env(safe-area-inset-right));
  overflow: hidden;
}

/* Navbar tab: figlio diretto di body (non dentro main overflow:hidden) */
body.app-shell > .bottom-tab-nav {
  flex-shrink: 0;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

.seg-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  width: 100%;
}

.seg-links__actions {
  display: contents;
}

.seg-links__acq {
  display: none !important;
  grid-column: 1 / -1;
  grid-row: 1;
  flex-direction: column;
  gap: 0.28rem;
  width: 100%;
}

body.panel-3d-active .seg-links__acq {
  display: flex !important;
}

.acq-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
}

.acq-stat-row > .acq-stat {
  flex: 1 1 calc(50% - 0.2rem);
  min-width: 7.2rem;
}

.acq-stat--identity {
  border-top: 2px solid #a371f7;
}

.acq-stat--identity.acq-stat--pending .acq-stat__value {
  color: #8b949e;
}

.acq-stat--identity.acq-stat--identity-ok .acq-stat__value {
  color: #c297ff;
}

.acq-stat--identity.acq-stat--identity-warn .acq-stat__value {
  color: #ffd966;
}

.acq-stat--identity.acq-stat--identity-crit .acq-stat__value {
  color: #ff7b72;
}

.acq-stat--identity .acq-stat__value {
  font-size: clamp(0.72rem, 2.6vw, 0.86rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acq-stat {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0.38rem 0.5rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.2rem;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  box-sizing: border-box;
  min-height: 3.1rem;
}

.acq-stat--bin {
  border-top: 2px solid #58a6ff;
}

.acq-stat--cluster {
  border-top: 2px solid #d29922;
}

.acq-stat--cluster.acq-stat--prov .acq-stat__value {
  color: #79c0ff;
}

.acq-stat--ehs {
  border-top: 2px solid #3fb950;
}

.acq-stat--ehs.acq-stat--pending .acq-stat__value {
  color: #8b949e;
}

.acq-stat--ehs.acq-stat--ehs-ok .acq-stat__value {
  color: #7ee787;
}

.acq-stat--ehs.acq-stat--ehs-warn .acq-stat__value {
  color: #ffd966;
}

.acq-stat--ehs.acq-stat--ehs-crit .acq-stat__value {
  color: #ff7b72;
}

.acq-stat__label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b949e;
  line-height: 1.1;
}

.acq-stat__value {
  font-size: clamp(0.82rem, 3vw, 0.95rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #e6edf3;
  line-height: 1.2;
}

.acq-stat__value-row {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.2em;
}

.acq-stat__service-icon {
  display: inline-flex;
  align-items: center;
  color: #ff7b72;
  flex-shrink: 0;
}

.acq-stat__service-icon[hidden] {
  display: none !important;
}

.acq-corridor {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0.32rem 0.45rem;
  font-size: 0.6rem;
  line-height: 1.2;
  text-align: center;
  color: var(--muted);
  background: rgba(63, 185, 80, 0.07);
  border: 1px solid rgba(63, 185, 80, 0.22);
  border-radius: 6px;
  box-sizing: border-box;
}

.acq-corridor__label {
  flex: 0 0 auto;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.54rem;
  color: rgba(63, 185, 80, 0.85);
}

.acq-corridor__label::after {
  content: "·";
  margin-left: 0.35rem;
  font-weight: 400;
  opacity: 0.7;
}

.acq-corridor__val {
  flex: 0 1 auto;
  min-width: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #3fb950;
  white-space: nowrap;
}

.acq-corridor--empty {
  background: rgba(48, 54, 61, 0.4);
  border-color: #30363d;
}

.acq-corridor--empty .acq-corridor__label,
.acq-corridor--empty .acq-corridor__val {
  color: #8b949e;
}

#btnReset3dView {
  grid-column: 1;
  grid-row: 1;
  display: none;
}

#toolbarMode {
  display: none;
  grid-column: 2;
  grid-row: 1;
}

#btnNew {
  grid-column: 2;
  grid-row: 1;
}

body.panel-home-active .seg-links,
body.panel-operator-active .seg-links {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

body.panel-home-active #toolbarMode,
body.panel-operator-active #toolbarMode {
  display: contents;
}

body.panel-home-active #btnReset3dView,
body.panel-operator-active #btnReset3dView {
  display: none;
}

body.panel-home-active #modeSA,
body.panel-operator-active #modeSA {
  grid-column: 1;
  grid-row: 1;
}

body.panel-home-active #modeCO,
body.panel-operator-active #modeCO {
  grid-column: 2;
  grid-row: 1;
}

body.panel-home-active #btnNew,
body.panel-operator-active #btnNew {
  grid-column: 3;
  grid-row: 1;
}

body.panel-home-active .seg-link,
body.panel-home-active .seg-mode-btn,
body.panel-operator-active .seg-link,
body.panel-operator-active .seg-mode-btn {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.45rem 0.35rem;
  font-size: clamp(0.78rem, 2.8vw, 0.92rem);
  box-sizing: border-box;
}

body.panel-home-active .seg-mode-btn.active,
body.panel-home-active .seg-mode-btn[aria-pressed="true"],
body.panel-operator-active .seg-mode-btn.active,
body.panel-operator-active .seg-mode-btn[aria-pressed="true"] {
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.62);
  background: rgba(255, 255, 255, 0.1);
}

.seg-mode-btn {
  min-width: 0;
  min-height: var(--touch-min);
  margin: 0;
  padding: 0.4rem 0.25rem;
  font: inherit;
  font-size: clamp(0.68rem, 2.5vw, 0.8rem);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.seg-mode-btn:hover {
  color: var(--text);
}

.seg-mode-btn.active,
.seg-mode-btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

body.panel-3d-active .seg-links {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.28rem;
}

body.panel-3d-active #toolbarMode {
  display: none !important;
}

body.panel-3d-active .seg-links__acq {
  flex-direction: column;
  gap: 0.28rem;
}

body.panel-3d-active .acq-stat {
  padding: 0.28rem 0.4rem 0.3rem;
}

body.panel-3d-active #btnReset3dView {
  grid-column: 1;
  grid-row: 2;
  display: inline-flex;
}

body.panel-3d-active #btnBaseline {
  grid-column: 2;
  grid-row: 2;
}

body.panel-3d-active #btnClearScia {
  grid-column: 3;
  grid-row: 2;
  display: inline-flex;
}

body.panel-3d-active #btnNew {
  grid-column: 4;
  grid-row: 2;
}

body.panel-3d-active #btnNew:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

body.panel-3d-active .seg-link {
  min-height: 38px;
  font-size: 0.65rem;
  padding: 0 0.2rem;
}

body.panel-3d-active .toolbar {
  margin-bottom: 0.2rem;
}

.seg-link {
  width: 100%;
  min-width: 0;
  min-height: var(--touch-min);
  margin: 0;
  padding: 0.45rem 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  font: inherit;
  font-size: clamp(0.78rem, 2.8vw, 0.92rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.seg-link:hover {
  color: var(--text);
}

.seg-link.active,
.seg-link[aria-pressed="true"] {
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.62);
  background: rgba(255, 255, 255, 0.1);
}

.seg-link.seg-link--scene {
  font-weight: 600;
}

.seg-link.seg-link--scene:not(.active):active {
  color: var(--accent);
}

@media (min-width: 540px) {
  .toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  .seg-links {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }
}

.bottom-tab-nav {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: stretch;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5000;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  flex-shrink: 0;
  padding: 0.35rem max(0.5rem, env(safe-area-inset-left)) max(0.35rem, env(safe-area-inset-bottom))
    max(0.5rem, env(safe-area-inset-right));
  border-top: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}

.bottom-tab-nav__btn {
  display: flex;
  flex: 1 1 16.666%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  min-width: 0;
  min-height: calc(var(--touch-min) + 4px);
  margin: 0;
  padding: 0.28rem 0.2rem 0.32rem;
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s ease, background 0.12s ease;
}

.bottom-tab-nav__ico {
  display: block;
  flex-shrink: 0;
  opacity: 0.92;
}

.bottom-tab-nav__txt {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 1.05;
}

.bottom-tab-nav__btn:hover {
  color: rgba(230, 237, 243, 0.92);
}

.bottom-tab-nav__btn.active,
.bottom-tab-nav__btn[aria-selected="true"] {
  color: var(--text);
  background: rgba(139, 148, 158, 0.18);
}

.bottom-tab-nav__btn[data-panel="panelCloud"] .bottom-tab-nav__txt {
  color: var(--text);
  font-weight: 700;
}

.bottom-tab-nav__btn.active .bottom-tab-nav__ico,
.bottom-tab-nav__btn[aria-selected="true"] .bottom-tab-nav__ico {
  opacity: 1;
}

.btn-primary,
.btn-secondary,
button.secondary {
  min-height: var(--touch-min);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text);
}

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

.btn-secondary:active,
button.secondary:active,
.btn-primary:active {
  opacity: 0.88;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.panel-viewport {
  display: block;
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-bottom: var(--bottom-tab-pad);
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem max(0.75rem, env(safe-area-inset-left)) 1.1rem max(0.75rem, env(safe-area-inset-right));
}

.panel.active {
  display: block;
}

.panel-lead {
  margin: 0 0 0.65rem;
  font-size: clamp(0.8rem, 3vw, 0.88rem);
  color: var(--muted);
}

.panel-lead strong {
  color: var(--text);
  font-weight: 600;
}

body.cloud-tab-open .toolbar,
body.history-tab-open .toolbar {
  display: none;
}

body.panel-3d-active .seg-link--baseline,
body.panel-3d-active .seg-link--clear-scia {
  display: inline-flex;
}

body.panel-3d-active #btnBaseline {
  font-weight: 700;
  color: #3fb950;
}

body.panel-3d-active #btnNew {
  font-weight: 600;
}

body.panel-3d-active .panel-viewport {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

body.panel-3d-active #panel3D.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  gap: 0.28rem;
  padding: 0.3rem 0.45rem 0.2rem;
  border: none;
  background: transparent;
}

body.panel-3d-active #panel3D .baseline3d__legend--bar {
  display: flex !important;
}

body.panel-3d-active .baseline3d__hud {
  flex-shrink: 0;
  gap: 0.35rem;
}

body.panel-3d-active .baseline3d__canvas {
  flex: 1 1 0%;
  min-height: 0;
  height: auto;
  max-height: none;
}

.seg-link--baseline {
  display: none;
  font-weight: 600;
  color: var(--accent);
}

.seg-link--clear-scia {
  display: none;
  font-weight: 600;
  color: var(--muted);
}

.build-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.12rem 0.45rem;
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
}

.seg-link--cloud[aria-pressed="true"] {
  color: var(--accent);
  font-weight: 700;
}

.panel-cloud {
  padding: 0.75rem 0.55rem 1rem;
}

.cloud-panel__lead {
  margin: 0 0 0.65rem;
  font-size: clamp(0.78rem, 2.8vw, 0.86rem);
  color: var(--muted);
}

.cloud-table-wrap {
  margin: 0 -0.15rem;
  overflow-x: hidden;
}

.cloud-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: clamp(0.72rem, 2.6vw, 0.78rem);
}

.cloud-table th,
.cloud-table td {
  padding: 0.55rem 0.45rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.cloud-table th {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.cloud-table th:nth-child(1),
.cloud-table td:nth-child(1) {
  width: 26%;
}

.cloud-table th:nth-child(2),
.cloud-table td:nth-child(2) {
  width: 20%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cloud-table th:nth-child(3),
.cloud-table td:nth-child(3) {
  width: 54%;
}

.cloud-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
}

.cloud-table td:last-child {
  white-space: normal;
  word-break: break-word;
}

.cloud-coord-link {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cloud-coord-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

.cloud-upload {
  font-variant-numeric: tabular-nums;
  white-space: normal;
  vertical-align: middle;
  line-height: 1.3;
}

.cloud-upload__state {
  display: inline;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.25;
  white-space: nowrap;
}

.cloud-upload__badge {
  display: inline;
  margin-left: 0.35rem;
  padding: 0.1rem 0.38rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 4px;
  vertical-align: baseline;
  white-space: nowrap;
}

.cloud-table tbody tr[data-fleet-row] {
  cursor: pointer;
}

.cloud-table tbody tr[data-fleet-row]:hover {
  filter: brightness(1.06);
}

.cloud-row--attention {
  background: rgba(163, 113, 247, 0.14);
}

.cloud-row--attention td:first-child,
.cloud-row--attention .cloud-unit-name {
  color: var(--violet);
  font-weight: 700;
}

.cloud-row--attention .cloud-upload__state {
  color: var(--violet);
}

.cloud-row--link-lost {
  background: rgba(88, 166, 255, 0.1);
}

.cloud-row--link-lost td:first-child,
.cloud-row--link-lost .cloud-unit-name {
  color: var(--accent);
  font-weight: 700;
}

.cloud-row--link-lost .cloud-upload__state {
  color: var(--accent);
}

.header-title-unit {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.cloud-row--device-offline {
  background: rgba(210, 153, 34, 0.12);
}

.cloud-row--device-offline td:first-child,
.cloud-row--device-offline .cloud-unit-name {
  color: #d29922;
  font-weight: 700;
}

.cloud-row--device-offline .cloud-upload__state {
  color: #e3b341;
}

.cloud-row--mains-absent {
  background: rgba(248, 81, 73, 0.1);
}

.cloud-row--mains-absent td:first-child,
.cloud-row--mains-absent .cloud-unit-name {
  color: var(--crit);
  font-weight: 700;
}

.cloud-row--mains-absent .cloud-upload__state--mains {
  color: var(--crit);
}

.panel-history {
  padding: 0.75rem 0.55rem 1rem;
}

.history-panel__lead {
  margin: 0 0 0.35rem;
  font-size: clamp(0.78rem, 2.8vw, 0.86rem);
  color: var(--muted);
}

.history-panel__meta {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.history-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.history-table {
  width: 100%;
  min-width: 28rem;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.history-table th,
.history-table td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.history-table th {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.history-kind {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.history-row--event .history-kind {
  background: rgba(248, 81, 73, 0.18);
  color: var(--crit);
}

.history-row--platform .history-kind {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent);
}

.history-row--platform td:last-child {
  font-weight: 600;
}

.history-row--event td:last-child {
  color: #f0c674;
}

#panelHistory.panel.active {
  display: block;
}

.thermo-hero {
  text-align: center;
  padding: 0.65rem 0 0.25rem;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 0.35rem;
}

.thermo-hero[hidden] {
  display: none !important;
}

.thermo-hero .badge {
  margin-top: 0.35rem;
}

.ehs-hero {
  text-align: center;
  padding: 0.75rem 0 0.5rem;
}

.ehs-score,
.ehs-score--secondary {
  font-size: clamp(2.1rem, 9.5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.ehs-score--secondary {
  color: var(--accent);
}

.ehs-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.hint-inline {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.68em;
}

.unit-meta {
  margin: 0.65rem 0 0;
  font-size: clamp(0.82rem, 3vw, 0.9rem);
  color: var(--muted);
}

.grid-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

@media (min-width: 380px) {
  .grid-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 720px) {
  .grid-metrics {
    grid-template-columns: repeat(3, 1fr);
  }
}

.metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.65rem;
  min-height: 4.5rem;
}

.metric .v {
  font-size: clamp(1.05rem, 4vw, 1.2rem);
  font-weight: 600;
}

.metric .k {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}

.metric .baseline-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
  line-height: 1.35;
}

.row-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.grid-metrics > .row-icons--with-linea {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  align-self: stretch;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: clamp(0.4rem, 2.5vw, 0.9rem);
  min-height: 4.5rem;
}

.grid-metrics > .row-icons--with-linea .phase-icon {
  min-width: 0;
  gap: 0.28rem;
}

@media (min-width: 720px) {
  .grid-metrics > .row-icons--with-linea {
    grid-column: 2 / -1;
    justify-content: center;
  }
}

.phase-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  min-width: var(--touch-min);
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

@media (min-width: 380px) {
  .dot {
    width: 18px;
    height: 18px;
  }
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(63, 185, 80, 0.45);
}

.dot.warn {
  background: var(--warn);
}

.dot.crit {
  background: var(--crit);
}

.subscores {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

@media (min-width: 480px) {
  .subscores {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(0.78rem, 3vw, 0.85rem);
  padding: 0.55rem 0.65rem;
  min-height: var(--touch-min);
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.badge {
  font-size: 0.62rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  font-weight: 700;
  flex-shrink: 0;
}

.badge.ok {
  background: rgba(63, 185, 80, 0.2);
  color: var(--ok);
}

.badge.warn {
  background: rgba(210, 153, 34, 0.2);
  color: var(--warn);
}

.badge.crit {
  background: rgba(248, 81, 73, 0.2);
  color: var(--crit);
}

.relay-section {
  margin-top: 0.85rem;
  text-align: center;
}

.relay-section[hidden] {
  display: none !important;
}

.relay-line {
  margin: 0;
  font-size: clamp(0.82rem, 3vw, 0.9rem);
  color: var(--text);
}

.relay-caption {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.chart-tap-hint {
  margin: 0 0 0.45rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.74rem;
  color: var(--muted);
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.22);
  border-radius: 6px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  height: min(78vh, 780px);
  min-height: 520px;
}

#chartCanvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.chart-canvas--has-red {
  cursor: help;
}

.chart-legend {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.65rem;
}

.chart-legend--list {
  list-style: none;
  padding: 0;
  margin: 0.65rem 0 0;
}

.chart-legend--list li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-swatch--corridor {
  background: rgba(186, 194, 204, 0.45);
  border: none;
}

.legend-swatch--series {
  background: #79c0ff;
}

.legend-swatch--out {
  background: rgba(248, 81, 73, 0.45);
}

.legend-swatch--stat {
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.55), rgba(163, 113, 247, 0.45));
  border: 1px solid rgba(88, 166, 255, 0.35);
}

.chart-meta {
  margin-top: 0.5rem;
}

.chart-legend__heading {
  margin-top: 0.55rem;
  margin-bottom: 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
}

.chart-legend__heading:first-child {
  margin-top: 0;
}

.stat-window {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(22, 27, 34, 0.65);
}

.stat-window__title {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.stat-window__lead {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
}

.stat-window__formula {
  margin: 0 0 0.55rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text);
  background: rgba(88, 166, 255, 0.08);
  border-radius: 4px;
  border: 1px solid rgba(88, 166, 255, 0.2);
}

.stat-window__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.75rem;
  margin: 0;
}

.stat-window__grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.stat-window__grid dt {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.stat-window__hint {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted);
}

.stat-window__grid dd {
  margin: 0;
}

.stat-window__ehs {
  grid-column: 1 / -1;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.stat-chip {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}

.stat-chip.ok {
  background: rgba(63, 185, 80, 0.15);
  color: var(--ok);
}

.stat-chip.warn {
  background: rgba(210, 153, 34, 0.15);
  color: var(--warn);
}

.stat-chip.crit {
  background: rgba(248, 81, 73, 0.15);
  color: var(--crit);
}

.stat-chip--neutral {
  background: rgba(139, 148, 158, 0.12);
  color: var(--muted);
  font-weight: 500;
}

.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.chart-modal[hidden] {
  display: none;
}

.chart-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 4, 9, 0.72);
}

.chart-modal__card {
  position: relative;
  z-index: 1;
  width: min(100%, 22rem);
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.chart-modal__title {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  font-weight: 600;
}

.chart-modal__text {
  margin: 0 0 0.85rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-line;
}

.chart-modal__ok {
  width: 100%;
  border-color: var(--border);
}

body.chart-modal-open {
  overflow: hidden;
}

body.theme-manual .legend-swatch--corridor {
  background: rgba(200, 206, 214, 0.4);
}

body.theme-manual .legend-swatch--series {
  background: #0969da;
}

body.theme-manual .legend-swatch--out {
  background: rgba(207, 34, 46, 0.35);
}

.api-block {
  margin-top: 0.5rem;
}

.api-block label,
.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.api-block input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  min-height: var(--touch-min);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 16px;
}

/* —— Tab AI: due fasi (prompt fullscreen → risposta fullscreen) —— */
body.ai-tab-open .panel-viewport {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.ai-tab-open #panelAI.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.panel-ai__shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  gap: 0.4rem;
  overflow: hidden;
}

.panel-ai__context {
  flex: 0 0 auto;
  display: none;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

body.mode-stand-alone .panel-ai__context.is-visible {
  display: block;
}

.panel-ai__label {
  display: block;
  margin: 0 0 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ai-title);
}

.panel-ai__context-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.4rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.4;
  resize: none;
}

.panel-ai__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.panel-ai__toolbar .btn-primary,
.panel-ai__toolbar .btn-secondary {
  flex: 1 1 calc(50% - 0.25rem);
  min-width: 8.5rem;
}

.panel-ai__toolbar .btn-primary {
  border-color: var(--border);
}

.panel-ai__status {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  min-height: 1.05em;
}

.panel-ai__prompt-card,
.panel-ai__response-card {
  flex: 1 1 auto;
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-ai__prompt-card[hidden],
.panel-ai__response-card[hidden] {
  display: none !important;
}

.panel-ai__prompt-field {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.45rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.42;
  resize: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.panel-ai__response-body {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.panel-ai__response-body.is-empty {
  color: var(--muted);
}

.panel-ai__response-body .ai-out__title {
  display: block;
  margin: 0.35rem 0 0.12rem;
  color: var(--ai-title);
  font-weight: 700;
  font-size: 0.78rem;
}

.panel-ai__response-body .ai-out__title:first-child {
  margin-top: 0;
}

#panelAI[data-phase="response"] .panel-ai__toolbar .btn-primary {
  flex: 1 1 100%;
}

.status-line {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.45rem;
}

.mini-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

@media (min-width: 480px) {
  .btn-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .btn-row .btn-primary,
  .btn-row button.secondary {
    flex: 1 1 auto;
    min-width: 10rem;
  }
}

/* ——— Smartphone: altezza finestra, scroll solo nel contenuto tab ——— */
@media (max-width: 639px) {
  :root {
    --touch-min: 40px;
    --radius: 8px;
    --bottom-tab-pad: calc(4.25rem + env(safe-area-inset-bottom, 0px));
  }

  .hide-below-sm {
    display: none !important;
  }

  .show-below-sm {
    display: inline !important;
  }

  body.app-shell {
    height: 100dvh;
    height: 100vh;
    min-height: 100dvh;
    padding-bottom: 0;
  }

  header {
    padding: 0.4rem 0.55rem;
    flex-shrink: 0;
  }

  header h1 {
    font-size: 0.92rem;
    margin: 0;
    line-height: 1.25;
  }

  .header-desc {
    display: none;
  }

  main.main-stack {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.35rem 0.45rem 0;
    overflow: hidden;
    max-width: none;
  }

  .toolbar {
    flex-shrink: 0;
    gap: 0.2rem;
    margin-bottom: 0.25rem;
  }

  .seg-links {
    gap: 0.28rem;
  }

  .seg-link {
    min-height: 42px;
    height: 42px;
    padding: 0 0.35rem;
    font-size: 0.72rem;
    line-height: 1.15;
  }

  body.panel-home-active .seg-mode-btn,
  body.panel-operator-active .seg-mode-btn {
    min-height: 42px;
    height: 42px;
    padding: 0 0.35rem;
    font-size: 0.72rem;
    line-height: 1.15;
  }

  #btnReset3dView.seg-link--view-reset {
    font-weight: 700;
    color: var(--text);
  }

  body.app-shell > .bottom-tab-nav {
    display: flex !important;
    padding: 0.32rem max(0.25rem, env(safe-area-inset-left)) max(0.45rem, env(safe-area-inset-bottom))
      max(0.25rem, env(safe-area-inset-right));
  }

  .bottom-tab-nav__btn {
    flex: 1 1 16.666%;
    min-height: 50px;
    padding: 0.22rem 0.06rem 0.24rem;
    gap: 0.12rem;
  }

  .bottom-tab-nav__ico {
    width: 21px;
    height: 21px;
    flex-shrink: 0;
  }

  .bottom-tab-nav__txt {
    font-size: 0.58rem;
    letter-spacing: 0.02em;
    line-height: 1.1;
  }

  .panel-viewport {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--bottom-tab-pad);
  }

  .panel {
    display: none;
    padding: 0.45rem 0.45rem 0.55rem;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
  }

  .panel.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  body.ai-tab-open #panelAI.panel.active {
    display: flex;
    flex: 1 1 0%;
    min-height: 0;
  }

  #panelCloud.panel.active,
  #panelHistory.panel.active {
    display: block;
  }

  #panel3D.panel.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  #panelGraph.panel.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  #panelGraph .chart-wrap {
    flex: 1 1 auto;
    width: 100%;
    height: min(62vh, 560px);
    min-height: 420px;
    max-height: none;
  }

  .thermo-hero {
    padding: 0.2rem 0;
    margin-bottom: 0.2rem;
  }

  .ehs-hero {
    padding: 0.3rem 0 0.2rem;
  }

  .ehs-score,
  .ehs-score--secondary {
    font-size: 1.85rem;
  }

  .ehs-label {
    font-size: 0.65rem;
  }

  .unit-meta {
    font-size: 0.68rem;
    margin-top: 0.2rem;
  }

  .grid-metrics {
    margin-top: 0.4rem;
    gap: 0.28rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-height: 0;
    padding: 0.38rem 0.4rem;
  }

  .metric .v {
    font-size: 0.88rem;
  }

  .metric .k {
    font-size: 0.58rem;
    margin-bottom: 0.15rem;
  }

  .metric .baseline-hint {
    font-size: 0.58rem;
    margin-top: 0.15rem;
    line-height: 1.2;
  }

  .subscores {
    margin-top: 0.4rem;
    gap: 0.22rem;
  }

  .sub {
    min-height: 0;
    padding: 0.32rem 0.38rem;
    font-size: 0.68rem;
  }

  .grid-metrics > .row-icons--with-linea {
    gap: 0.38rem;
    min-height: 0;
    padding: 0.1rem 0;
  }

  .grid-metrics > .row-icons--with-linea .dot {
    width: 14px;
    height: 14px;
  }

  .row-icons {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    gap: 0.65rem;
  }

  .phase-icon {
    font-size: 0.72rem;
    min-width: 0;
  }

  .relay-section {
    margin-top: 0.4rem;
  }

  .relay-caption {
    font-size: 0.65rem;
  }

  .panel-lead {
    font-size: 0.65rem;
    margin-bottom: 0.3rem;
    line-height: 1.3;
  }

  .chart-wrap {
    height: min(62vh, 560px);
    min-height: 420px;
    max-height: none;
  }

  .chart-legend--list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
    font-size: 0.58rem;
    margin-top: 0.3rem;
  }

  .chart-legend--list li {
    margin-bottom: 0;
  }

  .api-block input {
    min-height: 40px;
    padding: 0.45rem 0.5rem;
  }

  .panel-ai__prompt-field,
  .panel-ai__response-body {
    font-size: 0.75rem;
  }

  .panel-ai__response-body {
    padding: 0.38rem 0.42rem;
  }

  .panel-ai__toolbar .btn-primary,
  .panel-ai__toolbar .btn-secondary {
    min-height: 40px;
    font-size: 0.78rem;
  }

  .btn-row .btn-primary,
  .btn-row button.secondary {
    min-height: 40px;
    font-size: 0.78rem;
  }
}

/* —— Tab 3D (Three.js baseline demo) —— */
#panel3D.panel.active {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 0.25rem;
}

.baseline3d__lead {
  margin: 0;
  font-size: clamp(0.78rem, 3vw, 0.86rem);
  color: var(--muted);
  line-height: 1.35;
}

.baseline3d__hud {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  width: 100%;
}

.baseline3d__progress-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.baseline3d__progress-track {
  flex: 1 1 auto;
  height: 0.45rem;
  min-width: 4rem;
  border-radius: 999px;
  background: rgba(48, 54, 61, 0.9);
  border: 1px solid var(--border);
  overflow: hidden;
}

.baseline3d__progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #9e6a03 0%, #d29922 35%, #58a6ff 68%, #3fb950 100%);
  transition: width 0.35s ease;
}

.baseline3d__progress-steps {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.baseline3d__progress-step {
  flex: 1 1 0;
  text-align: center;
  padding: 0.1rem 0.15rem;
  border-radius: 3px;
  opacity: 0.45;
}

.baseline3d__progress-step.is-active {
  opacity: 1;
  color: #d29922;
  background: rgba(210, 153, 34, 0.12);
}

.baseline3d__progress-step.is-done {
  opacity: 0.85;
  color: #3fb950;
}

.baseline3d__progress-step.is-active.baseline3d__progress-step--prov {
  color: #58a6ff;
  background: rgba(88, 166, 255, 0.12);
}

.baseline3d__progress-step.is-active.baseline3d__progress-step--op {
  color: #3fb950;
  background: rgba(63, 185, 80, 0.12);
}

.baseline3d__progress-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
}

.baseline3d__phase {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 4px;
}

.baseline3d__phase--label {
  color: #c297ff;
  background: rgba(163, 113, 247, 0.14);
}

.baseline3d__phase--firma {
  color: #c297ff;
  background: rgba(163, 113, 247, 0.18);
}

.baseline3d__phase--learn {
  color: #d29922;
  background: rgba(210, 153, 34, 0.15);
}

.baseline3d__phase--prov {
  color: #58a6ff;
  background: rgba(88, 166, 255, 0.14);
}

.baseline3d__phase--op {
  color: #3fb950;
  background: rgba(63, 185, 80, 0.12);
}

.baseline3d__meta {
  margin: 0;
  flex: 1 1 12rem;
  font-size: clamp(0.72rem, 2.8vw, 0.82rem);
  color: var(--text);
  line-height: 1.35;
}

.baseline3d__layer-key {
  padding: 0.4rem 0.5rem;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
}

.baseline3d__layer-key--labelling {
  border-color: rgba(163, 113, 247, 0.35);
}

.baseline3d__layer-key--learning {
  border-color: rgba(210, 153, 34, 0.35);
}

.baseline3d__layer-key--frozen {
  border-color: rgba(63, 185, 80, 0.35);
}

.baseline3d__layer-key-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
}

.baseline3d__layer-key-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #8b949e;
}

.baseline3d__layer-key-load {
  font-size: 0.78rem;
  font-weight: 600;
  color: #c297ff;
}

.baseline3d__labelling-link {
  margin-left: auto;
  font-size: 0.68rem;
  color: #58a6ff;
  text-decoration: none;
}

.baseline3d__labelling-link:hover {
  text-decoration: underline;
}

.baseline3d__layer-key-svg {
  display: block;
  width: 100%;
  max-width: 11rem;
  height: auto;
}

.baseline3d__layer-key-caption {
  margin: 0.3rem 0 0;
  font-size: clamp(0.66rem, 2.4vw, 0.72rem);
  line-height: 1.35;
  color: #8b949e;
}

.baseline3d__layer-id {
  fill: none;
  stroke: #c297ff;
  stroke-width: 1.8;
}

.baseline3d__layer-op {
  fill: none;
  stroke: #56d364;
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
}

.baseline3d__layer-key--frozen .baseline3d__layer-op {
  stroke-dasharray: none;
  stroke-width: 1.7;
  opacity: 1;
}

.baseline3d__layer-key--labelling .baseline3d__layer-op {
  stroke-dasharray: none;
  opacity: 0.4;
}

.baseline3d__layer-key--learning .baseline3d__layer-op {
  opacity: 0.85;
}

.baseline3d__layer-sample {
  fill: #ffa657;
  stroke: #0d1117;
  stroke-width: 1;
}

.baseline3d__canvas {
  position: relative;
  width: 100%;
  height: clamp(220px, 42vh, 360px);
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #161b22;
  touch-action: none;
}

.baseline3d__canvas canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  z-index: 0;
}

.baseline3d__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.35rem;
}

.baseline3d__legend--bar {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 0.7rem;
  margin: 0;
  padding: 0.42rem 0.55rem;
  list-style: none;
  font-size: 0.68rem;
  color: #c9d1d9;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

#panel3D:not(.active) .baseline3d__legend--bar {
  display: none !important;
}

.baseline3d__axes {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.28rem;
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.15;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.baseline3d__axes::-webkit-scrollbar {
  display: none;
}

.baseline3d__ax {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.28rem;
  padding: 0.14rem 0.38rem;
  border-radius: 4px;
  background: rgba(13, 17, 23, 0.82);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.baseline3d__ax-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.92;
}

.baseline3d__ax-val {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.baseline3d__ax--x {
  color: #f85149;
}

.baseline3d__ax--y {
  color: #3fb950;
}

.baseline3d__ax--z {
  color: #58a6ff;
}

.baseline3d__learning-banner {
  margin: 0;
  align-self: flex-start;
  width: 100%;
  font-size: 0.7rem;
  font-weight: 600;
  color: #d29922;
  background: rgba(210, 153, 34, 0.18);
  border: 1px solid rgba(210, 153, 34, 0.45);
  padding: 0.28rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.baseline3d__cluster-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  align-self: flex-start;
}

.baseline3d__cluster-tag {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.14rem 0.38rem;
  border-radius: 4px;
  border: 1px solid;
  background: rgba(13, 17, 23, 0.82);
}

.baseline3d__cluster-tag--basso {
  color: #79c0ff;
  border-color: rgba(88, 166, 255, 0.55);
}

.baseline3d__cluster-tag--medio {
  color: #d29922;
  border-color: rgba(210, 153, 34, 0.55);
}

.baseline3d__cluster-tag--alto {
  color: #56d364;
  border-color: rgba(63, 185, 80, 0.45);
}

.baseline3d__keyline {
  margin: 0;
  align-self: flex-end;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(13, 17, 23, 0.8);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
}

.baseline3d__keyline strong {
  color: #3fb950;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.baseline3d__canvas--error {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.baseline3d__err {
  margin: 0;
  font-size: 0.82rem;
  color: #f85149;
  text-align: center;
  line-height: 1.4;
  max-width: 28rem;
}

.baseline3d__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: clamp(0.68rem, 2.6vw, 0.76rem);
  color: var(--muted);
}

.baseline3d__legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.baseline3d__swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.baseline3d__swatch--ok {
  background: #3fb950;
}

.baseline3d__swatch--warn {
  background: #d29922;
}

.baseline3d__swatch--crit {
  background: #f85149;
}

.baseline3d__swatch--cluster {
  background: radial-gradient(circle at 35% 35%, #79c0ff 0%, #58a6ff 55%, transparent 56%);
  border: 1px solid #79c0ff;
  border-radius: 50%;
}

.baseline3d__swatch--bin {
  background: #238636;
  opacity: 0.85;
}

.baseline3d__swatch--active {
  background: #58a6ff;
}

.baseline3d__swatch--ell {
  background: transparent;
  border: 2px solid #3fb950;
  border-radius: 50%;
  width: 0.7rem;
  height: 0.7rem;
}

.baseline3d__swatch--identity {
  background: transparent;
  border: 2px solid #a371f7;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  transform: rotate(45deg);
}

.baseline3d__identity-hint {
  margin: 0.35rem 0 0;
  padding: 0.35rem 0.5rem;
  font-size: clamp(0.68rem, 2.4vw, 0.74rem);
  line-height: 1.35;
  color: #c297ff;
  background: rgba(163, 113, 247, 0.08);
  border: 1px solid rgba(163, 113, 247, 0.22);
  border-radius: 8px;
}

.baseline3d__swatch--trail {
  background: #8b949e;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.baseline3d__hint {
  margin: 0;
  font-size: clamp(0.68rem, 2.5vw, 0.74rem);
  color: var(--muted);
  line-height: 1.3;
}

.hero-screen {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(2.5rem, 18vh, 4.25rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.55s ease;
}

.hero-screen.is-visible {
  opacity: 1;
}

.hero-screen.is-exiting {
  opacity: 0;
}

.hero-screen__bg {
  position: absolute;
  inset: 0;
  background-color: #0d1117;
  background-size: cover;
  background-position: center;
  filter: blur(16px) saturate(0.82) brightness(0.36);
  transform: scale(1.1);
  opacity: 0;
}

.hero-screen.is-visible .hero-screen__bg {
  animation: heroBgReveal 1.35s cubic-bezier(0.16, 1, 0.3, 1) forwards,
    heroBgDrift 7s ease-in-out 1.35s forwards;
}

.hero-screen.is-exiting .hero-screen__bg {
  animation: none;
  opacity: 0.6;
  transition: opacity 0.55s ease, filter 0.55s ease;
}

@keyframes heroBgReveal {
  from {
    opacity: 0;
    filter: blur(28px) saturate(0.55) brightness(0.2);
    transform: scale(1.22);
  }
  55% {
    opacity: 0.85;
    filter: blur(16px) saturate(0.75) brightness(0.34);
    transform: scale(1.08);
  }
  to {
    opacity: 1;
    filter: blur(12px) saturate(0.9) brightness(0.46);
    transform: scale(1.04);
  }
}

@keyframes heroBgDrift {
  0% {
    transform: scale(1.04);
  }
  50% {
    transform: scale(1.09);
  }
  100% {
    transform: scale(1.02);
    filter: blur(11px) saturate(0.92) brightness(0.48);
  }
}

.hero-screen__content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem 1.35rem 1.75rem;
  max-width: 18rem;
  opacity: 0;
  transform: translateY(28px) scale(0.9);
  filter: blur(4px);
}

.hero-screen.is-visible .hero-screen__content {
  animation: heroContentLift 1.05s cubic-bezier(0.16, 1, 0.3, 1) 0.08s forwards;
}

.hero-screen.is-exiting .hero-screen__content {
  animation: heroContentOut 0.5s ease forwards;
}

@keyframes heroContentLift {
  0% {
    opacity: 0;
    transform: translateY(28px) scale(0.9);
    filter: blur(4px);
  }
  70% {
    opacity: 1;
    transform: translateY(-4px) scale(1.02);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes heroContentOut {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

.hero-screen__eyebrow {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 5.8vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: none;
  color: #ffffff;
  opacity: 0;
}

.hero-screen.is-visible .hero-screen__eyebrow {
  animation: heroTextIn 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.35s forwards;
}

.hero-screen__title {
  margin: 0 0 0.35rem;
  font-size: clamp(0.88rem, 3.4vw, 0.98rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: #ffffff;
  opacity: 0;
}

.hero-screen.is-visible .hero-screen__title {
  animation: heroTitleIn 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.5s forwards;
}

.hero-screen__title::after {
  content: "";
  display: block;
  width: 0;
  height: 2px;
  margin: 0.7rem auto 0;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, #4f7cff 20%, #6e8fff 50%, #4f7cff 80%, transparent);
  opacity: 0.9;
}

.hero-screen.is-visible .hero-screen__title::after {
  animation: heroRuleExpand 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.95s forwards;
}

@keyframes heroRuleExpand {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    width: 70%;
    opacity: 1;
  }
}

.hero-screen__subtitle {
  margin: 0;
  font-size: clamp(0.72rem, 2.7vw, 0.8rem);
  font-weight: 400;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
  opacity: 0;
}

.hero-screen.is-visible .hero-screen__subtitle {
  animation: heroTextIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.72s forwards;
}

@keyframes heroTitleIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
    letter-spacing: 0.02em;
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    letter-spacing: -0.03em;
  }
}

@keyframes heroTextIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-screen,
  .hero-screen__bg,
  .hero-screen__content,
  .hero-screen__eyebrow,
  .hero-screen__title,
  .hero-screen__title::after,
  .hero-screen__subtitle {
    animation: none !important;
    transition: opacity 0.35s ease !important;
    transform: none !important;
  }

  .hero-screen.is-visible .hero-screen__bg,
  .hero-screen.is-visible .hero-screen__content,
  .hero-screen.is-visible .hero-screen__eyebrow,
  .hero-screen.is-visible .hero-screen__title,
  .hero-screen.is-visible .hero-screen__subtitle {
    opacity: 1 !important;
  }
}

/* —— Vista modulo 2D (toggle header, parallela al 3D) —— */
.baseline-viewport {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
}

body.panel-3d-view-2d .baseline3d__legend--bar {
  display: none !important;
}

body.panel-3d-view-2d #baseline3dCanvas {
  visibility: hidden;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

body.panel-3d-view-2d .baseline-viewport {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.panel-3d-view-2d #baseline2dPanel {
  display: block;
  flex: 1 1 0%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
}

.baseline-viewport .hero-screen {
  z-index: 24;
}

.fingerprint-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.5rem 0.45rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  background: rgba(5, 7, 10, 0.72);
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.fingerprint-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.fingerprint-overlay__panel {
  width: min(100%, 24rem);
  max-height: min(88%, 520px);
  overflow-y: auto;
  padding: 0.85rem 0.9rem 1rem;
  background: #161b22;
  border: 1px solid rgba(163, 113, 247, 0.35);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.fingerprint-overlay__kicker {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a371f7;
}

.fingerprint-overlay__title {
  margin: 0.2rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.fingerprint-overlay__load {
  margin: 0.65rem 0 0.5rem;
  padding: 0.45rem 0.55rem;
  background: rgba(163, 113, 247, 0.08);
  border: 1px solid rgba(163, 113, 247, 0.22);
  border-radius: 8px;
}

.fingerprint-overlay__load-k {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8b949e;
}

.fingerprint-overlay__load-v {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.92rem;
  color: #c297ff;
}

.fingerprint-overlay__metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.5rem;
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
}

.fingerprint-overlay__metrics dt {
  color: #8b949e;
  font-size: 0.62rem;
}

.fingerprint-overlay__metrics dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.fingerprint-overlay__chart-wrap {
  margin-top: 0.55rem;
}

.fingerprint-overlay__chart-k {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.65rem;
  color: #8b949e;
}

.fingerprint-overlay__chart-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #080b10;
}

.fingerprint-overlay__continue {
  width: 100%;
  margin-top: 0.75rem;
}

body.panel-3d-active .baseline3d__progress-hint {
  display: block;
  margin: 0;
}

.hero-screen--2d-end .hero-screen__title::after {
  display: none;
}

.hero-screen--2d-end .hero-screen__title {
  font-size: clamp(1.35rem, 5.8vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.baseline2d {
  display: none;
  flex-direction: column;
  gap: 0.32rem;
  min-height: min-content;
  padding: 0.28rem 0.2rem 0.5rem;
  font-variant-numeric: tabular-nums;
}

body.panel-3d-view-2d .baseline2d {
  display: flex;
  overflow: visible;
}

.baseline2d__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.55rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(22, 27, 34, 0.9);
  flex-shrink: 0;
}

.baseline2d__phase {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
}

.baseline2d__phase--learn {
  color: #79c0ff;
  background: rgba(88, 166, 255, 0.14);
}

.baseline2d__phase--prov {
  color: #d29922;
  background: rgba(210, 153, 34, 0.14);
}

.baseline2d__phase--op {
  color: #7ee787;
  background: rgba(63, 185, 80, 0.14);
}

.baseline2d__cluster,
.baseline2d__ehs {
  font-size: 0.72rem;
  color: var(--muted);
}

.baseline2d__ehs--warn {
  color: #ff7b72;
  font-weight: 600;
}

.baseline2d__quality {
  padding: 0.42rem 0.5rem;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.88);
  flex-shrink: 0;
}

.baseline2d__quality-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
  white-space: nowrap;
}

.baseline2d__quality-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #e6edf3;
}

.baseline2d__quality-samples {
  font-size: 0.64rem;
  color: #8b949e;
  font-weight: 700;
}

.baseline2d__quality-rows {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.baseline2d__quality-row {
  min-width: 0;
  padding: 0.34rem 0.38rem;
  border: 1px solid rgba(48, 54, 61, 0.9);
  border-radius: 6px;
  background:
    linear-gradient(
      90deg,
      rgba(63, 185, 80, var(--quality-alpha)) 0,
      rgba(63, 185, 80, var(--quality-alpha)) var(--quality-pct),
      rgba(48, 54, 61, 0.38) var(--quality-pct),
      rgba(48, 54, 61, 0.38) 100%
    );
}

.baseline2d__quality-k {
  display: block;
  font-size: 0.58rem;
  color: rgba(230, 237, 243, 0.86);
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.baseline2d__quality-v {
  display: block;
  margin-top: 0.08rem;
  font-size: 0.66rem;
  font-weight: 800;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.baseline2d__quality-state {
  margin-left: auto;
  padding: 0.1rem 0.34rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #8b949e;
  background: rgba(139, 148, 158, 0.14);
}

.baseline2d__quality-state--ready,
.baseline2d__quality-state--converging,
.baseline2d__quality-state--operativa,
.baseline2d__quality-state[class*="locked"] {
  color: #7ee787;
  background: rgba(63, 185, 80, 0.14);
}

.baseline2d__quality-state--unstable,
.baseline2d__quality-state--unbalanced,
.baseline2d__quality-state[class*="drift"] {
  color: #ffd966;
  background: rgba(210, 153, 34, 0.14);
}

@media (max-width: 720px) {
  .baseline2d__quality-rows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.baseline2d__metrics {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  flex-shrink: 0;
}

.baseline2d__metric {
  padding: 0.38rem 0.45rem 0.42rem;
  flex-shrink: 0;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #161b22;
}

.baseline2d__metric--estimate {
  background: rgba(22, 27, 34, 0.92);
}

.baseline2d__quality-row--locked {
  background:
    linear-gradient(
      90deg,
      rgba(63, 185, 80, 0.32) 0,
      rgba(63, 185, 80, 0.32) 100%
    );
}

.baseline2d__quality-row--deviation {
  border-color: rgba(63, 185, 80, 0.42);
  background:
    linear-gradient(
      90deg,
      rgba(var(--deviation-rgb, 63, 185, 80), calc(0.22 + var(--quality-alpha) * 0.68)) 0,
      rgba(var(--deviation-rgb, 63, 185, 80), calc(0.22 + var(--quality-alpha) * 0.68)) var(--quality-pct),
      rgba(48, 54, 61, 0.38) var(--quality-pct),
      rgba(48, 54, 61, 0.38) 100%
    );
}

.baseline2d__quality-row--severity-mid {
  border-color: rgba(210, 153, 34, 0.55);
}

.baseline2d__quality-row--severity-high {
  border-color: rgba(255, 123, 114, 0.62);
}

.baseline2d__metric-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.baseline2d__metric-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: #e6edf3;
}

.baseline2d__metric-status {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.baseline2d__metric-status--inside {
  color: #7ee787;
}

.baseline2d__metric-status--near {
  color: #ffd966;
}

.baseline2d__metric-status--outside {
  color: #ff7b72;
}

.baseline2d__metric-status--learning {
  color: #8b949e;
}

.baseline2d__estimate-vals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  font-size: 0.68rem;
  color: #8b949e;
  margin-bottom: 0.36rem;
}

.baseline2d__estimate-vals strong {
  color: #e6edf3;
  font-weight: 700;
}

/* Prima del freeze baseline: nessun semaforo rosso/verde/giallo sulle righe metriche */
.baseline2d--pre-baseline .baseline2d__metric-status--inside,
.baseline2d--pre-baseline .baseline2d__metric-status--near,
.baseline2d--pre-baseline .baseline2d__metric-status--outside {
  color: #8b949e !important;
}

.baseline2d--pre-baseline .baseline2d__track-marker--inside,
.baseline2d--pre-baseline .baseline2d__track-marker--near,
.baseline2d--pre-baseline .baseline2d__track-marker--outside {
  background: #8b949e !important;
}

.baseline2d__track {
  position: relative;
  height: 1.35rem;
  margin: 0.15rem 0 0.4rem;
  border-radius: 4px;
  background: repeating-linear-gradient(
    90deg,
    rgba(48, 54, 61, 0.55) 0,
    rgba(48, 54, 61, 0.55) 1px,
    transparent 1px,
    transparent 12.5%
  );
  border: 1px solid #30363d;
}

.baseline2d__track-band--outer {
  background: rgba(88, 166, 255, 0.06) !important;
  border-left: 1px dashed rgba(121, 192, 255, 0.30) !important;
  border-right: 1px dashed rgba(121, 192, 255, 0.30) !important;
}

.baseline2d__track--learning .baseline2d__track-band {
  background: rgba(139, 148, 158, 0.18) !important;
  border-left-color: rgba(139, 148, 158, 0.45) !important;
  border-right-color: rgba(139, 148, 158, 0.45) !important;
}

.baseline2d__track--learning .baseline2d__track-band--outer {
  background: rgba(139, 148, 158, 0.08) !important;
  border-left-color: rgba(139, 148, 158, 0.30) !important;
  border-right-color: rgba(139, 148, 158, 0.30) !important;
}

.baseline2d__track-band {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: var(--sigma-pct, 40%);
  transform: translateX(-50%);
  background: rgba(88, 166, 255, 0.14);
  border-left: 1px solid rgba(121, 192, 255, 0.45);
  border-right: 1px solid rgba(121, 192, 255, 0.45);
}

.baseline2d__track-mu {
  position: absolute;
  left: 50%;
  top: -0.15rem;
  bottom: -0.15rem;
  width: 2px;
  transform: translateX(-50%);
  background: #79c0ff;
  font-size: 0;
}

.baseline2d__track-band--identity {
  width: var(--sigma-pct, 14%);
  transform: translateX(-50%);
  background: rgba(163, 113, 247, 0.16);
  border-left: 1px dashed rgba(194, 151, 255, 0.75);
  border-right: 1px dashed rgba(194, 151, 255, 0.75);
  z-index: 1;
}

.baseline2d__track-identity {
  position: absolute;
  top: -0.35rem;
  bottom: -0.35rem;
  width: 3px;
  transform: translateX(-50%);
  background: #a371f7;
  font-size: 0;
  box-shadow: 0 0 6px rgba(163, 113, 247, 0.55);
  pointer-events: none;
  z-index: 2;
}

.baseline2d__swatch--identity {
  background: #a371f7;
  transform: rotate(45deg);
  border-radius: 2px;
}

.baseline2d__track-marker {
  position: absolute;
  top: 50%;
  width: 0.62rem;
  height: 0.62rem;
  margin-left: -0.31rem;
  transform: translateY(-50%);
  border-radius: 50%;
  border: 2px solid #0d1117;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.baseline2d__track-marker--inside {
  background: #7ee787;
}

.baseline2d__track-marker--near {
  background: #ffd966;
}

.baseline2d__track-marker--outside {
  background: #ff7b72;
}

.baseline2d__track-marker--learning {
  background: #8b949e;
}

.baseline2d__metric-vals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.68rem;
  color: #8b949e;
}

.baseline2d__val strong {
  color: #e6edf3;
  font-weight: 700;
}

.baseline2d__val-k {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6e7681;
}

.baseline2d__unit {
  font-size: 0.62rem;
  color: #6e7681;
}

.baseline2d__composite {
  margin: 0;
  padding: 0.38rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #30363d;
}

.baseline2d__composite--inside {
  color: #7ee787;
  background: rgba(63, 185, 80, 0.1);
}

.baseline2d__composite--near {
  color: #ffd966;
  background: rgba(210, 153, 34, 0.1);
}

.baseline2d__composite--outside {
  color: #ff7b72;
  background: rgba(248, 81, 73, 0.1);
}

.baseline2d__drivers {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.25;
  color: #a371f7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.baseline2d__trail-section {
  margin-top: 0.1rem;
  padding: 0.5rem 0.5rem 0.55rem;
  flex-shrink: 0;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.65);
  scroll-margin-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
}

.baseline2d__trail-title {
  margin: 0 0 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b949e;
}

.baseline2d__trail-section--drift {
  border-color: rgba(255, 123, 114, 0.46);
  background: rgba(38, 13, 17, 0.58);
}

.baseline2d__trail-section--drift .baseline2d__trail-title {
  color: #ffb3ad;
}

.baseline2d__strip {
  min-height: 1.15rem;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.baseline2d__strip-inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.26rem;
  min-width: min-content;
  padding-bottom: 0.1rem;
}

.baseline2d__trend {
  padding: 0.2rem 0.24rem 0.15rem;
  border: 1px solid rgba(48, 54, 61, 0.76);
  border-radius: 7px;
  background: rgba(13, 17, 23, 0.7);
}

.baseline2d__trend-svg {
  display: block;
  width: 100%;
  height: 3.45rem;
  overflow: visible;
}

.baseline2d__trend-band--inside {
  fill: rgba(63, 185, 80, 0.08);
}

.baseline2d__trend-band--near {
  fill: rgba(210, 153, 34, 0.1);
}

.baseline2d__trend-threshold {
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.baseline2d__trend-threshold--edge {
  stroke: rgba(126, 231, 135, 0.35);
}

.baseline2d__trend-threshold--outside {
  stroke: rgba(255, 217, 102, 0.45);
}

.baseline2d__trend-line {
  fill: none;
  stroke: #7ee787;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px rgba(126, 231, 135, 0.28));
}

.baseline2d__trend--near .baseline2d__trend-line {
  stroke: #ffd966;
  filter: drop-shadow(0 0 3px rgba(255, 217, 102, 0.32));
}

.baseline2d__trend--outside .baseline2d__trend-line,
.baseline2d__trend--drift .baseline2d__trend-line {
  stroke: #ff7b72;
  filter: drop-shadow(0 0 5px rgba(255, 123, 114, 0.55));
}

.baseline2d__trend-point {
  stroke: #0d1117;
  stroke-width: 1.2;
}

.baseline2d__trend-point--inside {
  fill: #7ee787;
}

.baseline2d__trend-point--near {
  fill: #ffd966;
}

.baseline2d__trend-point--outside,
.baseline2d__trend-point--drift {
  fill: #ff7b72;
}

.baseline2d__trend-point--drift {
  stroke: #ffa657;
  stroke-width: 1.6;
}

.baseline2d__trend-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  margin-top: -0.08rem;
  font-size: 0.58rem;
  line-height: 1.2;
  color: #8b949e;
  white-space: nowrap;
}

.baseline2d__dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}

.baseline2d__dot--inside {
  background: #7ee787;
}

.baseline2d__dot--near {
  background: #ffd966;
}

.baseline2d__dot--outside {
  background: #ff7b72;
}

.baseline2d__dot--learning {
  background: #8b949e;
}

.baseline2d__dot--drift {
  background: #ff7b72;
  box-shadow: 0 0 0 2px rgba(255, 166, 87, 0.95), 0 0 10px rgba(255, 123, 114, 0.55);
  transform: scale(1.28);
}

.baseline2d__dot--drift-latest {
  box-shadow: 0 0 0 3px rgba(255, 166, 87, 0.95), 0 0 14px rgba(255, 123, 114, 0.82);
  transform: scale(1.48);
}

.baseline2d__dot--freeze {
  box-shadow: 0 0 0 2px #79c0ff;
}

.baseline2d__freeze-caption {
  margin: 0.38rem 0 0;
  padding: 0;
  font-size: 0.62rem;
  line-height: 1.35;
  color: #79c0ff;
  white-space: normal;
  overflow: visible;
}

.baseline2d__empty {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.baseline2d__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem 0.5rem;
  margin: 0;
  padding: 0.28rem 0.4rem 0;
  flex-shrink: 0;
  list-style: none;
  font-size: 0.62rem;
  color: #8b949e;
  border-top: 1px solid var(--border);
}

.baseline2d__swatch {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.2rem;
  border-radius: 50%;
  vertical-align: middle;
}

.baseline2d__swatch--inside {
  background: #7ee787;
}

.baseline2d__swatch--near {
  background: #ffd966;
}

.baseline2d__swatch--outside {
  background: #ff7b72;
}

.baseline2d__swatch--learning {
  background: #8b949e;
}

