:root {
  --bg: #EEF2EC;          /* sage white — พื้นหลัง */
  --surface: #FFFFFF;
  --ink: #173326;         /* deep leaf — ตัวอักษร */
  --muted: #5B6F63;
  --line: #CFDACF;
  --leaf: #2E7A4E;        /* สีหลัก ปุ่ม/ลิงก์ */
  --leaf-soft: #DDEBDF;
  --grow: #B0357A;        /* แสงไฟ LED ปลูกพืช — ใช้กับแถบนำเข้าเท่านั้น */
  --grow-glow: rgba(176, 53, 122, .35);
  --warn: #A4510E;
  --warn-soft: #F7E7D6;
  --danger: #A12A2A;
  --danger-soft: #F6DEDC;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101A14; --surface: #17241C; --ink: #E3ECE5; --muted: #9AAEA1; --line: #2A3B30;
    --leaf: #6CC08D; --leaf-soft: #1F3527; --grow: #E46BB0; --grow-glow: rgba(228, 107, 176, .4);
    --warn: #E7A45F; --warn-soft: #3A2A18; --danger: #EE8A84; --danger-soft: #3B1F1D;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "IBM Plex Sans Thai", system-ui, sans-serif; line-height: 1.65;
  font-variant-numeric: tabular-nums;
}
a { color: var(--leaf); }
:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.75rem; line-height: 1.25; margin: 0 0 .25rem; font-weight: 600; }
h2 { font-size: 1.2rem; line-height: 1.35; margin: 0 0 .75rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 0 0 .4rem; font-weight: 600; }
p { margin: 0 0 .75rem; max-width: 72ch; }
.lead { color: var(--muted); margin-bottom: 1.75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* โครงหน้า: เมนูซ้าย + เนื้อหา */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.brand { display: flex; gap: .65rem; align-items: center; text-decoration: none; color: var(--ink); }
.brand svg { flex: none; }
.brand b { display: block; font-weight: 600; line-height: 1.2; }
.brand span { font-size: .8rem; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  text-decoration: none; color: var(--ink); padding: .5rem .75rem; border-radius: 8px;
}
.nav a:hover { background: var(--leaf-soft); }
.nav a[aria-current="page"] { background: var(--leaf-soft); color: var(--leaf); font-weight: 600; }
.side-foot { margin-top: auto; font-size: .85rem; color: var(--muted); }
.side-foot form { margin-top: .4rem; }
main { padding: 2.25rem 2.5rem 4rem; width: 100%; min-width: 0; max-width: 1760px; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-foot .who { display: block; color: var(--ink); text-decoration: none; font-weight: 600; word-break: break-all; }
.side-foot .tag { margin-top: .25rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.5rem; }
.split.wide { grid-template-columns: 2fr 1fr; }
@media (min-width: 1500px) { .split.dash { grid-template-columns: 1fr 1.6fr; } }

/* แท่งกราฟแนวนอน (ค่าเดียวต่อแถว สีเดียว ตัวเลขกำกับเสมอ) */
.bars { display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr auto; gap: .35rem .75rem; align-items: center; font-size: .9rem; }
.bars .lab { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .lab a { color: inherit; text-decoration: none; }
.bars .lab a:hover { text-decoration: underline; }
.bars .track { height: 14px; border-radius: 0 4px 4px 0; position: relative; }
.bars .fill { position: absolute; inset: 0 auto 0 0; background: var(--leaf); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .fill.dim { background: color-mix(in srgb, var(--leaf) 35%, var(--surface)); }
.bars .val { color: var(--muted); text-align: right; white-space: nowrap; }
/* แท่งแนวตั้งรายเดือน */
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; align-items: end; height: 160px;
  border-bottom: 1px solid var(--line); padding-top: 1.4rem; }
.cols div { position: relative; background: var(--leaf); border-radius: 4px 4px 0 0; min-height: 2px; }
.cols div span { position: absolute; bottom: 100%; left: 0; right: 0; text-align: center; font-size: .75rem; color: var(--muted); }
.cols-x { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; font-size: .75rem; color: var(--muted); text-align: center; }

.tag.warn { background: var(--warn-soft); color: var(--warn); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .25rem 1.5rem; margin: 0 0 1rem; }
.kv div { padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.kv dt { font-size: .8rem; color: var(--muted); }
.kv dd { margin: 0; }
details.help summary { cursor: pointer; color: var(--leaf); font-size: .9rem; }
.stage-list { margin: .5rem 0 0; padding: 0; list-style: none; font-size: .9rem; }
.stage-list li { padding: .45rem 0; border-top: 1px solid var(--line); }
.md { white-space: pre-wrap; font: inherit; font-size: .925rem; background: var(--bg); border-radius: 8px; padding: 1rem; margin: 0; }
tr.overdue td { background: var(--warn-soft); }

/* กล่องเนื้อหา */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
}
.panel > h2:first-child { margin-top: 0; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.row.top { align-items: flex-start; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* ตัวเลขสรุป: แถวเดียว คั่นเส้น ไม่ใช่การ์ดแยก */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); margin-bottom: 1.5rem; overflow: hidden; }
.figures div { padding: 1rem 1.25rem; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.figures b { display: block; font-size: 1.6rem; font-weight: 600; line-height: 1.2; }
.figures span { color: var(--muted); font-size: .875rem; }

/* ขั้นตอนเริ่มใช้งาน (เป็นลำดับจริง จึงมีหมายเลข) */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 2rem 1fr auto; gap: .75rem; align-items: center;
  padding: .7rem 0; border-top: 1px solid var(--line); counter-increment: s; }
.steps li:first-child { border-top: 0; }
.steps li::before { content: counter(s); width: 1.75rem; height: 1.75rem; border-radius: 50%;
  display: grid; place-items: center; font-size: .85rem; border: 1.5px solid var(--line); color: var(--muted); }
.steps li.done::before { content: "✓"; background: var(--leaf); border-color: var(--leaf); color: #fff; }
.steps li.done .t { color: var(--muted); }

/* ฟอร์ม */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input:not([type]), input[type=text], input[type=date], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .75rem;
}
textarea { min-height: 14rem; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--leaf); outline: 2px solid var(--leaf-soft); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: .55rem 1.1rem;
  border: 1px solid var(--leaf); background: var(--leaf); color: #fff; text-decoration: none; display: inline-block;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.quiet { background: transparent; color: var(--leaf); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.link { background: none; border: 0; color: var(--muted); padding: 0; font-weight: 400; text-decoration: underline; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ตาราง */
table { width: 100%; border-collapse: collapse; font-size: .925rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem; padding: .5rem .6rem;
  border-bottom: 1px solid var(--line); }
td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; }

.tag { display: inline-block; font-size: .8rem; padding: .05rem .55rem; border-radius: 999px;
  background: var(--leaf-soft); color: var(--leaf); white-space: nowrap; }
.tag.new, .tag.changed, .tag.expired { background: var(--warn-soft); color: var(--warn); }
.tag.missing, .tag.revoked, .tag.err { background: var(--danger-soft); color: var(--danger); }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--leaf-soft); }
.flash.error { background: var(--danger-soft); color: var(--danger); }

/* URL ของ key ที่เพิ่งออก — แสดงครั้งเดียว */
.once { border: 2px solid var(--leaf); }
.copy { display: flex; gap: .5rem; }
.copy input { font-size: .9rem; }

/* แถบนำเข้า: ชั้นวางถาดปลูกที่ไฟ LED ติดทีละช่อง — จุดเด่นเดียวของหน้า */
.shelf { display: grid; grid-template-columns: repeat(var(--cells, 40), 1fr); gap: 3px; margin: .75rem 0 .5rem;
  padding: 6px; border-radius: 8px; background: var(--ink); }
.shelf i { height: 14px; border-radius: 2px; background: color-mix(in srgb, var(--surface) 14%, transparent); }
.shelf i.on { background: var(--grow); box-shadow: 0 0 8px var(--grow-glow); }
@media (prefers-reduced-motion: no-preference) {
  .shelf i.on { transition: background .4s, box-shadow .4s; }
}
.joblog { background: var(--bg); border-radius: 8px; padding: .75rem 1rem; max-height: 16rem; overflow: auto;
  font: inherit; font-size: .85rem; white-space: pre-wrap; margin: 0; }

/* ผลค้นหา */
.result { padding: .9rem 0; border-top: 1px solid var(--line); }
.result:first-child { border-top: 0; padding-top: 0; }
.result h3 { margin-bottom: .2rem; }
.fact { padding: .35rem 0; }
.topic { padding: .75rem 0; border-top: 1px solid var(--line); }
.topic:first-of-type { border-top: 0; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .panel { width: 100%; max-width: 400px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 1rem; gap: .75rem; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 0; }
  main { padding: 1.5rem 1rem 3rem; }
  .side { position: static; height: auto; }
  .split, .split.wide, .split.dash { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .bars { grid-template-columns: minmax(7rem, 45%) 1fr auto; }
  .bars .lab { white-space: normal; }
  .steps li { grid-template-columns: 2rem 1fr; }
  .steps li .go { grid-column: 2; }
}

/* ── แพลตฟอร์ม: กลุ่มเมนู + แถบ staging ─────────────────────────────── */
.nav-group { margin: .9rem .6rem .25rem; font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); }
.nav-group:first-child { margin-top: 0; }
.nav a .tag { margin-left: .3rem; }
.staging-bar { position: relative; z-index: 50; background: var(--warn); color: #fff; text-align: center;
  font-size: .85rem; font-weight: 600; padding: .35rem 1rem; }
@media (max-width: 900px) { .nav-group { width: 100%; margin: .4rem 0 0; } }
.inline-ctl { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.inline-ctl > select, .inline-ctl > input { width: auto; min-width: 0; }
.inline-ctl > select:first-child, .inline-ctl > input:first-child { flex: 1 1 12rem; }
.inline-ctl > input:last-child { flex: 0 1 6.5rem; }
.nav a { padding-top: .38rem; padding-bottom: .38rem; }

/* ── รายการคน / key / หัวหน้า ─────────────────────────────── */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.page-head .lead { margin-bottom: 1.25rem; }
.actions { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
.panel.narrow { max-width: 40rem; }
.sub { margin: 1.25rem 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.panel h3.sub:first-of-type { margin-top: .25rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.danger-text { color: var(--danger) !important; }

.chip { display: inline-block; font-size: .78rem; padding: .1rem .55rem; border-radius: 6px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.chip.manager { background: var(--leaf); border-color: var(--leaf); color: var(--surface); }
.chip.operator { background: var(--leaf-soft); border-color: transparent; color: var(--leaf); }
.chip.global { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip.none { color: var(--muted); border-style: dashed; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }

.avatar { width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--leaf-soft); color: var(--leaf); font-weight: 600; }
.avatar.lg { width: 3.25rem; height: 3.25rem; font-size: 1.3rem; }
.user-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.25rem; }
.user-head h1 { margin: 0; }

.user-list, .key-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.user-list > li { border-top: 1px solid var(--line); }
.user-list > li:first-child { border-top: 0; }
.user-row { display: grid; grid-template-columns: auto 17rem 1fr auto auto; gap: 1rem; align-items: center;
  padding: .75rem .5rem; color: var(--ink); text-decoration: none; border-radius: 8px; }
.user-row:hover { background: var(--bg); }
.user-row .who, .key-row .who { display: flex; flex-direction: column; min-width: 0; }
.user-row .who .small, .key-row .who .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .go { color: var(--muted); font-size: 1.3rem; }
.user-row.off, .key-row.off { opacity: .6; }

.group-head { display: flex; gap: .5rem; align-items: center; margin: 1.5rem 0 0; padding-bottom: .4rem;
  border-bottom: 2px solid var(--line); }
.filter + .group-head { margin-top: 1rem; }
.key-row { display: grid; grid-template-columns: minmax(12rem, 1fr) 2fr auto; gap: 1rem; align-items: center;
  padding: .7rem .25rem; border-bottom: 1px solid var(--line); }
.key-row:last-child { border-bottom: 0; }
.key-row .meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.howto { margin: .75rem 0 0; padding-left: 1.2rem; }

details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 14rem; display: flex;
  flex-direction: column; gap: .1rem; padding: .4rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / .12); }
.menu-pop a, .menu-pop .btn.link { display: block; text-align: left; padding: .45rem .6rem; border-radius: 6px;
  text-decoration: none; color: var(--ink); font-size: .9rem; width: 100%; }
.menu-pop a:hover, .menu-pop .btn.link:hover { background: var(--bg); }

.role-row { display: grid; grid-template-columns: 1fr 10rem auto; gap: .75rem; align-items: center;
  padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.role-row.add { grid-template-columns: 1fr 10rem; border-bottom: 0; }
.role-row .role-dept { min-width: 0; }
.toggle-row { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem 0; font-weight: 400; cursor: pointer; }
.toggle-row input { width: auto; margin-top: .3rem; }
.toggle-row > span { display: flex; flex-direction: column; }

@media (max-width: 820px) {
  .user-row { grid-template-columns: auto 1fr auto; }
  .user-row .chips { grid-column: 2 / -1; }
  .user-row .state { grid-column: 2 / -1; }
  .user-row .go { grid-row: 1; grid-column: 3; }
  .key-row { grid-template-columns: 1fr auto; }
  .key-row .meta { grid-column: 1 / -1; grid-row: 2; }
  .role-row, .role-row.add { grid-template-columns: 1fr; }
}

/* ตารางกว้างบนมือถือ: เลื่อนแนวนอนในกรอบ คอลัมน์แรกค้างไว้ ไม่บีบจนอ่านไม่ออก */
.table-wrap { -webkit-overflow-scrolling: touch; }
td.id, th.id { white-space: nowrap; }
@media (max-width: 820px) {
  .figures { grid-template-columns: 1fr 1fr; }
  .table-wrap { margin: 0 -1rem; padding: 0 1rem; background:
    linear-gradient(to left, var(--surface), var(--surface)) left / 1rem 100% no-repeat local,
    radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / .14), transparent) right / .6rem 100% no-repeat scroll; }
  .table-wrap > table { min-width: 680px; }
  .table-wrap > table.fit { min-width: 0; }
  .table-wrap > table:not(.fit) td:first-child, .table-wrap > table:not(.fit) th:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
}
.stage-chips { margin: .75rem 0; gap: .4rem; }
.stage-chips .chip { text-decoration: none; padding: .3rem .7rem; font-size: .85rem; }
.stage-chips .chip:hover { border-color: var(--leaf); }
.mail-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.mail-list li { display: grid; grid-template-columns: 9rem 1fr auto; gap: 1rem; align-items: start; padding: .7rem 0;
  border-top: 1px solid var(--line); }
.mail-list li:first-child { border-top: 0; }
.mail-list .what { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 820px) {
  .mail-list li { grid-template-columns: 1fr auto; gap: .2rem .75rem; }
  .mail-list .when { grid-column: 1; }
  .mail-list .what { grid-column: 1 / -1; grid-row: 2; }
  .mail-list li > div:last-child { grid-column: 2; grid-row: 1; }
}
tr.muted-row td { color: var(--muted); }

/* เมนูข้าง: เดสก์ท็อปแสดงตลอด มือถือพับเป็นปุ่ม "เมนู" */
.side-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.side-menu { display: flex; flex-direction: column; gap: 1.5rem; flex: 1; }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: inline-block; }
  .side-menu { display: none; }
  .side.open .side-menu { display: flex; gap: .75rem; }
  .nav { gap: 2px 4px; }
  .page-head { margin-bottom: .5rem; }
  .page-head > .btn, .page-head > form { margin-bottom: .75rem; }
}

/* กันหน้าล้นจอ: คอลัมน์ grid หดได้ ข้อความยาวไม่มีช่องว่างตัดบรรทัดได้ */
.split > *, .grid3 > * { min-width: 0; }
td { overflow-wrap: anywhere; }
td.num, th.num { overflow-wrap: normal; white-space: nowrap; }
code { overflow-wrap: anywhere; }

/* ช่องเลือกไฟล์ให้เข้ากับปุ่มอื่น */
input[type=file] { font: inherit; font-size: .9rem; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; color: var(--leaf); background: transparent;
  border: 1.5px solid var(--leaf); border-radius: 8px; padding: .45rem .9rem; margin-right: .75rem; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--leaf-soft); }
.req { padding: 1rem 0; border-top: 1px solid var(--line); }
.panel > h2 + .req { border-top: 0; padding-top: .25rem; }
.req-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.req-head .chip { margin-right: .25rem; }
.req details { margin-top: .5rem; }
.req-act { margin-top: .75rem; align-items: center; }
.callout { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.25rem; margin-bottom: 1.5rem; border-radius: var(--radius);
  background: var(--warn-soft); color: var(--warn); text-decoration: none; font-weight: 600; }
.callout b { font-size: 1.4rem; }
.callout span { margin-left: auto; }
.callout:hover { filter: brightness(.97); }
a.figures > *, .figures > a { color: inherit; text-decoration: none; }
.figures > a { padding: 1rem 1.25rem; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.figures > a:hover { background: var(--leaf-soft); }
.figures > a span { color: var(--leaf); }
/* ระดับความลับเอกสาร — สีต่างกันชัด */
.cls { display: inline-block; font-size: .78rem; padding: .05rem .55rem; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.cls.public { border-color: var(--leaf); color: var(--leaf); }
.cls.internal { background: var(--leaf-soft); color: var(--leaf); }
.cls.restricted { background: var(--warn-soft); color: var(--warn); }
.cls.confidential { background: var(--danger-soft); color: var(--danger); }
.dept-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .2rem .75rem; }
.doc-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1.5rem; margin: 0 0 1.5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1.25rem; }
.doc-kv div { border-bottom: 0; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-size: .9rem; }
/* กฎ policy: แถวละกฎ มือถือซ้อนเป็นการ์ด */
.rules { display: flex; flex-direction: column; }
.rule { display: grid; grid-template-columns: 3.2rem minmax(12rem, 1.4fr) 11rem minmax(14rem, 1.6fr) 4rem; gap: .6rem; align-items: center;
  padding: .55rem 0; border-bottom: 1px solid var(--line); }
.rule.head { padding-top: 0; }
.rule.new { background: var(--leaf-soft); border-radius: 8px; padding: .55rem .5rem; }
.rule .mv { display: flex; gap: .2rem; }
.rule .mv .btn { text-decoration: none; font-size: 1.05rem; padding: 0 .2rem; }
.rule select, .rule input[type=text] { min-width: 0; }
.rule-ro { list-style: none; padding: 0; margin: 0; }
.rule-ro li { padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.tool-list { list-style: none; padding: 0; margin: 0; }
.tool-list li { display: grid; grid-template-columns: 1.6rem 1fr; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.tool-list li.off { opacity: .55; }
.tool-list .mark { color: var(--leaf); font-weight: 700; }
.page-head > form select { min-width: 16rem; }
@media (max-width: 820px) {
  .rule { grid-template-columns: 1fr 1fr; padding: .75rem 0; }
  .rule.head { display: none; }
  .rule .mv { grid-column: 2; grid-row: 1; justify-content: flex-end; }
  .rule > select[data-rule-action] { grid-column: 1 / -1; grid-row: 2; }
  .rule .lvl { grid-column: 1 / -1; }
  .rule .cond { grid-column: 1 / -1; }
  .page-head > form, .page-head > form select { width: 100%; min-width: 0; }
}
.audit-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.audit-list li { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem; padding: .65rem 0; border-top: 1px solid var(--line); }
.audit-list .what { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 820px) { .audit-list li { grid-template-columns: 1fr; gap: .15rem; } }
.toc { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.75rem 0 1.5rem; }
.toc a { padding: .3rem .75rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); text-decoration: none; }
.toc a:hover { border-color: var(--leaf); }
.radio-opt { align-items: flex-start; margin-bottom: .5rem; }
.radio-opt input { margin-top: .3rem; width: auto; }
section[id] { scroll-margin-top: 1rem; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  padding: 3px; gap: 2px; margin-bottom: 1.25rem; }
.seg a { padding: .35rem .9rem; border-radius: 999px; text-decoration: none; color: var(--ink); font-size: .9rem; }
.seg a[aria-current] { background: var(--leaf); color: var(--surface); }
.seg a b { font-weight: 600; margin-left: .2rem; }
details.overview-fold > summary { cursor: pointer; list-style: none; }
details.overview-fold > summary::-webkit-details-marker { display: none; }
details.overview-fold > summary h2::after { content: " ▾"; color: var(--muted); font-size: .9rem; }
details.overview-fold[open] > summary h2::after { content: " ▴"; }
@media (max-width: 820px) { .hide-sm { display: none; } }
