/* Layout: กระดานคิว ER (แถบตัวเลขบาง → รายชื่อแบบย่อ/การ์ด) + แผ่นประเมินเต็มจอ ทีละขั้นหรือหน้าเดียว */
:root {
  --brand: #0d6a4e; --brand-2: #0a5640; --brand-ink: #ffffff;
  --bg: #f1f5f2; --surface: #ffffff; --surface-2: #e8efea; --line: #d3ddd7;
  --fg: #14211b; --muted: #55665e; --focus: #1f6fd6;

  /* สีระดับตามโปสเตอร์ ปรับให้ตัวอักษรขาวอ่านได้ (≥ 4.5:1) */
  --l1: #c62828; --l1-ink: #ffffff; --l1-soft: #fdeaea; --l1-text: #a51d1d;
  --l2: #c2410c; --l2-ink: #ffffff; --l2-soft: #ffeedd; --l2-text: #9a3412;
  --l3: #f0b400; --l3-ink: #2f2400; --l3-soft: #fff6d1; --l3-text: #6b5000;
  --l4: #1e7a46; --l4-ink: #ffffff; --l4-soft: #e2f4e8; --l4-text: #17643a;
  --l5: #1f5fc4; --l5-ink: #ffffff; --l5-soft: #e6effc; --l5-text: #1a4fa3;
  --iso: #6f42b0; --iso-ink: #ffffff; --iso-soft: #efe7fa;
  --warn: #9a4a06; --warn-soft: #fff1dc; --warn-line: #d9822b;

  --font-body: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  --font-display: "Bai Jamjuree", "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(10, 40, 28, .06), 0 4px 14px rgba(10, 40, 28, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #13845f; --brand-2: #0f6e50; --bg: #0d1411; --surface: #151f1a; --surface-2: #1d2a23; --line: #2c3b33;
    --fg: #e5eee9; --muted: #a3b5ab; --focus: #6aa8ff;
    --l1-soft: #3b1718; --l2-soft: #3a2210; --l3-soft: #352b08; --l4-soft: #12301f; --l5-soft: #142640; --iso-soft: #2a1e3d;
    --l1-text: #ff9a9a; --l2-text: #ffb27a; --l3-text: #f5d36a; --l4-text: #7fe0a6; --l5-text: #9cc2ff;
    --warn: #f2a65a; --warn-soft: #36250f; --warn-line: #b8711f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #13845f; --brand-2: #0f6e50; --bg: #0d1411; --surface: #151f1a; --surface-2: #1d2a23; --line: #2c3b33;
  --fg: #e5eee9; --muted: #a3b5ab; --focus: #6aa8ff;
  --l1-soft: #3b1718; --l2-soft: #3a2210; --l3-soft: #352b08; --l4-soft: #12301f; --l5-soft: #142640; --iso-soft: #2a1e3d;
  --l1-text: #ff9a9a; --l2-text: #ffb27a; --l3-text: #f5d36a; --l4-text: #7fe0a6; --l5-text: #9cc2ff;
  --warn: #f2a65a; --warn-soft: #36250f; --warn-line: #b8711f;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
body.big { zoom: 1.15; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 50; background: var(--brand); }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap.narrow { max-width: 760px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.row.nowrap { flex-wrap: nowrap; }
.row.between { justify-content: space-between; }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }

/* ---------- ปุ่ม ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-align: center; line-height: 1.2; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--l1); border-color: var(--l1); color: var(--l1-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 15px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.iconbtn { width: 44px; height: 44px; flex: none; border-radius: 12px; border: 0; background: transparent; display: inline-grid; place-items: center; color: inherit; }
.iconbtn:hover { background: rgba(127,127,127,.16); }
.iconbtn svg { width: 22px; height: 22px; }
.linkish { all: unset; cursor: pointer; display: grid; gap: 2px; min-width: 0; }
.linkish:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.linkish.inline { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }

/* ---------- ส่วนหัว ---------- */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--brand); color: var(--brand-ink); }
.top .wrap { display: flex; align-items: center; gap: 6px; min-height: 60px; padding-block: 6px; }
.logo { width: 38px; height: 38px; flex: none; }
.top h1 { font-family: var(--font-display); font-size: 18px; line-height: 1.15; margin: 0; font-weight: 700; white-space: nowrap; }
.top h1 .h1sub { font-family: var(--font-body); font-weight: 500; font-size: 13px; opacity: .9; margin-left: 4px; }
@media (max-width: 560px) { .top h1 .h1sub { display: none; } }
.top .sub { font-size: 13px; opacity: .92; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .title { flex: 1; min-width: 0; margin-left: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #7cf0b0; display: inline-block; flex: none; }
.dot.off { background: #ffc46b; } .dot.demo { background: #ffffff; } .dot.practice { background: #d7b8ff; }
.top .newbtn { display: none; background: #ffffff; color: var(--brand); border-color: #ffffff; }
@media (min-width: 760px) { .top .newbtn { display: inline-flex; } }
.menu { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); top: 58px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; min-width: 260px; z-index: 30; max-height: calc(100vh - 80px); overflow-y: auto; }
.menu button, .menu label { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; min-height: 46px; padding: 0 12px; border: 0; background: transparent; border-radius: 10px; }
.menu button:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .who { padding: 8px 12px; font-size: 14px; color: var(--muted); }
.menu select { margin-left: auto; min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 0 8px; }

/* ---------- แถบแจ้ง ---------- */
.banners { display: grid; gap: 8px; }
.banners:empty { display: none; }
.banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--fg); border: 1px solid var(--line); font-size: 15px; }
.banner b { color: var(--warn); }
button.banner { width: 100%; text-align: left; justify-content: space-between; }
button.banner.nursebar { border: 2px solid var(--warn-line); min-height: 48px; }
button.banner.nursebar[aria-pressed="true"] { background: var(--warn); color: #ffffff; }
button.banner.nursebar[aria-pressed="true"] b { color: #ffffff; }
.banner.practicebar { background: var(--iso-soft); border: 2px solid var(--iso); }
.banner.practicebar b { color: var(--iso); }
.banner.practicebar .btn { margin-left: auto; }

/* ---------- ตัวเลขตามระดับ (แถวเดียว) ---------- */
.board { padding-block: 12px 120px; display: grid; gap: 12px; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.tile { border: 0; border-radius: 12px; padding: 6px 4px; text-align: center; display: grid; gap: 0; min-height: 64px; align-content: center; background: var(--c); color: var(--ci); box-shadow: var(--shadow); }
.tile .n { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.05; }
.tile .k { font-size: 12.5px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .w { font-size: 12px; opacity: .95; }
.tile[aria-pressed="true"] { outline: 3px solid var(--fg); outline-offset: 2px; }
.tile.zero { opacity: .5; }
@media (min-width: 760px) { .tiles { gap: 10px; } .tile { min-height: 84px; padding: 10px 12px; text-align: left; } .tile .n { font-size: 32px; } .tile .k { font-size: 14px; } }

.filters { display: grid; gap: 8px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; flex: 1; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; }
.tab[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tab .c { opacity: .75; margin-left: 5px; }
.viewbtn { border: 1px solid var(--line); background: var(--surface); }
.search { position: relative; }
.search input { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px 0 42px; font-size: 16px; }
.search svg { position: absolute; left: 13px; top: 13px; width: 20px; height: 20px; color: var(--muted); }

/* ---------- รายชื่อแบบย่อ ---------- */
.list.rows { display: grid; gap: 6px; }
.prow { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; min-height: 64px; padding: 8px 12px 8px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.prow:hover { background: var(--surface-2); }
.prow .plv { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--c); color: var(--ci); font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.prow .pmain { display: grid; min-width: 0; gap: 1px; }
.prow .pname { font-weight: 700; font-size: 16.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .psub { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .pflags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.prow .pside { display: grid; justify-items: end; gap: 4px; }
.prow .ptime { font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.prow .ptime.late { color: var(--l1-text); }
.prow.flash { animation: flash 1.6s ease-out 2; }

/* ---------- การ์ด ---------- */
.list.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
@media (max-width: 380px) { .list.cards { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; grid-template-columns: 8px 1fr; overflow: hidden; min-width: 0; }
.card .stripe { background: var(--c); }
.card .body { padding: 12px 14px; display: grid; gap: 8px; min-width: 0; }
.card.flash { animation: flash 1.6s ease-out 2; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--c); } 100% { box-shadow: var(--shadow); } }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 14px; font-weight: 700; background: var(--c); color: var(--ci); white-space: nowrap; }
.pill.tiny { min-height: 22px; padding: 0 7px; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 9px; border-radius: 8px; font-size: 14px; background: var(--surface-2); color: var(--fg); white-space: nowrap; }
.chip.bad { background: var(--l1-soft); color: var(--l1-text); font-weight: 700; }
.chip.iso { background: var(--iso); color: var(--iso-ink); font-weight: 600; }
.chip.nurse { background: var(--warn-soft); color: var(--warn); font-weight: 700; border: 1px solid var(--warn-line); }
.chip.nurse.late { background: var(--l1); color: #ffffff; border-color: var(--l1); }
.chip.nurse-ok { background: var(--l4-soft); color: var(--l4-text); font-weight: 700; }
.chip.ovr { background: var(--l5-soft); color: var(--l5-text); font-weight: 600; }
.chip.st-waiting { background: var(--l3-soft); color: var(--l3-text); }
.chip.st-treating { background: var(--l5-soft); color: var(--l5-text); }
.chip.st-referred { background: var(--iso-soft); }
.chip.st-discharged { background: var(--l4-soft); color: var(--l4-text); }
.name { font-weight: 700; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.en { font-size: 13px; color: var(--muted); }
.why { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.timer { display: grid; gap: 4px; }
.timer .t { font-size: 15px; font-weight: 700; }
.timer .t.late { color: var(--l1-text); }
.bar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--c); border-radius: 6px; }
.bar.late i { background: var(--l1); }
.card .actions { display: flex; gap: 8px; }
.card .actions .btn { flex: 1; min-height: 46px; padding: 0 8px; white-space: nowrap; font-size: 15px; }
.btn.nursebtn { width: 100%; min-height: 48px; background: var(--warn-soft); border: 2px solid var(--warn-line); color: var(--fg); }
.pending { font-size: 13px; color: var(--warn); }
.empty { grid-column: 1 / -1; text-align: center; padding: 40px 16px; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); display: grid; gap: 12px; justify-items: center; }
.empty b { font-size: 18px; color: var(--fg); }

/* ---------- ปุ่มลอย ---------- */
.fab svg { width: 24px; height: 24px; }
.fab { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); min-height: 60px; padding: 0 26px; border-radius: 999px; font-size: 18px; box-shadow: 0 8px 24px rgba(13,106,78,.35); width: min(420px, calc(100% - 32px)); }
@media (min-width: 760px) { .fab { display: none; } }

/* ---------- แผ่นซ้อนเต็มจอ ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: grid; grid-template-rows: auto auto 1fr auto; padding-top: env(safe-area-inset-top, 0px); }
.sheet-head { background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-head .wrap { display: flex; align-items: center; gap: 6px; min-height: 58px; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: 19px; flex: 1; min-width: 0; }
.sheet-sub { background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-sub:empty { display: none; }
.sheet-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-scroll .wrap { max-width: 760px; padding-block: 16px 28px; display: grid; gap: 16px; }
.sheet-foot { background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.sheet-foot .wrap { max-width: 760px; display: flex; gap: 10px; padding-block: 10px; }
.sheet-foot .btn { flex: 1; min-height: 54px; font-size: 17px; }
.sheet-foot .btn.back { flex: 0 0 auto; min-width: 96px; }
.sheet-foot .delbtn { color: var(--l1-text); }
.sheet-foot .wrap > .btn { white-space: nowrap; }
@media (max-width: 480px) { .sheet-foot .wrap { gap: 6px; } .sheet-foot .btn { font-size: 15px; padding: 0 8px; } .sheet-foot .btn.back { min-width: 0; } }
.modebtn { min-height: 40px; font-size: 14px; border: 1px solid var(--line) !important; }
.confirmbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; width: 100%; }
.confirmbar .btn { min-width: 110px; }

.steps { display: flex; gap: 4px; padding-block: 8px; }
.steps i { flex: 1; height: 5px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--brand); }
.steps i.done { background: var(--brand); opacity: .45; }
.stepinfo { font-size: 13.5px; color: var(--muted); padding-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 30px; }
.wrap.narrow.stepinfo { padding-top: 8px; }

.wsec { display: grid; gap: 14px; }
.wsec + .wsec { border-top: 2px dashed var(--line); padding-top: 18px; }
.q h3 { font-family: var(--font-display); font-size: 22px; line-height: 1.25; margin: 0 0 4px; text-wrap: balance; }
.q p { margin: 0; color: var(--muted); }
.optend { height: 1px; }

.opts { display: grid; gap: 6px; }
.opt { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 12px; text-align: left; min-height: 56px; padding: 8px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); }
.opt .ck { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--muted); display: grid; place-items: center; }
.opt .ck svg { width: 18px; height: 18px; opacity: 0; color: #fff; }
.opt .p { font-size: 16.5px; font-weight: 600; line-height: 1.35; display: block; }
.opt .m { font-size: 13px; color: var(--muted); display: block; line-height: 1.3; }
.opt[aria-pressed="true"] { border-color: var(--c, var(--brand)); background: var(--cs, var(--surface-2)); }
.opt[aria-pressed="true"] .ck { background: var(--c, var(--brand)); border-color: var(--c, var(--brand)); }
.opt[aria-pressed="true"] .ck svg { opacity: 1; }
.opt.lv3[aria-pressed="true"] .ck svg { color: var(--l3-ink); }
.opt.unsure { border-style: dashed; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); max-width: 100%; }
.seg button { min-height: 48px; padding: 0 16px; border: 0; background: transparent; font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.seg.fill { display: flex; }
.seg.fill button { flex: 1; padding: 0 8px; }
.seg.wrapseg { display: flex; flex-wrap: wrap; }
.seg.wrapseg button { flex: 1 1 auto; border-bottom: 1px solid var(--line); }
.seg.statusseg { display: flex; flex-wrap: wrap; }
.seg.statusseg button { flex: 1 1 40%; }
.seg.lvseg { display: flex; }
.seg.lvseg button { flex: 1; font-size: 20px; font-family: var(--font-display); }
.seg.lvseg button[aria-pressed="true"] { background: var(--c); color: var(--ci); }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-weight: 600; font-size: 15px; }
.field small { color: var(--muted); font-size: 13px; }
.input { width: 100%; min-width: 0; max-width: 100%; min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); padding: 0 14px; font-size: 18px; }
.input.small { min-height: 44px; font-size: 15px; }
textarea.input { min-height: 88px; padding: 10px 14px; font-size: 16px; resize: vertical; }
select.input { font-size: 16px; }
input[type=date].input { font-size: 16px; padding: 0 10px; -webkit-appearance: none; appearance: none; display: block; }
.input:focus { border-color: var(--focus); outline: none; }
.input.pin { font-size: 28px; letter-spacing: .4em; text-align: center; font-family: var(--font-display); }
.input.agein { max-width: 120px; text-align: center; font-size: 22px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 620px) { .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.scanbtn { border: 2px solid var(--line); height: 52px; width: 52px; }
.scanner { display: grid; gap: 8px; }
.scanner video { width: 100%; max-height: 260px; border-radius: 12px; background: #000; object-fit: cover; }

.vital { display: grid; gap: 6px; padding: 12px; border-radius: 14px; background: var(--surface); border: 2px solid var(--line); min-width: 0; }
.vital.bad { border-color: var(--l1); background: var(--l1-soft); }
.vital.crit { border-color: var(--l1); background: var(--l1-soft); box-shadow: inset 0 0 0 2px var(--l1); }
.vital.implausible { border-color: var(--warn-line); background: var(--warn-soft); border-style: dashed; }
.vital.implausible .flag { color: var(--warn); }
.vital .lab { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-weight: 700; }
.vital .lab em { font-style: normal; font-weight: 500; font-size: 13px; color: var(--muted); }
.vital input:not([type=checkbox]) { width: 100%; min-height: 50px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); text-align: center; font-size: 22px; font-weight: 700; font-family: var(--font-display); }
.vital .bp { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.vital .bp b { font-size: 22px; }
.vital .hint { font-size: 12.5px; color: var(--muted); }
.vital .flag { font-size: 13.5px; font-weight: 700; color: var(--l1-text); min-height: 1em; }
.vital .o2 { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 36px; }
.vital .o2 input { width: 22px; height: 22px; }
.childq { padding: 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); }

.pain { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; }
.pain button { min-height: 50px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; font-size: 17px; padding: 0; }
.pain button[aria-pressed="true"] { background: var(--pc); border-color: var(--pc); color: #fff; }
.pain-scale { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }

.alertbox { border-radius: 14px; padding: 14px 16px; background: var(--c); color: var(--ci); display: grid; gap: 4px; }
.alertbox b { font-size: 19px; font-family: var(--font-display); }

/* ---------- ผลการประเมิน ---------- */
.result { border-radius: 18px; padding: 18px; background: var(--c); color: var(--ci); display: grid; gap: 6px; }
.result .lv { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.result .big { font-family: var(--font-display); font-size: 56px; line-height: 1; font-weight: 700; }
.result .nm { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1.1; }
.result .en2 { font-size: 14px; opacity: .92; }
.result .tg { font-size: 18px; font-weight: 700; }
.result .ovrnote { font-size: 14.5px; font-weight: 600; background: rgba(0,0,0,.14); border-radius: 8px; padding: 6px 10px; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 8px; min-width: 0; }
.box h4 { margin: 0; font-size: 15px; letter-spacing: .02em; color: var(--muted); font-weight: 700; }
.box ol, .box ul { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.box ul.plain { padding-left: 0; }
.box li { overflow-wrap: anywhere; }
.box.todo { border: 2px solid var(--c); }
.box.todo li { font-size: 17px; font-weight: 600; }
.box.warn { background: var(--warn-soft); }
.box.nursebox { border: 2px solid var(--warn-line); background: var(--warn-soft); }
.box.ovbox { border: 2px solid var(--l5); }
ul.reasons { list-style: none; padding: 0; }
.reason .lvtag { display: inline-block; min-width: 24px; text-align: center; border-radius: 6px; font-size: 13px; font-weight: 700; padding: 0 5px; margin-right: 6px; background: var(--c); color: var(--ci); }
.err { color: var(--l1-text); font-weight: 600; font-size: 15px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.hist { display: grid; gap: 8px; font-size: 14.5px; }
.hist div { display: grid; grid-template-columns: 56px 1fr; gap: 10px; }
.hist time { color: var(--muted); }
.tablewrap { overflow-x: auto; }
table.vtable, table.peds { border-collapse: collapse; width: 100%; font-size: 14px; }
table.vtable th, table.vtable td, table.peds th, table.peds td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; white-space: nowrap; }
table.vtable th, table.peds th { background: var(--surface-2); }
.recheck { display: grid; gap: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.recheck h4 { color: var(--fg); }
.confirm { border: 2px solid var(--l1); border-radius: 14px; padding: 14px; display: grid; gap: 10px; background: var(--l1-soft); }

/* ---------- ผู้ใช้ ---------- */
.ulist { display: grid; gap: 6px; }
.urow { display: grid; grid-template-columns: 1fr minmax(120px, 170px) auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.urow > div { display: grid; min-width: 0; }
.urow.off { opacity: .55; }
@media (max-width: 420px) { .urow { grid-template-columns: 1fr auto; } .urow select { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- เข้าสู่ระบบ / ล็อก ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding-block: 24px; background: linear-gradient(180deg, var(--brand) 0 38%, var(--bg) 38%); }
.login .card2 { width: min(440px, 100%); background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); padding: 24px; display: grid; gap: 16px; }
.login .brandline { display: flex; gap: 12px; align-items: center; }
.login .brandline .logo { width: 52px; height: 52px; }
.login h1 { margin: 0; font-family: var(--font-display); font-size: 24px; line-height: 1.2; }
.login h2 { font-family: var(--font-display); font-size: 20px; }
.login .note { font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.lockscr { position: fixed; inset: 0; z-index: 45; overflow-y: auto; }

/* ---------- สัญญาณเตือนเต็มจอ ---------- */
.alarm { position: fixed; inset: 0; z-index: 60; background: var(--c); color: var(--ci); display: grid; place-items: center; text-align: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.alarm .in { display: grid; gap: 14px; max-width: 560px; justify-items: center; }
.alarm .big { font-family: var(--font-display); font-size: clamp(40px, 12vw, 84px); line-height: 1; font-weight: 700; }
.alarm .msg { font-size: clamp(22px, 5.5vw, 32px); font-weight: 700; line-height: 1.25; text-wrap: balance; }
.alarm .who { font-size: 18px; opacity: .95; }
.alarm .btn { background: #fff; color: #111; border-color: #fff; min-height: 64px; font-size: 20px; padding: 0 40px; }
.alarm.pulse { animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.2); } }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 55; left: 0; right: 0; top: calc(66px + env(safe-area-inset-top, 0px)); display: grid; justify-items: center; gap: 8px; pointer-events: none; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.toast { pointer-events: auto; background: var(--fg); color: var(--bg); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 520px; width: 100%; display: flex; gap: 8px; align-items: center; font-size: 15px; }
.toast > span { flex: 1; min-width: 0; }
.toast.late { background: var(--l1); color: #fff; }
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 8px; min-height: 40px; padding: 0 12px; font-weight: 600; flex: none; }

/* ---------- ตารางเกณฑ์ ---------- */
.crit-level { border-left: 8px solid var(--c); }
.crit-level h4 { color: var(--fg); font-size: 16px; }

.lv1 { --c: var(--l1); --ci: var(--l1-ink); --cs: var(--l1-soft); }
.lv2 { --c: var(--l2); --ci: var(--l2-ink); --cs: var(--l2-soft); }
.lv3 { --c: var(--l3); --ci: var(--l3-ink); --cs: var(--l3-soft); }
.lv4 { --c: var(--l4); --ci: var(--l4-ink); --cs: var(--l4-soft); }
.lv5 { --c: var(--l5); --ci: var(--l5-ink); --cs: var(--l5-soft); }
.lviso { --c: var(--iso); --ci: var(--iso-ink); --cs: var(--iso-soft); }

@media (prefers-reduced-motion: reduce) { .alarm.pulse, .card.flash, .prow.flash { animation: none; } }

/* ---------- ปรับปรุง 2026-10-29: ใช้ง่ายขึ้นบนมือถือ ---------- */
.req { color: var(--l1); }
.seg.agegrp { display: flex; flex-wrap: wrap; margin-top: 8px; width: 100%; }
.seg.agegrp button { flex: 1 1 30%; min-height: 46px; padding: 0 6px; font-size: 14.5px; border-bottom: 1px solid var(--line); }
.box.ctx { border: 2px solid var(--c, #b45309); }
.box.ctx.lv1 { background: var(--cs); }
.banner.howto { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; text-align: left; }
.banner.howto ol { margin: 6px 0; padding-left: 22px; }
.stepinfo .pill { font-size: 15px; padding: 4px 12px; }
@media (max-width: 559px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile .k { white-space: normal; font-size: 13px; }
  .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; }
  .tab { padding: 4px 2px; font-size: 13.5px; line-height: 1.15; min-height: 52px; border-radius: 14px; }
  .tab .c { display: block; margin: 2px 0 0; }
  .pain { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .pain button { min-height: 52px; font-size: 19px; }
  .pain-scale { display: none; }
  .banner.howto { flex-direction: column; }
}
