/* Device Health & Identity — super-admin Devices expander (Phase C, 2026-06-24).
   Matches the platform dark theme (tokens.css): blue/grey, indigo accent.
   Mobile-first: the Identity/Health grid collapses to one column under 640px. */

/* ── per-row health dot (Devices table "Health" column) ── */
.dh-row-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dh-row-dot-ok      { background: var(--ok); }
.dh-row-dot-warn    { background: var(--warn); }
.dh-row-dot-crit    { background: var(--danger); }
.dh-row-dot-unknown { background: var(--text-faint); }
/* Device OFFLINE → the verdict is the LAST snapshot's, possibly days old:
   hollow ring in the same color + muted, so stale never reads as current.
   (Tooltip carries the "(last report Xd ago)" age — healthDotEl, admin.js.) */
.dh-row-dot--stale { background: transparent !important; opacity: .75; }
.dh-row-dot-ok.dh-row-dot--stale      { box-shadow: inset 0 0 0 1.5px var(--ok); }
.dh-row-dot-warn.dh-row-dot--stale    { box-shadow: inset 0 0 0 1.5px var(--warn); }
.dh-row-dot-crit.dh-row-dot--stale    { box-shadow: inset 0 0 0 1.5px var(--danger); }
.dh-row-dot-unknown.dh-row-dot--stale { box-shadow: inset 0 0 0 1.5px var(--text-faint); }

/* ── the expander cell (full-width <td> after the device row) ── */
.dh-expander {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}
.dh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* minmax(0,…): with bare `1fr` the NIC table's min-content width becomes the
   track's floor, so on phones the identity card pushed the whole grid past
   the viewport (IP/State columns unreachable). The table then pans inside
   the card instead (rule below). */
@media (max-width: 640px) { .dh-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  /* The NIC table isn't always inside .dh-nic-wrap (the modal mounts it bare
     in .dh-block), so the table itself becomes the pan container. */
  .dh-nic-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dh-nic-tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

.dh-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 14px;
}
.dh-block h3 {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 12px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.dh-trends { margin-top: 16px; }

/* ── identity key/values ── */
.dh-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12px; margin: 0; }
.dh-kv dt { color: var(--text-muted); }
.dh-kv dd { margin: 0; color: var(--text-1); overflow-wrap: anywhere; }
.dh-kv dd.mono { font-family: var(--font-mono); }
.dh-kv dd.empty { color: var(--text-faint); }

/* ── NIC table ── */
.dh-nic-tbl { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 11px; }
.dh-nic-tbl th {
  text-align: left; color: var(--text-muted); font-weight: 500;
  border-bottom: 1px solid var(--border-subtle); padding: 4px 8px;
}
.dh-nic-tbl td { padding: 4px 8px; border-bottom: 1px solid var(--border-subtle); }
.dh-nic-tbl td.mono { font-family: var(--font-mono); }
.dh-nic-name { color: var(--text-1); }
.dh-nic-state { display: inline-block; padding: 1px 6px; border-radius: var(--r-pill); font-size: 10px; }
.dh-nic-state-up { background: var(--ok-dim); color: var(--ok); }
.dh-nic-state-down,
.dh-nic-state-disconnected { background: var(--bg-input); color: var(--text-muted); }
/* Stale snapshot: state pills go neutral regardless of recorded state — a
   powered-off device must never show a live green "up" (tooltip explains). */
.dh-nic-state-stale { background: var(--bg-input); color: var(--text-muted); }
.dh-empty-note { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* ── stale snapshot cue (device offline / snapshot older than online window) ──
   The whole Health & trends panel is a last-known snapshot; when stale it must
   READ as one. Mirrors the platform's existing stale patterns (monitor grey-out
   + badge, greyed trace names): amber banner + slight desaturation of tiles. */
.dh-stale-banner {
  display: flex; align-items: center; gap: 8px;
  background: var(--warn-dim); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: var(--r-sm); padding: 8px 12px;
  font-size: 12px; margin-bottom: 12px;
}
.dh-stale-banner-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.dh-stale .dh-gauges,
.dh-stale .dh-nic-tbl { filter: saturate(.55); opacity: .9; }

/* ── status chip ── */
.dh-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600;
}
.dh-chip-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dh-chip-ok      { background: var(--ok-dim);     color: var(--ok); }
.dh-chip-ok      .dh-chip-dot { background: var(--ok); }
.dh-chip-warn    { background: var(--warn-dim);   color: var(--warn); }
.dh-chip-warn    .dh-chip-dot { background: var(--warn); }
.dh-chip-crit    { background: var(--danger-dim); color: var(--danger); }
.dh-chip-crit    .dh-chip-dot { background: var(--danger); }
.dh-chip-unknown { background: var(--bg-input);   color: var(--text-muted); }
.dh-chip-unknown .dh-chip-dot { background: var(--text-faint); }

/* ── gauges ── */
.dh-gauges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dh-gauge { background: var(--bg-input); border-radius: var(--r-sm); padding: 10px 12px; }
.dh-gauge-lab { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.dh-gauge-val { font-size: 18px; font-weight: 600; font-family: var(--font-mono); margin-top: 2px; color: var(--text-1); }
.dh-gauge-bar { height: 4px; border-radius: 2px; background: var(--border); margin-top: 8px; overflow: hidden; }
.dh-gauge-bar > i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.dh-gauge-bar > i.dh-fill-warn { background: var(--warn); }
.dh-gauge-bar > i.dh-fill-crit { background: var(--danger); }
/* Phase 3 sensor-suite: compact per-rail power breakdown + GPS coords sub-lines */
.dh-rails { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 6px; line-height: 1.3; word-break: break-word; }
.dh-coords { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 6px; }
.dh-throttle { font-size: 11px; color: var(--warn); margin-top: 10px; font-family: var(--font-mono); }
.dh-updated { font-size: 11px; color: var(--text-muted); margin-top: 10px; }

/* ── trends ── */
.dh-trend-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dh-trend-title { margin: 0 !important; }
.dh-range-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.dh-range-toggle button {
  background: none; border: none; color: var(--text-2);
  padding: 4px 12px; font-size: 11px; cursor: pointer;
}
.dh-range-toggle button.active { background: var(--accent-soft); color: var(--text-1); }
/* Phone: the 7-segment range picker (1h…90d + custom) is wider than the card
   at 320px — 30d/90d/custom were cut off, unreachable. Wrap the trend head
   and let the toggle pan horizontally (hidden scrollbar, touch-pannable). */
@media (max-width: 760px) {
  .dh-trend-head { flex-wrap: wrap; }
  .dh-range-toggle {
    max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .dh-range-toggle::-webkit-scrollbar { display: none; }
  .dh-range-toggle button { flex: none; white-space: nowrap; }
}

/* ── custom range row (Custom preset: from/to datetime-local + Apply) ── */
.dh-range-custom {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  margin-top: 10px;
}
.dh-range-lab {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 10px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-muted);
}
.dh-range-input {
  background: var(--bg-input); color: var(--text-1);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 4px 8px; font-size: 12px; font-family: inherit;
  width: auto; min-width: 0; /* content-aware — datetime-local sizes itself */
  color-scheme: dark; /* native picker chrome matches the dark theme */
}
.dh-range-apply {
  background: var(--bg-input); color: var(--text-1);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.dh-range-apply:hover { background: var(--accent-soft); }
.dh-range-error { font-size: 11px; color: var(--danger); align-self: center; }

.dh-charts { margin-top: 12px; display: flex; flex-direction: column; gap: 14px; }
.dh-chart-wrap { width: 100%; }
.dh-chart-title { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.dh-chart-fallback { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }

/* ── activity feed ── */
.dh-activity { margin-top: 16px; }
.dh-activity-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dh-activity-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--border-subtle); font-size: 12px;
}
.dh-activity-item:last-child { border-bottom: none; }
.dh-activity-time { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; flex: none; min-width: 64px; }
.dh-activity-name { color: var(--text-1); font-weight: 600; flex: none; }
.dh-activity-summary { color: var(--text-muted); overflow-wrap: anywhere; }

/* ── states ── */
.dh-no-data { font-size: 12px; color: var(--text-muted); padding: 8px 0; margin: 0; }
.dh-inline-error {
  font-size: 12px; color: var(--danger);
  background: var(--danger-dim); border-radius: var(--r-sm);
  padding: 8px 10px; margin-top: 8px;
}

/* ── Attached analyzers (2026-09-09) ──────────────────────────────────────────
   Per-analyzer apply status/error + observed configuration. A healthy
   analyzer stays visually quiet (name/kind/chip/timestamp only, observed
   config collapsed); a failing one grows a red callout that's impossible to
   miss without becoming a details blob. */
.dh-analyzers { margin-bottom: 16px; }
.dh-analyzer {
  background: var(--bg-input); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 12px;
}
.dh-analyzer + .dh-analyzer { margin-top: 8px; }
.dh-analyzer-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dh-analyzer-name { font-weight: 600; color: var(--text-1); }
.dh-analyzer-kind { font-size: 11px; color: var(--text-muted); }
.dh-analyzer-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.dh-analyzer-error { margin-top: 8px; }
.dh-analyzer-error-text { overflow-wrap: anywhere; font-family: var(--font-mono); }
.dh-analyzer-error-meta { color: var(--text-muted); font-size: 11px; margin-top: 4px; }
.dh-analyzer-drift { margin-top: 8px; }
.dh-analyzer-drift-title {
  font-size: 10px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--warn); font-weight: 600;
}
.dh-analyzer-drift-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: 11px; }
.dh-analyzer-drift-list li { padding: 2px 0; overflow-wrap: anywhere; }
.dh-analyzer-drift-desired { color: var(--text-muted); }
.dh-analyzer-drift-observed { color: var(--warn); font-weight: 600; }
.dh-observed { margin-top: 8px; }
.dh-observed summary {
  cursor: pointer; font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.dh-observed .dh-kv { margin-top: 8px; }
.dh-observed .dh-no-data { padding: 4px 0 0; }
