:root {
  --navy: #0f2a71;
  --navy-ink: #0a1d4f;
  --gold: #f3af0f;
  --cream: #fffdf0;
  --paper: #ffffff;
  --ink: #1c1d22;
  --ink-soft: #4a4b55;
  --line: #e2ddc8;
  --green-bg: #e5f3e1;
  --green-fg: #1f6d2f;
  --green-bd: #7fbf7a;
  --amber-bg: #fdf1d6;
  --amber-fg: #8a5a00;
  --amber-bd: #f3af0f;
  --red-bg: #fbe4e2;
  --red-fg: #a3231a;
  --red-bd: #e07a72;
  --na-bg: #eceae3;
  --na-fg: #5c5c5c;
  --na-bd: #c9c4b4;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: #e9e6da;
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #1b1c22;
  }
}

.page-shell {
  max-width: 210mm;
  margin: 24px auto;
  background: var(--cream);
  box-shadow: 0 8px 28px rgba(15, 42, 113, 0.18);
  border-radius: 4px;
  overflow: hidden;
}

/* ---------- header ---------- */

.doc-header {
  background: var(--navy);
  color: var(--cream);
  padding: 28px 22mm 22px;
  border-bottom: 5px solid var(--gold);
}

.doc-header__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.doc-header__brand-name {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--gold);
}

.doc-header__tag {
  font-size: 0.7rem;
  color: rgba(255, 253, 240, 0.75);
  border: 1px solid rgba(255, 253, 240, 0.35);
  border-radius: 999px;
  padding: 3px 10px;
}

.doc-header h1 {
  margin: 0 0 10px;
  font-size: 1.32rem;
  line-height: 1.4;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.doc-header__subtitle {
  margin: 0 0 14px;
  font-size: 1rem;
  color: var(--gold);
  font-weight: 600;
}

.doc-header__meta {
  font-size: 0.82rem;
  color: rgba(255, 253, 240, 0.85);
}

/* ---------- content ---------- */

.doc-body {
  padding: 22px 22mm 12px;
}

.refs {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  border-radius: 4px;
  padding: 14px 16px;
  margin: 0 0 22px;
  font-size: 0.86rem;
}

.refs__title {
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.refs ul {
  margin: 0 0 8px;
  padding-left: 20px;
}

.refs li {
  margin: 3px 0;
}

.refs__note {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-style: italic;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 20px;
  font-size: 0.8rem;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
}

section.doc-section {
  margin-bottom: 30px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--navy);
}

.section-title__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--gold);
  color: var(--navy-ink);
  font-size: 0.85rem;
  font-weight: 800;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.82em;
  font-weight: 700;
  border: 1.5px solid;
  white-space: nowrap;
  line-height: 1.6;
}

.badge--ok {
  background: var(--green-bg);
  color: var(--green-fg);
  border-color: var(--green-bd);
}

.badge--warn {
  background: var(--amber-bg);
  color: var(--amber-fg);
  border-color: var(--amber-bd);
}

.badge--bad {
  background: var(--red-bg);
  color: var(--red-fg);
  border-color: var(--red-bd);
}

.badge--na {
  background: var(--na-bg);
  color: var(--na-fg);
  border-color: var(--na-bd);
}

.badge-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.badge-group__sep {
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------- summary table ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
}

table.summary {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  font-size: 0.86rem;
  table-layout: fixed;
}

table.summary col.col-num {
  width: 7%;
}
table.summary col.col-req {
  width: 37%;
}
table.summary col.col-status {
  width: 14%;
}
table.summary col.col-note {
  width: 42%;
}

table.summary th {
  background: var(--navy);
  color: var(--cream);
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 10px;
}

table.summary td {
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

table.summary tr:nth-child(even) td {
  background: #fbf9ee;
}

table.summary td.num {
  font-weight: 700;
  color: var(--navy);
  text-align: center;
  white-space: nowrap;
}

/* ---------- Phần A cards ---------- */

.item-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.item-card--ok {
  border-left-color: var(--green-bd);
}
.item-card--warn {
  border-left-color: var(--amber-bd);
}
.item-card--bad {
  border-left-color: var(--red-bd);
}
.item-card--mixed {
  border-left-color: var(--navy);
}

.item-card__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  font-weight: 800;
  color: var(--navy-ink);
  font-size: 0.95rem;
}

.item-card__code {
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  background: var(--navy);
  color: var(--gold);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 0.82rem;
}

.item-card p {
  margin: 6px 0;
  font-size: 0.88rem;
  color: var(--ink);
}

.item-card__arrow {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-weight: 600;
  color: var(--navy-ink);
}

.item-card__sub {
  margin: 8px 0 4px;
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.item-card ul {
  margin: 4px 0 8px;
  padding-left: 20px;
  font-size: 0.88rem;
}

.item-card ul li {
  margin: 3px 0;
}

.item-card ul li::marker {
  color: var(--navy);
}

/* ---------- Phần B list ---------- */

.b-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.b-item {
  display: flex;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

.b-item__tag {
  flex: none;
  font-weight: 800;
  color: var(--navy);
  min-width: 34px;
}

.b-item__src {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--navy-ink);
  background: #eef0fb;
  border: 1px solid #c8cdf0;
  border-radius: 3px;
  padding: 0 5px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ---------- Phần C steps ---------- */

.step-list {
  counter-reset: step;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-list li {
  counter-increment: step;
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 14px 10px 44px;
  font-size: 0.9rem;
}

.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 10px;
  top: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy-ink);
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- footer ---------- */

.doc-footer {
  background: var(--navy);
  color: rgba(255, 253, 240, 0.85);
  padding: 16px 22mm;
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 3px solid var(--gold);
}

.doc-footer a {
  color: var(--gold);
  text-decoration: none;
}

.doc-footer a:hover {
  text-decoration: underline;
}

/* ---------- print ---------- */

@page {
  size: A4;
  margin: 0;
}

@media print {
  body {
    background: var(--cream);
  }

  .page-shell {
    max-width: none;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
  }

  .doc-header {
    padding: 14mm 16mm 8mm;
  }

  .doc-body {
    padding: 8mm 16mm;
  }

  .doc-footer {
    display: none;
  }

  table.summary {
    font-size: 9.5pt;
  }

  .item-card,
  .b-item,
  .step-list li,
  table.summary tr {
    break-inside: avoid;
  }

  .section-title {
    break-after: avoid;
  }

  .refs,
  .legend {
    break-inside: avoid;
  }
}

@media screen and (max-width: 640px) {
  .doc-header,
  .doc-body,
  .doc-footer {
    padding-left: 5mm;
    padding-right: 5mm;
  }

  .doc-header h1 {
    font-size: 1.1rem;
  }

  table.summary {
    font-size: 0.78rem;
  }

  table.summary col.col-req {
    width: 34%;
  }
  table.summary col.col-note {
    width: 40%;
  }
  table.summary col.col-status {
    width: 16%;
  }
}
