/* ── Stat cards (Home overview) ──────────────────────────────────────── */

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

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.3rem; }
.stat-card.healthy .stat-value { color: var(--ok); }
.stat-card.warning .stat-value { color: var(--warn); }

/* Compliance Posture — full-width banner at the top of the dashboard.
   Pulled out of the stat-card grid so the chart strip + supporting
   copy don't sit alongside short, equal-height stat cards (which read
   as visually unbalanced). The banner itself has a percentage value,
   a context line, an "awaiting evidence" badge when relevant, and a
   passive progress bar visualising the percentage value. */
.home-posture-banner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.home-posture-banner[hidden] { display: none; }
.home-posture-banner::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--accent);
}
.home-posture-banner.ok::after   { background: var(--ok); }
.home-posture-banner.warn::after { background: var(--warn); }
.home-posture-banner.bad::after  { background: var(--danger); }

.home-posture-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.home-posture-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.home-posture-sub {
  font-size: 0.95rem;
  color: var(--text);
}
.home-evidence-badge {
  align-self: flex-start;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
/* Manual-attestation count. Excluded from the pass rate (posture.js) but
   never hidden — a 100% banner with outstanding attestations must say so.
   --info, not --warn: these are not overdue, they are simply not machine
   checkable, and they must not read as the same alarm as "awaiting evidence". */
.home-manual-badge {
  align-self: flex-start;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info-border);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: help;
}

.home-posture-figure {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 200px;
}
.home-posture-value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
}
.home-posture-banner.ok   .home-posture-value { color: var(--ok); }
.home-posture-banner.warn .home-posture-value { color: var(--warn); }
.home-posture-banner.bad  .home-posture-value { color: var(--danger); }
.home-posture-bar {
  width: 220px;
  max-width: 100%;
  height: 6px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}
.home-posture-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.home-posture-banner.ok   .home-posture-bar-fill { background: var(--ok); }
.home-posture-banner.warn .home-posture-bar-fill { background: var(--warn); }
.home-posture-banner.bad  .home-posture-bar-fill { background: var(--danger); }

/* Uniform stat row beneath the posture banner. Every card has
   identical dimensions, padding, and typography so the row reads as
   one unit. */
.home-hero-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}
.home-hero-row[hidden] { display: none; }

#home-hero-kpi[hidden] { display: none; }
.home-hero-secondary {
  display: contents;
}

.home-stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  position: relative;
  overflow: hidden;
  min-height: 84px;
}

.home-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.home-stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.05;
  color: var(--text);
}
.home-stat-value-row {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}
.home-stat-card.is-critical .home-stat-value { color: var(--sev-critical); }
.home-stat-card.is-high     .home-stat-value { color: var(--sev-high); }
.home-stat-card.is-ok       .home-stat-value { color: var(--ok); }
.home-stat-sub {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Delta badge ("↑2 since last scan") on Critical/High cards. Mirrors the
   convention from finance dashboards — up-arrow + red for "more bad
   findings", down-arrow + green for "fewer bad findings", em-dash dim
   for flat. Hidden when there's no previous history row to compare. */
.home-stat-delta {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.home-stat-delta.is-up   { color: var(--danger-2); }
.home-stat-delta.is-down { color: var(--ok); }
.home-stat-delta.is-flat { color: var(--muted); }

/* Item 6 — freshness indicator next to the dashboard subtitle. */
.home-freshness {
  display: inline-block;
  margin-left: 0.75rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-a10);
  border: 1px solid var(--accent-a35);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: help;
}

.home-empty-card {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 2rem 1.5rem;
  text-align: center;
}
.home-empty-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}
.home-empty-card p {
  margin: 0 auto;
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 60ch;
}
.home-empty-card code {
  background: var(--inset);
  border: 1px solid var(--border);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.home-section-sub {
  font-size: 0.78rem;
  margin: -0.25rem 0 0.25rem;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .home-hero-row { grid-template-columns: 1fr; }
}

/* ── Service list (clickable rows → Inventory filtered) ──────────────── */
/* Visually distinct from the stat cards above — these are anchor rows
   with a count + label + chevron, not number-foreground cards. Hover
   makes the link affordance explicit so users don't have to guess
   whether the card is interactive. */

.home-service-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.45rem;
}

.home-service-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.home-service-row:hover {
  border-color: var(--accent);
  background: var(--accent-a04);
}
.home-service-row .home-service-count {
  font-weight: 700;
  color: var(--accent);
  min-width: 1.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.home-service-row .home-service-label {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-service-row .home-service-svc-key {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  white-space: nowrap;
}
.home-service-row .home-service-arrow {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.12s, color 0.12s;
}
.home-service-row:hover .home-service-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

/* ── Engine state list (replaces the loading-bar-shaped chart) ───────── */
/* A simple dot + label + count list — for a small N this reads as a
   status breakdown rather than a progress display. */

.home-status-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.home-status-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.3rem 0.55rem;
  font-size: 0.88rem;
}
.home-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}
.home-status-row.healthy  .home-status-dot { background: var(--ok); }
.home-status-row.degraded .home-status-dot { background: var(--warn); }
.home-status-row.failed   .home-status-dot { background: var(--danger); }
.home-status-row.unknown  .home-status-dot {
  background: transparent;
  border: 1px solid var(--muted);
}
.home-status-label {
  color: var(--text);
  text-transform: capitalize;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-status-row.unknown .home-status-label { color: var(--muted); }
.home-status-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

/* H.9 — Compliance by Framework */
.home-fw-sub {
  font-size: 0.78rem;
  margin: 0 0 0.6rem;
}
.home-fw-row {
  display: grid;
  grid-template-columns: 130px 1fr 50px auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.home-fw-row:last-child { border-bottom: none; }
.home-fw-name {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.home-fw-bar {
  height: 8px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}
.home-fw-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 2px;
}
.home-fw-bar-fill.ok   { background: var(--ok); }
.home-fw-bar-fill.warn { background: var(--warn); }
.home-fw-bar-fill.bad  { background: var(--danger); }
.home-fw-pct {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
}
.home-fw-pct.ok   { color: var(--ok); }
.home-fw-pct.warn { color: var(--warn); }
.home-fw-pct.bad  { color: var(--danger); }
.home-fw-counts { font-size: 0.78rem; }
.home-fw-breach {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--danger-bg);
  color: var(--danger-2);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Per-framework manual-attestation count — same treatment as the hero badge
   so the two surfaces read as the same fact. Not uppercase: it is a count,
   not an alarm label like SLA×. */
.home-fw-manual {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: help;
}
/* Critical + High severity pills — separate, color-coded so "2C 10H"
   no longer reads as one ambiguous label. Each pill shows only when
   its count > 0 so a critical-only framework doesn't render an empty
   High pill. */
.home-fw-sev-pill {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.home-fw-sev-pill.is-critical {
  background: var(--sev-critical-bg);
  color: var(--sev-critical);
  border: 1px solid var(--sev-critical-border);
}
.home-fw-sev-pill.is-high {
  background: var(--sev-high-bg);
  color: var(--sev-high);
  border: 1px solid var(--sev-high-border);
}

/* Limited-coverage frameworks collapse — a framework with fewer than
   3 applicable controls is too noisy to render alongside well-covered
   ones (1/1 fail flips it to 0% with no nuance). The expandable
   surfaces the data without letting it dominate the chart. */
.home-fw-limited {
  margin-top: 0.6rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.45rem;
}
.home-fw-limited > summary {
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.25rem 0;
  list-style: none;
}
.home-fw-limited > summary::marker { content: ""; }
.home-fw-limited > summary::before { content: "▸ "; color: var(--muted); }
.home-fw-limited[open] > summary::before { content: "▾ "; }
.home-fw-row-limited {
  grid-template-columns: 130px 1fr;
}
.home-fw-limited-note {
  font-size: 0.78rem;
}

/* ── Vulnerabilities (VA) view ───────────────────────────────────── */
/* Patch-currency rollup line under the status text — leads the page
   because patch currency is the authoritative VA signal. */
.vuln-patch-rollup {
  margin: 0.2rem 0 0.6rem;
  font-size: 0.85rem;
}
.vuln-patch-behind  { color: var(--danger-2); }
.vuln-patch-current { color: var(--ok); }
.vuln-patch-unknown { color: var(--accent-hi); }

.vuln-upgrade-target code { font-size: 0.78rem; }

/* Per-row patch-status pills in the fleet table. */
.badge.vuln-patch-status-behind  { background: var(--danger-bg); color: var(--danger-2); text-transform: none; }
.badge.vuln-patch-status-current { background: var(--ok-bg); color: var(--ok); text-transform: none; }
.badge.vuln-patch-status-unknown { background: var(--accent-a16); color: var(--accent-hi); text-transform: none; }
