/* Sổ tay Kiến trúc — giao diện */
:root {
  --bg: #f6f5f1; --surface: #ffffff; --surface2: #f0eee8; --ink: #1d2428; --ink2: #51606a; --line: #dedbd2;
  --brand: #0f6e6e; --brand-ink: #ffffff; --brand-soft: #dff0ee; --accent: #c8581e; --accent-soft: #fbe9dc;
  --ok: #1f7a4d; --ok-soft: #dcf1e5; --warn: #a56a00; --warn-soft: #fbefcf; --bad: #b3261e; --bad-soft: #fbe0de; --info: #2a5db0; --info-soft: #dfe9fa;
  --p1: #b3261e; --p2: #a56a00; --p3: #2a7a5a;
  --shadow: 0 1px 2px rgba(20,30,35,.06), 0 6px 20px rgba(20,30,35,.06);
  --r: 14px; --r-sm: 9px; --side: 264px; --fs: 1;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #12171a; --surface: #1b2226; --surface2: #232c31; --ink: #e8ecee; --ink2: #9fb0b8; --line: #2f3a40;
  --brand: #4fc3bd; --brand-ink: #06201f; --brand-soft: #173a3a; --accent: #f08a50; --accent-soft: #3b2619;
  --ok: #5fd39b; --ok-soft: #173826; --warn: #f0c050; --warn-soft: #3a2f10; --bad: #ff8a80; --bad-soft: #3d1a18; --info: #8db4ff; --info-soft: #1a2a48;
  --p1: #ff8a80; --p2: #f0c050; --p3: #5fd39b;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #12171a; --surface: #1b2226; --surface2: #232c31; --ink: #e8ecee; --ink2: #9fb0b8; --line: #2f3a40;
    --brand: #4fc3bd; --brand-ink: #06201f; --brand-soft: #173a3a; --accent: #f08a50; --accent-soft: #3b2619;
    --ok: #5fd39b; --ok-soft: #173826; --warn: #f0c050; --warn-soft: #3a2f10; --bad: #ff8a80; --bad-soft: #3d1a18; --info: #8db4ff; --info-soft: #1a2a48;
    --p1: #ff8a80; --p2: #f0c050; --p3: #5fd39b;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { font-size: calc(16px * var(--fs)); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.55; min-height: 100vh; }
a { color: var(--brand); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; font-family: var(--serif); letter-spacing: -.01em; }
h2 { font-size: 1.3rem; font-family: var(--serif); }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: 8px 14px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink2); }
.small { font-size: .86rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.hide { display: none !important; }

/* ---- khung ---- */
#app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
#side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px 24px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; text-decoration: none; color: var(--ink); }
.brand .logo { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; font-family: var(--serif); font-size: 1.1rem; flex: none; }
.brand b { display: block; font-family: var(--serif); font-size: 1.02rem; line-height: 1.15; }
.brand span { font-size: .74rem; color: var(--ink2); }
.navgrp { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink2); padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); font-size: .95rem; }
.nav a:hover { background: var(--surface2); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.nav .ic { width: 22px; text-align: center; flex: none; }
.nav .badge { margin-left: auto; }
#main { min-width: 0; display: flex; flex-direction: column; }
#top { position: sticky; top: 0; z-index: 20; display: flex; gap: 10px; align-items: center; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
#top .menu { display: none; }
#gsearch { flex: 1 1 auto; max-width: 560px; position: relative; }
#gsearch input { width: 100%; padding: 9px 14px 9px 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
#gsearch .si { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink2); pointer-events: none; }
#view { padding: 22px 24px 90px; max-width: 1180px; width: 100%; margin: 0 auto; outline: none; }
#tabbar { display: none; }

/* ---- thành phần ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem; min-height: 40px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 5px 11px; min-height: 32px; font-size: .86rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; }
.iconbtn:hover { border-color: var(--brand); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { margin-bottom: .35em; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gauto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.page-h { display: flex; gap: 14px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.page-h p { margin: 0; color: var(--ink2); }
.crumbs { font-size: .85rem; color: var(--ink2); margin-bottom: 6px; }
.crumbs a { color: var(--ink2); }
.badge, .chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 650; background: var(--surface2); color: var(--ink2); white-space: nowrap; border: 1px solid transparent; }
.chip { cursor: pointer; padding: 5px 12px; font-size: .85rem; border-color: var(--line); background: var(--surface); }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.p1 { background: var(--bad-soft); color: var(--p1); } .p2 { background: var(--warn-soft); color: var(--p2); } .p3 { background: var(--ok-soft); color: var(--p3); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); } .badge.brand { background: var(--brand-soft); color: var(--brand); }
.stat { padding: 16px; }
.stat .n { font-size: 1.9rem; font-weight: 750; font-family: var(--serif); line-height: 1.1; }
.stat .l { color: var(--ink2); font-size: .85rem; }
.bar { height: 8px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }
.bar.seg { display: flex; }
.bar.seg > i { border-radius: 0; }
.ring { --v: 0; width: 84px; height: 84px; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--v) * 1%), var(--surface2) 0); display: grid; place-items: center; flex: none; }
.ring > span { width: 66px; height: 66px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 750; font-size: 1.1rem; }
.tag { display: inline-block; padding: 0 7px; border-radius: 6px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; vertical-align: 1px; border: 1px solid transparent; font-family: var(--font); }
.tag-src { background: var(--info-soft); color: var(--info); } .tag-res { background: var(--ok-soft); color: var(--ok); } .tag-inf { background: var(--warn-soft); color: var(--warn); } .tag-rec { background: var(--accent-soft); color: var(--accent); }
.fref, .sref { font-weight: 650; text-decoration: none; border-bottom: 1px dotted currentColor; }
input[type=text], input[type=search], input[type=number], select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; }
textarea { min-height: 110px; resize: vertical; }
label.fld { display: block; font-size: .85rem; font-weight: 650; margin-bottom: 4px; color: var(--ink2); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select { width: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs button { background: none; border: none; padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; color: var(--ink2); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--brand); border-color: var(--brand); }
.empty { text-align: center; padding: 38px 14px; color: var(--ink2); }
.empty b { display: block; font-size: 1.05rem; color: var(--ink); margin-bottom: 6px; }

/* ---- markdown ---- */
.md { overflow-wrap: anywhere; }
.md p { margin: 0 0 .75em; }
.md ul, .md ol { margin: 0 0 .8em; padding-left: 1.3em; }
.md li { margin: .22em 0; }
.md h3, .md h4, .md h5 { margin-top: 1em; }
.md blockquote { margin: .5em 0 .9em; padding: 6px 14px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 10px 10px 0; }
.md blockquote p:last-child { margin-bottom: 0; }
.md code { background: var(--surface2); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.md pre.code { background: var(--surface2); padding: 12px; border-radius: 10px; overflow: auto; font-size: .82rem; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }
.tbl-wrap { overflow-x: auto; margin: .4em 0 1em; border: 1px solid var(--line); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 520px; }
.md th { background: var(--surface2); text-align: left; font-weight: 700; }
.md th, .md td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.md tr:last-child td { border-bottom: none; }

/* ---- thư viện / yếu tố ---- */
.fcard { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; position: relative; transition: transform .12s, border-color .12s; }
.fcard:hover { transform: translateY(-2px); border-color: var(--brand); }
.fcard .id { font-family: var(--serif); font-weight: 800; font-size: 1.15rem; color: var(--brand); }
.fcard .fn { font-weight: 650; line-height: 1.3; }
.fcard .meta { display: flex; gap: 5px; flex-wrap: wrap; }
.fav-btn { background: none; border: none; cursor: pointer; font-size: 1.25rem; color: var(--ink2); padding: 2px 6px; line-height: 1; }
.fav-btn[aria-pressed="true"] { color: #e0a100; }
.fcard .fav-btn { position: absolute; top: 10px; right: 8px; }
.gdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.sections { display: flex; flex-direction: column; gap: 10px; }
.sec { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.sec > summary { list-style: none; cursor: pointer; padding: 13px 16px; display: flex; gap: 10px; align-items: center; font-weight: 700; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary .num { width: 26px; height: 26px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: .85rem; flex: none; }
.sec > summary .chev { margin-left: auto; transition: transform .2s; color: var(--ink2); }
.sec[open] > summary .chev { transform: rotate(90deg); }
.sec[open] > summary { border-bottom: 1px solid var(--line); }
.sec .body { padding: 14px 18px 8px; }
.sec .done-row { padding: 0 18px 14px; }
.sec.read > summary .num { background: var(--ok); color: #fff; }
.fhead { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.sticky-tools { position: sticky; top: 58px; z-index: 5; }
.layout2 { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.sidecol { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 14px; }
.toc a { display: flex; gap: 8px; padding: 5px 8px; text-decoration: none; color: var(--ink); border-radius: 8px; font-size: .9rem; }
.toc a:hover { background: var(--surface2); }
.toc a .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-top: 7px; flex: none; }
.toc a.read .dot { background: var(--ok); }
.lvl { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: .78rem; font-weight: 700; }
.lvl0 { background: var(--ok-soft); color: var(--ok); } .lvl1 { background: var(--warn-soft); color: var(--warn); } .lvl2 { background: var(--accent-soft); color: var(--accent); } .lvl3 { background: var(--bad-soft); color: var(--bad); }
.thr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.thr > div { padding: 8px 10px; border-radius: 9px; font-size: .88rem; }
.thr .g { background: var(--ok-soft); } .thr .w { background: var(--warn-soft); } .thr .f { background: var(--bad-soft); }
.thr small { display: block; font-weight: 700; margin-bottom: 2px; }

/* ---- checklist ---- */
.chk { display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.chk:last-child { border-bottom: none; }
.chk .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; color: var(--ink2); padding-top: 4px; }
.seg3 { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg3 button { background: var(--surface); border: none; padding: 6px 10px; cursor: pointer; font-size: .82rem; font-weight: 650; border-right: 1px solid var(--line); min-height: 34px; }
.seg3 button:last-child { border-right: none; }
.seg3 button[aria-pressed="true"].ok { background: var(--ok); color: #fff; }
.seg3 button[aria-pressed="true"].more { background: var(--warn); color: #fff; }
.seg3 button[aria-pressed="true"].fail { background: var(--bad); color: #fff; }

/* ---- thẻ ghi nhớ ---- */
.fc-wrap { max-width: 720px; margin: 0 auto; }
.fc { perspective: 1200px; min-height: 320px; cursor: pointer; }
.fc-in { position: relative; min-height: 320px; transition: transform .5s; transform-style: preserve-3d; }
.fc.flip .fc-in { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 26px 28px; overflow: auto; display: flex; flex-direction: column; }
.fc-back { transform: rotateY(180deg); background: var(--brand-soft); }
.fc-face .lab { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink2); margin-bottom: 10px; font-weight: 700; }
.fc-face .txt { margin: auto 0; font-size: 1.12rem; }
.fc-front .txt { font-size: 1.22rem; font-family: var(--serif); }
.fc.noanim .fc-in { transition: none; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.rate button { padding: 10px 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; }
.rate button small { display: block; font-weight: 500; color: var(--ink2); font-size: .75rem; }
.rate .danger { border-color: var(--bad); } .rate .warn { border-color: var(--warn); } .rate .ok { border-color: var(--ok); } .rate .info { border-color: var(--info); }
.rate button:hover { filter: brightness(.96); }

/* ---- quiz ---- */
.qwrap { max-width: 780px; margin: 0 auto; }
.qcard { padding: 22px; }
.qtext { font-size: 1.12rem; font-weight: 600; margin-bottom: 14px; }
.opt { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; margin-bottom: 9px; }
.opt:hover:not([disabled]) { border-color: var(--brand); }
.opt .k { width: 26px; height: 26px; border-radius: 8px; background: var(--surface2); display: grid; place-items: center; font-weight: 800; font-size: .82rem; flex: none; }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt[disabled] { cursor: default; }
.expl { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface2); }
.expl.ok { background: var(--ok-soft); } .expl.bad { background: var(--bad-soft); }
.prog { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.prog i { flex: 1 1 14px; min-width: 8px; max-width: 28px; height: 6px; border-radius: 3px; background: var(--surface2); }
.prog i.ok { background: var(--ok); } .prog i.bad { background: var(--bad); } .prog i.cur { background: var(--brand); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---- bản đồ ---- */
.mapbox { position: relative; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; touch-action: none; }
.mapbox svg { display: block; width: 100%; height: min(72vh, 680px); cursor: grab; }
.mapbox svg.drag { cursor: grabbing; }
.mapbox .node { cursor: pointer; }
.mapbox .node text { font-size: 11px; font-weight: 700; fill: #fff; pointer-events: none; text-anchor: middle; dominant-baseline: central; }
.mapbox .node.dim, .mapbox .edge.dim { opacity: .12; }
.mapbox .edge { stroke: var(--ink2); stroke-opacity: .35; fill: none; }
.mapbox .edge.conflict { stroke: var(--bad); stroke-opacity: .55; stroke-dasharray: 5 3; }
.mapbox .edge.hi { stroke-opacity: .95; stroke-width: 2.2; }
.mapbox .glabel { font-size: 13px; font-weight: 800; fill: var(--ink2); text-anchor: middle; pointer-events: none; }
.maplegend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8rem; color: var(--ink2); margin-top: 8px; }
.mapinfo { position: absolute; left: 12px; bottom: 12px; right: 12px; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); font-size: .9rem; }
.heat { display: grid; gap: 8px; }
.heat-row { display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: start; }
.heat-cells { display: flex; flex-wrap: wrap; gap: 6px; }
.cell { padding: 6px 10px; border-radius: 9px; text-decoration: none; font-size: .85rem; font-weight: 700; border: 2px solid transparent; color: var(--ink); position: relative; }
.cell small { display: block; font-weight: 500; font-size: .7rem; color: var(--ink2); max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.p1 { border-color: var(--p1); } .cell.p2 { border-color: var(--p2); } .cell.p3 { border-color: var(--p3); }
.cell.rd::after { content: '✓'; position: absolute; top: -6px; right: -4px; background: var(--ok); color: #fff; width: 16px; height: 16px; border-radius: 50%; font-size: 10px; display: grid; place-items: center; }

/* ---- thuật ngữ, ghi chú ---- */
.term { padding: 14px 16px; }
.term h3 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.alpha { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.alpha button { min-width: 32px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 650; }
.alpha button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.note { padding: 14px 16px; }
.note .t { font-weight: 700; }
.note pre { white-space: pre-wrap; font-family: inherit; margin: 6px 0; }

/* ---- toast / dialog ---- */
#toast { position: fixed; bottom: 82px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: .92rem; transition: opacity .3s, transform .3s; text-align: center; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast.warn { background: var(--warn); color: #fff; }
dialog { border: none; border-radius: 18px; padding: 0; max-width: min(94vw, 640px); width: 100%; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(10,15,18,.55); }
.dlg-in { padding: 22px; max-height: 86vh; overflow: auto; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* ---- biểu đồ nhỏ ---- */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.spark i { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.spark i.z { background: var(--surface2); }
.heatcal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heatcal i { width: 14px; height: 14px; border-radius: 3px; background: var(--surface2); }
.heatcal i.l1 { background: color-mix(in srgb, var(--brand) 30%, var(--surface2)); } .heatcal i.l2 { background: color-mix(in srgb, var(--brand) 55%, var(--surface2)); } .heatcal i.l3 { background: var(--brand); }
.pathrow { display: flex; gap: 0; overflow-x: auto; padding-bottom: 6px; }
.step { flex: 1 0 150px; padding: 10px 12px; border: 1px solid var(--line); background: var(--surface); position: relative; }
.step:first-child { border-radius: 12px 0 0 12px; } .step:last-child { border-radius: 0 12px 12px 0; }
.step.gate { background: var(--bad-soft); }
.callout { padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); margin-bottom: 14px; }
.callout.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.callout.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.hl { background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 3px; }
.kbd { font-family: ui-monospace, Menlo, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; font-size: .8em; background: var(--surface); }

/* ---- đáp ứng ---- */
@media (max-width: 1100px) { .layout2 { grid-template-columns: 1fr; } .sidecol { position: static; } .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 880px) {
  #app { grid-template-columns: 1fr; }
  #side { position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: min(84vw, 300px); transform: translateX(-102%); transition: transform .25s; box-shadow: var(--shadow); }
  body.menu-open #side { transform: none; }
  body.menu-open::after { content: ''; position: fixed; inset: 0; background: rgba(10,15,18,.45); z-index: 55; }
  #top { padding: 8px 12px; }
  #top .menu { display: inline-grid; }
  #view { padding: 16px 14px 96px; }
  #tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  #tabbar a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px 6px; text-decoration: none; color: var(--ink2); font-size: .7rem; font-weight: 600; background: none; border: none; cursor: pointer; }
  #tabbar a .ic { font-size: 1.25rem; line-height: 1.2; }
  #tabbar a[aria-current="page"] { color: var(--brand); }
  .g3, .g4 { grid-template-columns: repeat(2, 1fr); }
  .heat-row { grid-template-columns: 1fr; gap: 4px; }
  h1 { font-size: 1.4rem; }
  .fc-face { padding: 20px 18px; }
  .thr { grid-template-columns: 1fr; }
  .chk { grid-template-columns: 1fr; gap: 6px; }
  .fhead { grid-template-columns: 1fr; }
  #toast { bottom: 76px; }
}
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .gauto { grid-template-columns: 1fr; } .stat .n { font-size: 1.6rem; } .rate button small { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } .fc-in { transition: none; } }
@media print {
  #side, #top, #tabbar, .no-print, #toast { display: none !important; }
  #app { display: block; } #view { max-width: none; padding: 0; }
  .card, .sec { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
  .sec:not([open]) .body { display: block; }
}

/* Bảng tra cứu: cuộn ngang trên màn hình hẹp thay vì bẻ chữ */
.tbl-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:8px 0}
.tbl-wrap table{min-width:680px}
.tbl-wrap td,.tbl-wrap th{min-width:70px}
@media print{.tbl-wrap{overflow:visible}.tbl-wrap table{min-width:0}}
