/* Saúde da Conta redesenhada (health-client-v1.js). Cores pelos tokens --fx-* do
   sistema visual v2, que já trazem os temas claro e escuro. */

/* A tela original fica escondida; a janela da apelação (ah-overlay + ah-drawer) continua. */
.panel.ah-root.hx-on > :not(.hx-root):not(.ah-overlay):not(.ah-drawer) {
  display: none !important;
}

.hx-root {
  --hx-risk: var(--fx-crit, #ff4d6d);
  --hx-fair: var(--fx-warn, #ffc35c);
  --hx-great: var(--fx-ok, #2fd88f);
  --hx-fantastic: var(--fx-accent, #48a8ff);
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--fx-text);
  font-variant-numeric: tabular-nums;
}

.hx-root button {
  font: inherit;
  cursor: pointer;
}

.hx-root button:focus-visible {
  outline: 2px solid var(--fx-accent);
  outline-offset: 2px;
}

.hx-root svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Cabeçalho ── */
.hx-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 8px;
}

.hx-account {
  margin: 10px 0 0;
  color: var(--fx-muted);
  font-size: 14.5px;
}

.hx-account span {
  color: var(--fx-text);
}

.hx-refresh {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--fx-line-2);
  background: var(--fx-surface-2);
  color: var(--fx-text);
  font-size: 12.5px !important;
  font-weight: 600 !important;
  white-space: nowrap;
}

.hx-refresh:hover:not(:disabled) {
  background: var(--fx-surface-3);
  border-color: var(--fx-line-3);
}

.hx-refresh:disabled {
  opacity: 0.6;
  cursor: wait;
}

.hx-refresh svg {
  width: 15px;
  height: 15px;
}

/* ── Cards ── */
.hx-card {
  position: relative;
  padding: 20px 22px 22px;
  border-radius: 18px;
  border: 1px solid var(--fx-line);
  background: var(--fx-surface);
  box-shadow: var(--fx-hair);
}

html[data-af-theme=light] .hx-card {
  box-shadow: var(--fx-lift);
}

.hx-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.hx-card-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fx-text);
}

.hx-card-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--fx-muted);
}

.hx-kicker {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fx-faint);
}

.hx-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 16px;
}

/* ── Nota: medidor em arco ── */
.hx-standing {
  background: radial-gradient(60% 45% at 50% 0%, var(--hx-glow, transparent), transparent 100%), var(--fx-surface);
}

.hx-tone-risk { --hx-tone: var(--hx-risk); --hx-glow: var(--fx-crit-soft); }
.hx-tone-fair { --hx-tone: var(--hx-fair); --hx-glow: var(--fx-warn-soft); }
.hx-tone-great { --hx-tone: var(--hx-great); --hx-glow: var(--fx-ok-soft); }
.hx-tone-fantastic { --hx-tone: var(--hx-fantastic); --hx-glow: var(--fx-accent-soft); }
.hx-tone-neutral { --hx-tone: var(--fx-faint); }

.hx-gauge {
  position: relative;
  width: min(100%, 340px);
  margin: 0 auto;
}

.hx-gauge svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.hx-seg {
  stroke-width: 14;
  stroke-linecap: butt;
  stroke: var(--fx-surface-3);
  transition: stroke 0.4s ease;
}

.hx-seg.is-on.hx-risk { stroke: var(--hx-risk); }
.hx-seg.is-on.hx-fair { stroke: var(--hx-fair); }
.hx-seg.is-on.hx-great { stroke: var(--hx-great); }
.hx-seg.is-on.hx-fantastic { stroke: var(--hx-fantastic); }
.hx-seg.is-on:not(.is-current) { opacity: 0.45; }

.hx-knob {
  stroke: var(--fx-surface);
  stroke-width: 4;
  filter: drop-shadow(0 0 6px currentColor);
}

.hx-knob.hx-risk { fill: var(--hx-risk); }
.hx-knob.hx-fair { fill: var(--hx-fair); }
.hx-knob.hx-great { fill: var(--hx-great); }
.hx-knob.hx-fantastic { fill: var(--hx-fantastic); }

.hx-gauge-value {
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.hx-gauge-value strong {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 200;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--hx-tone);
}

.hx-gauge-value span {
  font-size: 13px;
  font-weight: 600;
  color: var(--fx-text);
}

.hx-glabels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 340px);
  margin: 10px auto 0;
  text-align: center;
}

.hx-glabel {
  font-size: 11px;
  color: var(--fx-faint);
}

.hx-glabel.is-current {
  color: var(--fx-text);
  font-weight: 600;
}

.hx-message {
  margin: 14px auto 0;
  max-width: 44ch;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fx-muted);
}

.hx-next {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--fx-faint);
}

.hx-next b {
  color: var(--fx-text);
  font-weight: 600;
}

/* ── Nível: anel + trilha ── */
.hx-valid {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--fx-surface-2);
  border: 1px solid var(--fx-line);
  font-size: 11.5px;
  color: var(--fx-muted);
  white-space: nowrap;
}

.hx-level-main {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 6px 0 20px;
}

.hx-ring {
  position: relative;
  flex: none;
  width: 128px;
  height: 128px;
}

.hx-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.hx-ring-track {
  stroke: var(--fx-surface-3);
  stroke-width: 10;
}

.hx-ring-fill {
  stroke: var(--fx-accent);
  stroke-width: 10;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.hx-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hx-ring-label strong {
  font-size: 42px;
  font-weight: 200;
  line-height: 1;
  color: var(--fx-text);
}

.hx-ring-label span {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fx-faint);
}

.hx-level-copy {
  min-width: 0;
  flex: 1;
}

.hx-points {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.hx-points strong {
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  color: var(--fx-text);
}

.hx-points span {
  font-size: 13px;
  color: var(--fx-faint);
}

.hx-level-copy p {
  margin: 8px 0 12px;
  font-size: 13px;
  color: var(--fx-accent-text);
  font-weight: 500;
}

.hx-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--fx-surface-3);
  overflow: hidden;
}

.hx-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--fx-btn);
}

.hx-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 16px 0 0;
  list-style: none;
  border-top: 1px solid var(--fx-line);
}

.hx-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.hx-step::before {
  content: "";
  position: absolute;
  top: 5px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--fx-surface-3);
}

.hx-step:first-child::before {
  content: none;
}

.hx-step.is-done::before,
.hx-step.is-current::before {
  background: var(--fx-accent);
}

.hx-dot {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--fx-surface-3);
  border: 2px solid var(--fx-surface);
}

.hx-step.is-done .hx-dot {
  background: var(--fx-accent);
}

.hx-step.is-current .hx-dot {
  background: var(--fx-accent);
  box-shadow: 0 0 0 4px var(--fx-accent-soft);
}

.hx-step b {
  font-size: 12px;
  font-weight: 500;
  color: var(--fx-faint);
}

.hx-step.is-current b {
  color: var(--fx-text);
  font-weight: 600;
}

.hx-step small {
  font-size: 11px;
  color: var(--fx-faint);
}

/* ── Faixa-resumo ── */
.hx-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.hx-kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--fx-line);
  background: var(--fx-surface);
}

.hx-kpi span {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fx-faint);
}

.hx-kpi strong {
  font-size: 26px;
  font-weight: 300;
  line-height: 1.1;
  color: var(--fx-text);
}

.hx-kpi.is-alert strong {
  color: var(--fx-alert-text);
}

.hx-kpi.is-ok strong {
  color: var(--fx-ok-text);
}

.hx-kpi strong.hx-kpi-date {
  font-size: 16px;
  font-weight: 500;
  padding-top: 6px;
}

/* ── Registros ── */
.hx-group + .hx-group {
  margin-top: 18px;
}

.hx-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.hx-group-head b {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fx-muted);
}

.hx-group ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hx-item {
  --hx-sev: var(--fx-warn);
  --hx-sev-soft: var(--fx-warn-soft);
  --hx-sev-text: var(--fx-warn-text);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--fx-line);
  background: var(--fx-surface-2);
}

.hx-item.hx-sev-medium { --hx-sev: var(--fx-alert); --hx-sev-soft: var(--fx-alert-soft); --hx-sev-text: var(--fx-alert-text); }
.hx-item.hx-sev-high { --hx-sev: var(--fx-crit); --hx-sev-soft: var(--fx-crit-soft); --hx-sev-text: var(--fx-crit-text); }

.hx-sev-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--hx-sev-soft);
  color: var(--hx-sev);
}

.hx-sev-icon svg {
  width: 20px;
  height: 20px;
}

.hx-item-main {
  min-width: 0;
}

.hx-item-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.hx-item-title strong {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--fx-text);
}

.hx-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fx-surface-3);
  color: var(--fx-muted);
  font-size: 11px;
  font-weight: 600;
}

.hx-sev-chip {
  background: var(--hx-sev-soft);
  color: var(--hx-sev-text);
}

.hx-item-main p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--fx-muted);
}

.hx-item-main small {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--fx-faint);
}

.hx-appeal {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--fx-line-2);
  background: var(--fx-surface);
  color: var(--fx-text);
  font-size: 12.5px !important;
  font-weight: 600 !important;
  white-space: nowrap;
}

.hx-appeal:hover {
  border-color: var(--fx-accent-line);
  background: var(--fx-accent-soft);
}

.hx-appeal svg {
  width: 15px;
  height: 15px;
}

.hx-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 12px 10px;
  text-align: center;
}

.hx-empty svg {
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: 50%;
  background: var(--fx-ok-soft);
  color: var(--fx-ok);
  stroke-width: 2.4;
}

.hx-empty strong {
  font-size: 15px;
  color: var(--fx-text);
}

.hx-empty span {
  max-width: 44ch;
  font-size: 13px;
  color: var(--fx-muted);
}

.hx-source {
  margin: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--fx-faint);
}

/* ── Celular ── */
@media (max-width: 900px) {
  .hx-hero {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .hx-card {
    padding: 16px 16px 18px;
  }

  .hx-level-main {
    gap: 16px;
  }

  .hx-ring {
    width: 104px;
    height: 104px;
  }

  .hx-ring-label strong {
    font-size: 34px;
  }

  .hx-points strong {
    font-size: 28px;
  }

  .hx-kpis {
    gap: 8px;
  }

  .hx-kpi {
    padding: 12px;
  }

  .hx-kpi span {
    font-size: 9.5px;
    letter-spacing: 0.14em;
  }

  .hx-kpi strong {
    font-size: 22px;
  }

  .hx-kpi strong.hx-kpi-date {
    font-size: 12.5px;
  }

  .hx-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .hx-appeal {
    grid-column: 1 / -1;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hx-seg,
  .hx-ring-fill {
    transition: none;
  }
}

/* Janela da apelação (original do app): rótulos na tipografia da marca. */
.ah-drawer :is(.ah-drawer-sub, .ah-drawer-tags, .ah-drawer-tags *, .ah-tag) {
  font-family: var(--fx-font) !important;
}
