/* =========================================================
   Sổ tay Hành chính số 360° — giao diện
   Màu chủ đạo: đỏ son – vàng kim
   ========================================================= */
:root {
  --red-950: #3a0408;
  --red-900: #5d070d;
  --red-800: #8e0b14;
  --red-600: #bf151f;
  --gold-300: #ffe577;
  --gold-400: #ffd85a;
  --gold-600: #d9a62a;
  --gold-800: #8a6410;
  --paper: #fbf5e9;
  --paper-2: #fffdf7;
  --ink: #2b1714;
  --ink-2: #5e4741;
  --line: rgba(142, 11, 20, .14);
  --green: #1f7a4a;
  --green-bg: #eaf6ee;
  --amber: #a86a00;
  --amber-bg: #fff4d6;

  --hero-bg:
    radial-gradient(circle at 50% 5%, rgba(255, 229, 119, .16), transparent 34%),
    linear-gradient(135deg, #5d070d 0%, #8e0b14 55%, #bf151f 100%);
  --gold-text: linear-gradient(180deg, #fff6c9 0%, #ffe577 35%, #e3b23c 70%, #fff1a8 100%);

  --radius: 18px;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 2px 4px rgba(58, 4, 8, .06), 0 10px 24px -8px rgba(58, 4, 8, .18);
  --shadow-3d: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 6px 0 -1px rgba(142, 11, 20, .10), 0 18px 36px -12px rgba(58, 4, 8, .35);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --gutter: clamp(16px, 4vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 216, 90, .14), transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(191, 21, 31, .06), transparent 45%),
    var(--paper);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
svg { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; text-wrap: balance; }
/* Playfair mặc định dùng số kiểu cổ (số 0 thấp như chữ o) — ép về số thẳng hàng */
.hero__title, .book__deg, .stat b, .part__num, .flip__code, .weight__seg b, .weight__total b, .group__no, .group__pts,
.metric__pts, .code-tab b, .impact__code, .node__code, .paper__body { font-variant-numeric: lining-nums; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold-400); outline-offset: 3px; border-radius: 8px; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 99; background: var(--gold-400); color: var(--red-900); padding: 8px 14px; border-radius: 8px; font-weight: 700; }
.skip:focus { left: 8px; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 0; border-radius: 999px; padding: .62em 1.15em;
  font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s;
}
.btn--gold {
  color: var(--red-900);
  background: linear-gradient(180deg, #fff3b0 0%, var(--gold-400) 55%, var(--gold-600) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 4px 0 var(--gold-800), 0 10px 18px -6px rgba(0, 0, 0, .45);
}
.btn--red {
  color: #fff;
  background: linear-gradient(180deg, var(--red-600), var(--red-800));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 4px 0 var(--red-950), 0 10px 18px -6px rgba(58, 4, 8, .5);
}
.btn--ghost {
  color: var(--red-800); background: var(--paper-2);
  border: 1.5px solid rgba(142, 11, 20, .25);
  box-shadow: 0 3px 0 rgba(142, 11, 20, .18);
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-800); }
.btn--red:active { box-shadow: 0 1px 0 var(--red-950); }
.btn--lg { font-size: 1.05rem; padding: .8em 1.5em; }

/* =========================================================
   ĐẦU TRANG (HERO)
   ========================================================= */
.hero {
  position: relative;
  color: #fff;
  background: var(--hero-bg);
  border-bottom: 1px solid rgba(255, 216, 90, .45);
  padding: 14px var(--gutter) clamp(36px, 6vw, 72px);
  overflow: hidden;
  isolation: isolate;
}
.hero::before { /* hoa văn trống đồng cách điệu */
  content: ""; position: absolute; inset: -40% -10% auto auto; width: 720px; aspect-ratio: 1;
  background: repeating-radial-gradient(circle, rgba(255, 216, 90, .10) 0 2px, transparent 2px 26px);
  border-radius: 50%; z-index: -1; opacity: .7;
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%); mask: radial-gradient(circle, #000 30%, transparent 70%);
}
.hero::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 4px;
  background: linear-gradient(90deg, transparent, var(--gold-400), transparent);
  opacity: .7;
}
.hero__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1180px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand__logo {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff, #f6ead0);
  box-shadow: 0 0 0 2px var(--gold-400), 0 6px 14px rgba(0, 0, 0, .35);
}
.brand__logo img { width: 36px; height: auto; }
.brand__text { font-size: .78rem; line-height: 1.3; color: rgba(255, 255, 255, .85); text-transform: uppercase; letter-spacing: .02em; }
.brand__text strong { color: var(--gold-300); font-size: .92rem; }
#nut-cai-dat svg { width: 18px; height: 18px; }
#nut-cai-dat[hidden] { display: none; }

.hero__body {
  max-width: 1180px; margin: clamp(24px, 5vw, 56px) auto 0;
  display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(24px, 4vw, 56px);
}
.kicker {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold-300); padding: 4px 12px; border: 1px solid rgba(255, 216, 90, .5); border-radius: 999px;
  background: rgba(0, 0, 0, .12);
}
.hero__title {
  margin-top: 14px;
  font-family: var(--serif); font-weight: 900;
  font-size: clamp(2.3rem, 6.4vw, 4.6rem); line-height: 1.04;
  letter-spacing: -.01em;
  /* chữ nổi 3D nhiều lớp */
  text-shadow:
    0 1px 0 #e9b949, 0 2px 0 #c9971c, 0 3px 0 #a87b12, 0 4px 0 #8a6410,
    0 5px 0 #6e4f0b, 0 10px 14px rgba(0, 0, 0, .45), 0 18px 30px rgba(0, 0, 0, .3);
  color: #fff8de;
}
.hero__title span { display: block; color: var(--gold-300); }
.deg { font-style: normal; color: #fff; white-space: nowrap; }
.deg sup { font-size: .62em; top: -.62em; position: relative; vertical-align: baseline; margin-left: .02em; color: var(--gold-400); }
.hero__slogan { margin-top: 16px; font-size: clamp(1rem, 2.1vw, 1.2rem); font-weight: 600; color: rgba(255, 255, 255, .92); }
.hero__slogan i { color: var(--gold-400); font-style: normal; margin: 0 .25em; }
.hero__stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 28px; }
.stat {
  padding: 10px 16px; border-radius: 14px; min-width: 104px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .04));
  border: 1px solid rgba(255, 216, 90, .35);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 8px 18px -8px rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
}
.stat b { display: block; font-family: var(--serif); font-size: 1.8rem; line-height: 1; color: var(--gold-300); }
.stat span { font-size: .8rem; color: rgba(255, 255, 255, .8); }

/* ---- Cuốn sổ 3D ---- */
.hero__scene { position: relative; display: grid; place-items: center; perspective: 1400px; min-height: 420px; }
.book {
  position: relative; width: min(280px, 64vw); aspect-ratio: 3 / 4;
  transform-style: preserve-3d;
  transform: rotateY(-28deg) rotateX(8deg);
  animation: bookFloat 7s ease-in-out infinite;
}
.book__cover {
  position: absolute; inset: 0; border-radius: 6px 16px 16px 6px;
  background:
    radial-gradient(circle at 30% 15%, rgba(255, 229, 119, .28), transparent 45%),
    linear-gradient(150deg, #a60f19 0%, #7a0911 60%, #4d050a 100%);
  border: 2px solid var(--gold-600);
  box-shadow: inset 0 0 0 6px rgba(255, 216, 90, .12), inset 0 0 0 7px rgba(255, 216, 90, .5), 0 30px 60px -10px rgba(0, 0, 0, .6);
  transform: translateZ(18px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px;
  padding: 24px 18px; overflow: hidden;
}
.book__cover::after { /* ánh sáng lướt */
  content: ""; position: absolute; inset: -50%;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .22) 50%, transparent 60%);
  animation: sheen 6s ease-in-out infinite;
}
.book__emblem {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px;
  background: radial-gradient(circle at 35% 30%, #fff, #f4e3bd);
  box-shadow: 0 0 0 3px var(--gold-400), 0 0 0 6px rgba(255, 216, 90, .25), 0 8px 18px rgba(0, 0, 0, .4);
}
.book__emblem img { width: 54px; }
.book__label { font-size: .78rem; letter-spacing: .5em; color: var(--gold-300); font-weight: 700; padding-left: .5em; }
.book__name { font-family: var(--serif); font-size: 1.6rem; font-weight: 800; line-height: 1.1; background: var(--gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.book__deg { font-family: var(--serif); font-size: 3.4rem; font-weight: 900; line-height: 1; background: var(--gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .35)); }
.book__line { width: 60%; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-400), transparent); margin: 4px 0; }
.book__small { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .85); line-height: 1.6; }
.book__spine {
  position: absolute; top: 0; bottom: 0; left: 0; width: 36px;
  background: linear-gradient(90deg, #3a0408, #6b0810 60%, #3a0408);
  transform-origin: left; transform: rotateY(90deg) translateX(-18px) translateZ(0);
  border-radius: 4px 0 0 4px;
}
.book__pages {
  position: absolute; top: 6px; bottom: 6px; right: -2px; width: 34px;
  background: repeating-linear-gradient(90deg, #fffaf0 0 2px, #e8dcc2 2px 3px);
  transform-origin: right; transform: rotateY(90deg) translateX(17px);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, .2);
}
.orbit { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; transform-style: preserve-3d; }
.orbit span {
  position: absolute; width: min(400px, 88vw); aspect-ratio: 1; border-radius: 50%;
  border: 1.5px dashed rgba(255, 216, 90, .45);
  transform: rotateX(72deg) rotateZ(0);
  animation: orbit 18s linear infinite;
}
.orbit span:nth-child(2) { width: min(340px, 76vw); border-style: solid; border-color: rgba(255, 216, 90, .22); animation-duration: 26s; animation-direction: reverse; }
.orbit span:nth-child(3) { width: 14px; height: 14px; border: 0; background: radial-gradient(circle, #fff7c2, var(--gold-400)); box-shadow: 0 0 18px 4px rgba(255, 216, 90, .7); animation: dot 9s linear infinite; }

@keyframes bookFloat { 0%, 100% { transform: rotateY(-28deg) rotateX(8deg) translateY(0); } 50% { transform: rotateY(-18deg) rotateX(4deg) translateY(-12px); } }
@keyframes sheen { 0%, 60% { transform: translateX(-60%); } 100% { transform: translateX(60%); } }
@keyframes orbit { to { transform: rotateX(72deg) rotateZ(360deg); } }
@keyframes dot {
  0% { transform: translate(190px, 0) scale(1); } 25% { transform: translate(0, 50px) scale(1.3); }
  50% { transform: translate(-190px, 0) scale(1); } 75% { transform: translate(0, -50px) scale(.6); opacity: .6; } 100% { transform: translate(190px, 0) scale(1); }
}

/* =========================================================
   MỤC LỤC DÍNH
   ========================================================= */
.toc {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(93, 7, 13, .97), rgba(142, 11, 20, .96));
  border-bottom: 1px solid rgba(255, 216, 90, .45);
  box-shadow: 0 8px 20px -10px rgba(58, 4, 8, .6);
  backdrop-filter: blur(8px);
}
.toc__track {
  max-width: 1180px; margin: 0 auto; display: flex; gap: 6px; padding: 8px var(--gutter);
  overflow-x: auto; scrollbar-width: none;
}
.toc__track::-webkit-scrollbar { display: none; }
.toc a {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 6px; border-radius: 999px; text-decoration: none;
  color: rgba(255, 255, 255, .85); font-weight: 600; font-size: .9rem; white-space: nowrap;
  transition: background .2s, color .2s, transform .2s;
}
.toc a b {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  font-family: var(--serif); font-size: .85rem; color: var(--gold-300);
  border: 1px solid rgba(255, 216, 90, .5);
}
.toc a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.toc a.is-active { background: linear-gradient(180deg, #fff3b0, var(--gold-400)); color: var(--red-900); box-shadow: 0 3px 0 var(--gold-800); transform: translateY(-1px); }
.toc a.is-active b { background: var(--red-800); color: var(--gold-300); border-color: var(--red-800); }

/* =========================================================
   KHUNG PHẦN
   ========================================================= */
main { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
.part { padding: clamp(40px, 7vw, 80px) 0 0; }
.part__head { display: flex; align-items: center; gap: clamp(12px, 3vw, 24px); margin-bottom: 20px; }
.part__num { /* số La Mã nổi khối 3D */
  flex: none; display: grid; place-items: center;
  width: clamp(64px, 12vw, 92px); aspect-ratio: 1; border-radius: 22px;
  font-family: var(--serif); font-weight: 900; font-size: clamp(1.9rem, 5vw, 2.8rem);
  color: var(--gold-300);
  background: var(--hero-bg);
  border: 1px solid rgba(255, 216, 90, .5);
  text-shadow: 0 1px 0 #c9971c, 0 2px 0 #a87b12, 0 3px 0 #6e4f0b, 0 6px 10px rgba(0, 0, 0, .5);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 0 var(--red-950), 0 16px 26px -8px rgba(58, 4, 8, .55);
  transform: perspective(500px) rotateX(10deg) rotateY(-12deg);
}
.part__label { font-size: .78rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--red-600); }
.part__head h2 { font-family: var(--serif); font-weight: 800; font-size: clamp(1.35rem, 3.2vw, 2rem); color: var(--red-900); }
.lead { font-size: 1.04rem; color: var(--ink-2); max-width: 75ch; margin-bottom: 18px; }
.lead strong { color: var(--red-800); }
.hint { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink-2); margin: 10px 0 18px; }
.hint svg { color: var(--red-600); width: 18px; height: 18px; }

/* ---- Hiệu ứng nghiêng (dùng chung) ---- */
[data-tilt] {
  --rx: 0deg; --ry: 0deg; --gx: 50%; --gy: 50%;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .45s cubic-bezier(.2, .8, .2, 1), box-shadow .3s;
  will-change: transform;
}
[data-tilt].is-tilting { transition: transform .08s linear, box-shadow .3s; }

/* ---- Hiện dần ---- */
.reveal { opacity: 0; translate: 0 28px; transition: opacity .7s ease, translate .7s cubic-bezier(.2, .8, .2, 1); }
.reveal.is-in { opacity: 1; translate: 0 0; }

/* =========================================================
   PHẦN I — Lời nói đầu
   ========================================================= */
.paper {
  position: relative; border-radius: var(--radius);
  background:
    radial-gradient(circle at var(--gx) var(--gy), rgba(255, 229, 119, .18), transparent 40%),
    linear-gradient(180deg, var(--paper-2), #fff8e8);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-3d);
  padding: clamp(22px, 4vw, 44px) clamp(20px, 4vw, 52px);
}
.paper::before {
  content: "“"; position: absolute; top: -18px; left: 22px;
  font-family: var(--serif); font-size: 6rem; line-height: 1; color: var(--gold-600); opacity: .55;
}
.paper::after { /* gáy sổ */
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 5px; border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--red-600), var(--gold-400), var(--red-600));
}
.paper__body p { text-align: justify; hyphens: auto; }
.paper__body p + p { margin-top: 1em; }
.paper__body p:first-child::first-letter {
  float: left; font-family: var(--serif); font-weight: 900; font-size: 3.6em; line-height: .9;
  margin: .06em .1em 0 0; color: var(--red-800);
  text-shadow: 0 2px 0 var(--gold-400);
}

/* =========================================================
   PHẦN II — 10 trạng thái
   ========================================================= */
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.legend__item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow-1); font-size: .93rem; }
.legend__item--tg { border-left: 5px solid var(--gold-600); }
.legend__item--kt { border-left: 5px solid var(--red-600); }
.pill {
  display: inline-block; flex: none; padding: 3px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; line-height: 1.5;
}
.pill--tg { color: #6e4600; background: linear-gradient(180deg, #fff3c4, #ffd973); box-shadow: 0 2px 0 #c99a2e; }
.pill--kt { color: #fff; background: linear-gradient(180deg, var(--red-600), var(--red-800)); box-shadow: 0 2px 0 var(--red-950); }

.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 18px; }
.flip { perspective: 1100px; }
.flip__inner {
  position: relative; display: grid; width: 100%; min-height: 230px;
  border: 0; padding: 0; background: none; cursor: pointer; text-align: left;
  transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, 1.3, .5, 1);
}
.flip__inner.is-flipped { transform: rotateY(180deg); }
.flip__face {
  grid-area: 1 / 1; display: flex; flex-direction: column; gap: 10px;
  padding: 18px; border-radius: var(--radius);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 1px solid var(--line);
}
.flip__front {
  background:
    radial-gradient(circle at 85% 0%, rgba(255, 216, 90, .35), transparent 50%),
    linear-gradient(180deg, var(--paper-2), #fff6df);
  box-shadow: var(--shadow-3d);
}
.flip__front::after { content: ""; position: absolute; inset: auto 18px 0; height: 4px; border-radius: 4px 4px 0 0; background: var(--gold-600); }
.flip--kt .flip__front::after { background: var(--red-600); }
.flip__code {
  font-family: var(--serif); font-weight: 900; font-size: 3.2rem; line-height: 1;
  color: var(--red-800);
  text-shadow: 1px 1px 0 #e7b740, 2px 2px 0 #d39f2a, 3px 3px 0 #b5841c, 4px 4px 0 #8a6410, 6px 8px 12px rgba(58, 4, 8, .3);
  transform: translateZ(40px);
}
.flip__name { font-weight: 800; font-size: 1.05rem; color: var(--ink); flex: 1; }
.flip__front .pill { align-self: flex-start; }
.flip__turn { font-size: .75rem; color: var(--ink-2); font-weight: 600; }
.flip__back {
  transform: rotateY(180deg);
  color: #fff;
  background: var(--hero-bg);
  border-color: rgba(255, 216, 90, .45);
  box-shadow: 0 18px 36px -12px rgba(58, 4, 8, .55);
}
.flip--tg .flip__back { background: radial-gradient(circle at 50% 0%, rgba(255, 229, 119, .3), transparent 55%), linear-gradient(135deg, #6b4a06, #a8761a 60%, #c9971c); }
.flip__mini { font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-300); }
.flip__desc { font-size: .92rem; line-height: 1.5; flex: 1; }
.flip__moc { font-size: .86rem; font-weight: 700; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, .18); border: 1px solid rgba(255, 216, 90, .35); }
.flip__moc small { display: block; font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gold-300); }

/* =========================================================
   PHẦN III — Bộ chỉ số
   ========================================================= */
.weight { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.weight__bar {
  display: flex; height: 74px; border-radius: 16px; overflow: hidden;
  box-shadow: 0 6px 0 rgba(58, 4, 8, .25), 0 18px 30px -12px rgba(58, 4, 8, .45);
  transform: perspective(900px) rotateX(16deg); transform-origin: bottom;
}
.weight__seg {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0;
  text-decoration: none; color: #fff; position: relative;
  border-right: 1px solid rgba(255, 255, 255, .25);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25), inset 0 -6px 10px rgba(0, 0, 0, .18);
  transition: filter .2s, transform .2s;
}
.weight__seg:hover { filter: brightness(1.12); }
.weight__seg b { font-family: var(--serif); font-size: 1.5rem; line-height: 1; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.weight__seg span { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .9; white-space: nowrap; }
.weight__seg--1 { background: linear-gradient(180deg, #c41a24, #8e0b14); }
.weight__seg--2 { background: linear-gradient(180deg, #a5121b, #6d0810); }
.weight__seg--3 { background: linear-gradient(180deg, #d9a62a, #a87b12); color: #3a2500; }
.weight__seg--4 { background: linear-gradient(180deg, #b8841c, #7d5a0c); }
.weight__seg--5 { background: linear-gradient(180deg, #7a0911, #4d050a); }
.weight__total { align-self: flex-end; display: flex; align-items: baseline; gap: 10px; color: var(--ink-2); font-weight: 600; }
.weight__total b { font-family: var(--serif); font-size: 1.6rem; color: var(--red-800); }

.groups { display: flex; flex-direction: column; gap: 14px; }
.group { border-radius: var(--radius); background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow-1); overflow: hidden; }
.group summary {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, #fff, #fff4dc);
  border-bottom: 1px solid transparent;
}
.group summary::-webkit-details-marker { display: none; }
.group[open] summary { background: var(--hero-bg); color: #fff; border-bottom-color: rgba(255, 216, 90, .45); }
.group__no {
  font-family: var(--serif); font-weight: 800; font-size: .95rem; white-space: nowrap;
  padding: 4px 12px; border-radius: 10px; color: var(--red-800); background: #ffe9a8; box-shadow: 0 3px 0 #d3a53a;
}
.group__name { font-weight: 800; text-transform: uppercase; letter-spacing: .02em; font-size: .98rem; }
.group__pts { font-family: var(--serif); font-weight: 800; color: var(--red-800); white-space: nowrap; }
.group[open] .group__pts { color: var(--gold-300); }
.group__chev { width: 12px; height: 12px; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(45deg); transition: transform .3s; margin: 0 4px 4px; }
.group[open] .group__chev { transform: rotate(225deg); margin-bottom: -4px; }
.group__body { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; padding: 18px; }
.metric {
  display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px;
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 229, 119, .25), transparent 45%), #fff;
  border: 1px solid var(--line); box-shadow: var(--shadow-3d);
}
.metric__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.metric__code { font-weight: 800; font-size: .8rem; color: #fff; background: linear-gradient(180deg, var(--red-600), var(--red-800)); padding: 3px 10px; border-radius: 8px; box-shadow: 0 3px 0 var(--red-950); }
.metric__pts { font-family: var(--serif); font-weight: 800; color: var(--gold-800); background: var(--amber-bg); padding: 2px 10px; border-radius: 8px; border: 1px solid #f0d27a; }
.metric h4 { font-size: 1rem; font-weight: 700; color: var(--ink); }
.formula { font-size: .88rem; line-height: 1.5; padding: 10px 12px; border-radius: 10px; background: #fbf3df; border: 1px dashed rgba(168, 123, 18, .5); color: #4a3510; }
.formula small { display: block; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-800); margin-bottom: 2px; }

/* =========================================================
   PHẦN IV — Tác động & giải pháp
   ========================================================= */
.code-tabs {
  position: relative; scroll-padding-inline: var(--gutter);
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 20px;
}
.code-tab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 10px 12px; border-radius: 14px; cursor: pointer;
  background: linear-gradient(180deg, #fff, #fff4dc); border: 1px solid var(--line);
  box-shadow: 0 4px 0 rgba(142, 11, 20, .16), 0 8px 14px -8px rgba(58, 4, 8, .3);
  transition: transform .15s, box-shadow .15s, background .2s;
}
.code-tab b { font-family: var(--serif); font-size: 1.05rem; color: var(--red-800); }
.code-tab span { font-size: .78rem; line-height: 1.3; color: var(--ink-2); font-weight: 600; }
.code-tab:hover { transform: translateY(-2px); }
.code-tab[aria-selected="true"] {
  background: var(--hero-bg); border-color: rgba(255, 216, 90, .6);
  box-shadow: 0 4px 0 var(--red-950), 0 14px 22px -8px rgba(58, 4, 8, .55);
  transform: translateY(-3px);
}
.code-tab[aria-selected="true"] b { color: var(--gold-300); }
.code-tab[aria-selected="true"] span { color: #fff; }

.impact.is-in { animation: swingIn .55s cubic-bezier(.2, .8, .2, 1); }
@keyframes swingIn { from { opacity: 0; transform: perspective(1000px) rotateX(-12deg) translateY(16px); } }
.impact__head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  padding: 18px 20px; border-radius: var(--radius); color: #fff;
  background: var(--hero-bg); border: 1px solid rgba(255, 216, 90, .45);
  box-shadow: 0 6px 0 var(--red-950), 0 18px 30px -12px rgba(58, 4, 8, .55);
  margin-bottom: 18px;
}
.impact__head h3 { font-family: var(--serif); font-size: clamp(1.25rem, 3vw, 1.6rem); color: var(--gold-300); }
.impact__head p { font-size: .94rem; color: rgba(255, 255, 255, .9); margin-top: 4px; }
.impact__code {
  display: grid; place-items: center; width: 64px; aspect-ratio: 1; border-radius: 16px;
  font-family: var(--serif); font-weight: 900; font-size: 1.9rem; color: var(--red-800);
  background: linear-gradient(180deg, #fff3b0, var(--gold-400) 60%, var(--gold-600));
  box-shadow: 0 1px 0 #fff inset, 0 5px 0 var(--gold-800), 0 10px 16px rgba(0, 0, 0, .35);
  transform: perspective(400px) rotateY(-14deg);
}
.impact__cols { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 16px; align-items: start; }
.col { padding: 18px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-3d); border-top: 5px solid; }
.col h4 { display: flex; align-items: center; gap: 8px; font-size: .95rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 12px; }
.col h4 svg { width: 22px; height: 22px; }
.col--metric { border-top-color: var(--gold-600); }
.col--metric h4 { color: var(--gold-800); }
.col--fix { border-top-color: var(--green); }
.col--fix h4 { color: var(--green); }
.col--trap { border-top-color: var(--red-600); background: linear-gradient(180deg, #fff6f5, #fff); }
.col--trap h4 { color: var(--red-600); }
.col__sub { font-weight: 700; margin-bottom: 8px; }
.empty { font-size: .9rem; color: var(--ink-2); font-style: italic; }
.ticks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: .93rem; line-height: 1.5; }
.ticks li { position: relative; padding-left: 26px; }
.ticks li::before { content: ""; position: absolute; left: 0; top: .3em; width: 16px; height: 16px; border-radius: 50%; }
.ticks--metric li::before { background: radial-gradient(circle at 35% 30%, #fff3b0, var(--gold-600)); box-shadow: 0 2px 0 var(--gold-800); }
.ticks--fix li::before { background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 8 3 3 5-6' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100%; box-shadow: 0 2px 0 #0f4d2c; }
.ticks--warn li::before { background: var(--red-600) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 4v5m0 3v.3' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center/100%; box-shadow: 0 2px 0 var(--red-950); }
.ticks--warn li { color: #6e1016; }

/* =========================================================
   PHẦN V — Sơ đồ luồng
   ========================================================= */
.flow-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.flow-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.flow-legend span { display: inline-flex; align-items: center; gap: 8px; }
.sw { width: 18px; height: 18px; border-radius: 5px; display: inline-block; }
.sw--mc { background: linear-gradient(180deg, var(--red-600), var(--red-800)); }
.sw--cm { background: linear-gradient(180deg, #4a2a26, #2b1714); box-shadow: inset 0 0 0 2px var(--gold-600); }
.sw--end { background: linear-gradient(180deg, #fff3b0, var(--gold-600)); }

.flow {
  padding: clamp(16px, 3vw, 32px); border-radius: 24px;
  background:
    radial-gradient(circle, rgba(142, 11, 20, .07) 1px, transparent 1.5px) 0 0 / 22px 22px,
    linear-gradient(180deg, #fffaf0, #fbf0da);
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 12px rgba(58, 4, 8, .06);
}
.flow__row { display: flex; align-items: stretch; justify-content: center; gap: 14px; }
.flow__row--start, .flow__row--mid { align-items: center; }
.flow__row--start > *, .flow__row--mid > .node { flex: 0 1 340px; }
.flow__row--branch { display: grid; gap: 14px; align-items: start; position: relative; padding-top: 14px; }
.flow__row--branch::before { /* thanh phân nhánh */
  content: ""; position: absolute; top: 0; left: 10%; right: 10%; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--red-800) 8%, var(--red-800) 92%, transparent);
}
.flow__row--branch > .node::before {
  content: ""; position: absolute; top: -14px; left: 50%; width: 3px; height: 14px; background: var(--red-800); translate: -50% 0;
}
.flow__row--5 { grid-template-columns: repeat(5, 1fr); }
.flow__row--4 { grid-template-columns: repeat(4, 1fr); }
.flow__arrow { display: block; width: 3px; height: 34px; margin: 6px auto; background: var(--red-800); position: relative; border-radius: 3px; }
.flow__arrow::after { content: ""; position: absolute; bottom: -2px; left: 50%; translate: -50% 0; border: 8px solid transparent; border-top: 10px solid var(--red-800); border-bottom: 0; }
.flow__arrow--h { width: 40px; height: 3px; margin: 0; flex: none !important; }
.flow__arrow--h::after { bottom: auto; top: 50%; left: auto; right: -4px; translate: 0 -50%; border: 8px solid transparent; border-left: 10px solid var(--red-800); border-right: 0; }
.flow__arrow--red { background: repeating-linear-gradient(180deg, var(--red-600) 0 6px, transparent 6px 10px); }
.flow__arrow--red::after { border-top-color: var(--red-600); }
.flow__label { text-align: center; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--red-800); margin: -2px 0 10px; }
.flow__label--red { color: var(--red-600); }
.flow__split { display: grid; grid-template-columns: minmax(240px, .9fr) 2.1fr; gap: 22px; align-items: start; }
.flow__lane { display: flex; flex-direction: column; align-items: stretch; }
.flow__note { margin-top: 18px; font-size: .86rem; color: var(--ink-2); font-style: italic; text-align: center; }

.node {
  position: relative; display: flex; flex-direction: column; text-align: left;
  border-radius: 16px; padding: 0; border: 0; cursor: pointer; overflow: visible;
  background: #fff; box-shadow: 0 5px 0 rgba(58, 4, 8, .25), 0 16px 26px -12px rgba(58, 4, 8, .45);
}
.node:hover { box-shadow: 0 7px 0 rgba(58, 4, 8, .25), 0 22px 34px -12px rgba(58, 4, 8, .55); }
.node--static { cursor: default; }
.node__head { display: flex; flex-direction: column; padding: 12px 14px; border-radius: 16px 16px 0 0; color: #fff; position: relative; overflow: hidden; }
.node__head::after { content: ""; position: absolute; inset: 0 0 50% 0; background: linear-gradient(180deg, rgba(255, 255, 255, .22), transparent); pointer-events: none; }
.node__code { font-family: var(--serif); font-weight: 900; font-size: 1.1rem; color: var(--gold-300); text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.node__name { font-weight: 800; text-transform: uppercase; font-size: .9rem; line-height: 1.3; }
.node__bp { font-size: .78rem; opacity: .9; }
.node--mc .node__head { background: linear-gradient(160deg, var(--red-600), var(--red-800)); }
.node--cm .node__head { background: linear-gradient(160deg, #4a2a26, #2b1714); box-shadow: inset 0 0 0 2px var(--gold-600); }
.node--end .node__head { background: linear-gradient(160deg, #fff3b0, var(--gold-400) 50%, var(--gold-600)); color: var(--red-900); }
.node--end .node__code { color: var(--red-800); text-shadow: none; }
.node--static .node__head, .node:not(:has(.node__steps)):not(:has(.node__more)) .node__head { border-radius: 16px; }
.node__steps { margin: 0; padding: 12px 14px 14px; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 7px; font-size: .85rem; line-height: 1.45; color: var(--ink); }
.node__steps li { counter-increment: s; position: relative; padding-left: 28px; }
.node__steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, var(--red-600), var(--red-800)); box-shadow: 0 2px 0 var(--red-950);
}
.node__steps li.is-warn { color: var(--red-600); font-weight: 700; }
.node--cm .node__steps li::before { background: linear-gradient(180deg, #4a2a26, #2b1714); box-shadow: 0 2px 0 #000; }
.node__more { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; font-size: .82rem; font-weight: 700; color: var(--ink-2); }

.alarm {
  flex: 0 0 auto; width: 168px; aspect-ratio: 1; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; padding: 14px;
  color: #fff; background: radial-gradient(circle at 35% 30%, #e8343e, var(--red-600) 45%, var(--red-900));
  box-shadow: 0 0 0 4px rgba(255, 216, 90, .7), 0 8px 0 var(--red-950), 0 20px 30px -10px rgba(58, 4, 8, .6);
  animation: pulse 2.4s ease-in-out infinite;
}
.alarm b { font-size: .86rem; text-transform: uppercase; line-height: 1.25; }
.alarm small { font-size: .74rem; opacity: .9; }
.alarm__icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-400); color: var(--red-900); font-weight: 900; font-size: 1.2rem; margin-bottom: 4px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255, 216, 90, .15), 0 8px 0 var(--red-950), 0 20px 30px -10px rgba(58, 4, 8, .6); } }

/* =========================================================
   HỘP THOẠI
   ========================================================= */
.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: 22px; background: transparent; color: var(--ink); overflow: visible;
}
.modal--wide { width: min(1100px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(30, 3, 6, .62); backdrop-filter: blur(4px); }
.modal[open] .modal__inner { animation: popIn .45s cubic-bezier(.2, 1.2, .3, 1); }
@keyframes popIn { from { opacity: 0; transform: perspective(900px) rotateX(18deg) translateY(30px) scale(.94); } }
.modal__inner {
  position: relative; max-height: calc(100dvh - 48px); overflow: auto;
  padding: 22px; border-radius: 22px; background: var(--paper-2);
  border: 1px solid rgba(255, 216, 90, .6); box-shadow: 0 30px 60px -10px rgba(0, 0, 0, .55);
}
.modal__close { position: sticky; top: 0; float: right; z-index: 2; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; background: var(--red-800); color: #fff; box-shadow: 0 3px 0 var(--red-950); margin: -6px -6px 0 8px; }
.modal__close svg { width: 20px; height: 20px; }
.dlg-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.dlg-kicker { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--red-600); }
.dlg-head h3, .dlg-title { font-family: var(--serif); font-size: 1.4rem; color: var(--red-900); }
.dlg-title { margin-bottom: 14px; padding-right: 44px; }
.dlg-desc { margin-bottom: 12px; }
.dlg-moc { padding: 10px 12px; border-radius: 12px; background: var(--amber-bg); border: 1px solid #f0d27a; font-weight: 700; margin-bottom: 16px; }
.dlg-moc small { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-800); }
.modal h4 { font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; color: var(--red-800); margin-bottom: 8px; }
.node__steps--dlg { padding: 0 0 18px; font-size: .95rem; }
.zoom { overflow: auto; border-radius: 14px; border: 1px solid var(--line); cursor: zoom-in; max-height: calc(100dvh - 200px); }
.zoom img { width: 100%; height: auto; }
.zoom.is-zoomed { cursor: zoom-out; }
.zoom.is-zoomed img { width: 1491px; max-width: none; }

/* =========================================================
   CHÂN TRANG
   ========================================================= */
.footer {
  margin-top: clamp(48px, 8vw, 96px); padding: 36px var(--gutter) calc(36px + env(safe-area-inset-bottom));
  text-align: center; color: rgba(255, 255, 255, .9); background: var(--hero-bg);
  border-top: 1px solid rgba(255, 216, 90, .45);
}
.footer img { margin: 0 auto 12px; width: 72px; height: auto; padding: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px var(--gold-400), 0 10px 20px rgba(0, 0, 0, .4); }
.footer strong { color: var(--gold-300); text-transform: uppercase; letter-spacing: .03em; }
.footer__small { font-size: .85rem; opacity: .8; margin-top: 4px; }

.to-top {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40;
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  color: var(--red-900); background: linear-gradient(180deg, #fff3b0, var(--gold-400) 60%, var(--gold-600));
  box-shadow: 0 4px 0 var(--gold-800), 0 12px 20px -6px rgba(0, 0, 0, .4);
  opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .25s, transform .25s;
}
.to-top svg { width: 22px; height: 22px; stroke-width: 2.6; }
.to-top.is-on { opacity: 1; pointer-events: auto; transform: none; }

/* =========================================================
   ĐÁP ỨNG MÀN HÌNH
   ========================================================= */
@media (max-width: 1000px) {
  .flow__row--5 { grid-template-columns: repeat(3, 1fr); }
  .flow__split { grid-template-columns: 1fr; }
  .flow__lane--alt { order: -1; }
  .impact__cols { grid-template-columns: 1fr 1fr; }
  .col--fix { grid-column: 1 / -1; grid-row: 1; }
}
@media (max-width: 860px) {
  .hero__body { grid-template-columns: 1fr; }
  .hero__scene { min-height: 360px; order: -1; margin-top: -8px; }
  .code-tabs { display: flex; overflow-x: auto; padding: 4px 2px 10px; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-snap-type: x mandatory; scrollbar-width: none; }
  .code-tabs::-webkit-scrollbar { display: none; }
  .code-tab { flex: 0 0 148px; scroll-snap-align: start; }
}
@media (max-width: 640px) {
  .brand__text { font-size: .68rem; }
  .brand__text strong { font-size: .8rem; }
  #nut-cai-dat { padding: .5em .8em; font-size: .82rem; }
  .hero__scene { min-height: 300px; }
  .book { width: 190px; }
  .book__deg { font-size: 2.6rem; }
  .book__name { font-size: 1.2rem; }
  .book__emblem { width: 56px; height: 56px; }
  .book__emblem img { width: 40px; }
  .stat { min-width: 0; flex: 1; padding: 8px 10px; }
  .stat b { font-size: 1.5rem; }
  .hero__slogan i { display: block; height: 0; overflow: hidden; }
  .part__head { align-items: flex-start; }
  .weight__bar { height: 64px; }
  .weight__seg b { font-size: 1.15rem; }
  .weight__seg span { font-size: .6rem; }
  .group summary { grid-template-columns: 1fr auto; padding: 12px 14px; gap: 6px 10px; }
  .group__no { grid-column: 1; justify-self: start; }
  .group__pts { grid-column: 2; grid-row: 1; }
  .group__name { grid-column: 1 / -1; font-size: .92rem; }
  .group__chev { display: none; }
  .group__body { padding: 14px; }
  .impact__head { grid-template-columns: auto 1fr; }
  .impact__head .pill { grid-column: 1 / -1; justify-self: start; }
  .impact__code { width: 54px; font-size: 1.6rem; }
  .impact__cols { grid-template-columns: 1fr; }
  .col--fix { grid-column: auto; grid-row: auto; }
  .flow__row--start, .flow__row--mid { flex-direction: column; }
  .flow__row--start > *, .flow__row--mid > .node { flex: none; width: 100%; }
  .flow__arrow--h { width: 3px; height: 28px; }
  .flow__arrow--h::after { top: auto; right: auto; bottom: -2px; left: 50%; translate: -50% 0; border: 8px solid transparent; border-top: 10px solid var(--red-800); border-bottom: 0; }
  .flow__row--5, .flow__row--4 { grid-template-columns: 1fr; padding: 0 0 0 18px; }
  .flow__row--branch::before { top: 0; bottom: 20px; left: 4px; right: auto; width: 3px; height: auto; background: var(--red-800); }
  .flow__row--branch > .node::before { top: 22px; left: -14px; width: 14px; height: 3px; translate: 0 0; }
  .alarm { width: 150px; }
  .paper__body p { text-align: left; }
}
@media (hover: none) {
  [data-tilt] { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; translate: none; }
}
@media print {
  .toc, .to-top, .hero__scene, #nut-cai-dat, .flow-tools .btn { display: none !important; }
  .hero { background: #8e0b14; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .reveal { opacity: 1; translate: none; }
  .flip__back { display: none; }
}
