/*
 * Bộ giao diện kiểu "bảng số liệu" — dùng chung cho cả 8 trang.
 * Kế thừa biến màu trong styles.css, KHÔNG định nghĩa bảng màu mới.
 *
 * Quy ước: mọi component ở đây mặc định nằm trên nền TỐI (navy).
 * Đặt trên nền sáng thì bọc trong .panel-light.
 */

:root {
  /*
   * IBM Plex Mono không có glyph ฿ (U+0E3F). Thiếu fallback là trình duyệt mượn
   * font hệ thống có độ rộng lệch, làm ฿ chồng lên số. Đặt IBM Plex Sans Thai
   * ngay sau để ký hiệu tiền lấy từ font đã nạp sẵn.
   */
  --mono: "IBM Plex Mono", "IBM Plex Sans Thai", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --up: #3fbf7f;
  --down: #ff6b6b;
  --warn: #e8b64c;
  --grid-line: rgba(215, 181, 104, 0.14);
  --panel-bg: rgba(255, 255, 255, 0.035);
  --panel-line: rgba(215, 181, 104, 0.22);
}

/* ---------- Khung bảng điều khiển ---------- */

.report-panel {
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    var(--navy-900);
  box-shadow: 0 24px 60px rgba(3, 8, 20, 0.42);
  overflow: hidden;
}

.report-panel-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.report-panel-dots {
  display: inline-flex;
  gap: 5px;
}

.report-panel-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.report-panel-body {
  padding: 18px 16px 20px;
}

/* ---------- Thẻ chỉ số ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 14px 15px 15px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--panel-bg);
}

.stat-label {
  display: block;
  margin-bottom: 7px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  color: #fff;
  font-family: var(--mono);
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-delta.is-up {
  color: var(--up);
  background: rgba(63, 191, 127, 0.12);
}

.stat-delta.is-down {
  color: var(--down);
  background: rgba(255, 107, 107, 0.12);
}

.stat-note {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ---------- Bảng chấm điểm GOOD / FAIR / POOR ---------- */

/* Dùng như <ul> nên phải tự dọn padding/marker mặc định, không thì lệch 40px và tràn màn hình hẹp. */
.score-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--grid-line);
  overflow: hidden;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 15px;
  background: var(--navy-900);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.9rem;
}

.score-row span {
  min-width: 0;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.score-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.score-badge.is-good {
  color: var(--up);
  background: rgba(63, 191, 127, 0.12);
}

.score-badge.is-fair {
  color: var(--warn);
  background: rgba(232, 182, 76, 0.13);
}

.score-badge.is-poor {
  color: var(--down);
  background: rgba(255, 107, 107, 0.12);
}

/* ---------- Biểu đồ cột thuần CSS ---------- */

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 92px;
  padding-top: 6px;
}

.bar-chart i {
  flex: 1;
  min-width: 0;
  height: var(--h, 40%);
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, rgba(242, 217, 152, 0.92), rgba(200, 157, 77, 0.5));
}

.bar-chart i.is-muted {
  background: rgba(255, 255, 255, 0.1);
}

.chart-caption {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--mono);
  font-size: 0.74rem;
}

/* ---------- Dải chỉ số nhỏ nằm ngang ---------- */

.kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  padding: 14px 0 2px;
}

.kpi-strip div {
  display: grid;
  gap: 2px;
}

.kpi-strip dt,
.kpi-strip .kpi-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kpi-strip dd,
.kpi-strip .kpi-value {
  margin: 0;
  color: rgba(241, 221, 166, 0.95);
  font-family: var(--mono);
  font-size: 1.02rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Bước đánh số kiểu bảng ---------- */

.flow-steps {
  display: grid;
  gap: 1px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--grid-line);
  overflow: hidden;
}

.flow-steps article {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  padding: 15px;
  background: var(--navy-900);
}

.flow-steps .flow-index {
  grid-row: span 2;
  align-self: start;
  color: rgba(241, 221, 166, 0.62);
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
}

.flow-steps h3 {
  margin: 0;
  color: #fff;
  font-size: 1rem;
}

.flow-steps p {
  margin: 0;
  grid-column: 2;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.9rem;
  line-height: 1.65;
}

/* ---------- Biến thể trên nền sáng ---------- */

.panel-light .report-panel,
.panel-light .stat-card,
.panel-light .score-list,
.panel-light .flow-steps {
  border-color: var(--line);
  background: var(--paper);
  box-shadow: 0 18px 44px rgba(6, 21, 47, 0.07);
}

.panel-light .report-panel-bar {
  border-bottom-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

.panel-light .score-list,
.panel-light .flow-steps {
  background: var(--line);
}

.panel-light .score-row,
.panel-light .flow-steps article {
  background: var(--paper);
  color: var(--ink);
}

.panel-light .stat-label,
.panel-light .kpi-strip .kpi-label {
  color: var(--muted);
}

.panel-light .stat-value,
.panel-light .flow-steps h3 {
  color: var(--ink);
}

.panel-light .stat-note,
.panel-light .flow-steps p {
  color: var(--muted);
}

.panel-light .kpi-strip .kpi-value {
  color: var(--gold-dark);
}

.panel-light .bar-chart i.is-muted {
  background: rgba(17, 24, 39, 0.08);
}

.panel-light .chart-caption {
  color: var(--muted);
}

@media (max-width: 560px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-row {
    font-size: 0.86rem;
  }
}

/* ---------- Khối bảng số liệu trên trang chủ ---------- */

.report-section {
  color: rgba(255, 255, 255, 0.9);
  background:
    radial-gradient(1100px 480px at 88% -10%, rgba(36, 79, 184, 0.24), transparent 62%),
    var(--navy-950);
}

.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  align-items: center;
  gap: 44px;
}

.report-section .section-heading h2 {
  color: #fff;
}

.report-section .section-heading p {
  color: rgba(255, 255, 255, 0.7);
}

.report-scores {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.report-disclaimer {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.78rem;
  line-height: 1.6;
}

@media (max-width: 980px) {
  .report-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
}

/* ---------- Nền lưới kiểu bảng điều khiển cho đầu trang phụ ---------- */

.page-hero {
  position: relative;
  padding-block: 54px 34px;
  overflow: hidden;
  background:
    radial-gradient(900px 420px at 82% -20%, rgba(36, 79, 184, 0.28), transparent 60%),
    var(--navy-950);
}

.page-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(215, 181, 104, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(215, 181, 104, 0.055) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 78%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 78%);
  pointer-events: none;
}

.page-hero > * {
  position: relative;
}

.page-hero .section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-hero .section-kicker::before {
  content: "";
  width: 22px;
  height: 1px;
  background: rgba(215, 181, 104, 0.7);
}

@media (max-width: 760px) {
  .page-hero {
    padding-block: 34px 24px;
  }

  .page-hero::before {
    background-size: 40px 40px;
  }
}

/* ---------- Chỉnh dải chỉ số nhỏ ---------- */

.report-layout .kpi-strip {
  gap: 14px 40px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--panel-line);
}

.report-layout .kpi-strip dd {
  font-size: 1.24rem;
}

/*
 * Dải tin cậy giữ nguyên thẻ trắng nổi của thiết kế gốc (.trust-grid có
 * margin-top âm để đè lên hero). Đã thử đổi sang nền tối và làm hỏng
 * độ tương phản vì nền trắng nằm ở .trust-grid chứ không phải .trust-strip.
 */

/* ---------- Nền lưới cho phần đầu trang chủ ---------- */

.hero {
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(215, 181, 104, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(215, 181, 104, 0.05) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(900px 520px at 20% 8%, rgba(0, 0, 0, 0.9), transparent 72%);
  -webkit-mask-image: radial-gradient(900px 520px at 20% 8%, rgba(0, 0, 0, 0.9), transparent 72%);
  pointer-events: none;
}

.hero > * {
  position: relative;
  z-index: 1;
}

/* ---------- Ba điểm nhấn ở hero: cho ra dáng thẻ số liệu ---------- */

.hero-focus-grid > div {
  border: 1px solid var(--panel-line) !important;
  border-radius: 14px;
  background: var(--panel-bg) !important;
}

.hero-focus-grid strong {
  color: rgba(241, 221, 166, 0.96);
}

.report-panel-spaced {
  margin-top: 22px;
}

/*
 * Ký hiệu ฿ không nằm trong IBM Plex Mono. Để nó rơi vào font dự phòng thì
 * độ rộng bị lệch và ký hiệu dính vào số. Tách riêng bằng span để lấy đúng
 * font Thái đã nạp, và tự kiểm soát khoảng cách.
 */
.cur {
  margin-right: 0.1em;
  font-family: "IBM Plex Sans Thai", Tahoma, sans-serif;
  font-weight: 500;
}

/* ---------- Phần đầu trang chủ: chất bảng điều khiển ---------- */

/* Chấm nhấp nháy cho dòng mở đầu — gợi ý "đang theo dõi số liệu" */
.hero .eyebrow::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 0 rgba(63, 191, 127, 0.55);
  animation: kpi-pulse 2.4s ease-out infinite;
  vertical-align: middle;
}

@keyframes kpi-pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 191, 127, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(63, 191, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 191, 127, 0); }
}

/* Bộ đếm lượt tải là số THẬT — cho nó font đều nét như các chỉ số khác */
/* Dấu phẩy trong font đều nét chiếm trọn một ô nên số bị giãn — kéo lại cho chặt. */
.download-counter [data-download-count] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
}

/* Ba ô điểm nhấn: thêm số thứ tự nhỏ như hàng chỉ số */
.hero-focus-grid {
  counter-reset: focus;
}

.hero-focus-grid > div {
  position: relative;
  counter-increment: focus;
  padding-top: 34px !important;
}

.hero-focus-grid > div::before {
  content: "0" counter(focus);
  position: absolute;
  top: 12px;
  left: 14px;
  color: rgba(241, 221, 166, 0.5);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .hero .eyebrow::after {
    animation: none;
  }
}

/* Thong bao noi khi an chi dat opacity:0 nen van bat duoc tieu diem ban phim va trinh doc man hinh. */
.download-toast:not(.is-visible) {
  visibility: hidden;
}

/*
 * Anh nen moi co chi tiet trai deu ca khung (anh cu don ve ben phai), nen lop
 * phu goc khong du toi -> chu de doc. Them mot lop lam toi rieng, va nang moi
 * con truc tiep len tren no.
 */
.download-panel {
  position: relative;
  isolation: isolate;
}

.download-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(4, 10, 22, 0.58), rgba(4, 10, 22, 0.76));
  pointer-events: none;
}

.download-panel > * {
  position: relative;
  z-index: 1;
}
