:root {
  /* Bảng màu Sổ Sửa Tủ Nguyễn Gia (docs/nguyengia/mockups/nguyengia.css):
     lạnh — petrol cho cấu trúc, ống đồng chỉ cho hành động chính. */
  --primary: #0b5a6b; --primary-hover: #0a4654; --primary-deep: #08333d;
  --accent: #b4501c; --accent-hover: #9a4316; --on-accent: #ffffff; --accent-soft: #fbe8dc;
  --bg: #f2f5f7; --surface: #ffffff; --surface-alt: #f7f9fa; --sunken: #e7eef1;
  --border: #d6dfe3; --border-strong: #c3d0d6;
  --text: #0f2530; --text-2: #34505c; --text-3: #577079;
  --link: #0b5a6b; --info: #0a4654; --info-bg: #e3eef2;
  --success: #1d6a45; --success-bg: #e2f1e9; --success-line: #a9d5bd;
  --warn: #7c5300; --warn-bg: #fbf0d2; --warn-line: #e9cf86;
  --error: #b3261e; --error-bg: #fde8e6; --error-line: #f0b7b1;
  --side-bg: #08333d; --side-deep: #05252c; --side-line: #12505f; --side-text: #d8e8ec; --side-dim: #8fb6bf;
  --focus: 0 0 0 3px rgba(180, 80, 28, 0.45);
  --side-w: 300px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 20px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.65;
  -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility;
}
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
[hidden], .role-hidden, .search-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- khung trang ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: #1d6273 transparent;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; border-bottom: 1px solid var(--side-line); color: #fff; text-decoration: none; }
.brand svg { width: 38px; height: 38px; flex: none; border-radius: 9px; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.brand strong { display: block; font-size: 15.5px; letter-spacing: -0.01em; line-height: 1.25; }
.brand small { display: block; color: var(--side-dim); font-size: 12.5px; line-height: 1.35; }
.side-search { padding: 14px 14px 4px; }
.side-search label { display: block; font-size: 12.5px; color: var(--side-dim); margin-bottom: 6px; font-weight: 500; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--side-dim); pointer-events: none; }
.search {
  width: 100%; height: 42px; padding: 0 12px 0 34px; border-radius: 8px; border: 1px solid var(--side-line);
  background: var(--side-deep); color: #fff; font: inherit; font-size: 14.5px;
}
.search::placeholder { color: #6f97a1; }
.search:focus { border-color: var(--accent-soft); }
.search-count { min-height: 22px; padding: 5px 2px 0; font-size: 12.5px; color: var(--side-dim); }
.toc { padding: 2px 10px 24px; flex: 1; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc > ol > li { margin: 1px 0; }
.toc a { display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; color: var(--side-text); text-decoration: none; border-radius: 7px; border-left: 3px solid transparent; font-size: 14px; font-weight: 500; line-height: 1.38; }
.toc a:hover { background: rgba(255,255,255,.06); color: #fff; }
.toc a .n { flex: none; min-width: 1.6em; color: var(--side-dim); font-variant-numeric: tabular-nums; font-weight: 600; }
.toc a[aria-current="true"] { background: rgba(224,138,84,.14); color: #fff; border-left-color: #e08a54; }
.toc a[aria-current="true"] .n { color: #e08a54; }
.side-foot { padding: 12px 18px 16px; border-top: 1px solid var(--side-line); font-size: 12.5px; color: var(--side-dim); line-height: 1.5; }
.side-foot a { color: var(--side-text); }

.topbar { display: none; }
.main { min-width: 0; padding: 28px 36px 80px; }
.main > * { max-width: 880px; }
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.eyebrow .pill { background: var(--accent-soft); color: #7a3210; border: 1px solid #f2c6a9; border-radius: 999px; padding: 2px 12px; letter-spacing: 0; text-transform: none; font-weight: 600; }
h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.015em; margin: 10px 0 8px; }
.lead { font-size: 17.5px; color: var(--text-2); margin: 0 0 22px; }
.lead b, .lead strong { color: var(--text); }

/* ---------- chọn vai trò ---------- */
.roles-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; margin: 0 0 26px; box-shadow: 0 1px 2px rgba(15,37,48,.05); }
.roles-q { margin: 0 0 2px; font-weight: 700; font-size: 16.5px; }
.roles-hint { margin: 0 0 12px; font-size: 14px; color: var(--text-3); }
.seg { display: flex; flex-wrap: wrap; gap: 10px; }
.seg button {
  font: inherit; font-weight: 600; text-align: left; cursor: pointer; min-width: 168px;
  border: 1.5px solid var(--border-strong); background: var(--surface-alt); color: var(--text);
  border-radius: 10px; padding: 9px 14px; line-height: 1.35;
}
.seg button small { display: block; font-weight: 400; color: var(--text-3); font-size: 12.8px; margin-top: 2px; }
.seg button:hover { border-color: var(--primary); }
.seg button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg button[aria-pressed="true"] small { color: var(--side-text); }

/* ---------- mục nội dung ---------- */
.topic { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px 24px 18px; margin: 0 0 18px; box-shadow: 0 1px 2px rgba(15,37,48,.05); }
.topic > h3 { margin: 0 0 10px; font-size: 18.5px; letter-spacing: -0.01em; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.topic p { margin: 8px 0; }
.topic ul, .topic ol { margin: 8px 0; padding-left: 24px; }
.topic li { margin: 5px 0; }
.topic li > ul, .topic li > ol { margin: 4px 0; }
.topic h4 { margin: 16px 0 4px; font-size: 15.5px; color: var(--info); }

/* nhãn giao diện: nút, tab, ô nhập như hiển thị trong app */
.ui {
  display: inline-block; background: var(--sunken); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 0 7px; font-weight: 600; font-size: 14px; color: var(--text);
  white-space: nowrap; text-decoration: none;
}
a.ui:hover { border-color: var(--primary); color: var(--primary-hover); }
.ui.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ui.danger { background: var(--error-bg); border-color: var(--error-line); color: var(--error); }
.menu { display: inline-block; border: 1px dashed var(--border-strong); border-radius: 7px; padding: 0 7px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.msg {
  display: inline-block; background: var(--error-bg); border: 1px solid var(--error-line);
  border-radius: 7px; padding: 1px 8px; font-size: 14px; color: var(--error); font-weight: 500; white-space: normal;
}
.role-badge { border-radius: 7px; padding: 1px 8px; font-size: 14px; font-weight: 600; background: var(--info-bg); color: var(--info); border: 1px solid var(--border-strong); }

/* ghi chú */
.note, .tip { display: flex; gap: 12px; border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.note { background: var(--info-bg); border: 1px solid #bfd8e0; }
.tip { background: var(--success-bg); border: 1px solid var(--success-line); }
.note .tag, .tip .tag { flex: none; font-weight: 700; font-size: 13px; margin-top: 2px; }
.note .tag { color: var(--info); }
.tip .tag { color: var(--success); }
.note p, .tip p { margin: 0; font-size: 15px; }

/* bảng */
.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14.8px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-alt); font-size: 13.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-alt); }
td code, li code, p code { background: var(--sunken); border-radius: 5px; padding: 1px 6px; font-size: 13.5px; }

/* ---------- mobile ---------- */
@media (max-width: 960px) {
  .shell { display: block; }
  .side { position: static; height: auto; }
  .toc { display: none; }
  .side-search { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 5;
    background: var(--side-bg); color: #fff; padding: 10px 14px;
  }
  .topbar .t-brand { font-weight: 700; flex: 1; }
  .topbar button { font: inherit; background: var(--side-deep); color: #fff; border: 1px solid var(--side-line); border-radius: 8px; padding: 7px 12px; font-weight: 600; cursor: pointer; }
  .m-nav { position: sticky; top: 53px; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 14px; }
  .m-nav[hidden] { display: none; }
  .m-nav a { display: block; padding: 8px 4px; text-decoration: none; color: var(--text-2); font-weight: 500; border-bottom: 1px solid var(--border); font-size: 15px; }
  .m-nav a:last-child { border-bottom: 0; }
  .main { padding: 18px 16px 60px; }
  .topic { padding: 16px 16px 14px; border-radius: 12px; }
  h1 { font-size: 24px; }
  .seg button { min-width: 140px; flex: 1 1 45%; }
}
@media print {
  .side, .topbar, .m-nav, .roles-card { display: none !important; }
  .shell { display: block; }
  .topic { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
  body { background: #fff; }
}
