: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 {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: rgba(255, 253, 240, 0.85);
}

.doc-header__lead {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: rgba(255, 253, 240, 0.94);
  max-width: 62ch;
}

/* ---------- 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;
  padding-left: 20px;
}

.refs li {
  margin: 4px 0;
}

.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: 32px;
}

.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;
}

.subsection-title {
  color: var(--navy-ink);
  font-size: 0.94rem;
  font-weight: 800;
  margin: 22px 0 10px;
}

.subsection-title:first-child {
  margin-top: 0;
}

.doc-section > p,
.subsection-body > p {
  margin: 0 0 10px;
  font-size: 0.9rem;
  line-height: 1.65;
}

.doc-section ul.plain,
.subsection-body ul.plain {
  margin: 0 0 10px;
  padding-left: 20px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.doc-section ul.plain li,
.subsection-body ul.plain li {
  margin: 4px 0;
}

/* ---------- 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);
}

/* ---------- tables (responsive: horizontal scroll + visible hint) ---------- */

.scroll-hint {
  display: none;
  font-size: 0.74rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 6px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
  position: relative;
  margin-bottom: 8px;
}

table.datatable {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: var(--paper);
  font-size: 0.85rem;
}

table.datatable.cols-4 {
  min-width: 760px;
}

table.datatable.cols-5 {
  min-width: 1000px;
}

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

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

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

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

table.datatable tr.group-row td {
  background: #eef0fb !important;
  color: var(--navy-ink);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 7px 10px;
  border-top: 2px solid var(--navy);
}

table.datatable td.tag-cell {
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}

@media screen and (max-width: 640px) {
  .scroll-hint {
    display: block;
  }
}

/* ---------- callouts ---------- */

.callout {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 4px;
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 0.87rem;
  line-height: 1.6;
}

.callout strong {
  color: var(--navy-ink);
}

.callout--internal {
  border-left-color: var(--red-bd);
  background: var(--red-bg);
}

.callout--internal .callout__flag {
  display: inline-block;
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--red-fg);
  margin-bottom: 6px;
}

/* ---------- Từ → Thành block ---------- */

.shift-block {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
  margin: 10px 0 16px;
}

.shift-block__col {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.shift-block__col--to {
  border: 1.5px solid var(--navy);
  background: #f3f5fc;
}

.shift-block__label {
  display: block;
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.shift-block__col--to .shift-block__label {
  color: var(--navy);
}

.shift-block__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 1.6rem;
  font-weight: 800;
}

@media screen and (max-width: 640px) {
  .shift-block {
    grid-template-columns: 1fr;
  }
  .shift-block__arrow {
    transform: rotate(90deg);
    font-size: 1.3rem;
  }
}

/* ---------- two-column list block (bất biến / linh hoạt) ---------- */

.twocol {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 10px 0 16px;
}

.twocol__col {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
}

.twocol__col--fixed {
  border-left: 5px solid var(--navy);
}

.twocol__col--flex {
  border-left: 5px solid var(--gold);
}

.twocol__title {
  font-weight: 800;
  font-size: 0.84rem;
  color: var(--navy-ink);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.twocol__col ol {
  margin: 0;
  padding-left: 20px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.twocol__col ol li {
  margin: 6px 0;
}

@media screen and (max-width: 640px) {
  .twocol {
    grid-template-columns: 1fr;
  }
}

/* ---------- item cards (findings, highlighted points, Q&A) ---------- */

.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--navy {
  border-left-color: var(--navy);
}
.item-card--gold {
  border-left-color: var(--gold);
}

.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);
  line-height: 1.6;
}

.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;
  line-height: 1.55;
}

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

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

.item-card__q {
  font-weight: 700;
  color: var(--navy-ink);
}

.item-card__a {
  color: var(--ink-soft);
}

.item-card__a strong {
  color: var(--navy);
}

/* ---------- numbered step list ---------- */

.step-list {
  counter-reset: step;
  list-style: none;
  margin: 0 0 10px;
  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;
  line-height: 1.55;
}

.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;
}

@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;
  }

  .scroll-hint {
    display: none !important;
  }

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

  table.datatable {
    min-width: 0 !important;
    width: 100%;
    table-layout: fixed;
    font-size: 8pt;
  }

  table.datatable.cols-5 th:nth-child(1),
  table.datatable.cols-5 td:nth-child(1) {
    width: 13%;
  }

  table.datatable th,
  table.datatable td {
    padding: 5px 6px;
  }

  table.datatable th {
    white-space: normal;
    font-size: 7pt;
    line-height: 1.25;
  }

  table.datatable td.tag-cell,
  table.datatable td.num {
    white-space: normal;
  }

  .item-card,
  .b-item,
  .step-list li,
  table.datatable tr,
  .twocol__col,
  .shift-block__col,
  .callout {
    break-inside: avoid;
  }

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

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

  .shift-block {
    grid-template-columns: 1fr auto 1fr;
  }

  .shift-block__arrow {
    transform: none;
    font-size: 1.3rem;
  }
}

@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;
  }

  .item-card__head {
    font-size: 0.9rem;
  }
}
