/* Salud del lote: one state per lot, one card per device, the week's incidents. */
/* State badges: a check, "!", "×" or "–" in a small rounded square. Never a
   glowing or pulsing dot. `--badge-*` is set by the state of the element or
   its parent (`data-health` on lot markers, `data-state` on Salud). */
.dash {
  --glyph-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%232f7a52' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4.5 8.3 2.3 2.3 4.7-5'/%3E%3C/svg%3E");
  --glyph-warn: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238a5a1c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 4.2v4.6M8 11.6v.1'/%3E%3C/svg%3E");
  --glyph-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23b9603f' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m5.3 5.3 5.4 5.4M10.7 5.3l-5.4 5.4'/%3E%3C/svg%3E");
  --glyph-none: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238b958f' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M5 8h6'/%3E%3C/svg%3E");
}
[data-health="ok"], [data-state="ok"] { --badge-bg: #e6efe8; --badge-glyph: var(--glyph-ok); --badge-ink: #2f7a52; }
[data-health="warn"], [data-state="warn"], [data-state="unwatched"] { --badge-bg: #f6efdf; --badge-glyph: var(--glyph-warn); --badge-ink: #8a5a1c; }
[data-health="down"], [data-state="down"], [data-state="silent"] { --badge-bg: #fbeae4; --badge-glyph: var(--glyph-down); --badge-ink: #b9603f; }
[data-health="none"], [data-health=""], [data-state="none"], [data-state="unknown"], [data-state=""] { --badge-bg: #eef0ec; --badge-glyph: var(--glyph-none); --badge-ink: #7b867f; }

.health-badge,
.health-dot,
.health-pill::before,
.health-chip::before {
  content: "";
  flex: none;
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--badge-bg, #eef0ec) var(--badge-glyph, var(--glyph-none)) center / 12px no-repeat;
  vertical-align: middle;
}
.health-badge[hidden] { display: none; }

/* The lot's state as words: the lot cards on Lotes. */
.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px 0 6px;
  border: 1px solid rgba(16, 32, 26, 0.08);
  border-radius: 999px;
  background: var(--color-paper);
  color: #3d4a43;
  font-size: 12.5px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.health-pill:empty { visibility: hidden; }

.health-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 28px;
  padding: 16px 20px;
  border: 1px solid rgba(16, 32, 26, 0.06);
  border-radius: 16px;
  background: var(--color-paper);
  box-shadow: 0 1px 2px rgba(16, 32, 26, 0.03), 0 8px 24px rgba(16, 32, 26, 0.04);
}
.health-banner .health-dot { width: 32px; height: 32px; border-radius: 10px; background-size: 18px; }
.health-banner strong { display: block; font-size: 16px; font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.health-banner p { margin: 2px 0 0; color: #7b867f; font-size: 13px; }

.health-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 10px;
}
.health-section-head h2 { margin: 0; font-size: 15px; font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.health-section-head.logs-head { align-items: center; }
.health-logs { margin-top: 28px; scroll-margin-top: 16px; }
.health-logs:empty { display: none; }
.health-logs .lede { margin-top: 0; }

.health-link {
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--color-accent);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
}
.health-link:hover { text-decoration: underline; }
.health-link:disabled { opacity: 0.5; cursor: default; }

.health-devices,
.health-incidents {
  display: grid;
  gap: 10px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}
.health-devices { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.health-device,
.health-incident {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid rgba(16, 32, 26, 0.06);
  border-radius: 16px;
  background: var(--color-paper);
  box-shadow: 0 1px 2px rgba(16, 32, 26, 0.03), 0 8px 24px rgba(16, 32, 26, 0.04);
}

.health-device-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.health-device-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-semibold);
}

.health-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--badge-ink, #7b867f);
  font-size: 12px;
  font-weight: var(--weight-medium);
}
.health-chip::before { width: 16px; height: 16px; border-radius: 5px; background-size: 11px; }

.health-meta {
  margin: 6px 0 0;
  color: #7b867f;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.health-hint {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f7f4;
  font-size: var(--text-sm);
  line-height: 1.45;
}
.health-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}
.health-ack {
  margin: 8px 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.health-actions .health-ack { margin: 0; }

.health-incident[data-open="true"] { box-shadow: inset 0 0 0 1px rgba(185, 96, 63, 0.35), 0 8px 24px rgba(16, 32, 26, 0.04); }
.health-incident-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
}
.health-incident-time { color: var(--color-text-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.health-incident .health-meta { margin-left: 0; }

.health-dialog {
  position: fixed;
  inset: 0;
  width: min(420px, calc(100vw - 32px));
  height: fit-content;
  margin: auto;
  padding: 22px;
  border: 1px solid var(--color-line);
  border-radius: 16px;
  background: var(--color-paper);
  box-shadow: var(--shadow-dash);
}
.health-dialog::backdrop { background: rgba(18, 36, 28, 0.35); }
.health-dialog h2 { margin: 0 0 8px; font-size: var(--text-lg); }
.health-field { display: grid; gap: 6px; margin-top: 14px; }
.health-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 20px;
}
.health-forget { margin-right: auto; color: var(--color-danger); white-space: nowrap; }

@media (max-width: 760px) {
  .health-devices { grid-template-columns: 1fr; }
  .health-banner { margin-bottom: 22px; }
  .health-dialog { padding: 18px; }
}
