/* ============================================================
   Commissioning «Accendi Ora» (dominio FIR) + Snapshot rete (RET)
   Frame derivato da commissioning-firma.html, adattato al tema
   EnergySync (variabili in styles.css).
   ============================================================ */

/* ——— Card firma in Sintesi ——— */
.firma-card {
  margin-top: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  padding: 0.85rem;
}

.firma-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.firma-card__load-name {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: clamp(0.92rem, 3.8vw, 1.02rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text);
}

.firma-card__match {
  flex-shrink: 0;
  margin-top: 0.1rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.firma-card__match--ok {
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.4);
  background: rgba(63, 185, 80, 0.1);
}

.firma-card__match--warn {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.45);
  background: rgba(210, 153, 34, 0.1);
}

.firma-card__match--hold {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.45);
  background: rgba(88, 166, 255, 0.1);
}

.firma-card__match--crit {
  color: var(--crit);
  border-color: rgba(248, 81, 73, 0.5);
  background: rgba(248, 81, 73, 0.12);
}

.firma-card__empty {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.firma-card__load-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.firma-card__mini {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0.65rem 0 0;
}

.firma-card__mini > div,
.firma-card__mini-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  min-width: 0;
}

.firma-card__mini-ref {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.62rem;
  font-weight: 400;
  color: var(--muted);
  font-family: inherit;
}

.firma-card__mini-val--warn {
  color: var(--warn);
}

.firma-card__mini dd.firma-card__mini-val--warn {
  color: var(--warn);
}

.firma-card__mini dt {
  margin: 0;
  font-size: 0.66rem;
  color: var(--muted);
}

.firma-card__mini dd {
  margin: 0.15rem 0 0;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 700;
}

.firma-card__actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.firma-card__btn {
  flex: 1 1 auto;
  min-height: 40px;
}

/* ——— Wizard overlay ——— */
.comm-wizard {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  justify-content: center;
  align-items: stretch;
  background: rgba(1, 4, 9, 0.78);
  backdrop-filter: blur(2px);
}

.comm-wizard[hidden] {
  display: none;
}

.comm-wizard__sheet {
  width: min(100%, 560px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  max-height: 100dvh;
}

.comm-wizard__header {
  position: relative;
  padding: 0.8rem 3rem 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.comm-wizard__kicker {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a371f7;
}

.comm-wizard__title {
  margin: 0.2rem 0 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.comm-wizard__close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.comm-step-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 1rem 0;
}

.comm-step-bar span {
  flex: 1;
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--border);
}

.comm-step-bar span.active {
  color: var(--accent);
  border-color: var(--accent);
}

.comm-step-bar span.done {
  color: var(--ok);
  border-color: var(--ok);
}

.comm-wizard__main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  padding: 1rem;
}

.comm-wizard__footer {
  display: grid;
  gap: 0.55rem;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.comm-wizard__btn {
  min-height: 46px;
}

/* ——— Step contesto ——— */
.comm-device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  padding: 1rem;
  margin-bottom: 0.85rem;
}

.comm-device-card__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.comm-device-card__name {
  margin: 0.35rem 0 0;
  font-size: clamp(0.92rem, 4.2vw, 1.15rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comm-device-card__model {
  margin: 0.25rem 0 0;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.comm-badge-ok {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(63, 185, 80, 0.12);
  border: 1px solid rgba(63, 185, 80, 0.35);
  color: var(--ok);
  font-size: 0.78rem;
  font-weight: 600;
}

.comm-badge-ok::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.comm-field {
  margin-bottom: 0.8rem;
}

.comm-field__label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.comm-field__input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.comm-field__input:focus {
  outline: none;
  border-color: var(--accent);
}

.comm-note {
  margin: 0.85rem 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--muted);
}

/* ——— Step acquisizione ——— */
.comm-acquire-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  padding: 1rem;
  margin-bottom: 0.85rem;
}

.comm-acquire__instruction {
  margin: 0 0 0.75rem;
  font-size: 0.86rem;
  line-height: 1.45;
}

.comm-acquire__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.7rem;
}

.comm-acquire__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.comm-acquire__dot--waiting {
  background: var(--warn);
  animation: commPulse 1.1s ease-in-out infinite;
}

.comm-acquire__dot--capturing {
  background: var(--accent);
  animation: commPulse 0.55s ease-in-out infinite;
}

.comm-acquire__dot--done {
  background: var(--ok);
  animation: none;
}

@keyframes commPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.comm-acquire__progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.comm-acquire__progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #316dca, #58a6ff);
  transition: width 0.18s linear;
}

.comm-acquire__meta {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.comm-acquire-visual {
  display: flex;
  flex-direction: column;
}

.comm-harm-wrap--live .comm-harm-plot {
  min-height: 7.5rem;
}

/* ——— Grafici (spunto, spettro) ——— */
.comm-chart-box {
  background: #080b10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.35rem 0.25rem;
  margin-bottom: 0.75rem;
}

body.theme-manual .comm-chart-box {
  background: #0d1117;
}

.comm-chart-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.35rem 0.35rem;
  font-size: 0.68rem;
  color: var(--muted);
}

.comm-chart-caption strong {
  color: var(--text);
  font-weight: 600;
}

.comm-chart-box canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ——— Baseline del carico (μ ± tolleranza) ——— */
.comm-baseline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  padding: 0.85rem;
  margin-bottom: 0.85rem;
}

.comm-baseline__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.comm-baseline__title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.comm-baseline__phase {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--border);
  color: var(--muted);
}

.comm-baseline__phase--prov {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.45);
  background: rgba(210, 153, 34, 0.1);
}

.comm-baseline__phase--oper {
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.4);
  background: rgba(63, 185, 80, 0.1);
}

.comm-baseline__count {
  margin: 0 0 0.6rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.comm-baseline__rows {
  display: grid;
  gap: 0.4rem;
}

.comm-baseline__row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.comm-baseline__row-k {
  font-size: 0.76rem;
  color: #b1bac4;
  min-width: 0;
}

.comm-baseline__row-mu {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 700;
}

.comm-baseline__row-tol {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.comm-baseline__row-tol small {
  display: block;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.58rem;
  font-weight: 400;
  color: var(--muted);
  text-align: right;
}

.comm-tol-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px dashed rgba(210, 153, 34, 0.45);
  border-radius: 8px;
  background: rgba(210, 153, 34, 0.06);
}

.comm-tol-row__label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--warn);
}

.comm-tol-row__select {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
}

.comm-baseline__note {
  margin: 0.65rem 0 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--muted);
}

.comm-signature-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  padding: 0.85rem;
  margin-bottom: 0.85rem;
}

.comm-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.comm-panel-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.comm-panel-sub {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.comm-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin: 0 0 0.65rem;
}

.comm-metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.45rem;
  min-width: 0;
}

.comm-metric dt {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.25;
}

.comm-metric dd {
  margin: 0.2rem 0 0;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.15;
}

.comm-metric--peak dd {
  color: #ff958f;
}

/* spettro armonico (scala log) */
.comm-harm-wrap {
  margin-top: 0.15rem;
}

.comm-harm-chart {
  display: grid;
  grid-template-columns: 2.85rem 1fr;
  gap: 0.35rem 0.45rem;
  align-items: start;
  padding: 0.55rem 0.4rem 0.35rem;
  background: #080b10;
  border-radius: 8px;
}

body.theme-manual .comm-harm-chart {
  background: #0d1117;
}

.comm-harm-y {
  position: relative;
  height: 100px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--muted);
  text-align: right;
}

.comm-harm-y span {
  position: absolute;
  right: 0;
  transform: translateY(50%);
}

.comm-harm-main {
  min-width: 0;
}

.comm-harm-plot {
  position: relative;
  height: 100px;
  border-left: 1px solid #21262d;
  border-bottom: 1px solid #21262d;
}

.comm-harm-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #21262d;
  pointer-events: none;
}

.comm-harm-bars {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 100%;
  padding: 0 0.15rem;
}

.comm-harm-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.comm-harm-stack {
  position: relative;
  width: 52%;
  min-width: 14px;
  max-width: 40px;
  display: flex;
  align-items: stretch;
}

.comm-harm-val {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  transform: translateX(-50%);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.56rem;
  line-height: 1;
  color: #7d8590;
  white-space: nowrap;
}

.comm-harm-bar {
  flex: 1 1 auto;
  width: 100%;
  min-height: 1px;
  background: linear-gradient(180deg, #6cb6ff 0%, #316dca 52%, #1a4f8c 100%);
}

.comm-harm-col--fund .comm-harm-bar {
  background: linear-gradient(180deg, #82c3ff 0%, #388bfd 42%, #0550ae 100%);
}

.comm-harm-col--minor .comm-harm-bar {
  background: linear-gradient(180deg, #768390 0%, #444c56 55%, #30363d 100%);
}

.comm-harm-col--acq .comm-harm-bar {
  background: linear-gradient(180deg, rgba(88, 166, 255, 0.45), rgba(88, 166, 255, 0.18));
}

.comm-harm-wrap--live {
  margin-top: 0.75rem;
}

.comm-harm-wrap--live .comm-harm-chart {
  min-height: 9.5rem;
}

.comm-harm-x {
  display: flex;
  justify-content: space-around;
  padding: 0.4rem 0.15rem 0;
  text-align: center;
}

.comm-harm-x span {
  flex: 1;
  font-size: 0.74rem;
  font-weight: 600;
}

.comm-harm-x-title {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}

.comm-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin: 0 0 0.4rem;
}

.comm-meta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
}

.comm-meta dt {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
}

.comm-meta dd {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ——— Storico: toggle Storico | Rete ——— */
/* ——— Bilanciamento fasi (Sintesi elettrica) ——— */
.phase-balance {
  margin-top: 0.7rem;
  margin-left: 0;
  margin-right: 0;
  padding: 0.7rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
}

.phase-balance__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
  margin-bottom: 0.55rem;
}

.phase-balance__title {
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0;
}

.phase-balance__sep {
  color: var(--muted);
  font-size: 0.78rem;
  user-select: none;
}

.phase-balance__imb {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
}

.phase-balance__imb--warn {
  color: var(--warn);
  font-weight: 700;
}

.phase-balance__chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.phase-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.3rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.phase-chip--warn {
  border-color: rgba(210, 153, 34, 0.5);
  background: rgba(210, 153, 34, 0.07);
}

.phase-chip--crit {
  border-color: rgba(248, 81, 73, 0.55);
  background: rgba(248, 81, 73, 0.08);
}

/* LED di fase: gradiente radiale (punto luce in alto a sx), ghiera scura e alone colorato */
.phase-chip .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow:
    inset 0 -3px 4px rgba(0, 0, 0, 0.45),
    inset 0 1px 2px rgba(255, 255, 255, 0.35),
    0 0 0 2px rgba(255, 255, 255, 0.05);
}

.phase-chip .dot.ok {
  background: radial-gradient(circle at 32% 28%, #d2ffd9 0%, #6ee07f 28%, #3fb950 55%, #1c7c33 100%);
  box-shadow:
    inset 0 -3px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.5),
    0 0 0 2px rgba(255, 255, 255, 0.05),
    0 0 9px rgba(63, 185, 80, 0.75),
    0 0 18px rgba(63, 185, 80, 0.35);
}

.phase-chip .dot.warn {
  background: radial-gradient(circle at 32% 28%, #fff3c4 0%, #f0c14b 28%, #d29922 55%, #8a6414 100%);
  box-shadow:
    inset 0 -3px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.5),
    0 0 0 2px rgba(255, 255, 255, 0.05),
    0 0 9px rgba(210, 153, 34, 0.75),
    0 0 18px rgba(210, 153, 34, 0.35);
}

.phase-chip .dot.crit {
  background: radial-gradient(circle at 32% 28%, #ffd3cf 0%, #ff7b72 28%, #f85149 55%, #a32f28 100%);
  box-shadow:
    inset 0 -3px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.5),
    0 0 0 2px rgba(255, 255, 255, 0.05),
    0 0 9px rgba(248, 81, 73, 0.8),
    0 0 18px rgba(248, 81, 73, 0.4);
}

.phase-chip__name {
  font-size: 0.78rem;
  font-weight: 700;
}

.phase-chip__state {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ok);
}

.phase-chip__state--warn {
  color: var(--warn);
}

.phase-chip__state--crit {
  color: var(--crit);
}

/* ——— Sintesi termodinamica ——— */
.sintesi-seg {
  margin: 0.15rem 0 0.8rem;
}

.sintesi-seg .history-seg__btn {
  min-width: 0;
  padding: 0.3rem 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 639px) {
  /* la Sintesi è una pagina che scorre (come Cloud/Storico), non un layout da comprimere a schermo */
  #panelHome.panel.active {
    display: block;
    flex: none;
  }

  #panelHome {
    padding-bottom: 1.2rem;
  }

  .sintesi-seg {
    margin: 0.1rem 0 0.5rem;
  }

  .sintesi-seg .history-seg__btn {
    font-size: 0.72rem;
    min-height: 34px;
  }

  .phase-balance {
    margin-top: 0.5rem;
    padding: 0.5rem 0.6rem;
  }

  .phase-balance__chips {
    gap: 0.3rem;
  }

  .phase-chip {
    padding: 0.38rem 0.25rem;
  }

}

.grid-metrics--thermo .v--warn {
  color: var(--warn);
}

/* Setpoint = firma della baseline: card evidenziata in accento */
.metric--setpoint {
  border-color: rgba(88, 166, 255, 0.45);
  background: rgba(88, 166, 255, 0.06);
}

.metric--setpoint .k {
  color: var(--accent);
}

/* T ambiente = variabile contestuale u(t): card tratteggiata */
.metric--context {
  border-style: dashed;
}

.metric--context .v {
  color: var(--muted);
}

.thermo-axes-cap {
  grid-column: 1 / -1;
  margin: 0.2rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}

.thermo-axes-cap--capped {
  color: var(--warn);
}

.thermo-axes-cap--capped strong {
  color: var(--crit);
}

.header-sn {
  font-size: 0.72em;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.thermo-note {
  margin: 0.4rem 0 0;
  padding: 0.7rem 0.8rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius, 12px);
}

.history-seg {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.history-seg__btn {
  flex: 1;
  min-height: 38px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.history-seg__btn.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.1);
}

/* ——— Snapshot RET ——— */
.ret-snapshot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  padding: 0.85rem;
}

.ret-snapshot__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.ret-evt {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.4);
  background: rgba(63, 185, 80, 0.1);
}

.ret-evt--warn {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.45);
  background: rgba(210, 153, 34, 0.1);
}

.ret-evt--crit {
  color: var(--crit);
  border-color: rgba(248, 81, 73, 0.45);
  background: rgba(248, 81, 73, 0.1);
}

.ret-snapshot__ts {
  font-size: 0.76rem;
  color: var(--muted);
}

.ret-snapshot__rep {
  margin-left: auto;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--warn);
  border: 1px solid rgba(210, 153, 34, 0.45);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}

.ret-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
}

.ret-grid > div {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.55rem;
  min-width: 0;
}

.ret-grid dt {
  margin: 0;
  font-size: 0.64rem;
  color: var(--muted);
  white-space: nowrap;
}

.ret-grid dd {
  margin: 0.18rem 0 0;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 700;
}

.ret-grid dd.ret-val--warn {
  color: var(--warn);
}

.ret-grid dd.ret-val--crit {
  color: var(--crit);
}

.ret-grid dd small {
  display: block;
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 0.1rem;
}

.ret-hold {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.7rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
  border: 1px dashed rgba(88, 166, 255, 0.45);
  border-radius: 8px;
}

.ret-hold__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: commPulse 1s ease-in-out infinite;
  flex-shrink: 0;
}

.ret-snapshot__note {
  margin: 0.7rem 0 0;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--muted);
}

.ret-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.ret-actions__btn {
  flex: 1 1 auto;
  min-height: 42px;
}

.ret-ai {
  margin-top: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  padding: 0.75rem 0.85rem;
}

.ret-ai__title {
  margin: 0 0 0.45rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.ret-ai__body {
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.ret-ring {
  margin-top: 0.9rem;
}

.ret-ring__title {
  margin: 0 0 0.45rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.ret-ring__table td,
.ret-ring__table th {
  white-space: nowrap;
}

@media (max-width: 420px) {
  .ret-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .firma-card__mini {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
