:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --surface: #fff; --subtle: #f0f2f5; --fg: #14181f; --muted: #5d6673;
  --line: #e2e5ea; --accent: #1f4fd8; --accent-soft: #e8eefc; --warn: #96560a; --warn-soft: #fdf3e3;
  --radius: 10px; --shadow: 0 1px 2px rgb(16 24 40 / 5%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --surface: #171b21; --subtle: #1f242c; --fg: #e9ecf1; --muted: #9aa3b0;
    --line: #2a3038; --accent: #86a8ff; --accent-soft: #1d2a4a; --warn: #f0b566; --warn-soft: #33260f;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 "Be Vietnam Pro", system-ui, "Segoe UI", sans-serif; }
h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.meta { color: var(--muted); font-size: .82rem; }

/* Thanh trên cùng */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1200px; margin: auto; padding: 0 24px; min-height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--fg); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.mark { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; background: var(--accent); color: var(--surface); font-size: .9rem; }
.tabs { display: flex; align-self: stretch; gap: 4px; }
.tabs button { padding: 0 14px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-pressed=true] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.topbar .meta { margin-left: auto; white-space: nowrap; }

/* Bố cục */
.layout { max-width: 1200px; margin: auto; padding: 24px; display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 32px; align-items: start; }
.side { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; }
.side-title { font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px 10px; }
.nav { display: flex; flex-direction: column; gap: 1px; margin-bottom: 22px; }
.nav button { display: flex; justify-content: space-between; gap: 8px; width: 100%; min-height: 34px; padding: 5px 10px; background: none; border: 0; border-radius: 7px; text-align: left; font-size: .9rem; cursor: pointer; }
.nav button:hover { background: var(--subtle); }
.nav button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav small { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
main { display: grid; gap: 28px; min-width: 0; }

/* Tìm kiếm */
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 46px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--muted); }
.search:focus-within { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; color: var(--fg); }
kbd { padding: 0 7px; border: 1px solid var(--line); border-radius: 5px; font: inherit; font-size: .75rem; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { font-size: 1.02rem; font-weight: 600; }

/* Thông số */
.fact-group + .fact-group { margin-top: 18px; }
.fact-group h3 { font-size: .85rem; font-weight: 600; margin-bottom: 8px; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.fact { display: flex; flex-direction: column; gap: 3px; padding: 13px 15px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.fact.stale { border-color: var(--warn); }
.fact-label { font-size: .8rem; color: var(--muted); }
.fact strong { font-size: 1.08rem; font-weight: 600; line-height: 1.35; font-variant-numeric: tabular-nums; }
.fact-note { font-size: .8rem; color: var(--muted); }
.fact a { margin-top: auto; padding-top: 6px; font-size: .8rem; }

/* Danh sách tài liệu */
.docs { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.docs > li { padding: 13px 16px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.docs > li:first-child { border-top: 0; }
.doc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.doc-title { all: unset; font-weight: 600; cursor: pointer; }
.doc-title:hover { color: var(--accent); }
.doc-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.doc-open { flex: none; font-size: .82rem; }
.doc-sum { margin-top: 2px; color: var(--muted); font-size: .87rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.badge { padding: 0 7px; border-radius: 5px; background: var(--subtle); color: var(--muted); font-size: .74rem; line-height: 1.7; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.empty { color: var(--muted); }

details summary { cursor: pointer; font-weight: 600; }
#changes ul { padding-left: 18px; font-size: .88rem; }

/* Dễ dùng: bảng thông số, nhóm tài liệu, đánh dấu từ khóa */
.clear { min-height: 30px; padding: 2px 10px; background: var(--subtle); border: 0; border-radius: 6px; font-size: .8rem; cursor: pointer; }
mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; font-weight: 600; }
.tabs small { margin-left: 5px; color: var(--muted); font-weight: 500; }
.nav button:disabled { opacity: .4; cursor: default; background: none; }
.fact-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.fact-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) minmax(0, 1fr) 54px; gap: 12px; align-items: baseline; padding: 10px 16px; border-top: 1px solid var(--line); font-size: .9rem; }
.fact-row:first-child { border-top: 0; }
.fact-row .plat { color: var(--muted); font-size: .82rem; }
.fact-row strong { font-weight: 700; font-size: 1.05rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.fact-row.important { background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn); }
.fact-row.important strong { color: var(--warn); }
.badge.alert { background: var(--warn); color: var(--surface); font-weight: 600; }
.fact-row .fact-note { display: block; }
.fact-row a { font-size: .8rem; text-align: right; }
.fact-row.stale { background: var(--warn-soft); }
.toggle { background: none; border: 0; color: var(--accent); font-size: .82rem; cursor: pointer; padding: 4px 0; min-height: 32px; }
.doc-group { padding: 8px 16px !important; background: var(--subtle); font-size: .8rem; font-weight: 600; color: var(--muted); }
.empty-box { padding: 20px 16px !important; color: var(--muted); }
.empty-box button { margin-left: 6px; background: none; border: 0; color: var(--accent); cursor: pointer; font-weight: 600; }
@media (max-width: 860px) {
  .fact-row { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .fact-row .plat { grid-column: 1 / -1; }
  .fact-row a { grid-row: 2 / span 2; grid-column: 2; align-self: center; }
  .tabs small { display: none; }
}

.md { font-size: .93rem; }
.md ol, .md ul { padding-left: 20px; margin: 6px 0 12px; }
.md li { margin: 4px 0; }

/* Nút lên đầu, xuống cuối */
.jump { position: fixed; right: 16px; bottom: 16px; z-index: 9; display: flex; flex-direction: column; gap: 6px; }
.jump button { width: 40px; height: 40px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 8px rgb(16 24 40 / 14%); color: var(--muted); cursor: pointer; }
.jump button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.jump button:disabled { opacity: .4; cursor: default; }

/* Cửa sổ đọc */
dialog { width: min(780px, calc(100vw - 32px)); max-height: 86vh; padding: 24px; background: var(--surface); color: inherit; border: 1px solid var(--line); border-radius: 14px; }
dialog::backdrop { background: rgb(10 14 20 / 45%); }
dialog h2 { font-size: 1.2rem; padding-right: 64px; }
dialog h3 { margin-top: 16px; font-size: .95rem; }
dialog pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .9rem; }
dialog ul { padding-left: 18px; font-size: .9rem; }
.close { float: right; }
.close button { min-height: 34px; padding: 3px 12px; background: var(--subtle); border: 0; border-radius: 7px; cursor: pointer; }

@media (max-width: 860px) {
  .topbar-in { flex-wrap: wrap; gap: 0 16px; padding: 8px 16px 0; }
  .brand { min-height: 36px; }
  .topbar .meta { display: none; }
  .tabs { width: 100%; }
  .tabs button { min-height: 42px; flex: 1; padding: 0 6px; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .side { position: static; max-height: none; overflow: visible; min-width: 0; }
  .side-title { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; margin-bottom: 8px; padding-bottom: 4px; }
  .nav button { width: auto; flex: none; border: 1px solid var(--line); background: var(--surface); min-height: 36px; align-items: center; white-space: nowrap; }
  kbd { display: none; }
}
