/* Trang «Tình trạng máy chủ» — chỉ biến màu hệ thống */
#health-body { display: grid; gap: 16px; margin-bottom: 16px; }
#health-body:empty { display: none; }
#health-body > *, #health-body .ah-grid > * { margin: 0; }

.ah-head { padding: 20px 24px; }
.ah-title-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  min-width: 0;
}
.ah-title {
  margin: 0; font-size: 18px; font-weight: 700; color: var(--text-strong);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ah-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 10px; color: var(--text-muted); font-size: 13px;
}
.ah-updated { font-variant-numeric: tabular-nums; }
.ah-refresh { margin-left: auto; min-height: 36px; }

.asg-status.ah-level-ok {
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 35%, var(--border));
}
.asg-status.ah-level-ok::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; margin-right: 6px;
}
.asg-status.ah-level-warn {
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 30%, var(--border));
}
.asg-status.ah-level-warn::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; margin-right: 6px;
}
.asg-status.ah-level-bad {
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 32%, var(--border));
}
.asg-status.ah-level-bad::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; margin-right: 6px;
}

.ah-kpis { margin-bottom: 0; }
.ah-kpis .stat .v {
  font-size: 18px; line-height: 1.25;
  overflow-wrap: anywhere; word-break: break-word;
}

.ah-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.ah-card { padding: 20px 24px; min-width: 0; }
.ah-card.tone-good { border-color: color-mix(in srgb, var(--green) 28%, var(--border)); }
.ah-card.tone-warn { border-color: color-mix(in srgb, var(--amber) 28%, var(--border)); }
.ah-card.tone-bad { border-color: color-mix(in srgb, var(--red) 28%, var(--border)); }

.ah-chip {
  display: inline-flex; align-items: center; min-height: 24px;
  padding: 0 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--border-soft);
  background: var(--surface-2); color: var(--text-muted);
  white-space: nowrap;
}
.ah-chip-good {
  background: color-mix(in srgb, var(--green) 12%, var(--surface));
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 30%, var(--border));
}
.ah-chip-warn {
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 30%, var(--border));
}
.ah-chip-bad {
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 30%, var(--border));
}

.ah-bar {
  height: 10px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--border) 55%, var(--surface));
  overflow: hidden; margin: 12px 0 14px;
}
.ah-bar-fill {
  height: 100%; border-radius: inherit;
  background: var(--green);
  transition: width 160ms ease;
}
.ah-bar-warn .ah-bar-fill { background: var(--amber); }
.ah-bar-bad .ah-bar-fill { background: var(--red); }
.ah-bar-good .ah-bar-fill { background: var(--green); }

.ah-card-line {
  margin: 0; font-size: 14px; color: var(--text); line-height: 1.45;
  overflow-wrap: anywhere;
}
.ah-card-sub {
  margin: 6px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.45;
  overflow-wrap: anywhere;
}
.ah-bak-missing { color: var(--red); font-weight: 600; }

.ah-skel { display: grid; gap: 16px; }
.ah-skel-kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
}
.ah-skel-cards {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
}

/* Tải máy chủ (PLAN-dot-9) */
.ah-load { padding: 20px 24px; min-width: 0; }
.ah-load-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; min-width: 0;
}
.ah-load-title {
  margin: 0; font-size: 17px; font-weight: 700; color: var(--text-strong);
}
.ah-load-sub { font-size: 13px; color: var(--text-muted); }
.ah-load-kpis { margin: 0 0 16px; }
.ah-load-kpis .stat { min-height: 88px; }
.ah-load-kpis .stat .v { font-variant-numeric: tabular-nums; }
.ah-load-wait {
  margin: 8px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.45;
}
.ah-charts { display: grid; gap: 16px; position: relative; min-width: 0; }
.ah-chart { min-width: 0; }
.ah-chart-lab {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 6px;
}
.ah-chart-leg {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 6px;
  font-size: 12px; color: var(--text-muted);
}
.ah-leg { display: inline-flex; align-items: center; gap: 6px; }
.ah-swatch {
  width: 12px; height: 3px; border-radius: var(--r-pill); display: inline-block;
  background: var(--accent);
}
.ah-swatch-machine { background: var(--accent); height: 3px; }
.ah-swatch-app { background: var(--text-muted); height: 2px; }
.ah-chart-svg {
  display: block; width: 100%; height: 72px;
  touch-action: none;
}
.ah-guide { stroke: var(--border-strong); stroke-width: 1; opacity: 0.55; }
.ah-guide-lab {
  fill: var(--text-faint); font-size: 9px;
  /* chữ không phóng theo SVG */
}
.ah-cross { stroke: var(--text-soft); stroke-width: 1; pointer-events: none; }
.ah-tip {
  position: absolute; z-index: 2; min-width: 140px; max-width: 220px;
  padding: 8px 10px; border-radius: var(--r);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 12px; line-height: 1.4; pointer-events: none;
}
.ah-tip-t { font-weight: 700; color: var(--text-strong); margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.ah-load-mode { margin-top: 12px; min-height: 36px; }
.ah-load-table-wrap { overflow-x: auto; max-height: 280px; overflow-y: auto; }
.ah-load-table { width: 100%; font-variant-numeric: tabular-nums; }
.ah-load-table th, .ah-load-table td { white-space: nowrap; }

@media (max-width: 767px) {
  .ah-load { padding: 16px; }
  .ah-load-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ah-denied .ah-empty-ico {
  width: 40px; height: 40px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  color: var(--amber);
}
.ah-denied .ah-empty-ico svg {
  width: 22px; height: 22px; fill: none;
  stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

@media (max-width: 1023px) {
  .ah-skel-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .ah-head, .ah-card { padding: 16px; }
  .ah-grid, .ah-skel-cards { grid-template-columns: 1fr; }
  .ah-title { white-space: normal; }
  .ah-refresh { margin-left: 0; width: 100%; }
  .ah-meta { flex-direction: column; align-items: stretch; }
  .ah-kpis .stat .v { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .ah-bar-fill { transition: none; }
}

/* Quản trị · thẻ cài đặt (Đúng/Sai · ảnh phiếu · mẫu phiếu) */
#v-admin .adm-grid {
  display: grid; gap: 16px; margin-bottom: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}
#v-admin .adm-grid > #tf-card { grid-column: 1 / -1; }
#v-admin .adm-grid > .card { margin: 0; min-width: 0; display: flex; flex-direction: column; padding: 20px 24px; }
#v-admin .adm-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
#v-admin .adm-head-txt { min-width: 0; }
#v-admin .adm-title { margin: 0; font-size: 17px; font-weight: 700; color: var(--text-strong); line-height: 1.3; }
#v-admin .adm-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.45; }
#v-admin .adm-ico {
  --tone: var(--accent);
  width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--tone) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tone) 28%, var(--border));
  color: var(--tone);
}
#v-admin .adm-ico.tone-green { --tone: var(--green); }
#v-admin .adm-ico.tone-amber { --tone: var(--amber); }
#v-admin .adm-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#v-admin .adm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; padding-top: 16px; }

/* Bậc thang Đúng/Sai */
#v-admin .tf-ladder { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
#v-admin .tf-step {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 10px 8px; border-radius: var(--r); background: var(--surface-2);
  border: 1px solid var(--border-soft); cursor: text;
}
#v-admin .tf-step-bar {
  position: relative; height: 64px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  overflow: hidden;
}
#v-admin .tf-step-bar i {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2%;
  background: color-mix(in srgb, var(--accent) 70%, var(--surface));
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: height 160ms ease;
}
#v-admin .tf-step.is-full .tf-step-bar i { background: color-mix(in srgb, var(--green) 75%, var(--surface)); }
#v-admin .tf-step .cell-input {
  width: 100%; min-width: 0; text-align: center; font-weight: 700;
  font-variant-numeric: tabular-nums; padding-left: 4px; padding-right: 4px;
}
#v-admin .tf-step .cell-input::-webkit-inner-spin-button,
#v-admin .tf-step .cell-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#v-admin .tf-step .cell-input { -moz-appearance: textfield; appearance: textfield; }
#v-admin .tf-step .cell-input[aria-invalid="true"] { border-color: var(--red); color: var(--red); }
#v-admin .tf-step-k { font-size: 12px; color: var(--text-muted); text-align: center; white-space: nowrap; }

/* Ảnh phiếu */
#v-admin .adm-metric {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: var(--r); background: var(--surface-2);
  border: 1px solid var(--border-soft); margin-bottom: 16px;
}
#v-admin .adm-metric span { font-size: 13px; color: var(--text-muted); }
#v-admin .adm-metric b { font-size: 18px; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
#v-admin .adm-field-k { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
#v-admin .adm-seg {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 3px;
  border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border-soft);
}
#v-admin .adm-seg button {
  min-height: 36px; padding: 0 8px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600;
  white-space: nowrap; cursor: pointer; transition: background 140ms ease, color 140ms ease;
}
#v-admin .adm-seg button:hover { color: var(--text-strong); }
#v-admin .adm-seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow); }
#v-admin .adm-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Mẫu phiếu (thẻ do sheet-tpl.js chèn) */

@media (max-width: 767px) {
  #v-admin .adm-grid { grid-template-columns: minmax(0, 1fr); }
  #v-admin .adm-grid > .card { padding: 16px; }
  #v-admin .tf-ladder { gap: 6px; }
  #v-admin .tf-step { padding: 8px 4px; }
  #v-admin .tf-step-bar { height: 48px; }
  #v-admin .adm-seg button { min-height: 44px; }
  #v-admin .adm-actions .btn-primary { flex: 1; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  #v-admin .tf-step-bar i, #v-admin .adm-seg button { transition: none; }
}

/* Biểu đồ tải: chữ trục là HTML phủ lên (SVG co giãn không làm méo chữ) */
.ah-plot { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; align-items: stretch; }
.ah-yax { position: relative; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ah-yax span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.ah-plot-area { position: relative; min-width: 0; }
.ah-guide-lab {
  position: absolute; right: 4px; transform: translateY(-115%); font-size: 11px; color: var(--text-muted);
  background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 0 4px; border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.ah-base { stroke: var(--border); stroke-width: 1; }
.ah-guide { stroke: var(--border-strong); stroke-width: 1; }
.ah-xax {
  display: flex; justify-content: space-between; margin-left: 60px; margin-top: -8px;
  font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
