/* RxAlert — modern dashboard styles */
:root {
  color-scheme: light;
  --font: 'IBM Plex Sans Thai', 'Leelawadee UI', 'Segoe UI', system-ui, sans-serif;
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --border: rgba(15, 23, 42, .08);
  --border-strong: rgba(15, 23, 42, .14);
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8a94a6;
  --grid: #e7ebf1;
  --axis: #cbd2dc;
  --hover: rgba(15, 23, 42, .045);
  --accent: #0d9488;
  --accent-2: #0f766e;
  --accent-soft: rgba(13, 148, 136, .10);
  --accent-grad: linear-gradient(135deg, #14b8a6 0%, #2563eb 100%);
  --series-1: #2a78d6;
  --crit: #d03b3b;
  --warn: #fab219;
  --serious: #ec835a;
  --good: #0ca30c;
  --good-text: #067a3a;
  --info: #64748b;
  --crit-soft: rgba(208, 59, 59, .10);
  --warn-soft: rgba(250, 178, 25, .16);
  --info-soft: rgba(100, 116, 139, .12);
  --good-soft: rgba(12, 163, 12, .10);
  --side-bg: linear-gradient(180deg, #0b1422 0%, #0e1b2e 100%);
  --side-text: #aebbd0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .16);
  --radius: 16px;
  --radius-sm: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0e14; --surface: #121821; --surface-2: #171e29; --surface-3: #1d2532;
    --border: rgba(255, 255, 255, .07); --border-strong: rgba(255, 255, 255, .14);
    --text: #e8edf4; --text-2: #aab4c3; --muted: #7c8696; --grid: #222a36; --axis: #353f4c; --hover: rgba(255, 255, 255, .05);
    --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: rgba(45, 212, 191, .12); --series-1: #3987e5;
    --good-text: #3ecf6a; --info: #8b97a8;
    --crit-soft: rgba(208, 59, 59, .18); --warn-soft: rgba(250, 178, 25, .14); --info-soft: rgba(139, 151, 168, .14); --good-soft: rgba(12, 163, 12, .16);
    --side-bg: linear-gradient(180deg, #070b11 0%, #0b121c 100%);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e14; --surface: #121821; --surface-2: #171e29; --surface-3: #1d2532;
  --border: rgba(255, 255, 255, .07); --border-strong: rgba(255, 255, 255, .14);
  --text: #e8edf4; --text-2: #aab4c3; --muted: #7c8696; --grid: #222a36; --axis: #353f4c; --hover: rgba(255, 255, 255, .05);
  --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: rgba(45, 212, 191, .12); --series-1: #3987e5;
  --good-text: #3ecf6a; --info: #8b97a8;
  --crit-soft: rgba(208, 59, 59, .18); --warn-soft: rgba(250, 178, 25, .14); --info-soft: rgba(139, 151, 168, .14); --good-soft: rgba(12, 163, 12, .16);
  --side-bg: linear-gradient(180deg, #070b11 0%, #0b121c 100%);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; width: 100%; overflow-x: hidden;
}
/* จอมือถือ: ให้เต็มความกว้างจริง ไม่มีขอบ/แถบข้าง */
.app, .main, .view { max-width: 100%; min-width: 0; }
.board-view.view { width: 100%; box-sizing: border-box; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; padding: 18px 14px; z-index: 30; overflow: hidden;
}
/* เมนูเลื่อนภายในแถบข้างได้ — พื้นหลังแถบข้างเต็มคอลัมน์เสมอ (ไม่ขาดสีเวลาเมนูยาวเกินจอ) */
.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav::-webkit-scrollbar { width: 7px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 999px; }
.nav::-webkit-scrollbar-track { background: transparent; }
/* แบรนด์ในแถบข้าง — ดีไซน์เดียวกับหน้าเข้าสู่ระบบ (แบนเนอร์ไล่เฉด) */
.brand { display: flex; align-items: center; gap: 12px; padding: 14px 12px; margin-bottom: 14px; color: #fff;
  border-radius: 14px; background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #0f172a));
  box-shadow: 0 10px 24px -10px rgba(2, 6, 23, .55); overflow: hidden; position: relative; }
.brand::before { content: ''; position: absolute; width: 120px; height: 120px; right: -30px; top: -50px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); pointer-events: none; }
.logo {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #fff; flex: none;
  background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); position: relative; z-index: 1;
}
.logo svg { width: 22px; height: 22px; }
.logo.logo-img { background: none; box-shadow: none; overflow: hidden; }
.logo.logo-img img { width: 100%; height: 100%; border-radius: 11px; display: block; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; position: relative; z-index: 1; }
.brand-text b { font-size: 18px; letter-spacing: .3px; font-weight: 800; }
.brand-text small { font-size: 11.5px; color: rgba(255, 255, 255, .82); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #5d6a80; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--side-text);
  font-weight: 500; position: relative; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav a.active { background: rgba(45, 212, 191, .12); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #2dd4bf; }
.nav a.active .ic { color: #2dd4bf; }
/* กลุ่มเมนูพับได้ (เช่น บริบาลทางเภสัชกรรม) */
.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-grp-h { cursor: pointer; }
.nav-grp-caret { margin-left: auto; font-size: 11px; transition: transform .15s; opacity: .7; }
.nav-group.open > .nav-grp-h .nav-grp-caret { transform: rotate(180deg); }
.nav-grp-items { display: none; flex-direction: column; gap: 3px; margin-left: 14px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.08); }
.nav-group.open > .nav-grp-items { display: flex; }
.nav-grp-items a { padding: 8px 12px; font-size: 13.5px; }
/* กล่องรวมตัวเลขท้ายเมนู: แดง = แจ้งเตือนความเสี่ยงที่ยังไม่ตรวจ · ส้ม = ใบสั่งยาที่รอดำเนินการ
   (สีส้มให้ตรงกับปุ่มในหน้าการแจ้งเตือน จะได้รู้ว่าเป็นคนละชุดกัน) */
.nav .nav-counts { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav .nav-counts .count { margin-left: 0; }
.nav .count-ord { background: #ea580c; }
.nav .count { margin-left: auto; background: var(--crit); color: #fff; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 0 7px; min-width: 20px; text-align: center; line-height: 19px; }
.side-foot { margin-top: auto; }
.conn-card { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .06); border-radius: 13px; padding: 12px; font-size: 12.5px; }
.conn-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.conn-row span:last-child { margin-left: auto; color: #e2e8f0; font-weight: 500; }

/* ชื่อผู้ล็อกอิน + ปุ่มออกจากระบบ ลอยบนขวาเสมอ (บน top bar แบบ sticky) */
.top-user { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, var(--card, #fff)); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); white-space: nowrap; max-width: 260px; }
.top-user .tu-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: #fff; }
.top-user .tu-ic svg { width: 15px; height: 15px; }
.top-user .tu-meta { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.top-user .tu-name { font-weight: 800; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.top-user .tu-role { font-size: 10.5px; color: var(--muted, #64748b); }
.top-user .tu-logout { display: inline-flex; align-items: center; gap: 4px; background: #fee2e2; color: #b91c1c;
  border: 1px solid #fca5a5; border-radius: 999px; padding: 4px 11px; font-weight: 800; font-size: 12px; cursor: pointer; }
.top-user .tu-logout:hover { background: #fecaca; }
.top-user .tu-logout svg { width: 13px; height: 13px; }
@media (max-width: 900px) { .top-user .tu-meta { display: none; } .top-user { padding: 4px; } }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 16px; padding: 18px 28px; position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.top-title { min-width: 0; }
.top-title h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.2px; line-height: 1.25; }
.top-title p { margin: 1px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-status { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.view { padding: 24px 28px 48px; max-width: 1560px; width: 100%; }
.view.enter { animation: enter .28s ease; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.scrim { display: none; }
.only-mobile { display: none !important; }

/* ---------- pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); white-space: nowrap; box-shadow: var(--shadow-sm);
}
.pill b { color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.bad { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.crit { background: var(--crit); }
.dot.info { background: var(--info); }
.dot.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.sev { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 999px; white-space: nowrap; }
.sev i { width: 8px; height: 8px; border-radius: 50%; }
.sev-crit { background: var(--crit-soft); color: var(--crit); } .sev-crit i { background: var(--crit); }
.sev-warn { background: var(--warn-soft); color: #a86b00; } .sev-warn i { background: var(--warn); }
:root[data-theme="dark"] .sev-warn { color: var(--warn); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sev-warn { color: var(--warn); } }
.sev-info { background: var(--info-soft); color: var(--info); } .sev-info i { background: var(--info); }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag.ok { background: var(--good-soft); color: var(--good-text); }
.tag.bad { background: var(--crit-soft); color: var(--crit); }
.tag.warn { background: var(--warn-soft); color: #a86b00; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag .ic { width: 13px; height: 13px; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--axis); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent-grad); color: #fff; border: 0; box-shadow: 0 4px 14px rgba(13, 148, 136, .28); }
.btn-primary:hover { background: var(--accent-grad); filter: brightness(1.06); }
.btn-danger { color: var(--crit); }
.btn-danger:hover { background: var(--crit-soft); border-color: transparent; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.win-close:hover { background: #c0392b; border-color: #c0392b; color: #fff; }
#minBtn, #closeBtn { font-size: 15px; font-weight: 700; line-height: 1; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* การ์ดพับในหน้ารายงาน — หัวข้อเป็นปุ่มกดกาง/พับ */
.rp-fold { padding: 0 !important; overflow: hidden; }
.rp-fold-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 16px 20px; background: transparent; border: none; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.rp-fold-head:hover { background: var(--surface-2); }
.rp-fold-head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.rp-fold-head .ic { width: 20px; height: 20px; color: var(--text-2); flex: 0 0 auto; }
.rp-fold-head .sub { font-size: 12.5px; color: var(--muted); }
.rp-fold-badge { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-weight: 600; color: var(--text-2); }
.rp-fold-hint { font-size: 12px; color: var(--muted); }
.rp-fold-chev { font-size: 12px; color: var(--muted); transition: transform .15s; flex: 0 0 auto; }
.rp-fold.open .rp-fold-chev { transform: rotate(180deg); }
.rp-fold.open .rp-fold-hint { display: none; }
.rp-fold-body { padding: 0 20px 18px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus, .chips-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.seg button .dot { width: 7px; height: 7px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 40px; height: 23px; border-radius: 999px; background: var(--axis); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); font-size: 13px; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-height: 30px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.card-head h2 .ic { color: var(--muted); }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .spacer { margin-left: auto; }
.card + .card { margin-top: 16px; }

.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.dash > .card + .card { margin-top: 0; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.row-2 { grid-row: span 2; }

.tile { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; }
.tile-top { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 500; font-size: 13px; }
.tile-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile-ic .ic { width: 19px; height: 19px; }
.tile-val { font-size: 34px; font-weight: 700; letter-spacing: -.8px; line-height: 1.15; margin-top: 8px; }
.tile-val small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.tile-sub { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tile.hero { background: var(--accent-grad); color: #fff; border: 0; box-shadow: 0 10px 30px rgba(37, 99, 235, .22); }
.tile.hero .tile-top, .tile.hero .tile-sub { color: rgba(255, 255, 255, .85); }
.tile.hero .tile-ic { background: rgba(255, 255, 255, .18); color: #fff; }
.tile.hero::after { content: ''; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.tile.hero .chip-sev { background: rgba(255, 255, 255, .16); color: #fff; }
.chip-sev { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-3); }
.tile-ic.blue { background: rgba(42, 120, 214, .12); color: var(--series-1); }
.tile-ic.violet { background: rgba(124, 58, 237, .11); color: #7c3aed; }
.tile-ic.rose { background: rgba(225, 29, 72, .1); color: #e11d48; }

.banner {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--radius); margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(20, 184, 166, .12), rgba(37, 99, 235, .10)); border: 1px solid rgba(20, 184, 166, .25);
}
.banner .tile-ic { width: 44px; height: 44px; }
.banner h3 { margin: 0; font-size: 15.5px; }
.banner p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.banner .btn { margin-left: auto; }
.banner.err { background: var(--crit-soft); border-color: rgba(208, 59, 59, .25); }
.banner.err .tile-ic { background: rgba(208, 59, 59, .15); color: var(--crit); }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--hover); }
.chart .lbl { fill: var(--text-2); font-size: 11px; font-weight: 600; font-family: var(--font); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--text); font-weight: 600; }
.empty { display: grid; place-items: center; text-align: center; color: var(--muted); padding: 28px 10px; gap: 8px; font-size: 13px; }
.empty .ic { width: 30px; height: 30px; color: var(--axis); }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.hbar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 7px; }
.hbar-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar-track { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hbar-track div { height: 100%; border-radius: 999px; background: var(--series-1); }

.tip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 11px; box-shadow: var(--shadow-lg); padding: 9px 12px; font-size: 12.5px; min-width: 130px;
}
.tip h4 { margin: 0 0 5px; font-size: 12.5px; font-weight: 600; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.tip-row i { width: 9px; height: 9px; border-radius: 3px; }
.tip-row b { margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; }

/* ---------- feed ---------- */
.feed { display: flex; flex-direction: column; margin: 0 -8px; }
.feed-item { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; padding: 11px 8px; border-radius: 12px; color: inherit; }
.feed-item:hover { background: var(--hover); }
.feed-item + .feed-item { border-top: 1px solid var(--border); }
.feed-bar { border-radius: 4px; background: var(--info); }
.feed-bar.crit { background: var(--crit); } .feed-bar.warn { background: var(--warn); }
.feed-top { display: flex; gap: 8px; align-items: baseline; }
.feed-top b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-top time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.feed-pt { color: var(--text-2); font-size: 12.5px; }
.feed-items { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-ack { align-self: center; color: var(--good); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl .r { text-align: right; }
.tbl .c { text-align: center; }
.items-list { display: flex; flex-direction: column; gap: 3px; }
.item-line { display: flex; gap: 7px; align-items: flex-start; }
.item-line .ic { width: 15px; height: 15px; margin-top: 3px; color: var(--muted); }
.item-line b { font-weight: 600; }
.usage-line { display: block; margin-top: 3px; padding: 4px 8px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); font-size: 12.5px; white-space: normal; }
.usage-line b { color: var(--text); font-weight: 600; }
.ack-done { color: var(--good-text); font-size: 12.5px; display: flex; gap: 6px; align-items: flex-start; }
.ack-done .ic { width: 15px; height: 15px; margin-top: 2px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input, .filters .select { width: auto; min-width: 150px; height: 38px; }
.search { position: relative; }
.search .ic { position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; color: var(--muted); }
.search .input { padding-left: 34px; }

/* ---------- rules ---------- */
.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; font-size: 16px; font-weight: 600; }
.section-title .count { color: var(--muted); font-size: 13px; }
.section-title:first-child { margin-top: 0; }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.rule-card { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; transition: border-color .15s, box-shadow .15s; }
.rule-card:hover { border-color: var(--border-strong); }
.rule-card.off { opacity: .62; }
.rule-card + .rule-card { margin-top: 0; }
.rule-head { display: flex; align-items: flex-start; gap: 10px; }
.rule-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.4; flex: 1; min-width: 0; }
.rule-head h3 a { color: inherit; }
.rule-head h3 a:hover { color: var(--accent); }
.rule-conds { display: flex; flex-wrap: wrap; gap: 6px; }
.cond-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; }
.cond-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cond-chip .ic { width: 14px; height: 14px; color: var(--accent); }
.cond-chip.more { color: var(--muted); font-weight: 600; background: transparent; border-style: dashed; }
.cond-chip.review { color: #a86b00; background: #fff6e5; border-color: #f0d59a; }
.bed-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 7px; white-space: nowrap; }
.bed-badge .ic { width: 13px; height: 13px; }
.chronic-cell { display: flex; flex-wrap: wrap; gap: 3px; }
.chip-chronic { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
/* ปุ่ม "เรียกชื่อ" (ตรวจก่อนจ่าย) — เด่นชัด ให้เภสัชเห็นง่าย */
.btn-call { background: linear-gradient(135deg, #2563eb, #1d4ed8); border-color: #1d4ed8; color: #fff; font-weight: 700; box-shadow: 0 2px 10px rgba(37,99,235,.35); }
.btn-call:hover { background: linear-gradient(135deg, #1d4ed8, #1e40af); color: #fff; border-color: #1e40af; }
.btn-call .ic { color: #fff; }
.print-badge { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--bad); background: var(--bad-soft, rgba(220,38,38,.1)); padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
.print-badge.partial { color: var(--warn); background: var(--warn-soft, rgba(217,119,6,.12)); }
/* ไฮไลท์เคส MR ที่มียาเรื้อรัง (ต้องทบทวน) */
tr.mr-hot { background: rgba(220,38,38,.045); }
tr.mr-hot td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.mrc-box { margin-top: 8px; border: 1px solid rgba(220,38,38,.3); border-left: 4px solid var(--bad); border-radius: 9px; padding: 7px 10px 9px; background: rgba(220,38,38,.05); }
.mrc-head { font-weight: 800; font-size: 12.5px; color: var(--bad); display: flex; align-items: center; gap: 5px; }
.mrc-head .ic { width: 15px; height: 15px; }
.mrc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 2px; }
.mrc-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 7px; }
.mrc-tag .ic { width: 12px; height: 12px; }
.mrc-tag.mrc-rueso { color: #0f7a46; background: rgba(14,160,90,.12); }
.mrc-tag.mrc-ext { color: #b26a12; background: rgba(224,138,30,.14); }
.mrc-list { font-size: 12px; margin-top: 4px; line-height: 1.5; }
.mrc-list b { font-weight: 700; }
.mrc-detail { margin-top: 7px; height: 28px; }
/* เครื่องคำนวณขนาดยา */
.dc-pt { padding: 14px 18px; }
.dc-pt-vit { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dc-bw { display: inline-flex; align-items: center; gap: 5px; font-size: 15px; font-weight: 800; color: #0f7a46; background: rgba(14,160,90,.12); border: 1px solid rgba(14,160,90,.35); padding: 4px 12px; border-radius: 9px; }
.dc-bw .ic { width: 15px; height: 15px; }
.dc-bw-miss { color: var(--bad); background: var(--bad-soft, rgba(220,38,38,.1)); border-color: rgba(220,38,38,.35); }
.dc-bw-ov { color: #b26a12; background: rgba(224,138,30,.14); border-color: rgba(224,138,30,.4); }
.dc-chip { font-size: 13px; color: var(--muted); background: var(--surface-2, rgba(127,127,127,.08)); padding: 4px 10px; border-radius: 9px; }
.dc-card { padding: 14px 18px; margin-top: 12px; border-left: 4px solid var(--accent); }
.dc-h { font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.dc-sig { margin: 2px 0 10px; padding: 11px 14px; background: rgba(14,160,90,.08); border: 1px solid rgba(14,160,90,.3); border-left: 4px solid #0ea05a; border-radius: 10px; }
.dc-sig-lbl { font-size: 12px; font-weight: 700; color: #0f7a46; display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.dc-sig-lbl .ic { width: 14px; height: 14px; }
.dc-sig-txt { font-size: 17px; font-weight: 800; line-height: 1.45; color: var(--text); }
.dc-perkg { font-size: 13px; margin-bottom: 6px; }
.dc-line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px dashed var(--border); font-size: 14px; }
.dc-lbl { color: var(--muted); }
.dc-renal { margin-top: 8px; font-size: 13px; color: #b26a12; background: rgba(224,138,30,.08); border-radius: 7px; padding: 5px 9px; display: flex; align-items: center; gap: 5px; }
.dc-renal .ic { width: 14px; height: 14px; }
.dc-note { margin-top: 8px; font-size: 12.5px; font-style: italic; }
.dc-warn { margin-top: 8px; font-size: 13px; color: var(--warn); display: flex; align-items: center; gap: 5px; }
.dc-warn .ic { width: 14px; height: 14px; flex-shrink: 0; }
.dc-warn.crit { color: var(--bad); font-weight: 700; background: var(--bad-soft, rgba(220,38,38,.08)); border-radius: 7px; padding: 5px 9px; }
.dc-flag { font-size: 13px; font-weight: 700; color: #b26a12; background: rgba(224,138,30,.14); padding: 4px 10px; border-radius: 9px; }
.dc-current { margin-top: 8px; font-size: 13.5px; background: var(--surface-2, rgba(127,127,127,.06)); border-radius: 8px; padding: 7px 10px; }
.dc-verdict { font-weight: 700; padding: 1px 7px; border-radius: 6px; font-size: 12.5px; }
.dc-verdict.ok { color: #0f7a46; background: rgba(14,160,90,.12); }
.dc-verdict.bad { color: var(--bad); background: var(--bad-soft, rgba(220,38,38,.1)); }
/* ความเสี่ยงกลับมานอนซ้ำ (IPD card) */
.ipd-readmit { margin-top: 6px; font-size: 12px; font-weight: 700; border-radius: 7px; padding: 3px 8px; display: inline-block; }
.ipd-readmit.high { color: var(--bad); background: var(--bad-soft, rgba(220,38,38,.1)); }
.ipd-readmit.med { color: #b26a12; background: rgba(224,138,30,.12); }
.cc-block { font-size: 12.5px; line-height: 1.5; }
.cc-line { margin-bottom: 2px; }
.cc-line b { color: var(--accent); font-weight: 700; margin-right: 2px; }
.cc-drugs { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); font-weight: 500; }
.cc-drug { margin: 2px 0 0 4px; line-height: 1.45; }
.dm-note-group { margin-bottom: 14px; }
.dm-note-group + .dm-note-group { border-top: 1px dashed var(--border); padding-top: 12px; }
.dm-note-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.dm-note-add { display: flex; gap: 8px; margin-bottom: 10px; }
.dm-note-add .input { flex: 1; }
.dm-notes { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.dm-note { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 6px 10px; background: var(--bg-soft, rgba(0,0,0,.02)); }
.dm-note-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.dm-note-meta b { color: var(--ink); font-weight: 600; }
.dm-note-text { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.dm-note-del { margin-left: auto; border: none; background: none; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 4px; line-height: 0; }
.dm-note-del:hover { color: var(--bad); background: var(--bad-soft, rgba(220,38,38,.1)); }
.dm-note-del .ic { width: 13px; height: 13px; }
/* บันทึกเพิ่มเติม/ติดตาม บนสุดของ drawer คลินิก — เน้น + อ่านง่าย */
.cln-note-top { border: 2px solid var(--accent); box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.cln-note-top .card-head h2 { font-size: 17px; }
.cln-note-top .dm-note-add .input { height: 40px; font-size: 15px; }
.dm-notes.cln-notes-big { max-height: 300px; gap: 10px; }
.dm-notes.cln-notes-big .dm-note { border-left-width: 4px; padding: 9px 12px; border-radius: 10px; }
.dm-notes.cln-notes-big .dm-note-meta { font-size: 13px; margin-bottom: 4px; }
.dm-notes.cln-notes-big .dm-note-meta b { font-size: 13.5px; }
.dm-notes.cln-notes-big .dm-note-text { font-size: 15.5px; line-height: 1.55; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dn-legend { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.dn-lg { display: flex; align-items: center; gap: 6px; }
.dn-lg i { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.dn-lg b { margin-left: 2px; }
/* ปกปิดข้อมูลผู้ป่วย (blind) — เบลอรูป + ปิดชื่อ จนกว่าจะปลดล็อกด้วยรหัส */
body.pii-hide .al-photo, body.pii-hide .ipd-photo, body.pii-hide .drawer-head img { filter: blur(9px) grayscale(.5); }
.pii-mask { letter-spacing: 1px; color: var(--muted); font-weight: 400; }
#piiBtn.on { color: var(--accent); background: var(--accent-soft); }
/* ---- โหมดนำเสนอ: ปกปิดข้อมูลส่วนบุคคลด้วยการเบลอ (ชื่อผู้ป่วย · HN/AN/รหัส · เจ้าหน้าที่ · รูป) ---- */
body.present-mode .al-name, body.present-mode .al-cid, body.present-mode .q-name, body.present-mode .q-hn,
body.present-mode .q-tv-nm, body.present-mode .q-tv-nmt, body.present-mode .q-tv-cnm, body.present-mode .q-tv-ipdnm, body.present-mode .q-chan-name,
body.present-mode .q-mnow-name, body.present-mode .q-mnext-nm, body.present-mode .q-mcalled-nm, body.present-mode .q-flash-name,
body.present-mode .ipd-name, body.present-mode .q-ipd-nm, body.present-mode .q-ipd-w, body.present-mode .nc-name, body.present-mode .pnl-name,
body.present-mode .hbar-name, body.present-mode .fr-name, body.present-mode .cln-vname, body.present-mode .pcp-nm, body.present-mode .md-nm, body.present-mode .tu-name, body.present-mode .abx-name,
body.present-mode .mono, body.present-mode .pc-id, body.present-mode .pii-staff, body.present-mode .note-by, body.present-mode .fp-staff {
  filter: blur(7px); -webkit-filter: blur(7px); user-select: none; -webkit-user-select: none; pointer-events: none;
}
body.present-mode .al-photo, body.present-mode .ipd-photo, body.present-mode .pc-avatar, body.present-mode .cs-photo, body.present-mode .drawer-head img { filter: blur(12px) grayscale(.55); }
/* ป้ายบอกสถานะโหมดนำเสนอ มุมล่างขวา — เตือนว่ากำลังปกปิดอยู่ */
.di-opt { padding: 7px 10px; cursor: pointer; border-top: 1px solid var(--line, #eef2f7); border-radius: 6px; }
.di-opt:hover, .di-opt.on { background: var(--hover, #f1f5f9); }
.di-opt:first-child { border-top: 0; }
.di-hd { margin: 14px 2px 4px; }
.di-hd h2 { margin: 0 0 2px; }
.di-sec { padding: 12px 16px; margin-top: 12px; }
.di-sec h3 { margin: 0 0 7px; font-size: 14.5px; }
.di-sec > div { margin: 3px 0; line-height: 1.5; }
.di-ul { margin: 2px 0; padding-left: 20px; }
.di-ul li { margin: 2px 0; line-height: 1.45; }
.di-edit { padding: 10px 16px; margin-top: 12px; }
.di-edit summary { cursor: pointer; font-weight: 600; }
.di-form { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.di-form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; font-weight: 600; }
.di-form textarea { font-weight: 400; }
#diFda summary { cursor: pointer; font-weight: 600; }
.di-fda { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.di-fda-sec b { display: block; font-size: 13px; margin-bottom: 2px; }
.di-fda-sec > div { font-size: 12.5px; line-height: 1.5; color: var(--ink-2, #475569); }
body.present-mode::after { content: '🔒 โหมดนำเสนอ · ปกปิดข้อมูลส่วนบุคคล'; position: fixed; right: 12px; bottom: 12px; z-index: 9998; background: rgba(15,23,42,.82); color: #fff; font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px; pointer-events: none; letter-spacing: .2px; }
.nav-lock { margin-top: 8px; opacity: .85; border-top: 1px solid var(--border); border-radius: 0; color: var(--muted); }
.nav-lock:hover { opacity: 1; color: var(--accent); }
body.menu-locked #rulesBtn, body.menu-locked #logsBtn, body.menu-locked #settingsBtn, body.menu-locked #scanBtn { display: none; }
.auth-close { position: fixed; top: 20px; right: 24px; z-index: 10; width: 42px; height: 42px; border-radius: 50%; border: none; background: rgba(255,255,255,.85); color: #334; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.auth-close:hover { background: #fff; color: #000; }
.auth-close .ic { width: 22px; height: 22px; }
/* ---------- ระบบเรียกคิว (โมเดิร์น/ทางการ) ---------- */
.q-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.q-h { font-size: 21px; font-weight: 800; letter-spacing: .2px; }
#qSound.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.q-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; align-items: start; }
.q-col { background: var(--card); border: 1px solid #dce3ee; border-radius: 14px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 10px 28px rgba(15,23,42,.05); }
.q-col-h { font-size: 17px; font-weight: 800; padding: 15px 18px; display: flex; align-items: baseline; gap: 10px; color: #fff; letter-spacing: .2px; box-shadow: inset 0 -1px 0 rgba(0,0,0,.12); }
.q-col-h span { font-size: 12.5px; font-weight: 600; opacity: .95; margin-left: auto; background: rgba(255,255,255,.16); padding: 3px 11px; border-radius: 999px; }
/* โทนสีทางการ (รพ.รัฐ): ชำระเงิน=ทองบรอนซ์ · รับยา=เขียวหมอ · เรียกแล้ว=กรมท่า */
.q-col-h.q-pay { background: linear-gradient(135deg, #b4710f, #875109); }
.q-col-h.q-ph { background: linear-gradient(135deg, #0f766e, #10564d); }
.q-col-h.q-cl { background: linear-gradient(135deg, #334a66, #1f2d40); }
.q-list { padding: 12px; display: flex; flex-direction: column; gap: 9px; max-height: calc(100vh - 240px); overflow-y: auto; }
.q-item { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 13px; padding: 11px 13px; border: 1px solid #e6eaf1; border-left: 3px solid #cfd8e6; border-radius: 10px; background: var(--card); transition: transform .12s, box-shadow .12s; }
.q-item:hover { box-shadow: 0 3px 12px rgba(15,23,42,.08); }
.q-item.q-done { opacity: .95; }
/* เอกลักษณ์สีรายคอลัมน์ (ป้ายเลข + ขอบซ้าย) — เรียบ ดูเป็นทางการ */
.q-col--pay .q-no { background: #fbf2e0; color: #8f5308; border-color: #efdcb7; }
.q-col--ph  .q-no { background: #e6f3f0; color: #0e6458; border-color: #c7e5de; }
.q-col--cl  .q-no { background: #eef1f6; color: #33475f; border-color: #d8e0ea; }
.q-col--pay .q-list > .q-item { border-left-color: #cf9442; }
.q-col--ph  .q-list > .q-item { border-left-color: #2a9a89; }
.q-col--cl  .q-list > .q-item { border-left-color: #5f7595; }
/* ปุ่มเรียกคิว = สีเดียวกับหัวคอลัมน์ (ทางการ ชัดเจน) */
.q-call { font-weight: 700; box-shadow: none; }
.q-col--pay .q-call { background: #b4710f; border-color: #9d6210; color: #fff; }
.q-col--pay .q-call:hover { background: #9d6210; }
.q-col--ph  .q-call { background: #0f766e; border-color: #0d665f; color: #fff; }
.q-col--ph  .q-call:hover { background: #0d665f; }
/* ปุ่ม "เรียกญาติ" = ม่วง (แยกจาก "เรียกคนไข้") */
.q-call-rel, .q-col--pay .q-call.q-call-rel, .q-col--ph .q-call.q-call-rel { background: #7c3aed; border-color: #6d28d9; color: #fff; font-weight: 700; }
.q-call-rel:hover, .q-col--pay .q-call.q-call-rel:hover, .q-col--ph .q-call.q-call-rel:hover { background: #6d28d9; }
.q-counter-set { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.q-counter-hl { box-shadow: 0 0 0 3px rgba(239,68,68,.45); border-color: #ef4444 !important; }
.q-setcounter { color: #b45309; border-color: #f0ddba; background: #fdf3e3; font-weight: 700; }
.q-wclear { color: #94a1b5; } /* เคลียร์คิวรอ (เรียกเองผ่านไมค์/จ่ายแล้ว) */
.q-wclear:hover { color: #b91c1c; background: #fdecec; border-color: #f3c6c6; }
/* ปุ่มกรองวอร์ด (หน้าผู้ป่วยใน) */
.q-ward-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 10px; }
.q-ward-chip { font-size: 12.5px; font-weight: 600; color: #475569; background: #eef2f8; border: 1px solid #dce4ef; padding: 4px 12px; border-radius: 999px; cursor: pointer; }
.q-ward-chip:hover { background: #e2e8f2; }
.q-ward-chip.on { color: #fff; background: #0f766e; border-color: #0f766e; }
.q-no { font-size: 26px; font-weight: 800; min-width: 58px; height: 52px; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: #eef2f8; color: #27405f; border: 1px solid #dce4ef; line-height: 1; font-variant-numeric: tabular-nums; }
.q-info { flex: 1 1 165px; min-width: 150px; } /* ชื่อได้ความกว้างพอ → ปุ่มตกลงแถวล่างเองเมื่อคอลัมน์แคบ */
.q-name { font-size: 18px; font-weight: 700; overflow-wrap: normal; word-break: normal; } /* แสดงชื่อเต็ม 1 บรรทัด (ตัดที่ช่องว่างคำเท่านั้น ไม่ตัดทีละตัวอักษร) */
.q-hn { font-size: 12px; margin-top: 1px; }
.q-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.q-empty { padding: 22px 10px; text-align: center; font-size: 13px; }
.q-called-h { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .3px; padding: 12px 16px 2px; border-top: 1px solid var(--border); margin-top: 6px; text-transform: uppercase; }
.q-called-list { padding-top: 6px; max-height: 42vh; }
.q-counter { min-width: 60px; padding: 5px 12px; border-radius: 12px; background: linear-gradient(135deg, #ef4444, #b91c1c); color: #fff; font-size: 26px; font-weight: 800; text-align: center; line-height: 1.05; letter-spacing: 2px; box-shadow: 0 3px 10px rgba(185,28,28,.3); }
.q-cols-2 { grid-template-columns: 1fr 1fr; }
.q-cols-3 { grid-template-columns: 0.95fr 1.1fr 1.35fr; } /* คอลัมน์ 3 (เรียกแล้ว) กว้างขึ้น ให้ชื่อไม่ตกบรรทัด */
/* ---- แท็บ ผู้ป่วยนอก / ผู้ป่วยใน ---- */
.q-tabs { display: inline-flex; gap: 6px; margin-left: 14px; }
.q-tabs .btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
/* ---- เรียกชื่อผู้ป่วยใน ---- */
.q-ipd { display: grid; grid-template-columns: 2.2fr 1fr; gap: 16px; align-items: start; }
.q-ipd-tools { padding: 12px 12px 4px; }
.q-ipd-tools .input { width: 100%; height: 40px; }
.q-ipd-list { padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; max-height: calc(100vh - 260px); overflow-y: auto; }
.q-ipd-waitlist { max-height: 44vh; overflow-y: auto; padding-top: 6px; }
/* รอรับยาผู้ป่วยใน (operator): ปุ่มเคลียร์ ✕ ลอยมุมขวาบนของการ์ด — เห็นชัดเสมอ ไม่ตกบรรทัดในคอลัมน์แคบ */
.q-ipd-waitlist .q-item { position: relative; padding-right: 42px; }
.q-ipd-waitlist .q-ipd-clear { position: absolute; top: 10px; right: 8px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border-radius: 8px; color: #dc2626; border-color: #fca5a5; }
.q-ipd-waitlist .q-ipd-clear:hover { background: #fee2e2; border-color: #ef4444; color: #b91c1c; }
.q-wait-clear { color: #dc2626; border-color: #fca5a5; }
.q-wait-clear:hover { background: #fee2e2; border-color: #ef4444; color: #b91c1c; }
.q-ipd-bedno { font-size: 14px; font-weight: 800; min-width: 54px; letter-spacing: .5px; }
.q-ipd-card { position: relative; display: flex; }
.q-ipd-card .q-ipd-name { flex: 1; width: 100%; padding-right: 34px; } /* เว้นที่ให้ปุ่มเคลียร์มุมขวาบน */
.q-ipd-clear { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; padding: 0; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--border); background: var(--card); color: #dc2626; font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer; opacity: .4; transition: opacity .12s, background .12s, border-color .12s; }
.q-ipd-card:hover .q-ipd-clear { opacity: 1; }
.q-ipd-clear:hover { background: #fee2e2; border-color: #ef4444; }
.q-ipd-name { display: flex; flex-direction: row; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--card); cursor: pointer; transition: transform .1s, box-shadow .1s, border-color .1s; }
.q-ipd-name:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(15,23,42,.1); transform: translateY(-1px); }
.q-ipd-name:active { transform: translateY(0); }
.q-ipd-name[disabled] { opacity: .5; pointer-events: none; }
.q-ipd-bed { flex: 0 0 auto; min-width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; padding: 0 6px; border-radius: 9px; background: var(--accent-soft, #e6f7f1); color: var(--accent, #0a7a5f); font-weight: 800; font-size: 15px; }
.q-ipd-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.q-ipd-nm { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.q-ipd-w { font-size: 12px; }
/* หัวข้อวอร์ด — เต็มความกว้าง grid, คั่นแต่ละวอร์ด */
.q-ward-h { grid-column: 1 / -1; font-size: 14px; font-weight: 800; color: var(--accent, #0a7a5f); padding: 8px 4px 2px; border-bottom: 2px solid var(--accent-soft, #e6f7f1); margin-top: 4px; }
.q-ward-h:first-child { margin-top: 0; }
.q-acts { display: inline-flex; flex-direction: row; gap: 5px; flex-shrink: 0; align-items: center; } /* ปุ่มเรียกซ้ำ/เคลียร์ เรียงแนวนอน ชิดขวา */
.q-acts .btn { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; font-size: 15px; border-radius: 9px; }
.q-acts .q-recall { color: #b4710f; }
.q-acts .q-recall:hover { background: #fdecd3; border-color: #e3a94b; }
.q-acts .q-clear { color: #0f766e; }
.q-acts .q-clear:hover { background: #d1fae5; border-color: #10b981; }
/* การ์ด "เรียกแล้ว" (หน้า operator): แถวเดียว ไม่ตกบรรทัด · ชื่อยาวตัด … · badge ช่องกะทัดรัด */
.q-called-list .q-item { flex-wrap: nowrap; }
.q-called-list .q-item .q-info { flex: 1 1 auto; min-width: 0; }
.q-called-list .q-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-called-list .q-counter { font-size: 19px; min-width: 42px; padding: 4px 9px; letter-spacing: 1px; border-radius: 9px; }
/* การ์ดเรียกแล้ว (การเงิน): ชื่อเต็ม ไม่ตัด · ไม่มีป้ายห้อง · ปุ่ม 🔁/✓ อยู่ข้างบรรทัดเวลา */
.q-called-list .q-item.q-done-pay .q-name { white-space: normal; overflow: visible; text-overflow: clip; }
.q-done-pay .q-hn { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-acts-inline { display: inline-flex; gap: 5px; }
.q-acts-inline .btn { width: 28px; height: 28px; padding: 0; display: inline-grid; place-items: center; font-size: 13px; border-radius: 8px; }
.q-acts-inline .q-recall { color: #b4710f; }
.q-acts-inline .q-recall:hover { background: #fdecd3; border-color: #e3a94b; }
.q-acts-inline .q-clear { color: #0f766e; }
.q-acts-inline .q-clear:hover { background: #d1fae5; border-color: #10b981; }
.q-tv-only { display: none; }
/* ================= บอร์ดจอ TV (ทางการ · ทันสมัย) ================= */
.q-tvboard { --qpay: #f59e0b; --qpay-d: #d97706; --qph: #0d9488; --qph-d: #0f766e;
  --qink: #1e293b;             /* ข้อความหลักบนการ์ดขาว */
  --qsurf: #ffffff;            /* พื้นการ์ด = ขาว */
  --qsurf2: #fafbfd;           /* แถวสลับ */
  --qline: #e4e9f1;            /* เส้นคั่น/ขอบ */
  --qmuted: #6b7688;           /* ข้อความรอง */
  display: grid; grid-template-columns: 1fr 1.12fr 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 14px; align-items: stretch; }
/* แถบหัวทางการ */
.q-tv-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 16px; border-radius: 12px; background: linear-gradient(120deg, #0f172a, #1e293b); color: #fff; box-shadow: 0 4px 16px rgba(15,23,42,.24); }
.q-tv-brand { display: flex; align-items: center; gap: 14px; }
.q-tv-logo { width: clamp(26px, 2vw, 36px); height: clamp(26px, 2vw, 36px); display: grid; place-items: center; border-radius: 9px; background: linear-gradient(135deg, #0f766e, #1e3a5f); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.q-tv-logo .ic { width: 60%; height: 60%; color: #fff; }
.q-tv-hname { font-size: clamp(15px, 1.2vw, 22px); font-weight: 800; letter-spacing: .2px; }
.q-tv-hsub { font-size: clamp(10px, .75vw, 14px); color: #a9b4c6; font-weight: 500; }
.q-tv-clock { text-align: right; display: flex; flex-direction: column; }
.q-tv-time { font-size: clamp(20px, 1.8vw, 36px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.q-tv-date { font-size: clamp(10px, .75vw, 14px); color: #a9b4c6; }
/* คอลัมน์ซ้าย/ขวา */
.q-tv-side { display: flex; flex-direction: column; min-height: 0; border-radius: 16px; overflow: hidden; box-shadow: 0 6px 22px rgba(15,23,42,.12); background: var(--qsurf); border: 1px solid var(--qline); }
.q-tv-h { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: clamp(22px, 1.9vw, 38px); font-weight: 800; color: #fff; padding: 12px 20px; letter-spacing: .3px; }
.q-tv-pay .q-tv-h { background: linear-gradient(120deg, var(--qpay), var(--qpay-d)); }
.q-tv-ph .q-tv-h { background: linear-gradient(120deg, var(--qph), var(--qph-d)); }
.q-tv-h-n { font-size: clamp(15px, 1.1vw, 22px); font-weight: 800; background: rgba(255,255,255,.22); border-radius: 999px; padding: 2px 14px; min-width: 40px; text-align: center; }
.q-tv-scroll { flex: 1; min-height: 0; overflow: hidden; } /* เลื่อนอัตโนมัติด้วย JS (ดูชื่อครบทุกคนบนทีวี) */
.q-tv-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.q-tv-tbl thead th { background: #f6f8fb; color: var(--qmuted); font-size: clamp(13px, 1vw, 20px); font-weight: 700; padding: 9px 12px; text-align: left; position: sticky; top: 0; border-bottom: 2px solid #e8ecf2; }
.q-tv-tbl thead th.q-tv-no, .q-tv-tbl td.q-tv-no { text-align: center; width: 48px; }
.q-tv-tbl tbody tr { border-bottom: 1px solid var(--qline); transition: background .15s; }
.q-tv-tbl tbody tr:nth-child(even) { background: var(--qsurf2); }
.q-tv-tbl tbody tr:first-child { background: rgba(245,158,11,.14); box-shadow: inset 3px 0 0 #f59e0b; } /* คิวถัดไป (บนสุด) — โทนทอง (ชำระเงิน) */
.q-tv-ph .q-tv-tbl tbody tr:first-child { background: rgba(20,184,166,.14); box-shadow: inset 3px 0 0 #14b8a6; } /* โทนเขียวหมอ (รับยา) */
.q-tv-tbl td { padding: 8px 12px; font-size: clamp(18px, 1.6vw, 38px); color: var(--qink); }
.q-tv-no { color: #94a1b5; font-weight: 700; }
.q-tv-code { display: inline-block; min-width: 66px; text-align: center; background: #fbf2e0; color: var(--qpay-d); font-weight: 800; border-radius: 9px; padding: 4px 9px; }
.q-tv-ph .q-tv-code { background: #e6f3f0; color: var(--qph-d); }
/* คอลัมน์หมายเลข = กว้างพอดีเนื้อหา (กันชื่อทับเลข) · คอลัมน์ชื่อ = กินที่เหลือทั้งหมด */
.q-tv-tbl th:nth-child(2), .q-tv-tbl td:nth-child(2) { width: 132px; white-space: nowrap; } /* หมายเลข = เว้นพอ 4 หลัก กันชื่อทับเลข */
.q-tv-tbl th:last-child, .q-tv-tbl td:last-child { width: auto; } /* ชื่อ = กินที่เหลือทั้งหมด */
.q-tv-nm { font-weight: 600; text-align: left; white-space: normal; overflow-wrap: break-word; line-height: 1.25; } /* ชิดซ้าย + แสดงชื่อเต็ม (ตัดบรรทัดถ้ายาว) */
/* ป้ายเวลารอโดยประมาณ (รอรับยา) */
.q-tv-eta { display: inline-block; font-size: clamp(12px, .9vw, 17px); font-weight: 700; color: #92560a; background: #fbf2e0; border: 1px solid #f0ddba; padding: 1px 11px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.q-tv-eta.ready { color: #0e6458; background: #e6f3f0; border-color: #c7e5de; }
.q-tv-eta.prep { color: #33475f; background: #eef1f6; border-color: #d8e0ea; }
.q-eta { display: inline-block; font-size: 11.5px; font-weight: 700; color: #92560a; background: #fbf2e0; border: 1px solid #f0ddba; padding: 0 7px; border-radius: 6px; white-space: nowrap; }
.q-eta.ready { color: #0e6458; background: #e6f3f0; border-color: #c7e5de; }
.q-eta.prep { color: #33475f; background: #eef1f6; border-color: #d8e0ea; }
.q-tv-empty { text-align: center; color: #aab4c2; padding: 26px; font-size: clamp(18px, 1.5vw, 30px); font-weight: 600; }
/* กลาง: ช่องชำระเงิน + รับยาช่อง 801-804 */
.q-tv-mid { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.q-chan { flex: 1; display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: var(--qsurf); box-shadow: 0 1px 2px rgba(15,23,42,.05); border: 1px solid var(--qline); transition: box-shadow .2s, border-color .2s; }
/* แถบหัวช่อง = น้ำเงินเข้ม โมเดิร์น (รับยาช่อง 801-803) */
.q-chan-head { background: linear-gradient(120deg, #0f172a, #1e3a5f); color: #fff; font-size: clamp(28px, 3vw, 58px); font-weight: 800; letter-spacing: .3px; padding: 8px 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.15; }
.q-chan-body { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; min-height: 58px; }
.q-chan-name { flex: 1; min-width: 0; font-size: clamp(22px, 2vw, 44px); font-weight: 800; color: var(--qink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-chan-empty { color: #b6bfcc; font-weight: 600; }
.q-chan-no { flex: 0 0 auto; font-size: clamp(22px, 1.9vw, 44px); font-weight: 900; color: #aeb8c7; background: #f1f4f9; border: 1px solid #e2e8f1; border-radius: 12px; padding: 4px 14px; min-width: 68px; text-align: center; font-variant-numeric: tabular-nums; }
.q-chan.on { box-shadow: 0 6px 18px rgba(15,118,110,.18); }
.q-chan.on .q-chan-no { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--qph), var(--qph-d)); }
/* ช่องชำระเงิน = แถบหัวทอง */
.q-chan-pay .q-chan-head { background: linear-gradient(120deg, #d97706, #f59e0b); }
.q-chan-pay.on { box-shadow: 0 10px 28px rgba(217,119,6,.28); border-color: #f5d79a; }
.q-chan-pay.on .q-chan-body { background: rgba(245,158,11,.12); }
.q-chan-pay.on .q-chan-no { color: #fff; border-color: transparent; background: linear-gradient(135deg, #f59e0b, #d97706); }
/* ช่องรับยา 801 / 802 / 803 = 3 สีสดใส modern แยกช่องชัด (teal · น้ำเงิน · ม่วง) */
.q-tv-mid .q-chan:nth-child(1) .q-chan-head { background: linear-gradient(120deg, #0f766e, #14b8a6); }
.q-tv-mid .q-chan:nth-child(2) .q-chan-head { background: linear-gradient(120deg, #1d4ed8, #3b82f6); }
.q-tv-mid .q-chan:nth-child(3) .q-chan-head { background: linear-gradient(120deg, #6d28d9, #8b5cf6); }
.q-tv-mid .q-chan:nth-child(1).on { box-shadow: 0 10px 28px rgba(20,184,166,.30); border-color: #99e6db; }
.q-tv-mid .q-chan:nth-child(2).on { box-shadow: 0 10px 28px rgba(59,130,246,.30); border-color: #bcd4fb; }
.q-tv-mid .q-chan:nth-child(3).on { box-shadow: 0 10px 28px rgba(139,92,246,.30); border-color: #d6c6fb; }
.q-tv-mid .q-chan:nth-child(1).on .q-chan-body { background: rgba(20,184,166,.13); }
.q-tv-mid .q-chan:nth-child(2).on .q-chan-body { background: rgba(59,130,246,.13); }
.q-tv-mid .q-chan:nth-child(3).on .q-chan-body { background: rgba(139,92,246,.14); }
.q-tv-mid .q-chan:nth-child(1).on .q-chan-no { background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; border-color: transparent; }
.q-tv-mid .q-chan:nth-child(2).on .q-chan-no { background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff; border-color: transparent; }
.q-tv-mid .q-chan:nth-child(3).on .q-chan-no { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; border-color: transparent; }
.q-tv-mid .q-chan.on .q-chan-name { color: #0f172a; }
.q-tv-mid .q-chan.on .q-chan-head { filter: saturate(1.05); }
/* ช่องชำระเงินในคอลัมน์ซ้าย = สูงพอดีเนื้อหา ไม่ยืดเต็ม (ให้ตารางรอชำระเงินมีที่) */
.q-tv-side .q-chan { flex: 0 0 auto; }
/* คอลัมน์ขวา: รอรับยาผู้ป่วยนอก 2/3 บน · รอรับยาผู้ป่วยใน 1/3 ล่าง */
.q-tv-ph .q-tv-scroll { flex: 2; }
.q-tv-ph .q-tv-ipdwait { flex: 1; margin-top: 12px; }
/* คอลัมน์ซ้าย: รอชำระเงิน 2/3 บน · เรียกแล้ว·ไปที่ช่อง 1/3 ล่าง (เลื่อนอัตโนมัติ) */
.q-tv-pay .q-tv-scroll { flex: 2; }
.q-tv-pay .q-tv-called { flex: 1; margin-top: 12px; }
.q-tv-called { min-height: 0; display: flex; flex-direction: column; background: var(--qsurf); border: 1px solid var(--qline); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,.05); }
.q-tv-called-h { background: linear-gradient(120deg, #334a66, #1f2d40); color: #fff; font-weight: 800; font-size: clamp(14px, 1.1vw, 20px); padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; }
.q-tv-called-h span { font-size: clamp(12px, .9vw, 16px); background: rgba(255,255,255,.18); border-radius: 999px; padding: 1px 10px; }
.q-tv-called-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px; }
.q-tv-crow { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-bottom: 1px solid var(--qline); }
.q-tv-cnum { flex: 0 0 auto; min-width: 58px; text-align: center; font-weight: 800; font-size: clamp(16px, 1.3vw, 28px); color: #33475f; background: #eef1f6; border: 1px solid #d8e0ea; border-radius: 9px; padding: 2px 10px; }
.q-tv-cnm { flex: 1; font-weight: 700; font-size: clamp(16px, 1.3vw, 28px); color: var(--qink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-tv-cch { flex: 0 0 auto; font-weight: 800; font-size: clamp(15px, 1.2vw, 24px); color: #fff; background: linear-gradient(135deg, #e11d48, #be123c); border-radius: 9px; padding: 3px 14px; white-space: nowrap; }
/* กล่อง "รอรับยาผู้ป่วยใน" */
.q-tv-ipdwait { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--qsurf); border: 1px solid var(--qline); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,.05); }
.q-tv-ipdwait-h { background: linear-gradient(120deg, #4338ca, #6366f1); color: #fff; font-weight: 800; font-size: clamp(18px, 1.4vw, 28px); padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; }
.q-tv-ipdwait-h span { font-size: clamp(13px, .95vw, 18px); background: rgba(255,255,255,.18); border-radius: 999px; padding: 1px 12px; min-width: 34px; text-align: center; }
.q-tv-ipdwait-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px; }
.q-tv-ipdrow { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-bottom: 1px solid var(--qline); }
.q-tv-ipdbed { flex: 0 0 auto; min-width: 72px; text-align: center; font-weight: 800; font-size: clamp(17px, 1.4vw, 30px); color: #4338ca; background: #eef0ff; border: 1px solid #c7ccfb; border-radius: 10px; padding: 3px 12px; }
.q-tv-ipdnm { flex: 1; font-weight: 600; font-size: clamp(15px, 1.2vw, 24px); color: var(--qink, #1e293b); overflow-wrap: break-word; }
.q-tv-ipdward { flex: 0 0 auto; font-size: clamp(12px, .9vw, 16px); color: #6b7688; }
.q-tv-ipdrow.called { background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(99,102,241,.03)); }
.q-tv-ipdtag { flex: 0 0 auto; font-size: clamp(13px, .95vw, 18px); font-weight: 800; color: #4338ca; background: #e0e3ff; border-radius: 8px; padding: 2px 10px; }
.q-tv-ipdeta { font-size: clamp(11px, .8vw, 15px); font-weight: 700; color: #b4710f; background: #fbf0dc; border-radius: 6px; padding: 0 7px; white-space: nowrap; }
/* พื้นหลัง + footer จอ TV ให้ดูทางการ */
body.q-fullscreen .view.q-tv { background: linear-gradient(160deg, #f3f6fb 0%, #e5ebf4 55%, #eef1f8 100%); padding: 14px 16px; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; }
body.q-fullscreen .view.q-tv .q-foot { color: #64748b; font-weight: 600; letter-spacing: .3px; padding: 8px 0 4px; }
/* ---- โหมดจอ TV: หน้าจอเต็ม ตัวใหญ่ อ่านจากไกล ---- */
.view.q-tv { --tvgap: clamp(12px, 1.4vw, 22px); }
.view.q-tv .q-cols { gap: var(--tvgap); }
.view.q-tv .q-col-h { font-size: clamp(18px, 1.6vw, 26px); padding: 12px 18px; }
.view.q-tv .q-col-h span { font-size: clamp(12px, .95vw, 16px); }
/* กะทัดรัดเพื่อให้เห็นหลายชื่อต่อจอ */
.view.q-tv .q-item { padding: 6px 12px; gap: 10px; }
.view.q-tv .q-no { font-size: clamp(20px, 1.7vw, 32px); min-width: clamp(48px, 3.4vw, 70px); height: clamp(38px, 2.8vw, 52px); border-radius: 10px; }
.view.q-tv .q-name { font-size: clamp(17px, 1.4vw, 26px); }
.view.q-tv .q-hn { display: none; } /* ไม่แสดง HN บนจอ TV (ข้อมูลผู้ป่วย) */
.view.q-tv .q-btns, .view.q-tv .q-acts { display: none; } /* จอ TV = แสดงอย่างเดียว */
.view.q-tv #qTabs { display: none; }
.view.q-tv .q-tv-only.q-called-list { display: flex; }
.view.q-tv .q-tv-only.q-called-h { display: block; }
.view.q-tv .q-list { gap: 8px; max-height: calc(100vh - 190px); }
/* คอลัมน์กลาง (รอรับยา) แสดง 2 คอลัมน์ชื่อ ใช้พื้นที่กว้างให้เห็นชื่อเยอะ · ขวาแคบลงลดที่ว่าง */
.view.q-tv .q-cols-3 { grid-template-columns: 1fr 1.7fr 1fr; }
.view.q-tv #qPh { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.view.q-tv #qPh .q-item { min-width: 0; }
.view.q-tv .q-counter { min-width: clamp(66px, 4.4vw, 104px); font-size: clamp(30px, 2.6vw, 50px); padding: 8px 12px; flex: 0 0 auto; }
.view.q-tv .q-called-list { max-height: none; }
.view.q-tv .q-called-list .q-item { background: linear-gradient(135deg, rgba(18,185,129,.16), rgba(18,185,129,.04)); border: 2px solid var(--accent, #12b981); border-radius: 16px; padding: 12px 16px; gap: 12px; }
.view.q-tv .q-called-list .q-name { font-size: clamp(19px, 1.6vw, 28px); font-weight: 800; line-height: 1.2; white-space: normal; overflow-wrap: break-word; } /* ชื่อเต็ม ไม่ตัด (ขึ้นบรรทัดที่ช่องว่าง) */
.view.q-tv .q-called-list .q-no { font-size: clamp(22px, 1.7vw, 30px); min-width: clamp(46px, 3vw, 64px); height: auto; background: transparent; color: var(--muted); }
.view.q-tv .q-called-list .q-hn { font-size: clamp(12px, .9vw, 16px); }
.view.q-tv .q-called-list .q-recall { display: none; }
.view.q-tv .q-called-big .q-item:first-child { box-shadow: 0 0 0 3px rgba(18,185,129,.4); animation: qpulse 1.2s ease-in-out 4; }
@keyframes qpulse { 0%,100% { box-shadow: 0 0 0 3px rgba(18,185,129,.35); } 50% { box-shadow: 0 0 0 10px rgba(18,185,129,.12); } }
/* การ์ดที่เพิ่งเรียก/เรียกซ้ำล่าสุด — เด้งเรียกความสนใจ (เด้งใหม่ทุกรอบ render) */
.q-called-list .q-item.q-latest { animation: qbounce 1s ease; }
@keyframes qbounce { 0%,100% { transform: scale(1); } 25% { transform: scale(1.06); } 55% { transform: scale(.99); } }
/* จอ TV: หมวด "เรียกแล้ว · การเงิน" เด่นเป็นสีทอง + รายการล่าสุดเต้นต่อเนื่อง */
.view.q-tv #qPayCalled .q-item { background: linear-gradient(135deg, rgba(245,158,11,.22), rgba(245,158,11,.05)); border-color: #f59e0b; }
.view.q-tv #qPayCalled .q-item.q-latest { box-shadow: 0 0 0 3px rgba(245,158,11,.5); animation: qpaypulse 1.2s ease-in-out infinite; }
@keyframes qpaypulse { 0%,100% { box-shadow: 0 0 0 3px rgba(245,158,11,.45); } 50% { box-shadow: 0 0 0 11px rgba(245,158,11,.12); } }
/* โหมดจอ TV เต็มจอ — วางทับเต็มหน้าจอ (fixed) ให้บอร์ดเต็มจอแน่นอน */
body.q-fullscreen .top, body.q-fullscreen #scrim { display: none !important; }
body.q-fullscreen #view { position: fixed; inset: 0; width: 100vw; max-width: none; height: 100vh; z-index: 1000; background: var(--bg); padding: 16px 22px; overflow: hidden; margin: 0; display: flex; flex-direction: column; }
body.q-fullscreen .q-bar { margin-bottom: 12px; flex: 0 0 auto; border-bottom: none; padding-bottom: 4px; }
/* โหมดทีวี: ซ่อนแถบควบคุม (นาฬิกา/เลือกเสียง/ปุ่มเสียง/ปุ่มออก) — เลื่อนเมาส์มาที่หัวแถบเพื่อเผย, ออกด้วยปุ่ม Esc */
body.q-fullscreen .q-bar #qClock, body.q-fullscreen .q-bar #qVoice,
body.q-fullscreen .q-bar #qSound, body.q-fullscreen .q-bar #qTv { opacity: 0; pointer-events: none; transition: opacity .2s; }
body.q-fullscreen .q-bar:hover #qClock, body.q-fullscreen .q-bar:hover #qVoice,
body.q-fullscreen .q-bar:hover #qSound, body.q-fullscreen .q-bar:hover #qTv { opacity: 1; pointer-events: auto; }
body.q-fullscreen .q-h { font-size: clamp(22px, 2vw, 34px); }
body.q-fullscreen .view.q-tv .q-cols { flex: 1 1 auto; min-height: 0; align-items: stretch; grid-template-rows: minmax(0, 1fr); }
body.q-fullscreen .view.q-tv #qIpd { flex: 1 1 auto; min-height: 0; align-items: stretch; grid-template-rows: minmax(0, 1fr); }
body.q-fullscreen .view.q-tv #qIpd .q-col { display: flex; flex-direction: column; min-height: 0; }
body.q-fullscreen .view.q-tv #qIpd .q-ipd-list, body.q-fullscreen .view.q-tv #qIpd .q-called-list { flex: 1; max-height: none; }
body.q-fullscreen .view.q-tv .q-ipd-nm { font-size: clamp(18px, 1.5vw, 26px); }
body.q-fullscreen .view.q-tv .q-col { display: flex; flex-direction: column; min-height: 0; }
body.q-fullscreen .view.q-tv .q-list { flex: 1; max-height: none; }
body.q-fullscreen .view.q-tv .q-col .q-called-list { flex: 0 1 auto; }
/* คอลัมน์ 3 (เรียกแล้ว·รับยา) — การ์ดกะทัดรัด เห็นได้หลายชื่อ (เลื่อนได้ถ้าเกิน) */
body.q-fullscreen .view.q-tv #qPhCalled { flex: 1 1 auto; gap: 8px; overflow-y: auto; align-content: start; }
body.q-fullscreen .view.q-tv #qPhCalled .q-item { flex: 0 0 auto; }
body.q-fullscreen .view.q-tv .q-called-list .q-item { padding: 8px 14px; }
body.q-fullscreen .view.q-tv .q-called-list .q-name { font-size: clamp(18px, 1.4vw, 26px); -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
/* บอร์ด TV ใหม่ (Smart Queue style) — เต็มจอ + ซ่อนแถบบน */
body.q-fullscreen .view.q-tv .q-bar { display: none; }
body.q-fullscreen .view.q-tv .q-tvboard { flex: 1 1 auto; min-height: 0; }
body.q-fullscreen .view.q-tv .q-tv-side, body.q-fullscreen .view.q-tv .q-tv-mid { min-height: 0; }
@media (max-width: 900px) { .q-cols, .q-cols-2, .q-cols-3 { grid-template-columns: 1fr; } }
/* ---------- ผู้ป่วยในทั้งหมด ---------- */
.ipd-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ipd-stats { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.ipd-stats span { color: var(--text-2); } .ipd-stats b { color: var(--text); font-size: 20px; margin-right: 4px; }
.ipd-stats .dc b { color: var(--accent); } .ipd-stats .warn b { color: var(--crit); }
.ipd-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.ipd-ward { margin-top: 12px; padding: 12px 14px; }
.ipd-ward h3 { margin: 0 0 2px; }
.ipd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; margin-top: 8px; }
.ipd-top-ctl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* แถบปุ่มแจ้งรถยาเสร็จเข้ากลุ่มไลน์ของตึก */
.ipd-cart { flex-basis: 100%; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 4px; padding-top: 10px; border-top: 1px dashed var(--border); }
.ipd-cart-l { font-size: 13px; font-weight: 600; color: var(--text-2); }
.ipd-cart-btn { font-weight: 700; border-color: #16a34a; color: #15803d; background: #f0fdf4; }
.ipd-cart-btn:hover { background: #16a34a; color: #fff; }
:root[data-theme="dark"] .ipd-cart-btn { background: rgba(22, 163, 74, .16); color: #86efac; border-color: rgba(22, 163, 74, .5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ipd-cart-btn { background: rgba(22, 163, 74, .16); color: #86efac; border-color: rgba(22, 163, 74, .5); } }
/* แถบปุ่มแจ้ง Ward บนหน้าแจ้งเตือน — consult เด่น (ส้ม) · รถยา (เขียว) แยกตำแหน่ง */
.al-wardbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.al-wardbar-gap { flex: 1 1 24px; min-width: 16px; }
.al-cart-l { font-size: 13px; font-weight: 600; color: var(--text-2); }
.al-consult-btn { font-weight: 800; color: #fff; background: #d97706; border: 1px solid #b45309; box-shadow: 0 2px 8px rgba(217,119,6,.35); padding: 9px 16px; border-radius: 10px; font-size: 14.5px; }
.al-consult-btn:hover { background: #b45309; box-shadow: 0 3px 12px rgba(217,119,6,.45); }
.al-cart-btn { font-weight: 700; border-color: #16a34a; color: #15803d; background: #f0fdf4; }
.al-cart-btn:hover { background: #16a34a; color: #fff; }
:root[data-theme="dark"] .al-cart-btn { background: rgba(22, 163, 74, .16); color: #86efac; border-color: rgba(22, 163, 74, .5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .al-cart-btn { background: rgba(22, 163, 74, .16); color: #86efac; border-color: rgba(22, 163, 74, .5); } }
/* ฟอร์มใน modal แจ้ง Ward consult */
.cs-field { margin-bottom: 12px; }
.cs-field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.cs-wards { display: flex; gap: 10px; flex-wrap: wrap; }
.cs-ward { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-weight: 600; }
.cs-ward:has(input:checked) { border-color: #d97706; background: #fff7ed; color: #b45309; }
:root[data-theme="dark"] .cs-ward:has(input:checked) { background: rgba(217,119,6,.18); color: #fdba74; }
/* ช่องค้นหาผู้ป่วยในป๊อปอัปแจ้ง Ward */
.cs-search { position: relative; }
.cs-sug { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin-top: 3px; max-height: 250px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.14); }
.cs-sug-item { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13.5px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.cs-sug-item:last-child { border-bottom: 0; }
.cs-sug-item:hover { background: var(--accent-soft); }
.cs-sug-name { font-weight: 600; }
.cs-sug-meta { color: var(--text-2); font-size: 12px; margin-left: auto; }
.cs-sug-empty { padding: 9px 11px; color: var(--text-2); font-size: 12.5px; }
/* การ์ดตัวอย่างก่อนส่ง (เลียนแบบการ์ด LINE) */
.cs-card { border: 1px solid #f0c38a; border-radius: 12px; overflow: hidden; background: #fff; box-shadow: 0 2px 10px rgba(180,83,9,.12); }
.cs-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 13px; background: #fff7ed; border-bottom: 1px solid #fde7c8; }
.cs-card-title { color: #b45309; font-weight: 800; font-size: 14.5px; }
.cs-card-ward { color: #92631f; font-size: 13px; font-weight: 600; }
.cs-card-body { padding: 10px 13px; font-size: 15px; color: #222; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.cs-card-foot { padding: 7px 13px 9px; font-size: 11.5px; color: #999; border-top: 1px solid #f3f4f6; }
/* แบนเนอร์เตือนคืนยาเดิม */
.hmr-list { display: flex; flex-direction: column; gap: 7px; }
.hmr-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 7px 11px; background: var(--surface); border: 1px solid #ddd0f5; border-radius: 9px; }
.hmr-pt { min-width: 210px; font-size: 13.5px; }
.hmr-meds { flex: 1; min-width: 180px; font-size: 12.5px; color: #5b21b6; }
:root[data-theme="dark"] .hmr-meds { color: #c4b5fd; }
.hmr-ack { margin-left: auto; white-space: nowrap; }
/* ตารางสรุปรายงานการใช้ยา — จัดกึ่งกลางทุกคอลัมน์ (ยกเว้นชื่อยาชิดซ้าย) อ่านง่าย */
.dr-sum th, .dr-sum td { text-align: center !important; }
.dr-sum th:first-child, .dr-sum td:first-child { text-align: left !important; }
/* โหมดเลือกเตียง (มือถือ) */
.ipd-beddetail { margin-top: 12px; }
.ipd-beddetail .ipd-card { font-size: 13px; padding: 12px 12px 12px 46px; }
.ipd-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-top: 10px; }
.ipd-chip { position: relative; min-height: 48px; padding: 6px 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 14px; line-height: 1.1; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ipd-chip i { font-style: normal; font-size: 9px; font-weight: 700; color: var(--crit); }
.ipd-chip.crit { border-color: var(--crit); color: var(--crit); background: rgba(220,53,69,.08); }
.ipd-chip.warn { border-color: var(--warn, #e0a800); box-shadow: inset 0 -3px 0 var(--warn, #e0a800); }
.ipd-chip.care { border-color: #a855f7; box-shadow: inset 0 -3px 0 #a855f7; }
.ipd-chip.priority { border: 2px solid #f59e0b; background: linear-gradient(135deg, rgba(245,158,11,.18), rgba(245,158,11,.03)); }
.ipd-chip.dc { border-style: dashed; }
.ipd-chip.sel { outline: 3px solid var(--accent); outline-offset: 1px; }
.ipd-card { position: relative; display: flex; align-items: flex-start; gap: 9px; padding: 7px 8px 7px 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 12px; }
.ipd-card.has-crit { border-color: var(--crit); box-shadow: inset 3px 0 0 var(--crit); }
.ipd-card.has-warn { box-shadow: inset 3px 0 0 var(--warn, #e0a800); }
.ipd-bed { position: absolute; left: 0; top: 0; bottom: 0; width: 33px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: var(--accent); background: var(--accent-soft); border-radius: 10px 0 0 10px; }
.ipd-photo { width: 36px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); flex: none; }
.ipd-body { flex: 1; min-width: 0; line-height: 1.35; }
.ipd-name { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ipd-meta { font-size: 11px; color: var(--text-2); }
.ipd-line { font-size: 11.5px; color: var(--text); margin-top: 1px; }
.ipd-line .ipd-lbl { color: var(--text-2); font-weight: 600; margin-right: 4px; }
.ipd-probs { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.ipd-prob { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 5px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ipd-prob.crit { color: #fff; background: var(--crit); }
.ipd-prob.warn { color: #7a5200; background: var(--crit-soft); }
.ipd-prob.info { color: var(--text-2); background: var(--surface); border: 1px solid var(--border); }
.ipd-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 5px; }
.ipd-tag.dc { color: var(--accent); background: var(--accent-soft); }
.ipd-tag.crit { color: #fff; background: var(--crit); }
.ipd-tag.warn { color: var(--crit); background: var(--crit-soft); }
.ipd-tag.care { color: #6b21a8; background: #f3e8ff; }
.ipd-tag.nodisp { color: #9a3412; background: #ffedd5; border: 1px solid #fdba74; }
/* ปุ่มฉลากวาร์ฟาริน — แดงให้เด่น เตือนว่าเคสนี้มีวาร์ฟาริน */
.pc-wflabel { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; font-weight: 700; }
.pc-wflabel:hover { background: #fee2e2; }
:root[data-theme="dark"] .pc-wflabel { background: rgba(220,38,38,.16); color: #fca5a5; border-color: rgba(220,38,38,.5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-wflabel { background: rgba(220,38,38,.16); color: #fca5a5; border-color: rgba(220,38,38,.5); } }
/* ผลแลป OCR ในหน้าตรวจก่อนจ่าย (modal #loModal) */
.lo-item { border: 1px solid var(--border); border-radius: 9px; margin-bottom: 8px; overflow: hidden; background: var(--surface-2); }
.lo-item.empty { opacity: .72; }
.lo-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; cursor: pointer; }
.lo-head:hover { background: var(--surface-3); }
.lo-date { font-weight: 700; font-size: 12.5px; }
.lo-form { font-size: 12px; color: var(--text-2); flex: 1; min-width: 0; }
.lo-badge.micro { font-size: 10.5px; font-weight: 700; color: #6b21a8; background: #f3e8ff; padding: 1px 7px; border-radius: 999px; }
.lo-conf { font-size: 10.5px; color: var(--text-2); }
.lo-sum { padding: 0 10px 8px; font-size: 12.5px; color: var(--text); }
.lo-detail { padding: 2px 10px 12px; border-top: 1px dashed var(--border); }
.lo-tb { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12px; }
.lo-tb th, .lo-tb td { border-bottom: 1px solid var(--border); padding: 3px 6px; text-align: left; }
.lo-tb th { color: var(--text-2); font-weight: 600; }
.lo-tb td.r, .lo-tb th.r { text-align: right; }
.lo-grp td { background: var(--surface-3); font-weight: 700; }
.lo-hi { color: var(--crit); font-weight: 800; }
.lo-lo { color: #1d4ed8; font-weight: 800; }
.lo-micro { margin-top: 8px; font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
.lo-org { margin-top: 4px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.lo-sus td { border-bottom: 1px solid var(--border); padding: 2px 6px; }
.lo-sus-s { color: #15803d; font-weight: 800; } .lo-sus-r { color: var(--crit); font-weight: 800; } .lo-sus-i { color: #b45309; font-weight: 800; }
/* ผู้จัดยา ในหน้าตรวจก่อนจ่าย — ไฮไลท์ให้เห็นชัด (เหลือง=ยังไม่เลือก · เขียว=เลือกแล้ว) */
.pc-picker-row { display: flex; align-items: center; gap: 9px; margin-top: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--border); transition: background .15s, border-color .15s; }
.pc-picker-row label { font-size: 13.5px; font-weight: 800; }
.pc-picker-row .pc-picker { width: auto; min-width: 230px; max-width: 100%; font-weight: 700; }
.pc-picker-row .pc-picker-hint { font-size: 12px; font-weight: 600; }
.pc-picker-row #pcPickerMsg { font-size: 12px; }
.pc-picker-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.pc-picker-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; padding: 3px 4px 3px 10px; border-radius: 999px; background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.pc-chip-x { border: none; background: rgba(0,0,0,.08); color: inherit; width: 17px; height: 17px; border-radius: 50%; cursor: pointer; font-size: 11px; line-height: 1; display: grid; place-items: center; padding: 0; }
.pc-chip-x:hover { background: rgba(0,0,0,.2); }
:root[data-theme="dark"] .pc-picker-chip { background: #0f2f1c; color: #86efac; border-color: #15803d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-picker-chip { background: #0f2f1c; color: #86efac; border-color: #15803d; } }
/* ยังไม่เลือก = เหลืองกระพริบเบา ๆ ให้สะดุดตา */
.pc-picker-row.unset { background: #fef9c3; border-color: #f59e0b; animation: pcPickerPulse 1.8s ease-in-out infinite; }
.pc-picker-row.unset label, .pc-picker-row.unset .pc-picker-hint { color: #92400e; }
.pc-picker-row.unset .pc-picker { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,.25); }
/* เลือกแล้ว = เขียวสงบ */
.pc-picker-row.set { background: #dcfce7; border-color: #86efac; animation: none; }
.pc-picker-row.set label, .pc-picker-row.set .pc-picker-hint { color: #166534; }
@keyframes pcPickerPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } 50% { box-shadow: 0 0 0 4px rgba(245,158,11,.22); } }
:root[data-theme="dark"] .pc-picker-row.unset { background: #3b2f0b; border-color: #b45309; }
:root[data-theme="dark"] .pc-picker-row.unset label, :root[data-theme="dark"] .pc-picker-row.unset .pc-picker-hint { color: #fcd34d; }
:root[data-theme="dark"] .pc-picker-row.set { background: #0f2f1c; border-color: #15803d; }
:root[data-theme="dark"] .pc-picker-row.set label, :root[data-theme="dark"] .pc-picker-row.set .pc-picker-hint { color: #86efac; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pc-picker-row.unset { background: #3b2f0b; border-color: #b45309; }
  :root:not([data-theme="light"]) .pc-picker-row.unset label, :root:not([data-theme="light"]) .pc-picker-row.unset .pc-picker-hint { color: #fcd34d; }
  :root:not([data-theme="light"]) .pc-picker-row.set { background: #0f2f1c; border-color: #15803d; }
  :root:not([data-theme="light"]) .pc-picker-row.set label, :root:not([data-theme="light"]) .pc-picker-row.set .pc-picker-hint { color: #86efac; }
}
.ipd-card.has-nodisp { box-shadow: inset 3px 0 0 #ea580c; }
.ipd-stats .nodisp b { color: #ea580c; }
.ipd-stats .nodisp.clickable { cursor: pointer; }
.ipd-stats .nodisp.on { background: #ffedd5; border-radius: 6px; outline: 1.5px solid #fdba74; }
.ipd-check { flex: none; padding: 0 8px; height: 28px; }
/* กลุ่มเป้าหมายบริบาลเภสัชกรรม */
.ipd-card.has-care { box-shadow: inset 3px 0 0 #a855f7; }
.ipd-card.has-crit.has-care { box-shadow: inset 3px 0 0 var(--crit), inset 6px 0 0 #a855f7; }
.ipd-stats .care b { color: #7e22ce; }
/* เริ่มยาครั้งแรก (insulin/พ่น/warfarin/TB) = บริบาลด่วน — ไฮไลท์เด่นสุด */
.ipd-card.has-priority { border: 2px solid #f59e0b; background: linear-gradient(135deg, rgba(245,158,11,.16), rgba(245,158,11,.03)); box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.ipd-tag.priority { color: #fff; background: linear-gradient(135deg, #f59e0b, #d97706); }
.ipd-newstart { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 2px; }
.ipd-newstart span { font-size: 11.5px; font-weight: 800; color: #b45309; background: #fff7ed; border: 1px solid #fdba74; border-radius: 6px; padding: 2px 8px; }
/* ผลเพาะเชื้อ/ความไวยา (C/S) */
.ipd-card.has-culture { border: 2px solid #0ea5a0; box-shadow: 0 0 0 2px rgba(14,165,160,.14); }
.ipd-tag.culture { color: #fff; background: linear-gradient(135deg, #0ea5a0, #0d9488); }
.ipd-culture { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 2px; }
.ipd-cs { font-size: 11.5px; font-weight: 700; color: #0f766e; background: #ccfbf1; border: 1px solid #5eead4; border-radius: 6px; padding: 2px 9px; }
.ipd-cs.has-img { cursor: pointer; }
.ipd-cs.has-img:hover { background: #99f6e4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ipd-cs { color: #5eead4; background: #10312e; border-color: #1c5450; } }
.labimg-ov { position: fixed; inset: 0; z-index: 6000; background: rgba(0,0,0,.82); display: flex; flex-direction: column; }
.labimg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; color: #fff; background: rgba(0,0,0,.4); }
.labimg-head .icon-btn { color: #fff; }
.labimg-body { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.labimg-body img { max-width: min(100%, 1100px); height: auto; border-radius: 6px; box-shadow: 0 4px 20px rgba(0,0,0,.5); background: #fff; }
.labimg-body img ~ .labimg-empty { display: none; }
/* template เงื่อนไข RDU */
.rtpl-wrap { width: min(100%, 1120px); display: flex; flex-direction: column; gap: 12px; }
.rtpl-card { background: var(--surface, #fff); color: var(--text); border-radius: 12px; padding: 14px 16px; box-shadow: 0 2px 14px rgba(0,0,0,.3); }
.rtpl-h { font-size: 14.5px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); line-height: 1.5; }
.rtpl-target { float: right; font-size: 12px; font-weight: 700; color: var(--series-1); white-space: nowrap; }
.rtpl-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; font-size: 13px; padding: 4px 0; line-height: 1.6; }
.rtpl-k { color: var(--muted); font-weight: 600; }
.rtpl-k.rtpl-ex { color: #c0271b; }
.rtpl-code { background: color-mix(in srgb, var(--series-1) 14%, transparent); border-radius: 5px; padding: 0 5px; font-size: 11.5px; display: inline-block; }
.rtpl-icds { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 16px; }
.rtpl-icd { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.rtpl-icd .rtpl-code { flex: 0 0 auto; }
.rtpl-icd-nm { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .rtpl-icds { grid-template-columns: 1fr; } }
.rtpl-nc { margin: 8px 0 2px; border-top: 1px dashed var(--border); padding-top: 8px; }
.rtpl-nc > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: #b45309; list-style: none; }
.rtpl-nc > summary::-webkit-details-marker { display: none; }
.rtpl-nc > summary::before { content: '▸ '; }
.rtpl-nc[open] > summary::before { content: '▾ '; }
.rtpl-icds-nc { margin-top: 8px; max-height: 320px; overflow-y: auto; }
.rtpl-icds-nc .rtpl-code { background: color-mix(in srgb, #b45309 14%, transparent); color: #92400e; }
.rtpl-icds-nc .rtpl-icd-nm { opacity: .85; }
.rcmp-wrap { width: min(100%, 900px); }
.rcmp-wrap table { background: var(--surface, #fff); color: var(--text); border-radius: 10px; overflow: hidden; }
.rcmp-big { color: #c0271b; font-weight: 800; }
/* ปุ่มลอยติดตั้งแอปจอทีวี + overlay */
.q-apk-fab { position: fixed; right: 14px; bottom: 14px; z-index: 40; border: none; border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; background: rgba(13,148,136,.9); color: #fff; box-shadow: 0 3px 14px rgba(0,0,0,.3); opacity: .55; transition: opacity .15s; }
.q-apk-fab:hover { opacity: 1; }
body.q-fullscreen .q-apk-fab { opacity: .25; }
body.q-fullscreen .q-apk-fab:hover { opacity: 1; }
.q-fs-fab { position: fixed; left: 14px; bottom: 14px; z-index: 40; border: none; border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; background: rgba(30,41,59,.9); color: #fff; box-shadow: 0 3px 14px rgba(0,0,0,.3); opacity: .55; transition: opacity .15s; }
.q-fs-fab:hover { opacity: 1; }
body.q-fullscreen .q-fs-fab { opacity: .25; }
body.q-fullscreen .q-fs-fab:hover { opacity: 1; }
.tvapk-ov { position: fixed; inset: 0; z-index: 7000; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 20px; }
.tvapk-card { position: relative; width: min(100%, 460px); background: var(--surface, #fff); color: var(--text); border-radius: 16px; padding: 26px 24px; box-shadow: 0 10px 40px rgba(0,0,0,.4); text-align: center; }
.tvapk-x { position: absolute; top: 12px; right: 12px; border: none; background: transparent; cursor: pointer; color: var(--muted); }
.tvapk-ic { font-size: 40px; }
.tvapk-card h2 { margin: 6px 0 4px; font-size: 19px; }
.tvapk-card p { margin: 0 0 14px; font-size: 13px; }
.tvapk-dl { display: inline-flex; font-size: 16px; padding: 12px 22px; margin-bottom: 12px; }
.tvapk-url { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; word-break: break-all; }
.tvapk-steps { text-align: left; font-size: 13px; line-height: 1.7; margin: 0 0 12px; padding-left: 20px; }
.tvapk-boot { text-align: left; font-size: 12.5px; line-height: 1.6; background: color-mix(in srgb, #0d9488 12%, transparent); border: 1px solid color-mix(in srgb, #0d9488 35%, transparent); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.tvapk-boot > div { margin-top: 5px; color: var(--muted); }
.rtpl-hdc { margin-top: 8px; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--border) 30%, transparent); border-radius: 8px; padding: 6px 10px; }
@media (max-width: 640px) { .rtpl-row { grid-template-columns: 1fr; gap: 2px; } }
.labimg-empty { color: #cbd5e1; }
.ipd-stats .priority b { color: #d97706; }
.wf-inr { font-size: 16px; font-weight: 800; }
.wf-inr.bad { color: var(--crit); } .wf-inr.warn { color: #b8860b; } .wf-inr.ok { color: #1a7a4d; }
.ipd-care { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.ipd-care-t { font-size: 10.5px; font-weight: 600; color: #6b21a8; background: #f3e8ff; padding: 1px 6px; border-radius: 5px; }
/* ---------- ผู้ป่วยในช่องแจ้งเตือน (ชื่อ+รูป เฉพาะในเครื่อง) ---------- */
.al-pt { display: flex; gap: 9px; align-items: flex-start; }
.al-photo { width: 42px; height: 52px; object-fit: cover; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-2); flex: none; }
.al-pt-info { min-width: 0; }
.al-name { font-weight: 700; font-size: 13.5px; }
.al-name:empty { display: none; }
.had-note { display: block; font-size: 12px; color: #a8410f; background: #fff2ec; border-left: 3px solid #e8703a; padding: 3px 8px; border-radius: 4px; margin-top: 3px; }
.lab-line { display: block; font-size: 12px; color: #1f6f5c; background: #eefaf4; border-left: 3px solid #35b98a; padding: 3px 8px; border-radius: 4px; margin-top: 3px; }
.pc-in { display: flex; gap: 10px; flex-wrap: wrap; }
.pc-in .input { flex: 1; min-width: 200px; font-size: 20px; font-weight: 600; letter-spacing: 1px; }
.pc-in .select { max-width: 130px; }
.pc-in .btn { white-space: nowrap; }
.pc-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.pc-head h2 { margin: 0; }
.pc-banner { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 10px; font-weight: 600; margin: 14px 0; }
.pc-banner.ok { background: #eafaf1; color: #1a7a4d; border: 1px solid #b7e4c9; }
.pc-banner.warn { background: #fff6e5; color: #96590a; border: 1px solid #f0d59a; }
.pc-banner.bad { background: #fdecec; color: #b02020; border: 1px solid #f2b8b8; }
.pc-probs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
/* การ์ด "ปัญหาที่พบ" ให้เด่นชัด — กรอบส้มหนา + ไอคอน ⚠️ + เงา */
.pc-probs-card { border: 2px solid var(--warn); box-shadow: 0 3px 16px var(--warn-soft); }
.pc-probs-card > h3 { display: flex; align-items: center; gap: 7px; font-size: 1.08em; }
.pc-probs-card > h3::before { content: '⚠️'; font-size: 1.1em; line-height: 1; }
.pc-prob { background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--muted); border-radius: 10px; padding: 12px 14px; }
/* แต่ละปัญหา: พื้นมีสีอ่อนตามระดับความรุนแรง ให้มองเห็นชัด (ไม่ใช่แค่ขีดซ้าย) */
.pc-prob.sev-crit { border-left-color: var(--crit); background: var(--crit-soft); border-color: rgba(208, 59, 59, .30); }
.pc-prob.sev-warn { border-left-color: var(--warn); background: var(--warn-soft); border-color: rgba(250, 178, 25, .38); }
.pc-prob.sev-info { border-left-color: #3b82c4; background: var(--info-soft); border-color: rgba(100, 116, 139, .26); }
.pc-prob-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.pc-review-tag { font-size: 11.5px; font-weight: 700; color: #7c3aed; background: #f3ecff; border: 1px solid #e0ceffaa; border-radius: 999px; padding: 1px 8px; }

/* ---- รายงานความเสี่ยงองค์กรแพทย์ (md-report) ---- */
.mdr-doc { max-width: 920px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 32px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mdr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 3px solid #0d9488; padding-bottom: 14px; margin-bottom: 18px; }
.mdr-title { font-size: 22px; font-weight: 800; color: var(--ink, #0f172a); line-height: 1.25; }
.mdr-subtitle { font-size: 13px; color: var(--muted); margin-top: 3px; }
.mdr-period { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.mdr-period b { display: block; font-size: 14px; color: var(--ink, #0f172a); margin: 2px 0; }
.mdr-sec-h { font-size: 15px; font-weight: 800; color: #0d9488; margin: 22px 0 10px; padding-left: 10px; border-left: 4px solid #0d9488; }
.ptc-sub-h { font-size: 13.5px; font-weight: 700; color: var(--text); margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 1px dashed var(--border); }
.ptc-tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, #f59e0b 22%, transparent); color: #b45309; vertical-align: middle; }
.ptc-tag.red { background: color-mix(in srgb, #e23b3b 20%, transparent); color: #c0271b; }
.ptc-trend { display: flex; align-items: flex-end; gap: 4px; height: 70px; padding-top: 4px; }
.ptc-tb { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; }
.ptc-tb-bar { width: 100%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 3px; }
.ptc-tb span { font-size: 9.5px; color: var(--muted); }
.ptc-gb-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.ptc-gb { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.ptc-gb-h { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.ptc-gb-bars { display: flex; align-items: flex-end; justify-content: space-around; gap: 8px; height: 100px; }
.ptc-gb-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; flex: 1; }
.ptc-gb-v { font-size: 11px; font-weight: 700; }
.ptc-gb-bar { width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; min-height: 4px; }
.ptc-gb-col span { font-size: 10px; color: var(--muted); }
@media (max-width: 720px) { .ptc-gb-wrap { grid-template-columns: 1fr 1fr; } }
.ptc-more { margin: 8px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.ptc-more > summary { cursor: pointer; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--series-1); list-style: none; }
.ptc-more > summary::-webkit-details-marker { display: none; }
.ptc-more > summary::before { content: '▸ '; }
.ptc-more[open] > summary::before { content: '▾ '; }
.ptc-more[open] > summary { border-bottom: 1px solid var(--border); }
.ptc-more > div { padding: 0 12px 12px; }
.ptc-sub-note { font-size: 12.5px; font-weight: 600; margin: 10px 0 6px; }
@media print { .ptc-more { border: none; } .ptc-more > summary { display: none; } .ptc-more > div { padding: 0; } .ptc-more:not([open]) > div { display: block !important; } }
.mdr-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; }
.mdr-tile { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.mdr-tile.good { border-top: 3px solid #0ea05a; } .mdr-tile.bad { border-top: 3px solid #e23b3b; }
.mdr-tile-l { font-size: 12.5px; color: var(--muted); } .mdr-tile-v { font-size: 26px; font-weight: 800; margin: 3px 0; line-height: 1.1; } .mdr-tile-s { font-size: 11.5px; color: var(--muted); }
.mdr-note { margin: 14px 0 4px; padding: 12px 14px; background: color-mix(in srgb, var(--border) 35%, transparent); border-radius: 10px; font-size: 13.5px; line-height: 1.7; }
.mdr-red { color: #c0271b; font-weight: 700; }
.mdr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.mdr-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.mdr-recs { margin: 6px 0 0; padding-left: 22px; font-size: 13.5px; line-height: 1.85; }
.mdr-recs li { margin-bottom: 6px; }
.mdr-foot { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); text-align: center; }
.mdr-ov { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 6px; }
.mdr-ov-i { text-align: center; border: 1px solid var(--border); border-radius: 12px; padding: 14px 10px; background: var(--surface); }
.mdr-ov-i b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.mdr-ov-i span { font-size: 12px; color: var(--muted); }
.mdr-ov-i.warn { border-color: #e23b3b; } .mdr-ov-i.warn b { color: #c0271b; }
.mdr-issues { display: flex; flex-direction: column; gap: 10px; }
.mdr-issue { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-left: 5px solid var(--muted); border-radius: 12px; padding: 14px 16px; background: var(--surface); break-inside: avoid; }
.mdr-issue.high { border-left-color: #e23b3b; } .mdr-issue.mid { border-left-color: #e8930a; } .mdr-issue.info { border-left-color: #0ea05a; }
.mdr-issue-n { flex: none; width: 30px; height: 30px; border-radius: 50%; background: #0d9488; color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.mdr-issue.high .mdr-issue-n { background: #e23b3b; } .mdr-issue.mid .mdr-issue-n { background: #e8930a; } .mdr-issue.info .mdr-issue-n { background: #0ea05a; }
.mdr-issue-main { flex: 1; min-width: 0; }
.mdr-issue-t { font-size: 16px; font-weight: 800; color: var(--ink, #0f172a); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mdr-issue-pri { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 9px; }
.mdr-issue-pri.high { background: #fde7e7; color: #c0271b; } .mdr-issue-pri.mid { background: #fdf0db; color: #9a6207; } .mdr-issue-pri.info { background: #e4f6ec; color: #0a7a42; }
.mdr-issue-d { font-size: 13.5px; color: var(--muted); margin: 5px 0; }
.mdr-issue-a { font-size: 14px; line-height: 1.6; }
.mdr-issue-a span { font-weight: 700; color: #0d9488; }
.mdr-detail { margin-top: 20px; border-top: 1px dashed var(--border); padding-top: 6px; }
.mdr-detail > summary { cursor: pointer; font-weight: 700; color: #0d9488; padding: 8px 0; font-size: 14px; }
.mdr-agenda { margin-top: 20px; border: 1.5px solid #0d9488; border-radius: 14px; padding: 16px 18px; background: color-mix(in srgb, #0d9488 5%, transparent); break-inside: avoid; }
.mdr-agenda-h { font-size: 16px; font-weight: 800; color: #0d9488; margin-bottom: 10px; }
.mdr-agenda-kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mdr-agenda-kpi > div { text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.mdr-agenda-kpi b { display: block; font-size: 23px; font-weight: 800; line-height: 1.1; }
.mdr-agenda-kpi span { font-size: 11.5px; color: var(--muted); }
.mdr-agenda-kpi > div.ok b { color: #0a7a42; } .mdr-agenda-kpi > div.bad b { color: #c0271b; }
.mdr-mini-h { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.mdr-ep-row { background: color-mix(in srgb, #e23b3b 12%, transparent); }
.mdr-discuss { margin-top: 12px; display: grid; gap: 10px; }
.mdr-discuss-q ul { margin: 6px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.8; }
.mdr-reso { background: color-mix(in srgb, #0ea05a 12%, transparent); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
@media (max-width: 720px) { .mdr-agenda-kpi { grid-template-columns: 1fr; } }
.mdr-risks { display: flex; flex-direction: column; gap: 8px; }
.mdr-risk { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); break-inside: avoid; }
.mdr-risk-sum { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; cursor: pointer; list-style: none; }
.mdr-risk-sum::-webkit-details-marker { display: none; }
.mdr-risk[open] > .mdr-risk-sum { border-bottom: 1px solid var(--border); }
.mdr-risk-rank { flex: none; width: 26px; height: 26px; border-radius: 7px; background: color-mix(in srgb, #e23b3b 14%, transparent); color: #c0271b; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.mdr-risk-main { flex: 1; min-width: 0; }
.mdr-risk-t { font-size: 14.5px; font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mdr-risk-meta { font-size: 13px; margin: 3px 0 0; }
.mdr-risk-chev { align-self: center; color: var(--muted); font-size: 13px; transition: transform .15s; }
.mdr-risk[open] .mdr-risk-chev { transform: rotate(180deg); }
.mdr-risk-cases { padding: 2px 14px 12px; }
.mdr-sub { border: 1px solid var(--line, #e5e7eb); border-radius: 10px; margin: 6px 0; background: var(--card, #fff); overflow: hidden; }
.mdr-sub-sum { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; list-style: none; }
.mdr-sub-sum::-webkit-details-marker { display: none; }
.mdr-sub[open] > .mdr-sub-sum { border-bottom: 1px solid var(--line, #e5e7eb); }
.mdr-sub-rank { flex: 0 0 auto; min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--chip, #f1f5f9); color: var(--muted, #64748b); font-size: 12px; font-weight: 700; }
.mdr-sub-main { flex: 1 1 auto; min-width: 0; }
.mdr-sub-t { font-size: 13px; font-weight: 600; }
.mdr-sub-meta { font-size: 11px; color: var(--muted, #64748b); }
.mdr-sub-n { flex: 0 0 auto; font-size: 12.5px; white-space: nowrap; }
.mdr-sub[open] > .mdr-sub-sum .mdr-risk-chev { transform: rotate(180deg); }
.mdr-sub-cases { padding: 2px 10px 10px; }
.mdr-cd { font-size: 12px; line-height: 1.5; min-width: 240px; }
.mdr-cd-prob { font-weight: 700; color: #c0271b; margin-bottom: 4px; }
.mdr-ci { display: flex; gap: 6px; align-items: flex-start; margin: 3px 0; }
.mdr-ci-ic { flex: 0 0 auto; }
.mdr-ci-b { min-width: 0; }
.mdr-ci-u { color: var(--muted); font-size: 11.5px; }
.mdr-ci-bad { color: #c0271b; font-weight: 600; }
.mdr-ci-note { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 11.5px; }
.mdr-list { margin: 6px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.75; }
.mdr-list li { margin-bottom: 4px; }
.mdr-benefit { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.mdr-ben-card { border: 1px solid var(--border); border-top: 3px solid #0d9488; border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.mdr-ben-card > b { font-size: 14.5px; }
.mdr-ben-card ul { margin: 7px 0 0; padding-left: 18px; font-size: 12.5px; line-height: 1.65; color: var(--muted); }
.mdr-ben-card li { margin-bottom: 4px; }
@media (max-width: 720px) { .mdr-grid, .mdr-grid2 { grid-template-columns: 1fr; } .mdr-doc { padding: 18px 16px; } }
@media print {
  body * { visibility: hidden !important; }
  #mrBody, #mrBody * { visibility: visible !important; }
  #mrBody { position: absolute; left: 0; top: 0; width: 100%; }
  .mdr-doc { border: 0; border-radius: 0; max-width: 100%; padding: 0; }
  .no-print { display: none !important; }
  .mdr-sec-h, .mdr-grid, .mdr-grid2, .mdr-tile, table { break-inside: avoid; }
  @page { size: A4; margin: 12mm; }
}
.pc-drugs { display: flex; flex-direction: column; gap: 6px; }
.pc-drug { padding: 7px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13.5px; }
.pc-drug-group { font-size: 11.5px; font-weight: 700; color: var(--text-2); margin: 6px 0 1px; padding-left: 2px; border-left: 3px solid var(--accent); padding-left: 7px; }
.pc-drug-group:first-child { margin-top: 0; }
.pc-actions { display: flex; flex-direction: column; gap: 10px; }
.pc-note { min-height: 40px; }
.pc-actions .btn-lg { align-self: flex-start; font-size: 16px; padding: 10px 22px; }
.pc-info { display: flex; flex-direction: column; gap: 10px; }
.pc-allergy { display: flex; align-items: flex-start; gap: 8px; font-weight: 600; color: #b02020; background: #fdecec; border: 1px solid #f2b8b8; padding: 8px 12px; border-radius: 8px; }
.pc-allergy .ic { flex: 0 0 auto; margin-top: 2px; }
.pc-allergy-text { flex: 1; min-width: 0; overflow-wrap: anywhere; word-break: break-word; line-height: 1.45; } /* แพ้ยายาว → ขึ้นบรรทัดใหม่ ไม่ล้น */
.pc-allergy.none { color: #1a7a4d; background: #eafaf1; border-color: #b7e4c9; font-weight: 500; }
.pc-info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 18px; }
.pc-info-grid > div { font-size: 13.5px; }
.pc-info-grid > div.wide { grid-column: 1 / -1; }
.pc-info-grid span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 1px; }
@media (max-width: 640px) { .pc-info-grid { grid-template-columns: 1fr; } }
/* แถบวันนัดถัดไป — ไฮไลท์เด่น */
.pc-appt { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 10px; border: 1.5px solid var(--accent); background: var(--accent-soft); margin: 2px 0; }
.pc-appt .pc-appt-l { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); margin: 0; white-space: nowrap; }
.pc-appt .pc-appt-l .ic { width: 15px; height: 15px; }
.pc-appt .pc-appt-d { font-size: 17px; font-weight: 800; color: var(--text); }
.pc-appt .pc-appt-c { font-size: 12.5px; }
.pc-appt .pc-appt-b { margin-left: auto; font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 999px; background: var(--accent); color: #fff; white-space: nowrap; }
.pc-appt.soon { border-color: #f0883e; background: rgba(240,136,62,.12); } .pc-appt.soon .pc-appt-b { background: #f0883e; }
.pc-appt.over { border-color: var(--crit); background: rgba(220,38,38,.1); } .pc-appt.over .pc-appt-b { background: var(--crit); }
/* แพทย์ที่ตรวจ — ไฮไลท์เด่น (แยกสีจากวันนัด) */
.pc-doctor { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 10px; border: 1.5px solid #6366f1; background: rgba(99,102,241,.1); margin: 2px 0; }
.pc-doctor .pc-doctor-l { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); margin: 0; white-space: nowrap; }
.pc-doctor .pc-doctor-l .ic { width: 15px; height: 15px; }
.pc-doctor .pc-doctor-n { font-size: 16px; font-weight: 800; color: var(--text); }
.pc-doctor .pc-doctor-ph { margin-left: auto; font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 999px; background: #6366f1; color: #fff; text-decoration: none; white-space: nowrap; }
.pc-head { align-items: flex-start; gap: 11px; padding: 11px 14px; }
.pc-photo-wrap { flex: 0 0 auto; }
.pc-photo { width: 56px; height: 70px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.pc-avatar { width: 56px; height: 70px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); align-items: center; justify-content: center; color: var(--muted); }
.pc-avatar .ic { width: 28px; height: 28px; }
/* คอลัมน์ชื่อ+ข้อมูล — ยืดเต็มพื้นที่ข้างรูป ไม่ให้ลอย */
.pc-idcol { flex: 1 1 320px; min-width: 0; }
.pc-head h2 { font-size: 20px; line-height: 1.2; }
/* แถวข้อมูลประจำตัว — จัดเป็นแถวเดียว ให้แบดจ์เรียงกลางแนวตั้ง · ปุ่มเรียกชิดขวาใช้พื้นที่ว่าง */
.pc-idline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 2px; margin-top: 4px; }
.pc-drug-head { display: flex; align-items: center; justify-content: flex-start; gap: 8px 10px; flex-wrap: wrap; }
.pc-drug-head h3 { margin: 0; }
label.pc-drug { display: flex; align-items: center; gap: 10px; cursor: pointer; }
label.pc-drug input { width: 18px; height: 18px; flex: 0 0 auto; }
label.pc-drug .pc-drug-body { flex: 1; min-width: 0; }
label.pc-drug:has(input:checked) { background: #eafaf1; }
.pc-usage { font-size: 13px; color: var(--muted); margin-top: 2px; }
.pc-qty-inline { display: inline-block; background: var(--accent-soft); color: var(--accent); font-weight: 800; padding: 1px 9px; border-radius: 7px; font-size: 14px; white-space: nowrap; }
.pc-dispense-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pc-dose { display: inline-block; font-size: 12.5px; margin-top: 4px; padding: 2px 9px; border-radius: 6px; font-weight: 500; }
.pc-dispenser { display: block; font-size: 12px; margin-top: 4px; padding: 2px 9px; border-radius: 6px; color: #475569; background: #f1f5f9; border: 1px dashed #cbd5e1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { .pc-dispenser { color: #cbd5e1; background: #1e293b; border-color: #475569; } } }
:root[data-theme="dark"] .pc-dispenser { color: #cbd5e1; background: #1e293b; border-color: #475569; }
.pc-dose.s-ok { color: #1a7a4d; background: #eafaf1; }
.pc-dose.s-high { color: #b02020; background: #fdecec; font-weight: 700; }
.pc-dose.s-low { color: #96590a; background: #fff6e5; font-weight: 700; }
.pc-dose.s-adult { color: var(--muted); background: var(--surface-2); }
.pc-dose.s-form { color: #96590a; background: #fff6e5; font-weight: 700; }
/* ระบบอ่านขนาดยาจากวิธีใช้ไม่ได้ (แม่แบบยังไม่ได้กรอก/เขียนปนความเข้มข้น) — ให้เภสัชคิดเอง ไม่ใช่ความผิดปกติของขนาดยา */
/* อยู่นอกช่วงแนะนำแต่ยอมรับได้ (มีเหตุผลกำกับ) · เกณฑ์อ้างอิงของยาความเสี่ยงต่ำ — ไม่ใช่ "เหมาะสม" เต็มตัว */
/* เคสที่มีประวัติแพ้ยา — ย้อมหน้าตรวจก่อนจ่ายเป็นแดงอ่อน ให้สังเกตได้ทันทีก่อนจ่ายยา */
body.pc-allergy-case #pcResult { background: #fff1f2; border-radius: 14px; padding: 6px; }
body.pc-allergy-case #pcResult .card { background: #fffafa; border-color: #fecdd3; }
body.pc-allergy-case #pcResult .pc-drug-head { border-bottom-color: #fecdd3; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.pc-allergy-case #pcResult { background: #2a1416; }
  :root:not([data-theme="light"]) body.pc-allergy-case #pcResult .card { background: #241316; border-color: #7f1d2b; }
}
:root[data-theme="dark"] body.pc-allergy-case #pcResult { background: #2a1416; }
:root[data-theme="dark"] body.pc-allergy-case #pcResult .card { background: #241316; border-color: #7f1d2b; }

/* คงคลังห้องยา (Sub-Stock) ข้างชื่อยา — แดง = หมด · ส้ม = ต่ำกว่าครึ่ง Min · เหลือง = ถึง Min */
/* ไฮไลท์ชื่อยาในหน้าตรวจก่อนจ่าย — แดง = ยาความเสี่ยงสูง (HAD) · ส้ม = Pregnancy category D/X ในหญิงวัยเจริญพันธุ์ */
.pc-drug-body b.dn-had { color: #b91c1c; }
.pc-drug-body b.dn-had::before { content: '⚠ '; }
.pc-drug-body b.dn-preg { color: #c2410c; }
.pc-dose.s-tol { color: #2563eb; background: #eff6ff; font-weight: 700; }
.pc-dose.s-info { color: var(--muted); background: var(--surface-2); font-weight: 600; }
.pc-dose.s-unclear { color: var(--muted); background: var(--surface-2); font-weight: 600; }
.pc-banner.done { background: #eef4ff; color: #2b5cb8; border: 1px solid #c3d6f5; align-items: flex-start; }
.pc-chronic { display: flex; flex-direction: column; gap: 5px; }
.pc-chr { font-size: 13px; display: flex; flex-direction: column; gap: 1px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.pc-chr:last-child { border-bottom: 0; }
.pc-chr-usage { display: block; font-size: 12.5px; color: var(--text); }
.pc-preg { margin-top: 7px; display: flex; gap: 7px; flex-wrap: wrap; align-items: center; flex-basis: 100%; }
.pc-call-hdr { border-radius: 22px; }
.pc-hdr-btn { border-radius: 22px; padding: 0 13px; }
/* เรียกคนไข้/เรียกญาติ ในแถวชื่อ (ถัดจากสิทธิ) — ใหญ่ กดง่าย */
.pc-idextra { display: inline-flex; align-items: center; gap: 7px; margin-left: 10px; vertical-align: middle; flex-wrap: wrap; }
.pc-call-big { height: 40px; font-size: 15px; font-weight: 800; padding: 0 15px; border-radius: 22px; }
.pc-call-big .ic { width: 18px; height: 18px; }
.pc-call-big .pc-call-ch, .pc-call-hdr .pc-call-ch { background: rgba(255,255,255,.28); border-radius: 10px; padding: 0 7px; margin-left: 2px; font-weight: 800; }
.pc-kbd { background: rgba(255,255,255,.25); border: 1px solid rgba(255,255,255,.55); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 800; letter-spacing: .5px; margin-left: 2px; }
.pc-disp-top { height: 34px; font-weight: 800; font-size: 14px; padding: 0 15px; border-radius: 9px; box-shadow: 0 2px 8px rgba(16,185,129,.35); }
.pc-disp-top .ic { width: 16px; height: 16px; }
/* ปุ่มบันทึกจ่ายยาในแถวหัวที่ลอย (sticky) — ชิดกลุ่มปุ่ม ไม่ดันสุดขอบ */
.pc-disp-hdr { font-weight: 800; border-radius: 22px; box-shadow: 0 2px 8px rgba(16,185,129,.35); }
.pc-preg-b { font-weight: 700; font-size: 13px; padding: 3px 12px; border-radius: 20px; }
.pc-preg-b.preg { color: #a11c6b; background: #fde6f2; border: 1px solid #f3badb; }
.pc-preg-b.lact { color: #0a6a82; background: #e5f6fb; border: 1px solid #b3e2ee; }
.pc-preg-b.neutral { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }
.pc-id { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.pc-copy { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px; background: var(--accent-soft); color: var(--accent); cursor: pointer; vertical-align: middle; }
.pc-copy:hover { background: var(--accent); color: #fff; }
.pc-copy .ic { width: 12px; height: 12px; }
.pc-ptnote { display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; font-size: 13.5px; color: #7a5200; background: #fff8e6; border: 1px solid #f0d488; }
.note-pop { width: min(440px, 92vw); display: flex; flex-direction: column; gap: 14px; padding: 22px; border-top: 5px solid #f0b400; }
.note-pop-h { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; color: #7a5200; }
.note-pop-h .ic { width: 20px; height: 20px; }
.note-pop-b { font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
.note-pop .btn-primary { height: 42px; justify-content: center; }
/* Drug profile modal */
.dp-card { width: min(1000px, 96vw); max-height: 90vh; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
/* ตารางเทียบรายอำเภอ (HDC RDU) */
.hdc-prov { font-size: 12px; }
.hdc-prov th, .hdc-prov td { padding: 5px 7px; }
.hdc-prov thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; white-space: nowrap; }
.hdc-prov .hdc-c { font-variant-numeric: tabular-nums; }
.hdc-prov .hdc-c.s-pass { background: color-mix(in srgb, #0ea05a 16%, transparent); }
.hdc-prov .hdc-c.s-warn { background: color-mix(in srgb, #f59e0b 22%, transparent); }
.hdc-prov .hdc-c.s-fail { background: color-mix(in srgb, #e23b3b 18%, transparent); color: #b0231a; font-weight: 700; }
.hdc-prov .hdc-c.s-nodata { color: var(--muted); }
.hdc-prov tr.hdc-me { outline: 2px solid var(--accent); }
.hdc-prov tr.hdc-me td { background: color-mix(in srgb, var(--accent) 8%, transparent); font-weight: 600; }
.dp-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dp-body { padding: 10px 14px; overflow-y: auto; flex: 1; }
.dp-foot { padding: 10px 14px; border-top: 1px solid var(--border); }
.dp-foot .btn-primary { width: 100%; height: 40px; justify-content: center; }
.dp-clinical { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.dp-cl-title { font-weight: 700; font-size: 12.5px; display: flex; align-items: center; gap: 5px; margin-bottom: 6px; color: var(--text-2); }
.dp-cl-row { display: grid; grid-template-columns: 92px 1fr; gap: 8px; font-size: 12.5px; padding: 2px 0; align-items: baseline; }
.dp-cl-row > span { color: var(--muted); font-size: 11.5px; }
.dp-cl-row.bad > div { color: #b02020; font-weight: 600; }
.dp-cl-row .pc-labs { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.dp-day { margin-bottom: 12px; }
.dp-date { font-weight: 700; font-size: 13px; position: sticky; top: -10px; z-index: 1; background: var(--surface); padding: 4px 0; border-bottom: 1px dashed var(--border); margin-bottom: 4px; }
.dp-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 5px 10px; }
.dp-item { display: flex; gap: 6px; align-items: flex-start; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.dp-kind { flex: none; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; margin-top: 1px; }
.dp-kind.continue { color: #1a5fb4; background: #e6f0ff; }
.dp-kind.oneday { color: #7a5200; background: #fff2d6; }
.dp-item-b { min-width: 0; font-size: 12px; line-height: 1.3; }
.dp-usage { font-size: 11px; }
.dp-meta { font-size: 10.5px; color: var(--text-2); }
/* แบนเนอร์แพ้ยา — เด่นชัดด้านบนสุดของ Drug profile */
.dp-allergy { display: flex; gap: 10px; align-items: flex-start; background: #fde2e2; border: 2px solid #dc2626; border-left-width: 6px; border-radius: 10px; padding: 9px 13px; margin-bottom: 12px; }
.dp-allergy-ic { font-size: 22px; line-height: 1.1; }
.dp-allergy-h { font-weight: 800; color: #b91c1c; font-size: 14px; letter-spacing: .2px; }
.dp-allergy-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.dp-allergy-item { background: #fff; border: 1px solid #f0a8a8; border-radius: 6px; padding: 2px 9px; font-weight: 700; color: #991b1b; font-size: 13px; }
.dp-allergy-item small { font-weight: 400; color: #b45454; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dp-allergy { background: #2a1414; border-color: #e05555; } :root:not([data-theme="light"]) .dp-allergy-h { color: #f5a5a5; } :root:not([data-theme="light"]) .dp-allergy-item { background: #1a0f0f; border-color: #5a2a2a; color: #f0b0b0; } }
/* สถานะ MR ในใบยา */
.dp-mr { font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; }
.dp-mr.done { color: #0f7a46; background: #e6f6ec; border: 1px solid #a6e0bf; }
.dp-mr.none { color: #b02020; background: #fdeaea; border: 1px solid #f3b9b9; }
.dp-mr-note { font-weight: 400; color: var(--text-2); margin-top: 2px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dp-mr.done { color: #6ee7a8; background: #0e2a1b; border-color: #1c5235; } :root:not([data-theme="light"]) .dp-mr.none { color: #f2a5a5; background: #2a1414; border-color: #4a2020; } }
/* โซนสีในใบยา */
.dp-zone { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px 10px; margin-bottom: 12px; border-left-width: 5px; }
.dp-zone-h { font-weight: 800; font-size: 13px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.dp-zone-h .ic { width: 16px; height: 16px; }
.dp-zone.zone-own { border-left-color: #0ea05a; background: rgba(14,160,90,.05); }
.dp-zone.zone-own .dp-zone-h { color: #0f7a46; }
.dp-zone.zone-ext { border-left-color: #e08a1e; background: rgba(224,138,30,.06); }
.dp-zone.zone-ext .dp-zone-h { color: #b26a12; }
.dp-zone.zone-days { border-left-color: #6366f1; background: rgba(99,102,241,.04); }
.dp-zone.zone-days .dp-zone-h { color: #4f46e5; }
.dp-zone.zone-advice { border-left-color: #8b5cf6; background: rgba(139,92,246,.06); }
.dp-zone.zone-advice .dp-zone-h { color: #7c3aed; }
.dp-advice { display: grid; gap: 7px; }
.dp-adv { border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; background: var(--surface); border-left: 3px solid #8b5cf6; }
.dp-adv.warn { border-left-color: #e0a800; }
.dp-adv.info { border-left-color: #2563eb; }
.dp-adv-h { font-size: 12.5px; }
.dp-adv-cat { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 10px; background: #ede9fe; color: #6d28d9; margin-right: 4px; }
.dp-adv.warn .dp-adv-cat { background: #fff3cd; color: #92610a; }
.dp-adv-t { font-size: 12px; margin-top: 2px; line-height: 1.35; }
.dp-adv-b { font-size: 10.5px; color: var(--text-2); margin-top: 3px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dp-zone.zone-advice .dp-zone-h { color: #c4b5fd; } :root:not([data-theme="light"]) .dp-adv-cat { background: #2a2140; color: #c4b5fd; } :root:not([data-theme="light"]) .dp-adv.warn .dp-adv-cat { background: #3a2e10; color: #f0c674; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dp-zone.zone-own .dp-zone-h { color: #6ee7a8; } :root:not([data-theme="light"]) .dp-zone.zone-ext .dp-zone-h { color: #f0b86a; } :root:not([data-theme="light"]) .dp-zone.zone-days .dp-zone-h { color: #a5b4fc; } }
/* กลุ่ม continue / one day ในแต่ละวัน */
.dp-daygrp { border-radius: 8px; padding: 5px 8px; margin: 5px 0; }
.dp-daygrp.cont { background: rgba(26,95,180,.06); border: 1px solid rgba(26,95,180,.18); }
.dp-daygrp.od { background: rgba(120,82,0,.05); border: 1px solid rgba(120,82,0,.15); }
.dp-daygrp-h { font-size: 11.5px; font-weight: 700; margin-bottom: 4px; color: var(--text-2); }
.dp-daygrp.cont .dp-daygrp-h { color: #1a5fb4; }
.dp-daygrp.od .dp-daygrp-h { color: #7a5200; }
.dp-item.k-continue { border-left: 3px solid #1a5fb4; }
.dp-item.k-oneday { border-left: 3px solid #c99320; }
/* รูปใบส่งตัว/MR scan */
.dp-scans { margin-top: 8px; }
.dp-scan-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.dp-scan { display: block; width: 92px; cursor: pointer; text-align: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); text-decoration: none; }
.dp-scan img { width: 100%; height: 110px; object-fit: cover; display: block; }
.dp-scan span { display: block; font-size: 10.5px; padding: 2px; color: var(--text-2); }
/* IPD: ข้อเสนอการรักษา (advisor) บนการ์ด */
.ipd-advice { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; align-items: stretch; }
.ipd-adv-h { font-size: 10.5px; font-weight: 800; color: #7c3aed; margin-right: 2px; }
.ipd-adv-item { font-size: 11.5px; padding: 3px 8px; border-radius: 8px; background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; line-height: 1.45; }
.ipd-adv-item.w { background: #fff3cd; color: #92610a; border-color: #f0d98a; }
.ipd-adv-item b { font-weight: 700; }
.ipd-adv-t { display: block; font-size: 11px; opacity: .92; margin-top: 1px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ipd-adv-item { background: #2a2140; color: #c4b5fd; border-color: #3a2f5a; } :root:not([data-theme="light"]) .ipd-adv-item.w { background: #3a2e10; color: #f0c674; border-color: #5a4718; } }
.ipd-adv { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }
.ipd-adv.w { background: #fff3cd; color: #92610a; border-color: #f0d98a; font-weight: 600; }
.ipd-stats .advice b { color: #7c3aed; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ipd-adv { background: #2a2140; color: #c4b5fd; border-color: #3a2f5a; } :root:not([data-theme="light"]) .ipd-adv.w { background: #3a2e10; color: #f0c674; border-color: #5a4718; } :root:not([data-theme="light"]) .ipd-adv-h { color: #c4b5fd; } }
/* IPD: ยาเบิกนรา / Refer back */
.ipd-tag.referback { background: #fde9cf; color: #b45309; }
.ipd-rb { font-size: 11.5px; color: #b45309; background: #fff4e5; border: 1px solid #f3d3a3; border-radius: 6px; padding: 2px 7px; margin: 3px 0; }
.ipd-rb b { color: #92400e; }
.ipd-card.has-rb { box-shadow: inset 3px 0 0 #e08a1e; }
.ipd-chip.has-rb { border-color: #e08a1e; }
.ipd-chip .rb-dot { position: absolute; top: -6px; right: -4px; font-style: normal; font-size: 8px; font-weight: 800; color: #fff; background: #e08a1e; padding: 1px 4px; border-radius: 8px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ipd-rb { background: #2a1e0c; border-color: #4a3613; color: #f0b86a; } :root:not([data-theme="light"]) .ipd-rb b { color: #f7c982; } }
.pc-ptnote .ic { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.pc-fin { font-weight: 700; font-size: 13px; padding: 3px 12px; border-radius: 20px; }
.pc-fin.ok { color: #1a7a4d; background: #eafaf1; border: 1px solid #b6e6cd; }
.pc-fin.no { color: #b02020; background: #fdecec; border: 1px solid #f3c0c0; }
.pc-pregcat { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 6px; vertical-align: middle; }
.pc-pregcat.ok { color: #1a7a4d; background: #eafaf1; }
.pc-pregcat.bad { color: #b02020; background: #fdecec; }
.pc-pregcat.warn { color: #9a5b00; background: #fff6e5; }
.pc-pregcat.unk { color: #5b6472; background: #eef1f5; }
/* ทะเบียนยาของ รพ.: ห้ามบด/NG tube และคู่ยาชื่อพ้องมองคล้าย (LASA) */
.pc-nocrush { display:inline-block; font-size:11.5px; font-weight:700; padding:1px 8px; border-radius:6px; vertical-align:middle; color:#9a3412; background:#ffedd5; }
.pc-g6pd { display:inline-block; font-size:11.5px; font-weight:700; padding:1px 8px; border-radius:6px; vertical-align:middle; color:#7c2d12; background:#fee2e2; cursor:help; }
.pc-left { display:inline-block; font-size:11.5px; font-weight:700; padding:1px 8px; border-radius:6px; vertical-align:middle; color:#1e40af; background:#dbeafe; }
.pc-inf { margin-top:4px; font-size:12.5px; color:#1e3a8a; background:#eff6ff; border-left:3px solid #3b82f6; border-radius:6px; padding:5px 9px; }
.pc-lasa { display:inline-block; font-size:11.5px; font-weight:700; padding:1px 8px; border-radius:6px; vertical-align:middle; color:#7c2d12; background:#fef3c7; cursor:help; }
.pc-ng { margin-top:4px; font-size:12.5px; color:#7c2d12; background:#fffbeb; border-left:3px solid #f59e0b; border-radius:6px; padding:5px 9px; white-space:pre-wrap; }
.lasa-pop { display:flex; gap:10px; flex-wrap:wrap; margin-top:5px; }
.lasa-pop figure { margin:0; width:104px; text-align:center; font-size:11.5px; color:#7c2d12; }
.lasa-pop img { width:104px; height:78px; object-fit:cover; border-radius:8px; border:1px solid #fcd34d; display:block; }
.pc-pregcat.warn { color: #b26a12; background: rgba(224,138,30,.14); }
/* เทียบยากับ visit เดิม */
.pc-chg { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 6px; vertical-align: middle; }
.pc-chg.chg-same { color: var(--muted); background: var(--surface-2); font-weight: 500; }
.pc-chg.chg-up { color: #b02020; background: #fdecec; }
.pc-chg.chg-down { color: #1666c7; background: #e8f1fd; }
.pc-chg.chg-changed { color: #96590a; background: #fff6e5; }
.pc-chg.chg-new { color: #1a7a4d; background: #eafaf1; }
.pc-missing { margin-top: 10px; font-size: 12.5px; font-weight: 600; color: #96590a; background: #fff6e5; border: 1px solid #f0d9a8; border-radius: 8px; padding: 8px 12px; line-height: 1.5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-missing { background: #2a2410; border-color: #4a3d18; color: #e0b969; } }
.pc-pending-row { cursor: pointer; }
.pc-pending-row:hover { background: var(--accent-soft); }
.pc-cam { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pc-cam video { width: 100%; max-width: 360px; border-radius: 10px; background: #000; }
.pc-src { font-size: 10.5px; font-weight: 700; color: #2b5cb8; background: #eef4ff; padding: 1px 6px; border-radius: 5px; vertical-align: middle; }
/* ประวัติยาเรื้อรัง แยกตามครั้งที่รับ (ใช้พื้นที่เต็ม ไม่ต้อง scroll เยอะ) */
.pc-cvisits { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.pc-cvisit { border: 1px solid var(--border); border-radius: 9px; padding: 7px 9px; background: var(--surface-2); }
.pc-cv-head { font-size: 12px; font-weight: 700; margin-bottom: 4px; padding-bottom: 3px; border-bottom: 1px dashed var(--border); }
.pc-cv-count { color: var(--accent); font-weight: 700; }
.pc-cv-group { font-size: 10.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 5px; display: inline-block; margin: 5px 0 2px; }
.pc-cv-drug { font-size: 12px; padding: 2px 0; line-height: 1.35; }
.pc-cv-drug b { font-weight: 600; }
.pc-cv-no { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 3px; margin-right: 5px; font-size: 10px; font-weight: 700; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.pc-cv-drug .pc-chr-usage { color: var(--text-2); }
.pc-qty { font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 0 6px; border-radius: 5px; font-size: 11.5px; white-space: nowrap; }
.pc-ext { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.pc-ext-loc { border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; background: var(--surface-2); }
.pc-ext-h { font-size: 12.5px; display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.pc-ext-h .ic { width: 13px; height: 13px; flex: none; color: var(--accent); }
.pc-ext-meds { font-size: 12.5px; margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 3px; }
.pc-ext-meds li { padding: 1px 0; }
.pc-ext-usage { display: block; font-size: 11.5px; color: var(--text-2); margin-left: 2px; }
.fy-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 14px; }
.fy-cell { display: flex; flex-direction: column; padding: 8px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); min-width: 120px; }
.fy-cell span { font-size: 12px; color: var(--muted); }
.fy-cell b { font-size: 22px; font-weight: 800; color: var(--accent); }
.fy-cell small { font-size: 11px; color: var(--muted); }
/* ตรวจก่อนจ่าย — จัดให้พอดีจอเดียว */
.pc-compact { display: flex; flex-direction: column; gap: 12px; }
.pc-compact .card { padding: 12px 14px; margin: 0; }
.pc-compact h3 { margin: 0 0 8px; }
.pc-head { position: relative; flex-wrap: wrap; }
.pc-head-banner { flex-basis: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
.pc-head-banner .pc-banner { margin: 0; padding: 6px 12px; font-size: 13px; flex: 1; min-width: 220px; }
.pc-grid { display: grid; grid-template-columns: minmax(300px, 1fr) 1.35fr; gap: 12px; align-items: start; }
.pc-colL, .pc-colR { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pc-info-grid { gap: 6px 16px; }
/* แถบ INR สำหรับผู้ป่วยที่ได้ warfarin — ต้องเห็นก่อนสิ่งอื่นในหน้าตรวจก่อนจ่าย
   เพราะขนาดยาที่ถูกต้องขึ้นกับค่านี้ล้วน ๆ และค่าที่ "ต่ำ" ก็อันตรายไม่แพ้ค่าสูง */
.pc-inr {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 10px 0; padding: 12px 15px; border-radius: 12px; border: 2px solid;
}
.pc-inr .pc-inr-v { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.pc-inr .pc-inr-l { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; opacity: .85; }
.pc-inr .pc-inr-txt { font-size: 14px; line-height: 1.45; }
.pc-inr .pc-inr-txt b { font-size: 15px; }
.pc-inr .pc-inr-when { font-size: 12.5px; opacity: .8; }
.pc-inr.ok   { background: #eafaf1; border-color: #9fe3c0; color: #0f5132; }
.pc-inr.low  { background: #fff4e6; border-color: #f3c48a; color: #8a4b08; }
.pc-inr.high { background: #fdecec; border-color: #f3b4b4; color: #8a1111; }
.pc-inr.none { background: #f3f5f8; border-color: #cfd6e0; color: #33414f; }

.pc-labs-wrap { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }
.pc-labs-title { font-size: 11.5px; color: var(--muted); }
.pc-labs { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 4px; }
.pc-lab { font-size: 13px; }
.pc-labmon { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }
.pc-labmon-list { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.pc-labmon-item { font-size: 12.5px; background: #fff6e5; border-radius: 6px; padding: 4px 8px; color: #96590a; }
.pc-vitals-wrap { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }
.pc-vitals { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 4px; }
.pc-vital { display: inline-flex; align-items: baseline; gap: 4px; font-size: 13px; padding: 3px 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.pc-vital-l { font-size: 11px; color: var(--muted); font-weight: 600; }
.pc-vital-u { font-size: 10.5px; color: var(--muted); }
.pc-vital.warn { background: #fff6e5; border-color: #f0c674; color: #96590a; }
.pc-vital.warn .pc-vital-l, .pc-vital.warn .pc-vital-u { color: #96590a; }
.pc-vital.bad { background: #fdecec; border-color: #e79a9a; color: #b02020; font-weight: 700; }
.pc-vital.bad .pc-vital-l, .pc-vital.bad .pc-vital-u { color: #b02020; }
.pc-probs { margin: 0 !important; }
.pc-prob { padding: 8px 12px; }
label.pc-drug { padding: 6px 8px; }
.pc-actions { flex-direction: row !important; align-items: center; }
/* แถบปุ่มจ่ายยา อยู่บนสุด + ติดขอบบนเวลาเลื่อนจอ กดง่าย */
.pc-actions-top { position: sticky; top: 8px; z-index: 20; box-shadow: 0 6px 18px -8px rgba(2,6,23,.35); }
.pc-actions-top #pcDispense { flex: none; min-width: 160px; }
.pc-actions .textarea { flex: 1; }
.pc-actions .btn-lg { white-space: nowrap; }
@media (max-width: 900px) { .pc-grid { grid-template-columns: 1fr; } .pc-actions { flex-direction: column !important; align-items: stretch; } }
.logic-chip { font-size: 11.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 8px; }
.rule-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--border); padding-top: 11px; margin-top: auto; }
.rule-foot .actions { margin-left: auto; display: flex; gap: 4px; }

.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.preset { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 14px; border: 1px dashed var(--border-strong); background: var(--surface-2); }
.preset h4 { margin: 0; font-size: 13.5px; font-weight: 600; }
.preset p { margin: 0; color: var(--muted); font-size: 12.5px; flex: 1; }
.preset .group { font-size: 11px; color: var(--accent); font-weight: 600; letter-spacing: .3px; }
.preset .btn { align-self: flex-start; }
details.presets > summary { list-style: none; cursor: pointer; }
details.presets > summary::-webkit-details-marker { display: none; }
details.presets[open] .chev { transform: rotate(180deg); }
.chev { transition: transform .2s; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.editor-side { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 16px; }
.editor .card + .card { margin-top: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.cond-list { display: flex; flex-direction: column; gap: 12px; }
.cond { border: 1px solid var(--border-strong); border-radius: 14px; padding: 14px 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 12px; position: relative; }
.cond-head { display: flex; align-items: center; gap: 10px; }
.cond-num { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex: none; }
.cond-head .select { width: auto; flex: 1; max-width: 300px; height: 36px; }
.cond-head .btn { margin-left: auto; }
.cond-join { align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 12px; margin: -4px 0; }
.cond-desc { color: var(--text-2); font-size: 13px; background: var(--surface); border-radius: 10px; padding: 10px 12px; border: 1px solid var(--border); }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }

.picker { position: relative; }
.chips-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 42px; padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.chips-input input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 160px; height: 30px; padding: 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--text); border-radius: 8px; padding: 3px 4px 3px 9px; font-size: 12.5px; max-width: 100%; }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip button { border: 0; background: transparent; cursor: pointer; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); flex: none; }
.chip button:hover { background: rgba(0, 0, 0, .08); color: var(--crit); }
.chip button .ic { width: 13px; height: 13px; }
.dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 300px; overflow: auto; padding: 5px; }
.dd-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.dd-item:hover, .dd-item.hl { background: var(--hover); }
.dd-item .code { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.dd-item .tick { width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--axis); display: grid; place-items: center; flex: none; color: #fff; }
.dd-item.sel .tick { background: var(--accent); border-color: var(--accent); }
.dd-item .tick .ic { width: 12px; height: 12px; }
.dd-msg { padding: 12px; color: var(--muted); font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }
.hint .ic { width: 14px; height: 14px; margin-top: 2px; }

.tg-preview { background: #e7efe3; background-image: radial-gradient(rgba(0, 0, 0, .04) 1px, transparent 1px); background-size: 14px 14px; border-radius: 14px; padding: 14px; }
:root[data-theme="dark"] .tg-preview { background-color: #0e1621; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tg-preview { background-color: #0e1621; } }
.tg-bubble { background: #fff; color: #111; border-radius: 12px 12px 12px 4px; padding: 9px 12px 7px; font-size: 13px; line-height: 1.55; box-shadow: 0 1px 1px rgba(0, 0, 0, .12); white-space: pre-wrap; word-break: break-word; }
:root[data-theme="dark"] .tg-bubble { background: #182533; color: #e8edf4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tg-bubble { background: #182533; color: #e8edf4; } }
.tg-bubble code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: #1a73e8; }
.tg-bubble .tg-time { display: block; text-align: right; font-size: 11px; color: #8a9aa9; margin-top: 2px; }
.tg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12.5px; color: var(--text-2); }
.tg-head .logo { width: 26px; height: 26px; border-radius: 50%; box-shadow: none; }
.tg-head .logo svg { width: 14px; height: 14px; }
.tg-head .logo::after { display: none; }

.result { border-radius: 12px; padding: 12px 14px; font-size: 13px; border: 1px solid var(--border); background: var(--surface-2); }
.result.ok { border-color: rgba(12, 163, 12, .3); background: var(--good-soft); }
.result.bad { border-color: rgba(208, 59, 59, .3); background: var(--crit-soft); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin-top: 8px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.steps { margin: 6px 0 0; padding-left: 20px; color: var(--text-2); font-size: 13px; }
.steps li { margin: 3px 0; }

.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings .card + .card { margin-top: 0; }
.card-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.recip-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, .8fr) minmax(0, .9fr) minmax(0, .9fr) auto auto auto; gap: 8px; align-items: center; }
.chip-sev[data-href], .chip-sev[data-drill] { cursor: pointer; }
.chip-sev[data-href]:hover, .chip-sev[data-drill]:hover { outline: 2px solid rgba(255, 255, 255, .5); }
.tile:not(.hero) .chip-sev[data-drill]:hover { outline-color: var(--accent); }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat-box.stat-cost { background: rgba(14,160,90,.08); border-color: rgba(14,160,90,.35); }
.stat-box.stat-cost b { color: #0f7a46; }
.stat-box span { display: block; font-size: 12px; color: var(--text-2); }
.stat-box b { display: block; font-size: 24px; font-weight: 700; line-height: 1.3; }
.stat-box small { color: var(--muted); font-size: 11.5px; }
.stat-box.warn { background: var(--warn-soft); border-color: rgba(250, 178, 25, .35); }
.stat-box.bad { background: var(--crit-soft); border-color: rgba(208, 59, 59, .3); }
.stat-box.ok { background: var(--good-soft); border-color: rgba(12, 163, 12, .3); }
#soundBtn.on { color: var(--good); background: var(--good-soft); }
.privacy-veil { position: fixed; inset: 0; z-index: 9000; background: var(--bg, #0b1220); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.privacy-veil .pv-box { display: flex; align-items: center; gap: 14px; padding: 22px 26px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.privacy-veil .pv-box svg { width: 34px; height: 34px; color: var(--accent); }
.privacy-veil .pv-box b { font-size: 17px; }
.wl-hours { display: flex; flex-direction: column; gap: 6px; }
.wl-hr { display: flex; align-items: center; gap: 8px; }
.wl-hr-l { width: 26px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; text-align: right; }
.wl-hr-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.wl-hr-bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.wl-hr-n { width: 34px; font-size: 12px; text-align: right; color: var(--text-2); }
/* เหรียญอันดับ 1/2/3 ในตารางภาระงาน — badge กลมสีทอง/เงิน/ทองแดง + ตัวเลขเด่น */
.wl-cell { display: inline-flex; align-items: center; gap: 7px; padding: 2px 10px 2px 4px; border-radius: 999px; }
.wl-cell.wl-r1 { background: linear-gradient(90deg, rgba(245,158,11,.16), rgba(245,158,11,.04)); }
.wl-cell.wl-r2 { background: linear-gradient(90deg, rgba(148,163,184,.18), rgba(148,163,184,.04)); }
.wl-cell.wl-r3 { background: linear-gradient(90deg, rgba(194,102,58,.16), rgba(194,102,58,.04)); }
.wl-rank { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; font-weight: 800; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; border: 1.5px solid rgba(255,255,255,.65); box-shadow: 0 1px 3px rgba(0,0,0,.28); flex: none; }
.wl-rank.r1 { background: linear-gradient(145deg, #fde047, #f59e0b); color: #7c4a03; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.wl-rank.r2 { background: linear-gradient(145deg, #f1f5f9, #94a3b8); color: #334155; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.wl-rank.r3 { background: linear-gradient(145deg, #fdba74, #c2663a); color: #fff; }
.wl-val { font-variant-numeric: tabular-nums; }
.wl-val.strong { font-size: 1.08em; font-weight: 800; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 14px; }
.progress div { height: 100%; border-radius: 999px; background: var(--good); }
.tbl tfoot td { border-top: 1px solid var(--border-strong); background: var(--surface-2); }
.rdu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.rdu-card { display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.rdu-card.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rdu-pct { font-size: 32px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
.gap-tag { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 6px; background: var(--crit-soft); color: var(--crit); margin-right: 4px; }
.recip-row .check { height: 40px; }
/* เคสที่มีบันทึกเพิ่มเติม — ต้องสะดุดตาทันทีที่เปิดเคส ไม่ใช่ช่องว่างเปล่าเหมือนเคสทั่วไป */
.pc-note.has-note { background: #fffbeb; border-color: #f59e0b; box-shadow: inset 0 0 0 1px #fcd34d; font-weight: 600; color: #78350f; }
.pc-note-meta { font-size: 12px; color: #b45309; font-weight: 700; margin: 3px 2px 0; }
.q-note { display: inline-flex; align-items: center; gap: 4px; background: #fef3c7; color: #78350f; border: 1px solid #f59e0b; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; margin-top: 3px; max-width: 100%; }

/* ปุ่มเลือกยาในหน้าต่างแจ้ง Ward — กดแล้วชื่อยาไปอยู่ในข้อความ */
.cs-drugs { display: flex; flex-wrap: wrap; gap: 6px; max-height: 108px; overflow: auto; }
.cs-drug { background: #f1f5f9; border: 1px solid #cbd5e1; color: #0f172a; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; }
.cs-drug:hover { background: #e2e8f0; }
.cs-drug.on { background: #0ea5e9; border-color: #0284c7; color: #fff; }

/* คำสั่งแพทย์นอกหมวดยาที่มีเนื้อหาเป็นยา — ต้องสะดุดตาใน Doctor Order Sheet */
.dos-other-drug { display: inline-block; margin-top: 3px; background: #fef3c7; color: #7c2d12; border: 1px solid #d97706; border-radius: 5px; padding: 1px 7px; font-size: 11.5px; font-weight: 700; }
.dos-scale { display: inline-block; margin-top: 3px; background: #ede9fe; color: #5b21b6; border: 1px solid #7c3aed; border-radius: 5px; padding: 1px 7px; font-size: 11.5px; font-weight: 700; }

/* ท้ายฉลากยา: QR + ลิงก์ตัวเล็ก (ฉลากพิมพ์ในกรอบ iframe แยก ใช้ em ให้ย่อตามฟอนต์ฉลาก) */
.dl-f-qr { display: flex; align-items: center; gap: .6em; justify-content: flex-end; }
.dl-qr svg { width: 9mm; height: 9mm; display: block; }
.dl-furl { font-size: .82em; opacity: .85; }

/* รายการกฎของกลุ่ม LINE ตึก (หมอพร้อม) — 65 กฎ ต้องเลื่อนดูได้ ไม่ดันหน้าตั้งค่ายาว */
.mp-rules { border: 1px solid var(--line, #d8dee6); border-radius: 8px; padding: 6px 10px; background: var(--bg-soft, #f7f9fc); }
.mp-rulelist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 14px; max-height: 240px; overflow: auto; margin-top: 6px; }
.mp-rulelist .check { font-size: 13px; height: auto; padding: 3px 0; }

.chat-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.chat-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.chat-item .btn { margin-left: auto; }
.recip-pick { display: flex; flex-direction: column; gap: 8px; }
.recip-pick .check { width: 100%; }
.recip-pick .tag { margin-left: auto; }
@media (max-width: 860px) { .recip-row { grid-template-columns: 1fr 1fr; } }

/* ---------- wall board (หน้าจอรวม) ---------- */
.view.board-view { max-width: none; padding: 8px; background: #111217; min-height: calc(100vh - 77px); }
body.kiosk .side, body.kiosk .top, body.kiosk .scrim { display: none !important; }
body.kiosk .app { grid-template-columns: minmax(0, 1fr); }
body.kiosk .view.board-view { min-height: 100vh; }
.board { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); grid-auto-rows: minmax(64px, auto); gap: 6px; color: #d8d9da;
  font-family: var(--font); }
.bp { background: #181b1f; border: 1px solid #22252b; border-radius: 3px; padding: 6px 10px; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.bp h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: #e6e7e8; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.bp h3 small { font-weight: 400; color: #8e939b; font-size: 11px; margin-left: auto; }
.bt { border-radius: 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4px 6px; min-width: 0;
  color: #fff; cursor: default; transition: filter .15s, transform .08s; position: relative; }
.bt[data-drill], .bt[data-href] { cursor: pointer; }
.bt[data-drill]:hover, .bt[data-href]:hover { filter: brightness(1.12); }
.bt .l { font-size: 11.5px; opacity: .9; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bt .v { font-size: clamp(24px, 2.4vw, 46px); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bt .s { font-size: 10.5px; opacity: .85; white-space: nowrap; }
.bt.dark { color: #1b1b1b; }
.c-yellow { background: #e0b400; } .c-green { background: #56a64b; } .c-lime { background: #73bf69; } .c-blue { background: #1f60c4; }
.c-sky { background: #3274d9; } .c-purple { background: #8f3bb8; } .c-violet { background: #a352cc; } .c-orange { background: #fa6400; }
.c-amber { background: #ff9830; } .c-salmon { background: #ff7383; } .c-mint { background: #5ae0a0; } .c-cyan { background: #3fb5c8; }
.c-grey { background: #c0d8e8; } .c-red { background: #c4162a; } .c-olive { background: #7d7d2e; } .c-teal { background: #1a8a7a; } .c-slate { background: #2f3a4a; }
.b-logo { background: linear-gradient(135deg, #0f766e, #1e3a8a); align-items: flex-start; justify-content: space-between; padding: 12px 14px; }
.b-logo b { font-size: 20px; color: #fff; line-height: 1.2; } .b-logo span { font-size: 12px; color: #cbd5e1; }
.b-clock .v { font-size: clamp(22px, 2vw, 38px); letter-spacing: .5px; }
.b-bars { display: flex; flex-direction: column; gap: 5px; overflow: hidden; }
.b-bar { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 12px; padding: 1px 3px; border-radius: 3px; }
.b-bar[data-drill], .b-bar[data-href] { cursor: pointer; } .b-bar[data-drill]:hover, .b-bar[data-href]:hover { background: #22262c; }
.b-bar .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #ccccdc; }
.b-bar .x { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }
.led { height: 14px; background: #262a30; border-radius: 2px; position: relative; overflow: hidden; }
.led i { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(90deg, var(--led) 0 5px, transparent 5px 7px); }
.b-feed { display: flex; flex-direction: column; overflow: hidden; }
.b-feed a { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 8px; padding: 4px 2px; color: #d8d9da; border-bottom: 1px solid #22252b; font-size: 12px; }
.b-feed a:hover { background: #22262c; }
.b-feed .bar { border-radius: 2px; } .b-feed .t { color: #8e939b; white-space: nowrap; }
.b-feed .m { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-rdu { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 5px; }
.b-rdu .bt { min-height: 62px; }
.b-foot { grid-column: span 24; display: flex; gap: 14px; justify-content: flex-end; align-items: center; font-size: 11.5px; color: #8e939b; padding: 0 4px; }
.b-foot button { background: #22252b; color: #d8d9da; border: 1px solid #33373e; border-radius: 3px; padding: 3px 10px; cursor: pointer; font: inherit; }
.b-chart svg text { fill: #8e939b; font-size: 10px; font-family: var(--font); }
@media (max-width: 1400px) { .board > .z-l, .board > .z-c, .board > .z-r { grid-column: span 12 !important; } }
@media (max-width: 860px) { .board > * { grid-column: span 12 !important; } .board { grid-template-columns: repeat(12, minmax(0, 1fr)); } }

/* wall board v2: เต็มจอ 100vh กริดตายตัว */
body.board-mode .side, body.board-mode .top, body.board-mode .scrim { display: none !important; }
body.board-mode .app { grid-template-columns: minmax(0, 1fr); }
body.board-mode { background: #111217; }
.view.board-view { min-height: 100vh; height: 100vh; padding: 8px; }
.board { height: calc(100vh - 16px); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2.6fr) minmax(0, 2.6fr) 26px; grid-auto-rows: unset; }
.bt .l { font-size: clamp(12px, .8vw, 15px); font-weight: 500; }
.bt .v { font-size: clamp(26px, 2.6vw, 52px); }
.bt .s { font-size: clamp(11px, .7vw, 13px); }
.bp h3 { font-size: clamp(13px, .85vw, 16px); }
.bp h3 small { font-size: 12px; }
.bp h3 small a { color: #8ab8ff; }
.b-bar { font-size: clamp(12px, .78vw, 14px); }
.b-bar .x { font-size: clamp(14px, .95vw, 18px); }
.led { height: 13px; }
.b-feed a { font-size: clamp(12px, .75vw, 14px); padding: 5px 2px; }
.b-feed .m b { color: #fff; font-weight: 600; }
.b-chart { flex: 1; min-height: 0; }
.b-chart svg text { font-size: 11px; }
.b-rdu { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.b-rdu .bt { min-height: 0; padding: 6px 2px; }
.b-rdu .bt .v { font-size: clamp(18px, 1.5vw, 28px); }
.b-empty { color: #6e737a; font-size: 12px; padding: 6px 0; }
.b-logo { gap: 4px; justify-content: center; }
.b-logo b { font-size: clamp(16px, 1.3vw, 24px); }
.b-foot { grid-column: span 24; justify-content: space-between; font-size: 12.5px; }
.b-foot nav { display: flex; gap: 14px; }
.b-foot nav a { color: #8ab8ff; }
.c-green { background: #3d8b40; } .c-salmon { background: #d4475f; } .c-mint { background: #1f9e6e; } .c-steel { background: #4a6d8c; }
.c-cyan { background: #1b8ea3; } .c-yellow { background: #e5b700; } .c-amber { background: #f29a1f; } .c-olive { background: #6d6d25; }
/* v3: TOP 5 ครบ 5 แถว, ตัวอักษรใหญ่ขึ้นสำหรับทีวี */
.board { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2.75fr) minmax(0, 2.45fr) 28px; }
.b-bars { gap: 2px; }
.b-bar { grid-template-columns: minmax(0, 50%) minmax(0, 1fr) auto; padding: 0 3px; line-height: 1.3; }
.led { height: 11px; }
.bp h3 { margin-bottom: 4px; }
.bt .s { font-size: clamp(12px, .8vw, 15px); }
.b-foot { font-size: 13.5px; }
.b-logo b { font-size: clamp(20px, 1.6vw, 30px); }
.b-logo span { font-size: clamp(13px, .85vw, 16px); }
.b-logo::before { content: 'Rx'; font-weight: 800; font-size: clamp(22px, 1.8vw, 34px); color: #fff; background: rgba(255, 255, 255, .15);
  border-radius: 10px; padding: 2px 10px; margin-bottom: 4px; }
@media (max-width: 1100px) {
  .view.board-view { height: auto; }
  .board { height: auto; grid-template-rows: none; grid-auto-rows: minmax(90px, auto); }
  .board > .bp { grid-column: span 12 !important; min-height: 260px; }
  .board > .bt { grid-column: span 4 !important; grid-row: auto !important; }
  .b-foot { flex-wrap: wrap; }
}

/* ---------- drill-down drawer ---------- */
.clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .08s; }
.clickable:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.hbar.clickable, .stat-box.clickable { border-radius: 10px; }
.hbar.clickable { padding: 4px 6px; margin: -4px -6px; }
.hbar.clickable:hover { background: var(--hover); box-shadow: none; }
.drawer-scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 150; animation: fade .2s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(1100px, 100vw); background: var(--bg); z-index: 151; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slidein .25s ease; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-head .sub { color: var(--muted); font-size: 12.5px; }
.drawer-body { overflow: auto; padding: 16px 22px 30px; flex: 1; }
.drawer-body .card { padding: 0; overflow: hidden; }
.drawer-body .table-wrap { margin: 0; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 420px; animation: enter .25s ease; transition: opacity .4s, transform .4s; }
.toast .ic { color: #34d399; }
.toast.err .ic { color: #fb7185; }
.toast.out { opacity: 0; transform: translateY(8px); }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- refinements ---------- */
.feed-card { display: flex; flex-direction: column; }
.feed-card .feed { flex: 1; max-height: 300px; overflow-y: auto; scrollbar-width: thin; }
.tile.hero .tile-val small { color: rgba(255, 255, 255, .78); }
.rule-foot > span { display: inline-flex; align-items: center; gap: 5px; }
.rule-foot > span > .ic { width: 14px; height: 14px; }
.filters .search .input { min-width: 260px; }
.tile.hero .dot.crit { box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
.tile.hero .dot.warn { box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .span-3 { grid-column: span 6; }
  .span-4 { grid-column: span 6; }
  .span-8 { grid-column: span 12; }
  .row-2 { grid-row: auto; }
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; }
}
@media (max-width: 1100px) {
  .settings { grid-template-columns: 1fr; }
  .top-status .pill.hide-md { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .top-title { flex: 1; }
  .legend { width: 100%; order: 3; }
  .card-head { flex-wrap: wrap; }
  .filters .input, .filters .select, .filters .search, .filters .search .input { min-width: 0; width: 100%; }
  .side { position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .25s; }
  .side.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 25; }
  .only-mobile { display: grid !important; }
  .top { padding: 12px 16px; flex-wrap: wrap; }
  .top-status { order: 5; width: 100%; justify-content: flex-start; margin-left: 0; }
  .top-actions { margin-left: auto; }
  .view { padding: 16px 16px 40px; }
  .span-3, .span-4, .span-5, .span-6, .span-7 { grid-column: span 12; }
  .rule-grid { grid-template-columns: 1fr; }
  .banner { flex-wrap: wrap; }
  .banner .btn { margin-left: 0; }
  .btn-primary .label { display: none; }
  .q-ipd { grid-template-columns: 1fr; }
  /* ตารางกว้างเลื่อนในกรอบ + ไม่ให้ขอบล้นออกนอกจอ (view padding 16px) */
  .table-wrap { margin: 0 -16px; -webkit-overflow-scrolling: touch; }
  /* ปุ่ม/ลิงก์เมนูแตะง่ายบนมือถือ */
  .btn, .seg-btn, .nav a { min-height: 38px; }
}
/* มือถือเล็ก — การ์ด/คอลัมน์เหลือคอลัมน์เดียว ให้เภสัชกรดูบนหอผู้ป่วยสะดวก */
@media (max-width: 560px) {
  .rdu-grid, .ptc-gb-wrap { grid-template-columns: 1fr; }
  .mdr-ov { grid-template-columns: 1fr 1fr; }
  .view { padding: 14px 14px 36px; }
  .top-title h1 { font-size: 18px; }
  html, body { overflow-x: hidden; } /* กันเลื่อนแนวนอนทั้งหน้า (ตารางยังเลื่อนในกรอบ .table-wrap ได้) */
}

/* ---------- DRP (ประเภทปัญหาจากการใช้ยา) ---------- */
.tag.drp { background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 500; white-space: normal; line-height: 1.35; }
.drp-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 10px; margin: 22px 0 10px; }
.drp-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.drp-head .muted { font-size: 12.5px; }
.drp-no { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 7px; background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 700; align-self: center; }

/* ---------- ผลการแก้ปัญหา (Pharmacist intervention) + รายงาน DRP ---------- */
.iv-form { display: flex; flex-direction: column; gap: 6px; min-width: 260px; max-width: 320px; }
.iv-form .select, .iv-form .input { height: 32px; font-size: 12.5px; }
.iv-form .iv-seg button { padding: 5px 10px; font-size: 12.5px; }
.iv-hint { font-size: 11.5px; background: var(--warn-bg, #fff4e5); color: var(--warn, #b45309); border-radius: 8px; padding: 5px 8px; display: flex; gap: 5px; align-items: center; }
.btn-risk { color: var(--bad, #dc2626); }
.btn-risk svg { color: var(--bad, #dc2626); }
.iv-problem { display: flex; flex-direction: column; gap: 6px; }
.iv-l { font-size: 11.5px; color: var(--text-2); margin-top: 2px; }
.iv-acts { display: flex; flex-wrap: wrap; gap: 4px; }
.iv-acts .check { padding: 3px 8px; font-size: 12px; gap: 5px; border-radius: 8px; }
.iv-acts .check input { width: 13px; height: 13px; }
.ack-done .tag { font-size: 11.5px; }
.stat-box small { display: block; font-size: 11.5px; color: var(--text-2); margin-top: 2px; }
.mini-title { margin: 0 0 6px; font-size: 13.5px; font-weight: 600; }
#drpBody .stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) { #drpBody .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- เข้าสู่ระบบ / ผู้ใช้ ---------- */
body.auth-mode .app { display: none; }
.auth { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; overflow: hidden auto;
  background:
    radial-gradient(1100px 600px at 12% -8%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 60%),
    radial-gradient(900px 620px at 108% 112%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 62%),
    var(--bg); }
.auth-orbs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.auth-orbs span { position: absolute; border-radius: 50%; filter: blur(46px); opacity: .5; background: var(--accent); animation: authFloat 16s ease-in-out infinite; }
.auth-orbs span:nth-child(1) { width: 340px; height: 340px; left: -60px; top: -40px; }
.auth-orbs span:nth-child(2) { width: 260px; height: 260px; right: -40px; bottom: 40px; background: color-mix(in srgb, var(--accent) 60%, #22d3ee); animation-delay: -5s; }
.auth-orbs span:nth-child(3) { width: 200px; height: 200px; right: 30%; top: 8%; opacity: .3; animation-delay: -9s; }
@keyframes authFloat { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(0,-26px) scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .auth-orbs span { animation: none; } }
.auth-box { position: relative; z-index: 1; display: grid; grid-template-columns: 1.05fr .95fr; align-items: stretch;
  width: min(880px, 100%); border-radius: 22px; overflow: hidden;
  box-shadow: 0 30px 80px -24px rgba(2, 6, 23, .5), 0 2px 8px rgba(2, 6, 23, .2); border: 1px solid var(--border); }
.auth-hero { padding: 40px 34px; color: #fff; display: flex; flex-direction: column; gap: 18px;
  background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #0f172a)); }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .16); backdrop-filter: blur(4px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.auth-logo .ic { width: 30px; height: 30px; color: #fff; }
.auth-logo.sm { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); box-shadow: none; }
.auth-logo.sm .ic { width: 21px; height: 21px; }
.auth-hero-name { font-size: 30px; font-weight: 800; letter-spacing: .5px; line-height: 1; }
.auth-hero-sub { font-size: 13.5px; line-height: 1.6; opacity: .92; }
.auth-feats { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.auth-feats li { display: flex; align-items: center; gap: 9px; font-size: 13px; opacity: .95; }
.auth-feats .ic { width: 17px; height: 17px; flex: none; opacity: .85; }
.auth-card { width: 100%; display: flex; flex-direction: column; gap: 13px; padding: 40px 34px; background: var(--surface); }
.auth-card-head { display: none; align-items: center; gap: 10px; }
.auth-card-head small { display: block; color: var(--text-2); font-size: 12px; }
.auth-card h2 { margin: 0; font-size: 22px; }
.auth-lead { margin: -6px 0 6px; color: var(--text-2); font-size: 13px; }
.auth-card .btn-primary, .auth-submit { height: 44px; justify-content: center; font-size: 14.5px; margin-top: 4px; }
.auth-foot { margin-top: 10px; text-align: center; font-size: 12px; color: var(--text-2); }
.auth-foot b { color: var(--accent); font-weight: 700; }
.auth-err { color: var(--crit); font-size: 13px; background: var(--crit-soft); padding: 8px 10px; border-radius: 9px; }
/* password dialog reuses .auth-card only */
#pwDlg.auth { background: rgba(15, 23, 42, .45); }
#pwDlg .auth-card { width: min(400px, 100%); border-radius: 16px; box-shadow: 0 24px 60px -18px rgba(2,6,23,.6); border: 1px solid var(--border); padding: 26px; }
@media (max-width: 720px) {
  .auth-box { grid-template-columns: 1fr; width: min(420px, 100%); }
  .auth-hero { display: none; }
  .auth-card-head { display: flex; }
}
.user-card { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 9px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; }
.user-card > .ic { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.user-card > div { flex: 1; min-width: 0; }
.user-card b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card small { color: var(--text-2); }
.user-card .icon-btn { width: 30px; height: 30px; }
body:not(.role-admin) .admin-only { display: none !important; }

/* ---------- wall board v4: OPD ซ้าย | IPD ขวา ---------- */
.board2 { display: grid; grid-template-columns: minmax(0, 1fr) 3px minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "top top top" "head head head" "opd div ipd"; gap: 6px 10px; height: calc(100vh - 16px); color: #d8d9da; font-family: var(--font); }
/* แถบเมนูด้านบน (ย้ายจากล่างขึ้นบน) + ปุ่มหน้าต่าง */
.b-topbar { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 4px 6px; background: #1b1e24; border: 1px solid #2b2f37; border-radius: 6px; }
.b-topbar nav { display: flex; gap: 4px; flex: 1; min-width: 0; flex-wrap: wrap; align-items: center; }
.b-topbar nav > a { color: #cfe0ff; background: #262b34; border: 1px solid #333844; border-radius: 6px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; white-space: nowrap; text-decoration: none; }
.b-topbar nav > a:hover { background: #2f6df2; border-color: #2f6df2; color: #fff; }
/* หมวดใหญ่ (บริบาลทางเภสัชกรรม) เป็น dropdown */
.b-navgrp { position: relative; }
.b-navgrp-btn { color: #ffe9b8; background: #3a2f16; border: 1px solid #6b5320; border-radius: 6px; padding: 6px 12px; font-size: 13.5px; font-weight: 700; white-space: nowrap; cursor: pointer; font-family: inherit; }
.b-navgrp-btn:hover { background: #b38600; border-color: #b38600; color: #fff; }
.b-navgrp-ca { font-size: 10px; }
.b-navgrp-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; display: none; flex-direction: column; gap: 2px; min-width: 200px; padding: 6px; background: #1b1e24; border: 1px solid #3a4150; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.b-navgrp:hover .b-navgrp-menu, .b-navgrp:focus-within .b-navgrp-menu { display: flex; }
.b-navgrp-menu a { color: #cfe0ff; background: #262b34; border: 1px solid #333844; border-radius: 6px; padding: 7px 12px; font-size: 13.5px; font-weight: 600; white-space: nowrap; text-decoration: none; }
.b-navgrp-menu a:hover { background: #2f6df2; border-color: #2f6df2; color: #fff; }
.b-sync { flex: 0 0 auto; font-size: 11.5px; color: #8e939b; }
.b-winbtns { flex: 0 0 auto; display: flex; gap: 6px; }
.b-winbtn { background: #22252b; color: #d8d9da; border: 1px solid #33373e; border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; }
.b-winbtn:hover { background: #2b2f37; }
.b-winbtn.b-close:hover { background: #c0392b; border-color: #c0392b; color: #fff; }
/* เลือกวันที่บนหน้าจอรวม — ดูข้อมูลย้อนหลังได้ */
.b-datebox { flex: 0 0 auto; display: flex; gap: 4px; align-items: center; }
.b-datebox .b-winbtn { padding: 6px 9px; }
.b-datebox .b-winbtn:disabled { opacity: .35; cursor: default; }
.b-date { background: #22252b; color: #d8d9da; border: 1px solid #33373e; border-radius: 6px; padding: 5px 8px; font: inherit; font-size: 13px; font-weight: 600; color-scheme: dark; cursor: pointer; }
.b-date:hover { background: #2b2f37; }
.b-winbtn.b-today { background: #2f6df2; border-color: #2f6df2; color: #fff; }
/* ช่องนาฬิกาเปลี่ยนเป็นวันที่ที่กำลังดูย้อนหลัง — ต้องเห็นชัดว่าไม่ใช่ข้อมูลสด */
.bt.b-past { background: #3a2f12; border-color: #8a6d1f; }
.b-pastday { font-size: clamp(18px, 1.6vw, 30px) !important; }

/* หน้าภาพรวมกะทัดรัด (#/panel) — พาเนลแคบ RxAlert.exe */
.view.panel-view { padding: 8px; height: auto; min-height: 100vh; background: #111217; }
.pnl { color: #d8d9da; font-family: var(--font); display: flex; flex-direction: column; gap: 8px; }
.pnl-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #1b1e24; border: 1px solid #2b2f37; border-radius: 8px; padding: 8px 12px; }
.pnl-name b { font-size: 17px; display: block; line-height: 1.2; } .pnl-name span { font-size: 11.5px; color: #9aa3af; }
.pnl-clock { font-size: 25px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pnl-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 7px; }
.pnl-tiles .bt { min-height: 74px; border-radius: 8px; }
.pnl-tiles .bt .v { font-size: clamp(24px, 7vw, 32px); }
.pnl-tiles .bt .l { font-size: 12px; }
.pnl-tiles .bt .s { font-size: 10.5px; }
.pnl-feed-h { font-weight: 700; color: #aeb4bd; margin-top: 2px; display: flex; justify-content: space-between; align-items: baseline; }
.pnl-feed-h a { color: #5aa0ff; }
.panel-view .b-feed { background: #1b1e24; border: 1px solid #2b2f37; border-radius: 8px; padding: 4px; }

.b2-head { grid-area: head; display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) minmax(0, 1.6fr); gap: 6px; height: clamp(76px, 10vh, 118px); }
.b2-head .b-logo { justify-content: center; }
.b2-head .b-logo::before { display: none; }
.b2-opd { grid-area: opd; } .b2-ipd { grid-area: ipd; }
.b2-side { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 6px; min-width: 0; min-height: 0; }
.b2-divider { grid-area: div; background: linear-gradient(180deg, transparent, #3a4150 12%, #3a4150 88%, transparent); border-radius: 2px; }
.b2-label { display: flex; align-items: center; gap: 8px; font-size: clamp(13px, .9vw, 16px); font-weight: 600; color: #aeb4bd; letter-spacing: .3px; }
.b2-label span { background: #2b3342; color: #fff; border-radius: 4px; padding: 1px 9px; font-weight: 700; }
.b2-opd .b2-label span { background: #b38600; } .b2-ipd .b2-label span { background: #1a8a7a; }
.b2-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: clamp(70px, 9.5vh, 112px); gap: 6px; }
.b2-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 6px; min-height: 0; }
.b2-opd .b2-panels { grid-template-rows: repeat(3, minmax(0, 1fr)); }
.b2-ipd .b2-panels { grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, .9fr); }
.b2-panels .b2-wide { grid-column: span 2; }
.board2 .b-rdu { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.board2 .b-rdu .bt { padding: 3px 2px; }
.board2 .b-rdu .bt .v { font-size: clamp(16px, 1.2vw, 24px); }
.board2 .b-rdu .bt .s { font-size: 11px; }
.board2 .b-foot { grid-area: foot; }
.b-ftbl { overflow: auto; min-height: 0; flex: 1; }
.b-ftbl table { width: 100%; border-collapse: collapse; font-size: clamp(12px, .78vw, 14px); font-variant-numeric: tabular-nums; }
.b-ftbl th, .b-ftbl td { padding: 3px 6px; border-bottom: 1px solid #22252b; text-align: right; white-space: nowrap; }
.b-ftbl th:first-child, .b-ftbl td:first-child { text-align: left; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; color: #ccccdc; }
.b-ftbl thead th { color: #8e939b; font-weight: 500; position: sticky; top: 0; background: #181b1f; }
.b-ftbl thead th[data-drill] { cursor: pointer; color: #8ab8ff; }
.b-ftbl td.z { color: #4b5058; }
.b-ftbl td.sum, .b-ftbl tfoot td { color: #5ae0a0; font-weight: 700; }
.b-ftbl tfoot td { border-bottom: 0; border-top: 1px solid #33373e; }

/* จอกลาง (โน้ตบุ๊ก/แท็บเล็ตแนวนอน) — เลื่อนหน้าได้ */
@media (max-width: 1280px) {
  .view.board-view { height: auto; min-height: 100vh; }
  .board2 { height: auto; grid-template-rows: auto auto auto; }
  .b2-panels, .b2-opd .b2-panels, .b2-ipd .b2-panels { grid-template-rows: none; grid-auto-rows: minmax(230px, auto); }
  .b-chart { min-height: 200px; }
}
/* แท็บเล็ต/มือถือ — OPD บน IPD ล่าง เส้นแบ่งแนวนอน */
@media (max-width: 900px) {
  .board2 { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "head" "opd" "div" "ipd" "foot"; gap: 8px; }
  .view.board-view { overflow-x: hidden; }
  /* แถบเมนูบน: ปุ่มเยอะ เรียงแนวนอน → ให้ตัดบรรทัดเมื่อจอแคบ (ไม่ดันทั้ง board ล้น) */
  .b-topbar { flex-wrap: wrap; row-gap: 6px; }
  .b-topbar .b-sync { width: 100%; order: 9; }
  .b2-divider { height: 3px; background: linear-gradient(90deg, transparent, #3a4150 10%, #3a4150 90%, transparent); }
  .b2-head { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); height: auto; grid-auto-rows: minmax(70px, auto); }
  .b2-head .b-logo, .b2-head .b-clock { grid-column: 1 / -1; min-height: 56px; }
  .b2-head .b-logo { order: -1; }
  /* การ์ดไหลตามความกว้างจริง (auto-fill) — อ่านง่ายทุกขนาดจอ รวมหน้าต่างแคบของ RxAlert.exe */
  .b2-tiles { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); grid-auto-rows: minmax(80px, auto); }
  .b2-panels, .b2-opd .b2-panels, .b2-ipd .b2-panels { grid-template-columns: minmax(0, 1fr); }
  .b2-panels .b2-wide { grid-column: span 1; }
  .bp { min-width: 0; overflow: hidden; }
  .b-ftbl { overflow-x: auto; }
  .board2 .b-foot { flex-wrap: wrap; justify-content: center; height: auto; row-gap: 6px; }
  .board2 .b-foot nav { flex-wrap: wrap; justify-content: center; }
  .board2 .hide-sm { display: none; }
  .bt .v { font-size: clamp(26px, 8vw, 40px); }
  .bt .l { white-space: normal; }
}
@media (max-width: 560px) {
  .b2-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(72px, auto); }
  .b2-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board2 .bt .v, .bt .v { font-size: clamp(20px, 9vw, 32px); }
  .board2 .bt .l, .bt .l { font-size: 11px; line-height: 1.25; }
  .board2 .b2-head .bt .v { font-size: clamp(20px, 8vw, 30px); }
  .view.board-view { padding: 6px; }
}
@media (max-width: 360px) {
  .b2-tiles, .b2-head { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- มือถือ ---------- */
@media (max-width: 640px) {
  .top { padding: 10px 12px; gap: 8px; }
  .top-title h1 { font-size: 17px; }
  .top-title p { display: none; }
  .top-status .pill { height: 28px; padding: 0 9px; font-size: 11.5px; }
  .view { padding: 12px 12px 36px; }
  .card { padding: 14px; border-radius: 14px; }
  .dash { gap: 10px; }
  .stat-row, #drpBody .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-row { grid-template-columns: minmax(0, 1fr); display: grid; }
  .seg { max-width: 100%; }
  .seg button { padding: 6px 10px; font-size: 12.5px; }
  .card-head h2 { font-size: 15px; }
  .card-foot { flex-wrap: wrap; }
  .card-foot .btn { flex: 1 1 auto; justify-content: center; }
  .drawer-head { padding: 12px 14px; flex-wrap: wrap; }
  .drawer-body { padding: 10px 10px 24px; }
  .tbl th:first-child, .tbl td:first-child { padding-left: 12px; }
  .tbl th:last-child, .tbl td:last-child { padding-right: 12px; }
  /* ตารางแจ้งเตือน → การ์ดทีละรายการ */
  .tbl.stack-sm thead { display: none; }
  .tbl.stack-sm, .tbl.stack-sm tbody { display: block; }
  .tbl.stack-sm tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .tbl.stack-sm td { display: block; border: 0; padding: 2px 0 !important; min-width: 0 !important; white-space: normal !important; }
  .tbl.stack-sm tbody tr:hover td { background: transparent; }
  .alerts-tbl td:nth-child(1) { grid-column: 1; font-size: 12px; color: var(--muted); }
  .alerts-tbl td:nth-child(2) { grid-column: 2; grid-row: 1; justify-self: end; }
  .alerts-tbl td:nth-child(3) { grid-column: 1 / -1; font-size: 14px; }
  .alerts-tbl td:nth-child(4) { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
  .alerts-tbl td:nth-child(4) > div { display: inline; }
  .alerts-tbl td:nth-child(5) { grid-column: 1 / -1; }
  .alerts-tbl td:nth-child(6) { grid-column: 1 / -1; }
  .alerts-tbl td:nth-child(7) { grid-column: 1 / -1; padding-top: 6px !important; }
  .iv-form { max-width: none; min-width: 0; }
  .recip-row { grid-template-columns: minmax(0, 1fr); }
  .rows-tbl .input, .rows-tbl .select { width: 140px !important; }
  .auth-card { padding: 20px; }
  .user-card { margin-top: 8px; }
}
.lock-wrap { display: grid; place-items: center; min-height: 50vh; }
.lock-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; padding: 28px; }
.lock-card h2 { margin: 0; font-size: 18px; }
.lock-card p { margin: 0; }
.lock-card .btn { justify-content: center; height: 40px; }
.lock-ic { width: 52px; height: 52px; margin: 0 auto 4px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.lock-ic .ic { width: 26px; height: 26px; }
.usage-tbl .spark { display: block; }
.usage-tbl tr.clickable-row { cursor: pointer; }
.tag.accent-soft { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 640px) { .usage-tbl th:nth-child(6), .usage-tbl td:nth-child(6), .usage-tbl th:nth-child(9), .usage-tbl td:nth-child(9) { display: none; } }

/* v4.1: ตัวอักษรไทยไม่ถูกตัด (สระบน/ล่าง) · กล่องละ 1 รายการ */
.board2 .bt { justify-content: space-evenly; padding: 4px 6px; overflow: hidden; }
.board2 .bt .l { line-height: 1.5; padding-top: 1px; font-size: clamp(12px, .78vw, 15px); overflow: visible; white-space: nowrap; text-overflow: clip; }
.board2 .bt .v { line-height: 1.12; font-size: clamp(24px, 2.35vw, 46px); }
.board2 .bt .s { line-height: 1.45; font-size: clamp(11px, .72vw, 14px); }
.board2 .b2-head .bt .v { font-size: clamp(26px, 2.6vw, 50px); }
.board2 .b2-head .b-clock .v { font-size: clamp(26px, 2.8vw, 54px); }
.board2 .b2-head .b-logo b { font-size: clamp(18px, 1.7vw, 32px); line-height: 1.35; }
.board2 .b2-head .b-logo span { line-height: 1.5; }
.board2 .b2-tiles { grid-auto-rows: clamp(80px, 10.2vh, 120px); }
.board2 .b2-label { line-height: 1.6; min-height: 24px; padding-top: 2px; }
.board2 .bp h3 { line-height: 1.5; margin-bottom: 2px; }
.board2 .b-bar { line-height: 1.5; }
.board2 .b-bar .n { padding: 1px 0; }
.board2 .b-feed .m { line-height: 1.5; }
.board2 .b-rdu { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); flex: 1; min-height: 0; }
.board2 .b-rdu .bt .l { font-size: 12px; }
.board2 .b-rdu .bt .v { font-size: clamp(16px, 1.25vw, 26px); }
.b2-opd .b2-panels { grid-template-rows: repeat(3, minmax(0, 1fr)); }
.b2-ipd .b2-panels { grid-template-rows: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, .8fr); }
.board2 .b-ftbl td, .board2 .b-ftbl th { line-height: 1.45; }
@media (max-width: 900px) {
  .board2 .bt .v { font-size: clamp(26px, 8vw, 40px); }
  .board2 .bt .l { white-space: normal; }
  .board2 .b2-tiles { grid-auto-rows: minmax(84px, auto); }
  .board2 .b-rdu { grid-auto-rows: minmax(64px, auto); }
}

/* v4.2: เผื่อความสูงให้บรรทัดล่างของการ์ด/แถวสุดท้ายของกล่อง */
.board2 .b2-head { height: clamp(96px, 12vh, 136px); }
.board2 .b2-head .bt .v { font-size: clamp(24px, 2.3vw, 44px); }
.board2 .b2-head .b-clock .v { font-size: clamp(26px, 2.6vw, 50px); }
.board2 .b2-tiles { grid-auto-rows: clamp(90px, 11vh, 130px); }
.board2 .bt .v { font-size: clamp(22px, 2.1vw, 42px); }
.board2 .bt { padding: 3px 6px 5px; }
.board2 .bp { padding: 5px 10px 6px; }
.board2 .b-bars { gap: 1px; }
.board2 .b-bar { line-height: 1.42; }
.board2 .b-feed a { padding: 3px 2px; }
.b2-ipd .b2-panels { grid-template-rows: minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, .5fr); }
.alerts-sec-head { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 14px; }
.alerts-sec-head .ic { width: 16px; height: 16px; color: var(--good); }
.done-sec { opacity: .92; }
#fReviewed, #fFixed { height: 38px; white-space: nowrap; }
/* หัวข้อการ์ดยาว ให้ย่อขนาดตัวอักษรเล็กน้อยแทนการตัด */
.board2 .b2-tiles .bt .l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1700px) { .board2 .b2-tiles .bt .l { font-size: clamp(11px, .72vw, 14px); } }

/* ---------- คลินิกเบาหวานระยะสงบ ---------- */
.ok-text { color: var(--good-text); } .bad-text { color: var(--crit); }
.dm-tbl td { vertical-align: middle; }
.dm-bands { display: flex; flex-direction: column; gap: 3px; min-width: 240px; }
.dm-band { display: grid; grid-template-columns: 60px 1fr 28px; align-items: center; gap: 8px; font-size: 12px; }
.dm-band .bar { height: 12px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.dm-band .bar i { display: block; height: 100%; }
.dm-band .c { text-align: right; font-variant-numeric: tabular-nums; }
.dm-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.dm-kvs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; }
.dm-kv { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--border); padding: 4px 0; font-size: 13px; }
.dm-kv span { color: var(--text-2); } .dm-kv b { font-variant-numeric: tabular-nums; min-width: 0; text-align: right; overflow-wrap: anywhere; }
/* milestone TB — label บน / ค่าล่าง (ไม่ทับกัน, ค่ายาว ๆ wrap ได้) */
.tb-mile { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 16px; margin-top: 8px; }
.tb-mile-row { display: flex; flex-direction: column; gap: 3px; border-top: 1px dashed var(--border); padding-top: 6px; }
.tb-mile-l { color: var(--text-2); font-size: 12.5px; }
.tb-mile-v { font-size: 13.5px; }
.card.tb-dc { border: 2px solid rgba(16,185,129,.5); }
/* รูปผลตรวจ (GeneXpert/AFB) */
.lab-imgs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.lab-img { display: block; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); text-decoration: none; width: 160px; }
.lab-img img { display: block; width: 160px; height: 120px; object-fit: cover; background: #f1f5f9; }
.lab-img-cap { display: block; padding: 4px 8px; font-size: 11.5px; color: var(--text-2); }
.lab-img:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(15,23,42,.12); }
.dm-drugs { margin-top: 12px; font-size: 13px; }
.dm-enroll { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.dm-rxhist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px 16px; align-items: start; }
.dm-rxday { border-left: 3px solid var(--accent-soft); padding-left: 10px; break-inside: avoid; }
.dm-rxdate { font-weight: 700; font-size: 12.5px; margin-bottom: 3px; color: var(--accent); }
.dm-rxitem { font-size: 12.5px; padding: 1px 0; }
.dm-rxusage { font-size: 11.5px; margin-left: 2px; }
.dm-trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.dm-trend h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.dm-chart { min-height: 150px; }
.dm-chart svg text { font-family: var(--font); }
@media (max-width: 640px) {
  .dm-tbl th:nth-child(4), .dm-tbl td:nth-child(4), .dm-tbl th:nth-child(6), .dm-tbl td:nth-child(6), .dm-tbl th:nth-child(9), .dm-tbl td:nth-child(9), .dm-tbl th:nth-child(10), .dm-tbl td:nth-child(10) { display: none; }
  .dm-trends { grid-template-columns: 1fr; }
}
/* ---- คลินิก Palliative ---- */
.pall-lab-for { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.pc-lab-none { border-style: dashed !important; opacity: .85; }
.pc-lab-none b { color: var(--muted) !important; }
.pall-row:hover, .clinic-row:hover { background: var(--accent-soft); }
.clinic-row.loss-fu { background: rgba(220,38,38,.07); box-shadow: inset 3px 0 0 var(--crit); }
.clinic-row.loss-fu:hover { background: rgba(220,38,38,.12); }
/* ทะเบียนคลินิกแบบ grid หนาแน่น — เห็นหลายคนต่อจอ ไม่ต้อง scroll เยอะ */
.clinic-modes { display: inline-flex; gap: 6px; }
.clinic-search { margin-left: auto; }
.clinic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 7px; }
.clinic-c { display: flex; gap: 9px; align-items: center; padding: 7px 9px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; background: var(--surface); transition: background .12s; min-width: 0; }
.clinic-c:hover { background: var(--accent-soft); border-color: var(--accent); }
.clinic-c-photo { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }
.clinic-c-body { min-width: 0; flex: 1; }
.clinic-c-top { display: flex; align-items: center; gap: 6px; }
.clinic-c-top .al-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.clinic-c-meta { font-size: 12px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clinic-c.loss-fu { background: rgba(220,38,38,.06); border-color: rgba(220,38,38,.4); box-shadow: inset 3px 0 0 var(--crit); }
.clinic-c.loss-fu:hover { background: rgba(220,38,38,.12); }
/* กำลัง admit — ไฮไลท์ฟ้า (มาก่อน loss-fu ในการเรียง) */
.clinic-c.admitted { background: rgba(37,99,235,.08); border-color: rgba(37,99,235,.45); box-shadow: inset 3px 0 0 #2563eb; }
.clinic-c.admitted:hover { background: rgba(37,99,235,.14); }
.tag.adm { background: #2563eb; color: #fff; }
/* TB ครบคอร์ส (D/C) — ขอบเขียว */
.clinic-c.tb-done { border-color: rgba(16,185,129,.5); }
/* แถวสถานะใต้การ์ด: แนวโน้มค่าไต + badge บันทึก */
.clinic-c-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; white-space: normal; }
.clinic-c-flags .tag { font-size: 11px; padding: 1px 6px; }
.tag.tr-up { background: rgba(16,185,129,.14); color: #047857; border: 1px solid rgba(16,185,129,.4); }
.tag.tr-down { background: rgba(245,158,11,.16); color: #b45309; border: 1px solid rgba(245,158,11,.45); }
.tag.tr-down2 { background: rgba(220,38,38,.14); color: #b91c1c; border: 1px solid rgba(220,38,38,.5); font-weight: 700; }
.tag.tr-stable { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.clinic-modes .mode-worse:not(.btn-primary) { border-color: rgba(220,38,38,.5); color: #b91c1c; }
.clinic-modes .mode-better:not(.btn-primary) { border-color: rgba(16,185,129,.5); color: #047857; }
/* ตัวเลขสรุปบนหัว = กดกรองได้ */
.ipd-stats span[data-mode] { cursor: pointer; border-radius: 6px; padding: 2px 7px; transition: background .12s, box-shadow .12s; }
.ipd-stats span[data-mode]:hover { background: var(--accent-soft); }
.ipd-stats span[data-mode].btn-primary { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tag.note-tag { background: #7c3aed; color: #fff; }
/* เคสที่มีบันทึกเพิ่มเติม — ไฮไลท์ขอบม่วง (เว้นไว้ถ้า admit/loss ไฮไลท์อยู่แล้ว) */
.clinic-c.has-note:not(.admitted):not(.loss-fu) { border-color: rgba(124,58,237,.5); box-shadow: inset 3px 0 0 #7c3aed; }
/* ปุ่มดาวติดตามต่อเนื่อง + เคสที่ติดตาม (outline ทอง ไม่ชนกับ box-shadow อื่น) */
.clinic-c-act { display: flex; align-items: center; gap: 2px; margin-left: auto; flex: 0 0 auto; }
.clinic-star { background: none; border: 0; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 3px; border-radius: 6px; opacity: .55; filter: grayscale(1); }
.clinic-star:hover { opacity: 1; filter: none; background: var(--surface-2); }
.clinic-star.on { opacity: 1; filter: none; }
.clinic-c.watched { outline: 2px solid #f59e0b; outline-offset: -2px; }
.ipd-stats .dc b { color: #059669; }
.pall-dx { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 3px 16px; font-size: 13.5px; }
.pall-medgrp { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 7px 12px; margin-bottom: 16px; align-items: start; }
.pall-medgrp-h { grid-column: 1 / -1; font-weight: 700; font-size: 13px; margin-bottom: 2px; padding-bottom: 3px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.pall-medgrp-h.op { color: var(--crit); }
.pall-medgrp-h.adj { color: #d97706; }
.pall-med { padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 13px; line-height: 1.3; }
/* ---- ประวัติยาจัดกลุ่มตาม visit ---- */
.cln-visits { display: flex; flex-direction: column; gap: 10px; }
.cln-visit { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cln-visit-d { background: var(--surface-2); padding: 5px 11px; font-weight: 700; font-size: 13px; border-bottom: 1px solid var(--border); }
.cln-visit-meds { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1px; background: var(--border); }
.cln-vmed { background: var(--surface); padding: 6px 10px; font-size: 13px; line-height: 1.3; }
.cln-vmed.key { background: color-mix(in srgb, var(--crit) 8%, var(--surface)); }
.cln-vname { font-weight: 600; }
.cln-vmed.key .cln-vname { color: var(--crit); }
.cln-vuse { display: block; color: var(--text-2); font-size: 12px; margin-top: 1px; }
/* ---- โหมดภายนอก (Cloudflare Tunnel) ---- */
.ext-banner { position: sticky; top: 0; z-index: 5000; background: #7c2d12; color: #fff; text-align: center; font-size: 13px; padding: 5px 12px; font-weight: 600; letter-spacing: .2px; }
/* ---- Antibiogram ---- */
.ab-toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.ab-year select { width: auto; display: inline-block; }
.ab-stat { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.ab-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 11px; font-size: 12.5px; }
.ab-chip.ok { border-color: #16a34a55; } .ab-chip.warn { border-color: #d9770655; }
.ab-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.ab-badge { background: var(--crit); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; margin-left: 2px; }
.ab-badge:empty { display: none; }
.ab-note { margin-top: 10px; font-size: 12.5px; color: var(--text-2); border-top: 1px solid var(--border); padding-top: 8px; }
.ab-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ab-tab { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--text); }
.ab-tab.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.ab-scroll { overflow-x: auto; }
.ab-grid { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
.ab-grid th, .ab-grid td { border: 1px solid var(--border); padding: 4px 6px; text-align: center; }
.ab-grid thead th { background: var(--surface-2); position: sticky; top: 0; vertical-align: bottom; }
.ab-grid thead th span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: 600; font-size: 11.5px; max-height: 120px; }
.ab-grid .ab-corner, .ab-grid .ab-org { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 190px; }
.ab-grid thead .ab-corner { z-index: 3; background: var(--surface-2); writing-mode: horizontal-tb; }
.ab-org { font-weight: 600; font-style: italic; }
.ab-n { font-style: normal; font-weight: 400; color: var(--text-2); font-size: 11px; display: block; }
.ab-cell { font-weight: 600; }
.ab-cell b { display: block; font-size: 13px; } .ab-cell small { color: inherit; opacity: .7; font-size: 10px; }
.ab-cell.ab-s3 { background: #16a34a; color: #fff; } .ab-cell.ab-s2 { background: #86efac; color: #14532d; }
.ab-cell.ab-s1 { background: #fde68a; color: #713f12; } .ab-cell.ab-s0 { background: #f87171; color: #450a0a; }
.ab-na { color: var(--text-3); }
.ab-gramhead td { text-align: left; font-weight: 700; font-size: 12px; padding: 3px 8px; background: var(--surface-2); position: sticky; left: 0; }
.ab-gramhead.ab-g-pos td { background: #dbeafe; color: #1e3a8a; }
.ab-gramhead.ab-g-neg td { background: #fee2e2; color: #7f1d1d; }
.ab-gramhead.ab-g-fungus td { background: #fef3c7; color: #713f12; }
.ab-foot { margin-top: 8px; font-size: 12px; color: var(--text-2); }
.ab-rev-head { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.ab-rev-list { display: flex; flex-direction: column; gap: 6px; }
.ab-rev-item { text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; cursor: pointer; }
.ab-rev-item:hover { border-color: var(--accent); }
.ab-rev-top { display: flex; gap: 8px; align-items: center; }
.ab-rev-top b { font-size: 13.5px; }
.ab-tag { font-size: 11px; border-radius: 10px; padding: 1px 8px; background: var(--surface); border: 1px solid var(--border); }
.ab-tag.img { background: #7c3aed; color: #fff; border: 0; }
.ab-rev-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.ab-onlyimg { font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; margin-left: auto; margin-right: 8px; }
.ab-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ab-imgs .lab-img img { max-height: 260px; border: 1px solid var(--border); border-radius: 8px; }
.ab-restext { font-size: 12.5px; background: var(--surface-2); border-radius: 8px; padding: 7px 10px; margin-bottom: 10px; }
.ab-field { margin-bottom: 10px; } .ab-field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 3px; }
.ab-orgs { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.ab-org-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--surface-2); }
.ab-org-top { display: flex; gap: 6px; margin-bottom: 8px; }
.ab-org-top .org-name { font-style: italic; }
.ab-abx-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 6px; }
.ab-abx-row { display: grid; grid-template-columns: 1fr 80px 110px 34px; gap: 6px; align-items: center; }
.ab-abx-row .abx-sir { text-align: center; }
.dmp-rx.ab-print th, .dmp-rx.ab-print td { text-align: center; font-size: 11px; padding: 2px 4px; }
.dmp-rx.ab-print td:first-child, .dmp-rx.ab-print th:first-child { text-align: left; }
.dmp-rx.ab-print small { font-size: 9px; color: #666; }
@media (max-width: 640px) { .ab-abx-row { grid-template-columns: 1fr 64px 34px; } .ab-abx-row .abx-mic { display: none; } }
/* ---- รายการยาในหน้ารอจ่ายยา ---- */
.pc-druglist { display: flex; flex-direction: column; gap: 5px; }
.pc-drug { font-size: 13px; line-height: 1.25; }
.pc-drug > b { font-weight: 600; }
.pc-drug-use { font-size: 12px; margin-top: 1px; }
/* ---- แฟลชชื่อผู้ป่วยเต็มจอตอนเรียกคิว ---- */
.q-flash { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; background: rgba(8,20,30,.94); cursor: pointer; animation: qflashin .3s ease; }
.q-flash.out { animation: qflashout .4s ease forwards; }
.q-flash-in { text-align: center; padding: 24px; max-width: 92vw; }
.q-flash-l { font-size: clamp(22px, 3vw, 44px); font-weight: 700; color: #7dd3fc; letter-spacing: 1px; margin-bottom: 12px; }
.q-flash-name { font-size: clamp(48px, 9vw, 150px); font-weight: 900; color: #fff; line-height: 1.05; overflow-wrap: break-word; text-shadow: 0 4px 30px rgba(0,0,0,.5); }
.q-flash-dest { margin-top: 28px; font-size: clamp(40px, 7vw, 120px); font-weight: 900; color: #fff; background: linear-gradient(135deg, #ef4444, #b91c1c); display: inline-block; padding: 14px 54px; border-radius: 999px; line-height: 1.1; max-width: 94vw; box-shadow: 0 10px 40px rgba(185,28,28,.5); letter-spacing: .5px; }
@keyframes qflashin { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@keyframes qflashout { to { opacity: 0; } }
/* ---- ค่าแลปผิดปกติ — ไฮไลท์เด่น ---- */
.pc-lab-abn { border: 1.5px solid var(--crit) !important; background: rgba(220,38,38,.1) !important; }
.pc-lab-abn b { color: var(--crit) !important; }
.pc-lab-flag { font-size: 11px; font-weight: 800; color: #fff; background: var(--crit); border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
.pc-lab-abn.low { border-color: #d97706 !important; background: rgba(217,119,6,.12) !important; } .pc-lab-abn.low b { color: #b45309 !important; } .pc-lab-abn.low .pc-lab-flag { background: #d97706; }
/* ---- ค่าแลปคลิกดูกราฟได้ ---- */
.lab-link { cursor: pointer; border-radius: 6px; padding: 1px 3px; transition: background .12s; }
.lab-link:hover { background: var(--accent-soft); }
.lab-link-ic { font-size: 11px; opacity: .55; }
.lab-link:hover .lab-link-ic { opacity: 1; }
/* ---- ลิขสิทธิ์ท้ายทุกหน้า ---- */
.app-foot { padding: 14px 22px 20px; text-align: center; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 18px; }
body.q-fullscreen .app-foot { display: none; } /* จอ TV เต็มจอมีเครดิตในหน้าเรียกคิวเอง */
.auth-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }
.q-foot { flex: 0 0 auto; text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0 2px; }
body.q-fullscreen .q-foot { font-size: clamp(12px, 1vw, 15px); }
/* แถบปลดล็อกเสียง — มุมล่าง ไม่บังบอร์ด (โผล่เฉพาะเมื่อเบราว์เซอร์บล็อกเสียง) */
.q-audio-gate { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 5000; display: flex; align-items: center; gap: 10px; max-width: 94vw; padding: 10px 14px; border-radius: 999px; background: rgba(15,30,45,.96); color: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.4); cursor: pointer; animation: qaudioin .3s ease; }
.q-audio-ic { font-size: 22px; animation: qaudiopulse 1.4s ease-in-out infinite; flex: 0 0 auto; }
.q-audio-t { font-size: 14px; line-height: 1.3; }
.q-audio-x { flex: 0 0 auto; background: transparent; border: none; color: #cbd5e1; font-size: 15px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.q-audio-x:hover { background: rgba(255,255,255,.12); color: #fff; }
@keyframes qaudioin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes qaudiopulse { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.18); opacity: 1; } }

/* ===== ตัวอักษรวิ่งด้านล่างจอ TV — วนต่อเนื่องไร้รอยต่อ (ข้อความ 2 ชุด เลื่อน -50%) ===== */
.q-foot.q-tv-ticker { overflow: hidden; white-space: nowrap; padding: 10px 0; position: relative;
  background: linear-gradient(90deg, #0b1220, #152642 50%, #0b1220); border-top: 2px solid rgba(148, 163, 184, .25); }
body.q-fullscreen .view.q-tv .q-foot.q-tv-ticker { color: #e2e8f0; font-size: clamp(18px, 1.5vw, 30px); font-weight: 700; letter-spacing: .3px; }
.q-tv-ticker-in { display: inline-flex; align-items: center; will-change: transform;
  animation: qticker 60s linear infinite; }
.q-tv-ticker-seg { display: inline-flex; align-items: center; gap: 0; padding-right: 6rem; white-space: nowrap; }
.q-tv-ticker-dot { display: inline-block; padding: 0 1.6rem; color: #38bdf8; }
/* ข้อความที่ติ๊ก "ไฮไลท์" ในหน้าตั้งค่า — เหลืองสว่างบนพื้นเข้ม อ่านจากปลายห้องได้ชัด */
.q-tv-ticker-hi { color: #fde047; font-weight: 900; background: rgba(250, 204, 21, .14);
  border: 2px solid rgba(250, 204, 21, .55); border-radius: 10px; padding: 2px 18px; letter-spacing: .5px; }
/* แถวแก้ข้อความวิ่งในหน้าตั้งค่า */
.tk-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tk-row .input { flex: 1; min-width: 0; }
.tk-row .check { white-space: nowrap; }
.tk-row .icon-btn[disabled] { opacity: .35; cursor: default; }
@media (max-width: 720px) { .tk-row { flex-wrap: wrap; } .tk-row .input { flex: 1 0 100%; } }
@keyframes qticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .q-tv-ticker-in { animation: none; } }

/* ===== สัดส่วนคอลัมน์ซ้าย: "เรียกแล้ว · ไปที่ช่อง" กินพื้นที่ครึ่งหนึ่งของฝั่งซ้าย ===== */
.q-tv-pay .q-tv-called { flex: 0 0 50%; min-height: 0; margin-top: 12px; }
.q-tv-pay .q-tv-scroll { flex: 1 1 auto; min-height: 0; }
/* แถวเรียกแล้วใหญ่ขึ้นตามพื้นที่ที่ได้มา — ผู้ที่พลาดคิวอ่านจากไกลได้ */
.q-tv-called-h { font-size: clamp(16px, 1.3vw, 26px); padding: 10px 16px; }
.q-tv-called-h span { font-size: clamp(14px, 1vw, 20px); }

/* ===== หัวข้อ "รอรับยาผู้ป่วยใน" — ตัวใหญ่ที่สุดเท่าที่พื้นที่จะรับได้ ===== */
.q-tv-ipdwait-h { font-size: clamp(22px, 2.4vw, 46px); padding: 10px 16px; gap: 10px; line-height: 1.1; white-space: nowrap; }
.q-tv-ipdwait-h span { font-size: clamp(16px, 1.4vw, 28px); padding: 2px 14px; min-width: 42px; }

/* ===== สัดส่วนคอลัมน์ขวา: "รอรับยาผู้ป่วยใน" กินพื้นที่ครึ่งหนึ่งของฝั่งขวา ===== */
.q-tv-ph .q-tv-ipdwait { flex: 0 0 50%; min-height: 0; margin-top: 12px; }
.q-tv-ph .q-tv-scroll { flex: 1 1 auto; min-height: 0; }

/* ===== ตัดแถบหัวออก — บอร์ดยืดเต็มขอบจอ นาฬิกาย้ายไปมุมขวาของแถบตัวอักษรวิ่ง ===== */
.q-tvboard { grid-template-rows: minmax(0, 1fr); }
body.q-fullscreen .view.q-tv { padding: 8px 8px 0; gap: 0; }
body.q-fullscreen .view.q-tv .q-foot.q-tv-ticker { margin: 8px -8px 0; border-radius: 0; }
  background: linear-gradient(90deg, rgba(11,18,32,0) 0%, #132340 24%, #0b1220 100%); }

/* ===== ชื่อผู้ป่วยบนจอ TV ตัวใหญ่ที่สุดเท่าที่พื้นที่จะรับได้ (อ่านจากท้ายห้องได้) ===== */
/* การ์ดช่องเรียก 701/801/802/803 — ชื่อเต็มเสมอ ไม่ตัดด้วย ... (ยาวก็ขึ้นบรรทัดใหม่) */
.q-chan-name { font-size: clamp(30px, 3.1vw, 72px); line-height: 1.1; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; }
.q-chan-no { font-size: clamp(22px, 1.8vw, 40px); min-width: 72px; padding: 4px 14px; }
.q-chan-body { padding: 12px 20px; gap: 18px; }

/* ตารางคิวที่รอ (รอชำระเงิน / รอรับยา) */
.q-tv-tbl td { font-size: clamp(20px, 1.9vw, 40px); padding: 8px 12px; }
.q-tv-nm { font-weight: 700; line-height: 1.18; }
.q-tv-code { min-width: 82px; padding: 4px 11px; }
.q-tv-tbl th:nth-child(2), .q-tv-tbl td:nth-child(2) { width: 168px; }
.q-tv-tbl thead th { font-size: clamp(14px, 1.05vw, 21px); }

/* เรียกแล้ว · ไปที่ช่อง */
.q-tv-cnm { font-size: clamp(19px, 1.7vw, 34px); font-weight: 700; }
.q-tv-cnum { font-size: clamp(18px, 1.5vw, 30px); min-width: 68px; padding: 2px 10px; }
.q-tv-cch { font-size: clamp(16px, 1.3vw, 26px); padding: 3px 14px; }
.q-tv-crow { padding: 8px 6px; gap: 12px; }

/* รอรับยาผู้ป่วยใน */
.q-tv-ipdnm { font-size: clamp(20px, 1.8vw, 36px); font-weight: 700; line-height: 1.18; }
.q-tv-ipdbed { font-size: clamp(19px, 1.6vw, 32px); min-width: 86px; padding: 3px 12px; }
.q-tv-ipdtag { font-size: clamp(14px, 1.1vw, 22px); padding: 2px 11px; }
.q-tv-ipdeta { font-size: clamp(14px, 1.1vw, 22px); padding: 1px 10px; }
.q-tv-ipdrow { padding: 9px 6px; gap: 14px; }

/* นาฬิกามุมขวา: แถบไล่สีให้ทึบพอที่ตัวอักษรวิ่งจะไม่ทะลุออกมาซ้อนตัวเลขเวลา */
  background: linear-gradient(90deg, rgba(11,18,32,0) 0%, rgba(13,24,44,.75) 32%, #0b1220 62%, #0b1220 100%); }

/* ===== ชื่อ 1 บรรทัดเสมอ — ขนาดตัวอักษรถูกคำนวณให้พอดีกล่องด้วย fitTvNames() ไม่ตัดด้วย ... ===== */
.q-chan-name, .q-tv-nm, .q-tv-cnm, .q-tv-ipdnm { white-space: nowrap; overflow: hidden; text-overflow: clip; line-height: 1.15; }
.q-tv-tbl td, .q-tv-crow, .q-tv-ipdrow { overflow: hidden; }

/* จอ TV ไม่แสดงนาฬิกา/วันที่แล้ว — แถบตัวอักษรวิ่งใช้ความกว้างเต็มแถบ */
.q-tv-fclock { display: none !important; }

/* ===== ตัวเลขจำนวนคิวข้างหัวข้อ "ช่องชำระเงิน 701" — ชิดขวาสุด + กึ่งกลางแนวตั้ง ===== */
/* เดิมหัวข้อกินที่จนดันตัวเลขเบียดติดกัน: ให้หัวข้อย่อได้ แล้วดันตัวเลขไปขวาสุดด้วย margin-left:auto */
.q-chan-pay .q-chan-head { align-items: center; padding: 6px 18px; }
.q-chan-pay .q-chan-head > span:first-child { flex: 0 1 auto; min-width: 0; font-size: clamp(24px, 2.5vw, 50px); line-height: 1.15; }
.q-chan-pay .q-chan-head .q-tv-h-n { margin-left: auto; align-self: center; display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.1em; height: 1.75em; padding: 0 .55em; line-height: 1; border-radius: 999px; font-size: clamp(18px, 1.5vw, 30px); }

/* ===== Doctor Order Sheet (paperless) — คำสั่งแพทย์ + ตรวจว่ารายการไหนยังไม่ได้ Add chart ===== */
.dp-h-acts { display: flex; align-items: center; gap: 8px; }
.dos-btn { white-space: nowrap; font-weight: 700; }
.dos-warn { background: #fff7ed; border: 1px solid #fdba74; border-left: 4px solid #ea580c; color: #7c2d12;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; line-height: 1.6; }
.dos-warn b { color: #9a3412; }
.dos-ok { background: #ecfdf5; border: 1px solid #a7f3d0; border-left: 4px solid #0f766e; color: #065f46;
  border-radius: 10px; padding: 9px 14px; margin-bottom: 12px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dos-order { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: #fff; }
.dos-oh { background: #f6f8fb; border-bottom: 1px solid var(--border); padding: 7px 14px; font-size: 13px; color: #334155; }
.dos-items { padding: 4px 8px; }
.dos-item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 6px; border-bottom: 1px solid #f1f5f9; }
.dos-item:last-child { border-bottom: 0; }
.dos-item.off { opacity: .62; }
.dos-item.off b { text-decoration: line-through; }
/* ยาที่ off แล้ว — ขีดฆ่าทั้งบรรทัดรวมวิธีใช้ ให้เห็นชัดเหมือนใน Order Sheet ของ HOSxP */
.dos-item.off .dp-usage { text-decoration: line-through; }
.dos-item.off .pc-qty { text-decoration: line-through; }
/* ป้ายประเภทคำสั่งที่ไม่ใช่ยา (Lab / อื่น ๆ / ผ่าตัด) */
.dos-type { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 700; color: #3730a3;
  background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
/* บันทึกความก้าวหน้าของแพทย์ (SOAP) */
.dos-soap { background: #f8fafc; border-left: 4px solid #64748b; border-bottom: 1px solid var(--border);
  padding: 8px 14px; font-size: 12.5px; line-height: 1.55; }
.dos-soap-l { display: flex; gap: 8px; align-items: flex-start; }
.dos-soap-l + .dos-soap-l { margin-top: 3px; }
.dos-soap-k { flex: 0 0 auto; min-width: 20px; font-weight: 800; color: #475569; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  .dos-type { color: #c7d2fe; background: #1e1b4b; border-color: #3730a3; }
  .dos-soap { background: #111827; border-left-color: #64748b; }
  .dos-soap-k { color: #94a3b8; }
} }
:root[data-theme="dark"] .dos-type { color: #c7d2fe; background: #1e1b4b; border-color: #3730a3; }
:root[data-theme="dark"] .dos-soap { background: #111827; }
:root[data-theme="dark"] .dos-soap-k { color: #94a3b8; }
.dos-item.miss { background: #fff7ed; border-radius: 8px; }
.dos-k { flex: 0 0 auto; min-width: 34px; text-align: center; font-size: 11px; font-weight: 800; border-radius: 6px; padding: 2px 7px; line-height: 1.5; }
.dos-k.continue { background: #e0edff; color: #1d4ed8; }
.dos-k.oneday, .dos-k.one_day { background: #f1f5f9; color: #475569; }
.dos-k.offk { background: #fee2e2; color: #b91c1c; }
.dos-stat { font-size: 11px; font-weight: 800; color: #b91c1c; background: #fee2e2; border-radius: 5px; padding: 1px 6px; }
.dos-home { display: inline-block; font-size: 11px; font-weight: 700; color: #0e6458; background: #d6efe9; border-radius: 5px; padding: 1px 7px; margin-top: 3px; }
.dos-miss { display: inline-block; font-size: 12px; font-weight: 800; color: #9a3412; background: #ffedd5; border-radius: 6px; padding: 1px 8px; margin-top: 3px; }
.dos-done { display: inline-block; font-size: 12px; font-weight: 700; color: #0e6458; background: #e6f3f0; border-radius: 6px; padding: 1px 8px; margin-top: 3px; }
.pc-rounds-card .dos-order:last-child { margin-bottom: 0; }

/* ===== ป๊อปอัป Note ผู้ป่วย (ptnote ของ HOSxP) ===== */
.note-pop-f { display: flex; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--border); }
.note-item { border-left: 3px solid #cbd5e1; background: #f8fafc; border-radius: 0 8px 8px 0; padding: 8px 12px; margin-bottom: 8px; }
.note-item.rx { border-left-color: #0f766e; background: #ecfdf5; }
.note-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.note-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: break-word; }
.note-rx { font-size: 11px; font-weight: 800; color: #0e6458; background: #d6efe9; border-radius: 5px; padding: 1px 7px; }
.note-title { font-weight: 800; margin: 10px 0 4px; }
.note-group { font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
.note-add { color: #0e6458; } .note-del { color: #b91c1c; text-decoration: line-through; }

/* ===== รายละเอียดประวัติแพ้ยา (กดจากแถบ "แพ้ยา") ===== */
.allergy-link { cursor: pointer; }
.allergy-link:hover { filter: brightness(.97); }
.pc-allergy-more { font-size: 12px; font-weight: 700; color: #b91c1c; white-space: nowrap; }
.alg-card { border: 1px solid var(--border); border-left: 4px solid #dc2626; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; background: #fff; }
.alg-kv { display: grid; grid-template-columns: minmax(130px, 32%) 1fr; gap: 2px 12px; font-size: 14px; line-height: 1.7; }
.alg-kv > span:nth-child(odd) { color: var(--muted); }
.alg-tag { display: inline-block; font-size: 12px; font-weight: 800; border-radius: 6px; padding: 1px 8px; }
.alg-tag.bad { color: #b91c1c; background: #fee2e2; }
.alg-tag.warn { color: #92560a; background: #fdf0d9; }

/* ===== ป้ายการปรับยาใน Drug profile ===== */
.dp-diff { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; font-weight: 800; border-radius: 6px; padding: 1px 8px; margin-top: 3px; }
.dp-diff span { font-weight: 600; opacity: .85; }
.dp-diff.new { color: #1d4ed8; background: #e0edff; }
.dp-diff.resume { color: #0e6458; background: #d6efe9; }
.dp-diff.up { color: #b91c1c; background: #fee2e2; }
.dp-diff.down { color: #92560a; background: #fdf0d9; }
.dp-diff.usage { color: #475569; background: #eef2f7; }
.dp-atb { font-size: 12px; font-weight: 700; color: #1d4ed8; background: #eff6ff; border-radius: 6px; padding: 1px 8px; margin-top: 3px; display: inline-block; }
.dp-dot { font-size: 12px; color: var(--muted); margin-top: 3px; }
/* สถานะคอร์สการรักษา — กำลังอยู่ในคอร์ส (น้ำเงิน) · วันสุดท้าย (ส้ม) · เกินคอร์ส (แดง) */
.dp-atb.st-last { color: #9a3412; background: #fff7ed; }
.dp-atb.st-over { color: #b91c1c; background: #fef2f2; }
.dp-atb-n { display: block; font-weight: 500; font-size: 11.5px; opacity: .85; }
/* ป้าย day ในตาราง Drug profile */
.pcp-day { display: inline-block; margin-left: 7px; font-size: 10.5px; font-weight: 800; white-space: nowrap;
  color: #1d4ed8; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 999px; padding: 0 7px; }
.pcp-day.st-last { color: #9a3412; background: #fff7ed; border-color: #fed7aa; }
.pcp-day.st-over { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dp-atb.st-last, :root:not([data-theme="light"]) .pcp-day.st-last { color: #fdba74; background: #2b1a0c; border-color: #7c2d12; }
  :root:not([data-theme="light"]) .dp-atb.st-over, :root:not([data-theme="light"]) .pcp-day.st-over { color: #fca5a5; background: #3f1414; border-color: #7f1d1d; }
  :root:not([data-theme="light"]) .pcp-day { color: #93c5fd; background: #10233f; border-color: #1e3a8a; }
}
:root[data-theme="dark"] .dp-atb.st-last, :root[data-theme="dark"] .pcp-day.st-last { color: #fdba74; background: #2b1a0c; border-color: #7c2d12; }
:root[data-theme="dark"] .dp-atb.st-over, :root[data-theme="dark"] .pcp-day.st-over { color: #fca5a5; background: #3f1414; border-color: #7f1d1d; }
:root[data-theme="dark"] .pcp-day { color: #93c5fd; background: #10233f; border-color: #1e3a8a; }
.dp-renal { font-size: 12px; font-weight: 700; color: #92560a; background: #fdf0d9; border-radius: 6px; padding: 1px 8px; margin-top: 3px; display: inline-block; }

/* ===== ตัวเลือกผู้ป่วยใต้ช่องกรอก HN (บันทึกส่งเวร) ===== */
.hn-ac-list {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 340px; max-width: 460px;
  max-height: 310px; overflow: auto; background: var(--card, #fff); border: 1px solid var(--line, #d8dee6);
  border-radius: 10px; box-shadow: 0 10px 28px rgba(16, 32, 56, .18); padding: 4px;
}
.hn-ac-i { display: flex; align-items: baseline; gap: 8px; padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.hn-ac-i.on, .hn-ac-i:hover { background: var(--hover, #eef4fb); }
.hn-ac-n { font-weight: 700; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hn-ac-hn { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; opacity: .75; flex: 0 0 auto; }
.hn-ac-t { flex: 0 0 auto; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.hn-ac-t.ipd { background: #e6f3ff; color: #14558f; }
.hn-ac-t.opd { background: #eafaf1; color: #12694a; }
.hn-ac-t.hn  { background: #f1f3f6; color: #5a6676; }
.hn-ac-e { padding: 9px; font-size: 13px; }

/* ===== รายเคสเวลารอรับยา (กดจากการ์ด Waiting time) ===== */
.wt-row td { white-space: nowrap; }
.wt-row.over td { background: #fff5f5; }
[data-wait] { cursor: pointer; }
[data-wait]:hover { filter: brightness(.98); }

/* ===== ปุ่มหมวด "ใบสั่งยาที่รอดำเนินการ" — ต้องสะดุดตาเมื่อมีใบรออยู่ ===== */
.ord-btn { font-weight: 800; border: 2px solid var(--border); gap: 7px; padding-right: 12px; }
.ord-btn .ord-dot { display: none; width: 9px; height: 9px; border-radius: 50%; background: #fff; }
.ord-btn .ord-n { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 26px; padding: 0 8px;
  border-radius: 999px; background: #eef2f7; color: #64748b; font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
.ord-btn .ord-u { font-size: 12px; font-weight: 600; opacity: .85; }
.ord-btn.has { background: linear-gradient(100deg, #b4710f, #92560a); color: #fff; border-color: transparent;
  box-shadow: 0 4px 16px rgba(180, 113, 15, .35); }
.ord-btn.has .ord-dot { display: inline-block; animation: ordPulse 1.6s ease-out infinite; }
.ord-btn.has .ord-n { background: #fff; color: #92560a; }
@keyframes ordPulse { 0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .75); } 70% { box-shadow: 0 0 0 9px rgba(255, 255, 255, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); } }
.ord-btn.on { background: linear-gradient(100deg, #0f766e, #115e56); color: #fff; border-color: transparent; box-shadow: 0 4px 16px rgba(15, 118, 110, .3); }
.ord-btn.on .ord-n { background: #fff; color: #0f766e; }
.ord-btn.on .ord-dot { display: none; }

/* เลขช่องที่จะเรียกไป บนปุ่มเรียกคนไข้ในหน้าตรวจก่อนจ่าย */
.pc-call-ch { display: inline-block; font-size: 12px; font-weight: 900; background: rgba(255,255,255,.26); border-radius: 6px; padding: 0 7px; margin-left: 4px; }

/* ===== หัวข้อทุกหัวข้อบนจอ TV จัดกึ่งกลาง · ตัวเลขจำนวนลอยชิดขวาและกึ่งกลางแนวตั้ง =====
   ใช้ position:absolute กับตัวเลข เพื่อให้ "ข้อความหัวข้อ" อยู่กึ่งกลางจริง ๆ ไม่ถูกตัวเลขดันเบี้ยว */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  position: relative; display: flex; align-items: center; justify-content: center; text-align: center;
  padding-left: clamp(56px, 6vw, 110px); padding-right: clamp(56px, 6vw, 110px);
}
.q-chan-head > span:first-child, .q-tv-h > span:first-child,
.q-tv-called-h, .q-tv-ipdwait-h { min-width: 0; }
.q-chan-pay .q-chan-head > span:first-child { flex: 0 1 auto; }

.q-chan-head .q-tv-h-n, .q-tv-h .q-tv-h-n, .q-tv-called-h > span:not(.q-tv-ht), .q-tv-ipdwait-h > span:not(.q-tv-ht) {
  position: absolute; right: clamp(12px, 1.2vw, 22px); top: 50%; transform: translateY(-50%);
  margin: 0; display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.1em; height: 1.75em; padding: 0 .5em; line-height: 1; border-radius: 999px;
}
/* หัวข้อที่มีไอคอนนำหน้า (💊 🏥 📣) — ไอคอนติดไปกับข้อความ จึงยังกึ่งกลางทั้งก้อน */
.q-tv-called-h, .q-tv-ipdwait-h { gap: 10px; }

/* ===== หัวข้อ 1 บรรทัดเสมอ — ให้ span กินความกว้างที่เหลือ แล้ว fitTvNames() ย่อขนาดให้พอดี ===== */
.q-chan-head > span:first-child, .q-tv-h > span:first-child, .q-tv-ht {
  flex: 1 1 auto; min-width: 0; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: clip; line-height: 1.15;
}
/* ตัวเลขลอยชิดขวาอยู่แล้ว จึงเผื่อที่ว่างสองข้างเท่ากันแค่พอให้ไม่ทับ */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  padding-left: clamp(40px, 3.6vw, 76px); padding-right: clamp(40px, 3.6vw, 76px);
}
/* "เรียกแล้ว · ไปที่ช่อง" และ "รอรับยาผู้ป่วยใน" — ให้ใหญ่ได้สุดแล้วค่อยย่อลงถ้าไม่พอ */
.q-tv-called-h, .q-tv-ipdwait-h { font-size: clamp(20px, 2.4vw, 46px); }

/* ===== หัวข้อ: บีบระยะเผื่อสองข้างให้เหลือเท่าที่วงกลมตัวเลขใช้จริง — ข้อความจะได้พื้นที่มากขึ้นและตัวโตขึ้น ===== */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  padding-left: clamp(30px, 2.4vw, 52px); padding-right: clamp(30px, 2.4vw, 52px);
  padding-top: 6px; padding-bottom: 6px;
}
/* เพดานของ CSS ต้องไม่ต่ำกว่าที่ fitTvNames() จะตั้งให้ (JS ตั้งเป็น inline style ทับอยู่แล้ว) */
.q-tv-called-h, .q-tv-ipdwait-h { font-size: clamp(20px, 3.2vw, 68px); }
.q-tv-h { font-size: clamp(20px, 3.2vw, 68px); }
.q-tv-h .q-tv-h-n, .q-tv-called-h > span:not(.q-tv-ht), .q-tv-ipdwait-h > span:not(.q-tv-ht) {
  font-size: clamp(15px, 1.2vw, 24px);
}

/* ===== ย้ำอีกครั้งท้ายไฟล์: หัวข้อทุกจุดกึ่งกลางเสมอ (กันกฎเดิม justify-content: space-between ที่ประกาศไว้ด้านบน) ===== */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h { display: flex; align-items: center; justify-content: center; text-align: center; }
.q-chan-head > span:first-child, .q-tv-h > span:first-child, .q-tv-ht { position: static; flex: 1 1 auto; min-width: 0; text-align: center; }

/* ===== ข้อความหัวข้อ: ไม่มีพื้นหลัง/ไฮไลต์ =====
   กฎเก่า ".q-tv-called-h span" และ ".q-tv-ipdwait-h span" เป็นแบบ descendant (ไม่มี >)
   จึงเผลอใส่พื้นหลังขาวโปร่งให้ span ของ "ข้อความหัวข้อ" ที่เพิ่งห่อใหม่ด้วย — ล้างทิ้งตรงนี้ */
.q-tv-ht, .q-chan-head > span:first-child, .q-tv-h > span:first-child {
  background: none !important; border: 0; border-radius: 0; padding: 0; min-width: 0;
}
/* เผื่อที่ให้วงกลมตัวเลขพอดี ไม่ให้ทับข้อความ และยังเท่ากันสองข้างเพื่อให้หัวข้ออยู่กึ่งกลางจริง */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  padding-left: clamp(44px, 3.4vw, 72px); padding-right: clamp(44px, 3.4vw, 72px);
}

/* ===== ชื่อผู้ป่วยทุกจุดบนจอ TV ห้ามตกบรรทัดเด็ดขาด =====
   ประกาศไว้ท้ายสุดและครอบทุกชื่อ (รวม .q-name ที่ใช้ร่วมกับหน้า operator) กันกฎเก่าที่ตั้ง white-space: normal ไว้
   min-width: 0 จำเป็นสำหรับ flex item ไม่งั้นมันจะไม่ยอมหดลงต่ำกว่าความกว้างข้อความ */
.view.q-tv .q-chan-name, .view.q-tv .q-tv-nm, .view.q-tv .q-tv-cnm,
.view.q-tv .q-tv-ipdnm, .view.q-tv .q-name, .view.q-tv .q-tv-ht {
  white-space: nowrap !important; word-break: keep-all; overflow-wrap: normal;
  overflow: hidden; text-overflow: clip; min-width: 0;
}
.view.q-tv .q-tv-ipdrow, .view.q-tv .q-tv-crow { flex-wrap: nowrap; }

/* แถบสถานะ Add chart ของผู้ป่วยใน (ตึก paperless) บนหัวหน้าตรวจก่อนจ่าย */
.pc-banner.pc-chart { gap: 10px; }
/* เตือนให้ osel โดยไม่ swab — ข้อความสองบรรทัด ต้องชิดบนไม่ใช่กลาง */
.pc-banner.pc-oselns { align-items: flex-start; }
.pc-banner.pc-chart .dos-btn { margin-left: auto; flex: 0 0 auto; }

/* ===== ช่องตั้งเลขช่องรับยาประจำเครื่อง — ต้องเห็นชัดว่าเครื่องนี้เรียกไปช่องไหน ===== */
.q-counter-set { gap: 8px; font-size: 13px; font-weight: 700; color: #0f766e;
  background: #e6f3f0; border: 2px solid #9ed4c9; border-radius: 10px; padding: 3px 10px 3px 12px; }
.q-counter-set #qCounter { width: 76px !important; height: 34px !important; text-align: center;
  font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; color: #0b5247;
  background: #fff; border: 2px solid #0f766e; border-radius: 8px; padding: 0 4px; }
.q-counter-set #qCounter::placeholder { font-size: 15px; font-weight: 700; color: #94a3b8; }
.q-counter-set #qCounter:focus { outline: none; box-shadow: 0 0 0 3px rgba(15,118,110,.25); }
/* ยังไม่ได้ตั้งเลขช่อง = เตือนด้วยสีแดงและกะพริบ จะได้ไม่กดเรียกแล้วเด้ง error */
.q-counter-set:has(#qCounter[value=""]), .q-counter-set.need { background: #fdecec; border-color: #f0a8a8; color: #b02020; }
.q-counter-set.need #qCounter { border-color: #b02020; color: #b02020; animation: qcNeed 1.2s ease-out infinite; }
@keyframes qcNeed { 0% { box-shadow: 0 0 0 0 rgba(176,32,32,.5); } 70% { box-shadow: 0 0 0 8px rgba(176,32,32,0); } 100% { box-shadow: 0 0 0 0 rgba(176,32,32,0); } }

/* ===== แถบสถานะใต้ชื่อบนจอ TV: กำลังจัดยา · รอประมาณ..นาที ===== */
.q-tv-nm, .q-tv-ipdnm { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.q-tv-nmt { display: block; white-space: nowrap; overflow: hidden; text-overflow: clip; max-width: 100%; }
.q-tv-sub { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; white-space: nowrap; }
.q-tv-sub .q-tv-eta { font-size: clamp(13px, 1.05vw, 21px); font-weight: 800; border-radius: 7px; padding: 1px 9px;
  color: #92560a; background: #fdf0d9; }
.q-tv-sub .q-tv-eta.prep { color: #1d4ed8; background: #e0edff; }

/* ===== ชื่อชิดตัวเลข — เว้นที่ให้เลขคิวแค่ 4 หลักพอ ไม่ต้องเผื่อเกิน ===== */
.q-tv-tbl th:nth-child(2), .q-tv-tbl td:nth-child(2) { width: 1%; white-space: nowrap; padding-right: 6px; }
.q-tv-code { min-width: 0; padding: 3px 8px; }
.q-tv-tbl th:last-child, .q-tv-tbl td:last-child { padding-left: 8px; }
.q-tv-tbl th.q-tv-no, .q-tv-tbl td.q-tv-no { width: 1%; padding-right: 4px; }
/* ผู้ป่วยใน: ป้ายเตียงกว้างพอ 4-5 ตัวอักษร แล้วชื่อชิดต่อเลย */
.q-tv-ipdbed { min-width: 0; padding: 3px 10px; }
.q-tv-ipdrow { gap: 10px; }
/* ไอคอนในแถบสถานะให้ขนาดพอดีตัวอักษร */
.q-tv-sub .q-tv-eta { display: inline-flex; align-items: center; gap: 5px; }
.q-tv-sub .q-tv-eta .ic { width: 1em; height: 1em; flex: 0 0 auto; }

/* ===== ป๊อปอัป Note ผู้ป่วย: อ่านง่าย ตัวอักษรพอดี ไม่มีช่องว่างเกิน =====
   ต้นเหตุเดิม: .note-pop-b ตั้ง white-space: pre-wrap ครอบทั้งกล่อง
   ช่องว่าง/ขึ้นบรรทัดระหว่างแท็กในโค้ดเลยกลายเป็นบรรทัดว่างจริงทั้งหมด */
.note-pop { width: min(720px, 94vw); gap: 12px; padding: 18px 20px; }
.note-pop-b { white-space: normal; font-size: inherit; line-height: inherit;
  max-height: min(62vh, 620px); overflow-y: auto; padding-right: 4px; }
.note-pop-h { font-size: 18px; }
.note-item { border: 1px solid #e3e8ef; border-left: 4px solid #cbd5e1; background: #fff;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.note-item:last-child { margin-bottom: 0; }
.note-item.rx { border-left-color: #0f766e; background: #f6fcfa; }
.note-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: #64748b; margin: 0 0 4px; padding-bottom: 4px; border-bottom: 1px dashed #e8edf4; }
.note-when { font-weight: 700; color: #475569; font-variant-numeric: tabular-nums; }
.note-by { color: #8b96a5; }
.note-by::before { content: '·'; margin-right: 8px; }
.note-rx { font-size: 11px; font-weight: 800; color: #0e6458; background: #d6efe9; border-radius: 5px; padding: 1px 7px; margin-left: auto; }
.note-text { font-size: 16px; line-height: 1.7; color: #1e293b; white-space: pre-wrap; overflow-wrap: break-word; }

/* ===== หัวข้อจอ TV: กึ่งกลางจริง และไม่ไปเบียดวงกลมตัวเลข =====
   วงกลมตัวเลขลอยชิดขวาแบบ absolute อยู่แล้ว จึงต้องกันที่สองข้างให้เท่ากันและกว้างพอ
   ไม่งั้นข้อความจะยืดไปจนเกือบชนตัวเลข ทำให้ดูเหมือนไม่ได้อยู่กึ่งกลาง */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  padding-left: clamp(54px, 4.4vw, 92px); padding-right: clamp(54px, 4.4vw, 92px);
  justify-content: center; text-align: center;
}
.q-tv-ht, .q-chan-head > span:first-child, .q-tv-h > span:first-child {
  flex: 0 1 auto; margin: 0 auto; text-align: center;
}

/* ===== ช่องเลือกวันที่หน้าตรวจก่อนจ่าย: เหลือแค่ไอคอนปฏิทิน ===== */
.pc-day { display: inline-flex; align-items: center; gap: 6px; }
.pc-day > .ic { display: none; }                       /* ไอคอนนาฬิกาเดิม ไม่ต้องแล้ว ใช้ปฏิทินของช่องวันที่แทน */
.pc-day #pcDate { width: 38px; min-width: 38px; padding: 0; border-radius: 9px; position: relative;
  color: transparent; background: #fff; cursor: pointer; }
.pc-day #pcDate::-webkit-datetime-edit, .pc-day #pcDate::-webkit-inner-spin-button,
.pc-day #pcDate::-webkit-clear-button { display: none; }
.pc-day #pcDate::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; opacity: .7; cursor: pointer; }
.pc-day #pcDate:hover::-webkit-calendar-picker-indicator { opacity: 1; }
/* ดูข้อมูลย้อนหลังอยู่ = ไฮไลต์ให้เห็นชัดว่าไม่ใช่ข้อมูลวันนี้ */
.pc-day #pcDate.on-back { background: #fdf0d9; box-shadow: 0 0 0 2px #e0a93a inset; }
body.pc-backday .pc-day::after { content: 'ดูข้อมูลของ ' attr(data-back); font-size: 11px; font-weight: 800;
  color: #92560a; background: #fdf0d9; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }

/* ===== หัวข้อ: คืนพื้นที่ให้ข้อความมากที่สุด =====
   ตัวจำกัดขนาดตัวอักษรคือ "ความกว้างที่เหลือ" ไม่ใช่ความสูง
   เดิมกันที่ไว้ข้างละ 92px ทั้งที่วงกลมตัวเลขใช้จริงราว 55px — คืนส่วนเกินให้ข้อความ */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  padding-left: clamp(42px, 3.3vw, 64px); padding-right: clamp(42px, 3.3vw, 64px);
  letter-spacing: 0;
}
.q-tv-called-h, .q-tv-ipdwait-h { gap: 6px; font-size: clamp(20px, 4vw, 84px); }
.q-tv-h { font-size: clamp(20px, 4vw, 84px); }
/* วงกลมตัวเลขเล็กลงนิด ชิดขอบขึ้น = ได้พื้นที่คืนอีก */
.q-chan-head .q-tv-h-n, .q-tv-h .q-tv-h-n,
.q-tv-called-h > span:not(.q-tv-ht), .q-tv-ipdwait-h > span:not(.q-tv-ht) {
  right: clamp(8px, .7vw, 14px); min-width: 1.9em; height: 1.6em; padding: 0 .4em;
}

/* หัวกลุ่มรายการยาแบบ "ตามรอบที่คีย์" — บอกวัน-เวลา และคนที่คีย์ */
.pc-drug-round { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums;
  color: #0e6458; background: #eefaf6; border: 1px solid #cdeae2; border-left: 4px solid #0f766e;
  border-radius: 8px; padding: 5px 12px; margin: 10px 0 6px; font-size: 13px; font-weight: 800; }
.pc-drug-round:first-child { margin-top: 0; }

/* รอบที่ไม่ใช่ยาผู้ป่วยใน (ER / ห้องตรวจ) — ใช้สีส้มตัดกับสีเขียวของรอบคีย์ยาในหอผู้ป่วย
   เภสัชจะได้แยกออกทันทีว่าแถวไหนคือยาที่เพิ่งคีย์ให้ผู้ป่วยใน แถวไหนติดมาจาก visit เดียวกัน */
.pc-drug-round.is-opd { color: #8a4b08; background: #fff7ed; border-color: #fed7aa; border-left-color: #ea580c; }
.pc-opd-tag { font-size: 10.5px; font-weight: 700; color: #9a3412; background: #ffedd5;
  border: 1px solid #fdba74; border-radius: 999px; padding: 1px 8px; margin-left: auto; white-space: nowrap; }
/* แถบเทียบปริมาณในรายงานภาระงานคีย์ยา — วาดนำหน้าตัวเลข ไม่บังข้อความ */
.ky-bar { display: inline-block; vertical-align: middle; height: 9px; width: var(--w, 0%); max-width: 76px;
  margin-right: 6px; border-radius: 3px; background: linear-gradient(90deg, #93c5fd, #3b82f6); }
.ky-bar.wide { max-width: none; height: 11px; }

/* หัวข้อหมวดแบบใบ Drug profile — Continue เขียว · One day ส้มอ่อน · ยา ER/ห้องตรวจ ส้มเข้ม */
.pc-drug-group.is-cont, .pc-drug-group.is-oneday, .pc-drug-group.is-other, .pc-drug-group.is-opd {
  font-size: 12.5px; padding: 4px 9px; border-radius: 6px; margin: 10px 0 3px; }
.pc-drug-group.is-cont { color: #065f46; background: #ecfdf5; border-left: 4px solid #10b981; }
.pc-drug-group.is-oneday { color: #92400e; background: #fffbeb; border-left: 4px solid #f59e0b; }
.pc-drug-group.is-other { color: #475569; background: #f8fafc; border-left: 4px solid #94a3b8; }
.pc-drug-group.is-opd { color: #9a3412; background: #ffedd5; border-left: 4px solid #ea580c; }
/* แถวยาของ ER/ห้องตรวจ — พื้นส้มให้ต่างจากยาผู้ป่วยในชัด ๆ */
.pc-drug.is-opd { background: #fff7ed; border-left: 3px solid #fb923c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  .pc-drug-round.is-opd { color: #fdba74; background: #2b1a0c; border-color: #7c3d10; border-left-color: #ea580c; }
  .pc-opd-tag { color: #fdba74; background: #3a2310; border-color: #7c3d10; }
  .pc-drug.is-opd { background: #231708; border-left-color: #7c3d10; }
  .pc-drug-group.is-cont { color: #6ee7b7; background: #0c2a21; border-left-color: #0f766e; }
  .pc-drug-group.is-oneday { color: #fcd34d; background: #2a2109; border-left-color: #a16207; }
  .pc-drug-group.is-other { color: #cbd5e1; background: #1a2232; border-left-color: #475569; }
  .pc-drug-group.is-opd { color: #fdba74; background: #2b1a0c; border-left-color: #ea580c; }
} }
:root[data-theme="dark"] .pc-drug-round.is-opd { color: #fdba74; background: #2b1a0c; border-color: #7c3d10; border-left-color: #ea580c; }
:root[data-theme="dark"] .pc-opd-tag { color: #fdba74; background: #3a2310; border-color: #7c3d10; }
:root[data-theme="dark"] .pc-drug.is-opd { background: #231708; border-left-color: #7c3d10; }
.pc-drug-head .spacer { flex: 1; }

/* ===== หัวข้อจอ TV: ใหญ่สุดจริง =====
   ก่อนหน้านี้ span หัวข้อตั้ง flex: 0 1 auto (กว้างเท่าข้อความ) ทำให้การวัดพื้นที่เพี้ยน
   แล้วตัวอักษรถูกย่อเล็กเกินจำเป็น — เปลี่ยนให้กินความกว้างที่เหลือทั้งหมด */
.q-tv-ht, .q-chan-head > span:first-child, .q-tv-h > span:first-child {
  flex: 1 1 auto !important; width: 100%; margin: 0 !important; min-width: 0; text-align: center;
}
/* กันที่ให้วงกลมตัวเลขเท่าที่ใช้จริง (วงกลมกว้างราว 46px) */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  padding-left: clamp(34px, 2.8vw, 54px); padding-right: clamp(34px, 2.8vw, 54px);
}

/* ===== หัวข้อจอ TV: กันที่ให้วงกลมตัวเลขพอ ไม่ให้ข้อความทับกัน =====
   วงกลมตัวเลขลอยชิดขวาแบบ absolute กว้างราว 60px + ระยะห่างขอบ จึงต้องกันไว้อย่างน้อย 78px
   (ก่อนหน้านี้กันไว้ 54px ข้อความเลยวิ่งไปทับตัวเลข) */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  padding-left: clamp(60px, 4.4vw, 86px); padding-right: clamp(60px, 4.4vw, 86px);
}
/* ตรึงขนาดวงกลมตัวเลขไม่ให้โตตามหัวข้อ จะได้คำนวณที่กันได้แน่นอน */
.q-chan-head .q-tv-h-n, .q-tv-h .q-tv-h-n,
.q-tv-called-h > span:not(.q-tv-ht), .q-tv-ipdwait-h > span:not(.q-tv-ht) {
  font-size: clamp(14px, 1.05vw, 21px); min-width: 2em; height: 1.7em; right: clamp(10px, .8vw, 16px);
}

/* ===== หัวข้อจอ TV: ขนาดเดียวกัน 40px ทุกหัวข้อ =====
   กันที่ให้วงกลมตัวเลขข้างละ 72px (วงกลม 42px + ระยะขอบ 16px + เผื่ออีก 14px)
   พื้นที่ข้อความที่เหลือพอสำหรับหัวข้อที่ยาวที่สุดที่ 40px */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  padding-left: clamp(52px, 3.8vw, 72px); padding-right: clamp(52px, 3.8vw, 72px);
  font-size: 40px;
}
.q-chan-head > span:first-child, .q-tv-h > span:first-child, .q-tv-ht { font-size: 40px; }

/* ===== หัวข้อจอ TV: ชิดซ้าย ขนาด 40px =====
   ชิดซ้ายแล้วไม่ต้องกันที่ด้านซ้ายไว้เยอะ เหลือกันเฉพาะด้านขวาให้วงกลมตัวเลข
   พื้นที่ข้อความจึงกว้างขึ้นอีก หัวข้อยาว ๆ ก็ยังได้ 40px เต็มโดยไม่ตกบรรทัด */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  justify-content: flex-start; text-align: left;
  padding-left: clamp(14px, 1.1vw, 20px); padding-right: clamp(56px, 4vw, 76px);
}
.q-chan-head > span:first-child, .q-tv-h > span:first-child, .q-tv-ht {
  text-align: left; margin: 0 !important;
}

/* หัวข้อย่อยในแต่ละรอบที่คีย์ยา — ถึงจะจัดกลุ่มตามเวลา ก็ยังต้องแยก Continue / One day ให้เห็น */
.pc-drug-sub { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700;
  margin: 4px 0 1px 12px; padding: 1px 9px; border-radius: 5px; }
.pc-drug-sub > span { font-weight: 600; opacity: .7; }
.pc-drug-sub.is-continue { color: #065f46; background: #ecfdf5; }
.pc-drug-sub.is-oneday { color: #92400e; background: #fffbeb; }
.pc-drug-sub.is-other { color: #475569; background: #f8fafc; }
.pc-drugs.is-dense .pc-drug-sub { margin: 2px 0 0 12px; }

/* พิมพ์สติ๊กเกอร์ยารายการนี้แล้ว — บอกด้วยแถบสีฟ้าริมซ้าย ไม่ใช้ป้ายข้อความ (รกตา)
   ใช้ inset box-shadow เพื่อให้อยู่ร่วมกับพื้นหลังของรายการที่ติ๊ก/ล็อกแล้วได้ */
/* พิมพ์สติ๊กเกอร์ยาตัวนี้แล้ว — ต้องเห็นชัดตั้งแต่เหลือบตามอง ไม่ใช่ต้องจำความหมายของสี */
.pc-drug.is-printed { box-shadow: inset 6px 0 0 #2563eb; background: #eff6ff; }
.pc-printed {
  display: inline-block; margin-left: 5px; padding: 1px 9px;
  font-size: .78em; font-weight: 800; white-space: nowrap;
  border-radius: 7px; background: #2563eb; color: #fff;
}
/* คำอธิบายแถบสี บนหัวการ์ดรายการยา */
.pc-legend { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.pc-legend::before { content: ''; width: 3px; height: 13px; border-radius: 2px; background: #3b82f6; }

/* ===== หัวข้อจอ TV: กลับมาจัดกึ่งกลาง (ขนาด 40px เท่าเดิม) ===== */
.q-chan-head, .q-tv-h, .q-tv-called-h, .q-tv-ipdwait-h {
  justify-content: center; text-align: center;
  padding-left: clamp(56px, 4vw, 72px); padding-right: clamp(56px, 4vw, 72px);
}
.q-chan-head > span:first-child, .q-tv-h > span:first-child, .q-tv-ht { text-align: center; }

/* ===== หน้าคำนวณขนาดยา: อ่านง่ายขึ้น + เน้นปริมาณที่ต้องได้ต่อครั้ง ===== */
.dc-card { padding: 16px 20px; }
.dc-h { font-size: 20px; font-weight: 800; }
.dc-h .muted { font-size: 17px; font-weight: 700; }
.dc-sig-txt { font-size: 20px; line-height: 1.5; }
.dc-sig-lbl { font-size: 13px; }
.dc-perkg { font-size: 15px; margin-bottom: 8px; }
.dc-line { font-size: 16px; padding: 7px 0; align-items: baseline; }
.dc-line b { font-size: 18px; font-variant-numeric: tabular-nums; }
.dc-lbl { font-size: 15px; }
/* บรรทัด "ต่อครั้ง" = ตัวเลขที่เภสัชต้องใช้จริง ต้องสะดุดตาที่สุดในการ์ด */
.dc-line.dc-dose { background: #fff7ed; border: 1px solid #fcd9a8; border-left: 4px solid #ea8a1e;
  border-radius: 10px; padding: 9px 14px; margin: 8px 0 2px; border-top: 1px solid #fcd9a8; }
.dc-line.dc-dose .dc-lbl { color: #92560a; font-weight: 800; font-size: 16px; }
.dc-line.dc-dose b { color: #7c3f06; font-size: 22px; font-weight: 900; }
.dc-note { font-size: 14px; }
.dc-warn { font-size: 14.5px; }
.dc-current { font-size: 15px; padding: 9px 12px; }

/* หมวด "admit ใหม่วันนี้" บนสุดของรายชื่อผู้ป่วยใน — ให้เด่นกว่าหัวข้อวอร์ดทั่วไป */
.q-ward-h.q-ward-new { color: #92560a; background: #fdf0d9; border: 1px solid #f0d59a;
  border-left: 4px solid #e0a93a; border-radius: 9px; padding: 6px 12px; }
/* หมวด "มียากลับบ้าน" — ถัดจาก admit ใหม่ · เขียวเพื่อไม่ให้สับสนกับสีส้มของ admit ใหม่ */
.q-ward-h.q-ward-home { color: #0e6458; background: #eefaf6; border: 1px solid #cdeae2;
  border-left: 4px solid #0f766e; border-radius: 9px; padding: 6px 12px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  .q-ward-h.q-ward-home { color: #5eead4; background: #10312e; border-color: #1c5450; border-left-color: #14b8a6; }
} }
:root[data-theme="dark"] .q-ward-h.q-ward-home { color: #5eead4; background: #10312e; border-color: #1c5450; border-left-color: #14b8a6; }

/* ===== ผู้ป่วยในทั้งหมด: อ่านง่ายขึ้น =====
   เดิมการ์ดกว้างขั้นต่ำ 300px พอหักที่ป้ายเตียง 40px + รูป 36px + ปุ่ม
   เหลือที่ให้ข้อความไม่ถึง 200px ข้อความจึงถูกบีบเป็นแถบสูงยาวอ่านยาก */
.ipd-grid { grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 12px; }
.ipd-card { font-size: 13.5px; padding: 10px 10px 10px 44px; gap: 11px; align-items: flex-start; }
.ipd-bed { width: 36px; font-size: 15px; }
.ipd-photo { width: 44px; height: 54px; }
.ipd-body { line-height: 1.5; }
.ipd-name { font-size: 15.5px; gap: 6px; }
.ipd-meta { font-size: 12.5px; margin-top: 1px; }
.ipd-line { font-size: 13px; margin-top: 3px; }
.ipd-line .ipd-lbl { margin-right: 5px; }
.ipd-prob { font-size: 12px; padding: 2px 8px; }
.ipd-probs { gap: 4px; margin-top: 5px; }
.ipd-care { gap: 4px; margin-top: 5px; }
.ipd-care-t { font-size: 12px; padding: 2px 8px; }
.ipd-advice { gap: 5px; margin-top: 6px; }
.ipd-adv-h { font-size: 12px; }
.ipd-adv-item { font-size: 12.5px; padding: 5px 10px; line-height: 1.55; }
.ipd-adv-t { font-size: 12px; }
.ipd-acts { gap: 5px; }
/* จอกว้างมาก ๆ ให้การ์ดไม่กว้างจนอ่านยาก */
@media (min-width: 1900px) { .ipd-grid { grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); } }

/* จำนวน 0 = อยู่ในใบสั่งยาแต่ไม่ได้เบิกเพิ่ม — ต้องเห็นชัดว่าเป็นศูนย์ ไม่ใช่ไม่มีข้อมูล */
.pc-qty-inline.is-zero { color: #92560a; background: #fdf0d9; border: 1px dashed #e0a93a; }

/* แถบสถานะข้างซ้าย: เหลือหัวข้อ + จุดสถานะ (รายละเอียดอยู่ใน tooltip)
   กฎเดิมดันลูกตัวสุดท้ายไปชิดขวา ซึ่งตอนนี้คือตัวหัวข้อเอง จึงต้องยกเลิก */
.conn-row span:last-child { margin-left: 0; }
.conn-row { gap: 9px; padding: 4px 0; cursor: default; }

/* ===== แถบสถานะข้างซ้าย: จัดสัดส่วนใหม่ =====
   พอเหลือแค่หัวข้อ การ์ดเดิมที่เว้นขอบไว้เยอะเลยดูโล่งและลอย
   จัดเป็นรายการชิด ๆ ความสูงเท่ากัน มีพื้นจาง ๆ ให้เป็นกลุ่มเดียวกัน */
.conn-card { padding: 8px; display: grid; gap: 2px; background: rgba(255,255,255,.05); border-radius: 12px; }
.conn-row { display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 0 10px;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: #cbd5e1; }
.conn-row:hover { background: rgba(255,255,255,.06); color: #f1f5f9; }
.conn-row .dot { width: 9px; height: 9px; flex: none; }

/* เวลารอรับยาแบบนับถอยหลัง — ใกล้ถึงคิวแล้วให้เปลี่ยนเป็นสีเขียวกะพริบ */
.q-tv-sub .q-tv-eta.q-eta-cd { font-variant-numeric: tabular-nums; }
.q-tv-sub .q-tv-eta.q-eta-cd.soon { color: #0e6458; background: #d6efe9; animation: etaSoon 1.4s ease-in-out infinite; }
@keyframes etaSoon { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ===== Drug profile ผู้ป่วยใน บนหน้าตรวจก่อนจ่าย =====
   จัดแบบใบ DRUG PROFILE ของ HOSxP: หนึ่งแถว = ยาหนึ่งตัว · คอลัมน์ขวา = จำนวนที่คีย์แต่ละวัน */
.pcp-card { margin-top: 12px; }
.pcp-tbl { font-size: 12.5px; }
.pcp-tbl th, .pcp-tbl td { padding: 4px 8px; vertical-align: top; }
.pcp-tbl .pcp-no { width: 30px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
/* ชื่อยาอยู่บรรทัดเดียวเสมอ ไม่ตกบรรทัด (ป้าย Day/OFF ยังลงบรรทัดใหม่ได้ตามปกติ) */
.pcp-tbl .pcp-nm { min-width: 190px; }
.pcp-tbl .pcp-nm b { white-space: nowrap; }
/* วิธีใช้: จำกัดความกว้าง ให้ข้อความยาวตัดบรรทัดแทนที่จะดันคอลัมน์วันที่ออกไปไกล
   (max-width บน td ไม่ได้ผลใน table layout แบบ auto จึงต้องครอบด้วย div ข้างใน) */
.pcp-tbl .pcp-us { color: var(--text-2); font-size: 12px; min-width: 430px; }
@media (max-width: 1200px) { .pcp-tbl .pcp-us { min-width: 300px; } }
/* จำกัดไว้ 2 บรรทัด ไม่ให้แถวสูงจนอึดอัด · ข้อความเต็มดูได้จากการชี้เมาส์ */
.pcp-tbl .pcp-us-in { min-width: 430px; max-width: 560px; white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 1200px) { .pcp-tbl .pcp-us-in { min-width: 300px; } }
/* ช่องว่างท้ายตาราง ดูดพื้นที่เหลือทั้งหมดไว้ คอลัมน์ที่เหลือจะได้เกาะกลุ่มกันทางซ้าย ไม่ต้องกวาดสายตาไกล */
.pcp-tbl .pcp-sp { width: 100%; padding: 0 !important; border-bottom-color: transparent; }
/* เส้นคั่นบาง ๆ ก่อนกลุ่มคอลัมน์วันที่ ให้สายตาแยกออกว่าเริ่มส่วนจำนวนแล้ว */
.pcp-tbl .pcp-d.d1, .pcp-tbl .pcp-q.d1 { border-left: 1px solid var(--border); }
.pcp-tbl .pcp-d  { width: 44px; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pcp-tbl .pcp-q  { width: 44px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--line); }
/* หัวข้อหมวด — เขียว = ยาประจำ · ส้ม = ยาครั้งเดียว */
.pcp-tbl .pcp-sect td { font-weight: 800; font-size: 13px; padding: 7px 10px; }
.pcp-tbl .pcp-sect.is-cont td { color: #0e6458; background: #eefaf6; border-left: 4px solid #0f766e; }
.pcp-tbl .pcp-sect.is-once td { color: #8a4b08; background: #fff7ed; border-left: 4px solid #ea580c; }
/* ยาที่ off แล้ว — ยังแสดงอยู่แต่ขีดฆ่า พร้อมป้ายบอกวันที่ off */
/* ยา Continue ที่ถูก off — ชื่อยายังอ่านได้ชัด ไม่ขีดฆ่า บอกวัน off ด้วยป้าย OFF */
.pcp-tbl tr.is-off .pcp-nm b { color: var(--text-2); }
.pcp-tbl tr.is-off .pcp-us { opacity: .7; }
/* เส้นลากยาวตั้งแต่ช่องวันที่ off ไปจนสุดตาราง — ต่อกันเป็นเส้นเดียวโดยกินขอบ cell ข้างละ 1px */
.pcp-tbl .pcp-q.is-stop { position: relative; color: var(--muted); }
.pcp-tbl .pcp-q.is-stop::after { content: ''; position: absolute; left: -1px; right: -1px; top: 50%;
  border-top: 2px solid #c0392b; pointer-events: none; }
/* คำว่า Off ที่ช่องจำนวนของวันที่หยุดยา — อยู่ใต้เส้น จะได้อ่านออกไม่โดนเส้นทับ */
.pcp-tbl .pcp-offmark { display: block; font-size: 10px; font-weight: 800; letter-spacing: .4px;
  color: #b91c1c; line-height: 1.15; margin-top: 2px; }
.pcp-off { display: inline-block; margin-left: 7px; font-size: 10.5px; font-weight: 800; color: #b91c1c;
  background: #fee2e2; border: 1px solid #fca5a5; border-radius: 999px; padding: 1px 8px;
  white-space: nowrap; text-decoration: none !important; vertical-align: 1px; }
.pcp-mr { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 800; color: #6d28d9;
  background: #ede9fe; border: 1px solid #ddd6fe; border-radius: 999px; padding: 1px 8px;
  white-space: nowrap; vertical-align: 1px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  .pcp-off { color: #fca5a5; background: #3f1414; border-color: #7f1d1d; }
  .pcp-mr { color: #c4b5fd; background: #2a1f52; border-color: #4c1d95; }
} }
:root[data-theme="dark"] .pcp-off { color: #fca5a5; background: #3f1414; border-color: #7f1d1d; }
:root[data-theme="dark"] .pcp-mr { color: #c4b5fd; background: #2a1f52; border-color: #4c1d95; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  .pcp-tbl .pcp-sect.is-cont td { color: #5eead4; background: #10312e; border-left-color: #14b8a6; }
  .pcp-tbl .pcp-sect.is-once td { color: #fdba74; background: #2b1a0c; border-left-color: #ea580c; }
} }
:root[data-theme="dark"] .pcp-tbl .pcp-sect.is-cont td { color: #5eead4; background: #10312e; border-left-color: #14b8a6; }
:root[data-theme="dark"] .pcp-tbl .pcp-sect.is-once td { color: #fdba74; background: #2b1a0c; border-left-color: #ea580c; }

/* แถบเลือกตึกในหน้าผู้ป่วยในทั้งหมด (ใช้ชิปแบบเดียวกับหน้าเรียกคิว) */
.ipd-wardchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ===== เมนูหลักที่ใช้บ่อยที่สุด (ตรวจก่อนจ่าย) — ทำให้เด่นกว่าเมนูอื่นในแถบซ้าย ===== */
/* เมนูสำคัญที่ใช้บ่อย — ใช้ "สีส้ม" คนละสีกับเมนูที่กำลังเปิดอยู่ (สีเขียว + แถบซ้าย)
   เดิมทั้งสองอย่างเป็นสีเขียวเหมือนกัน แยกไม่ออกว่ากำลังดูหน้าไหนอยู่ */
.nav a.nav-hot { color: #fff; font-weight: 700; background: rgba(251, 191, 36, .14);
  border: 1px solid rgba(251, 191, 36, .45); }
.nav a.nav-hot .ic { color: #fbbf24; }
.nav a.nav-hot:hover { background: rgba(251, 191, 36, .24); }
/* กำลังเปิดหน้านี้อยู่ = พื้นเขียวแบบเมนูทั่วไป + แถบเขียวด้านซ้าย (ตัวชี้ "อยู่ตรงนี้" มีที่เดียว)
   คงขอบส้มไว้ให้ยังรู้ว่าเป็นเมนูสำคัญ */
.nav a.nav-hot.active { background: rgba(45, 212, 191, .22); border-color: rgba(251, 191, 36, .55); }
.nav a.nav-hot.active .ic { color: #2dd4bf; }

/* ---- ผังความหนาแน่นผู้ป่วย (#/flow) ---- */
.flow-card { display: grid; grid-template-columns: 1fr 340px; grid-template-rows: auto 1fr; gap: 12px; padding: 14px; }
.flow-top { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flow-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.flow-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; min-width: 110px; }
.flow-stat span { display: block; font-size: 11.5px; color: var(--muted); }
.flow-stat b { font-size: 19px; line-height: 1.2; }
.flow-acts { display: flex; gap: 6px; align-items: center; }
.flow-stage { position: relative; height: 620px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(170deg, color-mix(in srgb, var(--accent) 7%, var(--surface)) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border); }
.flow-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.flow-3d { position: absolute; inset: 0; touch-action: none; }
.flow-3d canvas { touch-action: none; }
.flow-3d-hint { position: absolute; left: 10px; bottom: 10px; z-index: 5; background: rgba(12,19,32,.74); color: #cfe0ff; font-size: 12px; padding: 5px 10px; border-radius: 8px; pointer-events: none; }
.flow-tip { position: absolute; z-index: 3; pointer-events: none; background: rgba(15, 23, 42, .92); color: #fff;
  padding: 6px 10px; border-radius: 9px; font-size: 12px; line-height: 1.45; white-space: nowrap; }
.flow-hint { position: absolute; left: 12px; bottom: 12px; z-index: 3; max-width: 70%;
  background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  padding: 7px 12px; border-radius: 10px; font-size: 12.5px; }
.flow-side { overflow: auto; max-height: 620px; display: flex; flex-direction: column; gap: 10px; }
.flow-list { display: flex; flex-direction: column; gap: 4px; }
.flow-row { display: grid; grid-template-columns: 1fr 70px 52px 54px; grid-template-areas: "n b c w" "t t t t";
  gap: 4px 8px; align-items: center; text-align: left; padding: 8px 10px; border-radius: 10px;
  border: 1px solid transparent; background: var(--surface-2); color: inherit; cursor: pointer; font: inherit; }
.flow-row:hover { border-color: var(--border); }
.flow-row.is-sel { border-color: var(--accent); background: var(--accent-soft); }
.fr-name { grid-area: n; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-bar { grid-area: b; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.fr-bar i { display: block; height: 100%; border-radius: 99px; }
.fr-n { grid-area: c; text-align: right; font-weight: 700; font-size: 14px; }
.fr-n small { font-weight: 400; color: var(--muted); font-size: 11px; }
.fr-w { grid-area: w; text-align: right; font-size: 12px; color: var(--muted); }
.fr-today { grid-area: t; font-size: 11.5px; color: var(--muted); }
.flow-person { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 12px; padding: 12px; }
.fp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.fp-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.fp-path { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 2px; counter-reset: s; }
.fp-path li { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 4px 8px; border-radius: 7px; background: var(--surface); }
.fp-path li.cur { background: var(--accent); color: #fff; }
.fp-path li.cur span { color: rgba(255, 255, 255, .85); }
.fp-path li span { color: var(--muted); white-space: nowrap; }
@media (max-width: 1100px) {
  .flow-card { grid-template-columns: 1fr; }
  .flow-stage { height: 440px; }
  .flow-side { max-height: none; }
}

.flow-stat i { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-top: 1px; }
.fr-ipd { font-size: 10px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 4px; }
.flow-here { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 12px; }
.fh-list { display: flex; flex-direction: column; gap: 3px; max-height: 300px; overflow: auto; }
.fh-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left;
  padding: 6px 9px; border-radius: 8px; border: 1px solid transparent; background: var(--surface); color: inherit; cursor: pointer; font: inherit; }
.fh-row:hover { border-color: var(--accent); }
.fh-row b { font-size: 12.5px; }
.fh-row span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.fh-empty { font-size: 12.5px; color: var(--muted); padding: 6px 2px; }

/* ---- โหมดสื่อให้ความรู้บนจอเรียกคิว: สื่อซ้าย + แถบคิวขวา ---- */
/* ใช้สองคลาสเพื่อให้ชนะกฎ .q-tvboard เดิมแน่นอน (เดิมกำหนด 3 คอลัมน์ไว้)
   และต้องระบุความสูงเอง — ตอนเปิดในหน้าต่างปกติ (ไม่เต็มจอ) กล่องบอร์ดไม่มีความสูงที่แน่นอน
   วิดีโอที่ตั้ง height:100% จะยุบเหลือศูนย์ กลายเป็นจอว่างเปล่า */
.q-tvboard.q-media-mode { display: grid; grid-template-columns: 1fr 45vw; grid-template-rows: minmax(0, 1fr);
  gap: 0; min-height: 72vh; }
body.q-fullscreen .view.q-tv .q-tvboard.q-media-mode { height: 100%; min-height: 0; }
.q-media-stage { position: relative; background: #000; display: grid; place-items: center; overflow: hidden;
  min-height: 72vh; height: 100%; }
body.q-fullscreen .q-media-stage { min-height: 0; }
.q-media-stage video, .q-media-img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.q-media-none { color: #94a3b8; font-size: 2vw; text-align: center; line-height: 1.7; }
.q-media-none span { font-size: 1.2vw; opacity: .75; }
/* ---- โหมดสื่อ: ฝั่งเรียกคิว ----
   โทนสว่างแบบป้ายในโรงพยาบาล — พื้นขาว ตัวอักษรเข้ม ตัดกันชัด อ่านได้จากท้ายห้อง
   ใช้สีน้ำเงินราชการเป็นสีหลัก เขียวเฉพาะตอนกำลังเรียก ไม่ใช้สีนีออน/ไล่เฉดฉูดฉาด */
.q-media-side { display: flex; flex-direction: column; gap: 1vh; padding: 1.4vh 1.2vw; min-height: 0;
  background: #eef3f9; color: #16243a; border-left: .35vw solid #0b4ea2; }
.q-mside-h { font-size: 1.7vw; font-weight: 800; letter-spacing: .2px; color: #0b4ea2;
  display: flex; align-items: center; gap: .5vw; margin-bottom: .6vh; }
.q-mside-h .ic { width: 1.9vw; height: 1.9vw; }
.q-mside-now { border-radius: .6vw; padding: 1.6vh 1.2vw; background: #fff;
  border: 1px solid #c9d6e5; border-left: .6vw solid #9fb0c4; box-shadow: 0 1px 3px rgba(16, 36, 64, .10); }
.q-mside-now.on { border-left-color: #0f7a4d; box-shadow: 0 2px 12px rgba(15, 122, 77, .22);
  animation: qMNow 2s ease-in-out infinite; }
/* กะพริบด้วยพื้นหลังจาง ๆ แทนแสงเรืองรอบกล่อง — เรียกสายตาได้โดยไม่ดูเป็นป้ายโฆษณา */
@keyframes qMNow { 0%, 100% { background: #fff; } 50% { background: #eafaf2; } }
.q-mside-now.on .q-mside-h { color: #0f7a4d; }
.q-mnow-name { font-size: 3.6vw; font-weight: 900; line-height: 1.15; color: #0d1b2e; word-break: break-word; }
.q-mnow-ch { font-size: 2.1vw; color: #3c4d63; margin-top: .6vh; }
.q-mnow-ch b { font-size: 3.4vw; color: #0b4ea2; }
.q-mnow-idle { font-size: 2vw; color: #7b8a9e; padding: 1vh 0; }
.q-mside-block { background: #fff; border: 1px solid #c9d6e5; border-radius: .6vw;
  padding: 1.2vh 1.2vw; min-height: 0; box-shadow: 0 1px 3px rgba(16, 36, 64, .08); }
.q-mside-grow { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.q-mside-empty { color: #8294aa; font-size: 1.6vw; padding: .6vh 0; }
.q-mnext { display: flex; flex-direction: column; gap: .5vh; }
.q-mnext-row { display: flex; align-items: center; gap: .8vw; font-size: 2vw; color: #16243a; }
.q-mnext-no { min-width: 4.2vw; text-align: center; font-weight: 800; color: #fff; background: #0b4ea2;
  border-radius: .35vw; padding: 0 .4vw; }
.q-mnext-nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-mcalled { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: .5vh; }
.q-mcalled-row { display: flex; align-items: center; justify-content: space-between; gap: .6vw; font-size: 1.85vw;
  background: #f4f7fb; border: 1px solid #dde6f0; border-radius: .35vw; padding: .6vh .8vw; color: #16243a; }
.q-mcalled-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-mcalled-ch { color: #0b4ea2; font-weight: 800; white-space: nowrap; }
@media (max-width: 1100px) { .q-media-mode { grid-template-columns: 1fr; grid-template-rows: 1fr auto; } }

/* รายการไฟล์สื่อในหน้าตั้งค่า */
.md-list { display: flex; flex-direction: column; gap: 6px; }
.md-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.md-ic { font-size: 18px; }
.md-nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.md-sz { color: var(--muted); font-size: 12px; white-space: nowrap; }
.md-sub { font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
.q-media-yt { width: 100%; height: 100%; }
.q-media-yt iframe { width: 100%; height: 100%; border: 0; display: block; }
/* ปุ่มเล่นรายการถัดไป — จาง ๆ มุมล่างขวาของกรอบสื่อ ไม่รบกวนการดู */
.q-media-skip { position: absolute; right: 12px; bottom: 12px; z-index: 5; cursor: pointer;
  background: rgba(15,23,42,.55); color: #e2e8f0; border: 1px solid rgba(226,232,240,.25);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; opacity: .35; transition: opacity .2s; }
.q-media-stage:hover .q-media-skip { opacity: 1; }
.md-kind { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
/* ปุ่มสถานะในแถบหัวหน้าเรียกคิว — เปิด = เขียว · ปิด = แดง (ดูแวบเดียวก็รู้) */
.q-bar .btn.off { background: rgba(239, 68, 68, .10); border-color: #ef4444; color: #ef4444; font-weight: 700; }

/* หน่วยต่อท้ายตัวเลขบนการ์ดภาพรวม (เช่น "11 นาที") — เล็กกว่าตัวเลขแต่ยังอ่านออกจากไกล */
.bt .v small { font-size: .42em; font-weight: 600; margin-left: .22em; opacity: .9; letter-spacing: .2px; }

/* หมวด "เพิ่งคีย์ยาเสร็จ" บนสุดของรายชื่อผู้ป่วยใน — กลุ่มที่ห้องยากำลังจะเรียก
   ใช้สีน้ำเงิน ไม่ให้ชนกับสีส้มของ "admit ใหม่" และสีเขียวของ "มียากลับบ้าน" */
.q-ward-h.q-ward-keyed { color: #1e4b8f; background: #eef4fd; border: 1px solid #c3d8f5;
  border-left: 4px solid #2563eb; border-radius: 9px; padding: 6px 12px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  .q-ward-h.q-ward-keyed { color: #93c5fd; background: #10203a; border-color: #1e3a5f; border-left-color: #3b82f6; }
} }
:root[data-theme="dark"] .q-ward-h.q-ward-keyed { color: #93c5fd; background: #10203a; border-color: #1e3a5f; border-left-color: #3b82f6; }

/* ---- แก้น้ำหนัก + บันทึกความเสี่ยง (หน้าตรวจก่อนจ่าย) ---- */
.pc-bw { display: inline-flex; align-items: center; gap: 2px; }
.pc-bw.ov { color: #b26a12; font-weight: 600; }
.pc-bw-edit { background: none; border: 0; padding: 1px 3px; cursor: pointer; color: inherit; opacity: .55; line-height: 0; border-radius: 5px; }
.pc-bw-edit:hover { opacity: 1; background: rgba(127, 127, 127, .16); }
.pc-bw-edit svg { width: 13px; height: 13px; }

.rk-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rk-step { font-weight: 600; margin: 14px 0 7px; font-size: 13.5px; }
.rk-step:first-child { margin-top: 0; }
.rk-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 7px; }
.rk-kind { text-align: left; padding: 9px 11px; border: 1px solid var(--line, #d7dee6); border-radius: 9px;
  background: var(--card, #fff); cursor: pointer; display: flex; flex-direction: column; gap: 2px; color: inherit; font: inherit; }
.rk-kind b { font-size: 13.5px; }
.rk-kind span { font-size: 11.5px; opacity: .62; line-height: 1.35; }
.rk-kind:hover { border-color: #f0a04b; background: rgba(240, 160, 75, .07); }
.rk-kind.on { border-color: #e2711d; background: rgba(226, 113, 29, .13); box-shadow: 0 0 0 1px #e2711d inset; }
.rk-drugs { display: flex; flex-direction: column; gap: 3px; max-height: 230px; overflow: auto; }
.rk-chk { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.rk-chk:hover { background: rgba(127, 127, 127, .09); }
.rk-chk input { flex: none; }
.btn-risk { color: #b3541e; }

.pc-mrmeds { margin: 2px 0 10px; }
.pc-mr-h { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
.pc-mr-h svg { width: 14px; height: 14px; color: #1a9e62; }
/* ยาประจำจาก MR — แบ่ง 2 คอลัมน์ ซ้าย/ขวา ลด scroll (จอแคบยุบเหลือ 1 คอลัมน์) */
.pc-mr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; align-items: start; }
@media (max-width: 640px) { .pc-mr-grid { grid-template-columns: 1fr; } }
.pc-mr-item { padding: 7px 10px; border-left: 3px solid #1a9e62; background: rgba(26, 158, 98, .07); border-radius: 0 7px 7px 0; margin-bottom: 0; }
.pc-mr-use { font-size: 12px; margin-top: 2px; }
.pc-mr-meta { font-size: 11.5px; margin-top: 2px; opacity: .75; }
.pc-chr-sub { font-size: 12px; font-weight: 600; margin: 12px 0 6px; opacity: .8; }
.pc-chr-none { padding: 4px 2px; font-size: 13px; }
/* เลขเตียงผู้ป่วยใน — badge ในหัวหน้าตรวจก่อนจ่าย */
.pc-bed { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-size: 1.02em;
  background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; border-radius: 8px; padding: 2px 10px; white-space: nowrap; }
.pc-bed.none { font-weight: 600; font-size: .95em; background: transparent; color: var(--muted); border: 1px dashed var(--border); }
:root[data-theme="dark"] .pc-bed { background: rgba(37, 99, 235, .22); color: #bfdbfe; border-color: rgba(59, 130, 246, .5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-bed { background: rgba(37, 99, 235, .22); color: #bfdbfe; border-color: rgba(59, 130, 246, .5); } }

.pc-cov { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: rgba(45, 120, 220, .13); color: #1d5fb0; border: 1px solid rgba(45, 120, 220, .28); }
:root[data-theme="dark"] .pc-cov { color: #8fc0ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-cov { color: #8fc0ff; } }
.pc-cov.pay { background: rgba(214, 66, 36, .14); color: #b3340f; border-color: rgba(214, 66, 36, .45);
  font-weight: 700; animation: covPulse 2.2s ease-in-out 3; }
@keyframes covPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(214, 66, 36, 0); } 50% { box-shadow: 0 0 0 4px rgba(214, 66, 36, .22); } }
:root[data-theme="dark"] .pc-cov.pay { color: #ff9b7a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-cov.pay { color: #ff9b7a; } }
.pc-drug.locked { opacity: .78; background: rgba(26, 158, 98, .06); }
.pc-drug.locked input.pc-chk { cursor: not-allowed; }
.pc-lock { display: inline-block; margin-left: 6px; vertical-align: middle; border: 1px solid rgba(26, 158, 98, .4);
  background: rgba(26, 158, 98, .1); color: #137a4b; border-radius: 999px; padding: 2px 9px;
  font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; font-family: inherit; }
.pc-lock:hover { background: rgba(26, 158, 98, .2); }
.pc-drugs.is-dense .pc-lock { padding: 0 8px; }
:root[data-theme="dark"] .pc-lock { color: #6fdfab; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-lock { color: #6fdfab; } }
/* ปุ่มติ๊กทั้งหมด — ใช้บ่อยที่สุดในหน้านี้ ต้องเห็นทันทีไม่ต้องกวาดตาหา */
.pc-all-btn { background: #0e9f6e; border-color: #0e9f6e; color: #fff; font-weight: 700; box-shadow: 0 1px 3px rgba(14, 159, 110, .35); }
.pc-all-btn:hover { background: #0b8457; border-color: #0b8457; color: #fff; }
.pc-all-btn svg { color: #fff; }
/* คิวรอรับยา — เวลารอของแต่ละคน และเคสที่รอนานเกินเกณฑ์ */
.q-eta.waited { background: rgba(120, 130, 145, .16); color: var(--text-2); }
.q-eta.late { background: rgba(214, 48, 36, .16); color: #c42a18; font-weight: 700; }
.q-item.late { border-color: rgba(214, 48, 36, .55); background: rgba(214, 48, 36, .07); box-shadow: inset 3px 0 0 #d63024; }
.q-item.late .q-no { background: #d63024; color: #fff; }
:root[data-theme="dark"] .q-eta.late { color: #ff9b8a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .q-eta.late { color: #ff9b8a; } }
/* ป้ายแจ้งเมื่อเบราว์เซอร์ยังบล็อกเสียงสื่อให้ความรู้ */
.q-media-unmute { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: rgba(214, 48, 36, .92); color: #fff; border: 0; border-radius: 999px;
  padding: 10px 20px; font-size: 17px; font-weight: 700; cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45); z-index: 5; }
/* รายการที่ถูกยกเลิกการจ่าย — บอกว่าใครยกเลิกเมื่อไร แล้วติ๊กได้ใหม่ตามปกติ */
.pc-cancelled { display: inline-block; margin-left: 6px; vertical-align: middle; border: 1px solid rgba(214, 66, 36, .4);
  background: rgba(214, 66, 36, .10); color: #b3340f; border-radius: 999px; padding: 2px 9px;
  font-size: 11px; font-weight: 600; white-space: nowrap; }
:root[data-theme="dark"] .pc-cancelled { color: #ff9b7a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-cancelled { color: #ff9b7a; } }


/* ---------------- ฉลากช่วย (auxiliary label) 5 x 7 ซม. ---------------- */
.pc-auxtag { display: inline-block; font-size: 10.5px; font-weight: 800; white-space: nowrap;
  color: #7c3aed; background: #f5f3ff; border: 1px solid #ddd6fe; border-radius: 999px; padding: 0 7px; }
.pc-aux-n { display: inline-block; min-width: 16px; text-align: center; font-weight: 800;
  background: #7c3aed; color: #fff; border-radius: 999px; padding: 0 5px; margin-left: 3px; }
.al-card { width: min(720px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.al-body { overflow: auto; padding: 4px 2px; flex: 1; }
.al-sect { font-weight: 800; font-size: 12.5px; color: var(--muted); margin: 10px 4px 4px; }
.al-row { display: flex; gap: 9px; align-items: flex-start; padding: 7px 9px; border-radius: 8px; cursor: pointer; }
.al-row:hover { background: var(--hover, rgba(127,127,127,.09)); }
.al-row input { margin-top: 3px; }
.al-from { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
/* ตัวอย่างฉลากบนจอ — ใช้สัดส่วนจริง 50 x 70 มม. จะได้เห็นว่าเนื้อหาล้นไหมก่อนพิมพ์ */
.al-prev { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 8px 0; }
.al-prev .al-pg { padding: 1.8mm 2mm; box-sizing: border-box; overflow: hidden;
  display: flex; flex-direction: column; line-height: 1.26; background: #fff; color: #000;
  border: 1px solid #94a3b8; border-radius: 2px; font-family: "TH Sarabun New", "Sarabun", Tahoma, sans-serif; }
.al-prev .al-h { border-bottom: .5mm solid #000; padding-bottom: .6mm; margin-bottom: 1mm; }
.al-prev .al-t { font-weight: 700; font-size: 1.22em; line-height: 1.15; }
.al-prev .al-e { font-size: .78em; }
.al-prev .al-s { margin: 0; padding-left: 3.6mm; flex: 1; }
.al-prev .al-s li { margin-bottom: .5mm; }
.al-prev .al-fill div { border-bottom: .2mm dotted #000; padding: .4mm 0; }
.al-prev .al-g { flex: 1; } .al-prev .al-gi { margin-bottom: .8mm; }
.al-prev .al-n { border: .3mm solid #000; border-radius: 1mm; padding: .8mm 1mm; margin-top: 1mm; }
.al-prev .al-f { margin-top: 1mm; font-size: .72em; text-align: right; }
/* ย่อจนเล็กสุดแล้วยังล้น — เตือนเฉพาะบนจอตอนดูตัวอย่าง (ไม่ติดไปตอนพิมพ์) */
.al-prev .al-pg.is-over { outline: 2px dashed #dc2626; outline-offset: 1px; }


/* ---------------- กราฟแนวโน้มสัญญาณชีพ ---------------- */
/* ค่าที่กดดูกราฟได้ — ให้รู้ว่ากดได้ แต่ไม่ต้องเด่นจนรบกวนสายตา */
.pc-vital-go { cursor: pointer; border-bottom: 1px dashed currentColor; }
.pc-vital-go:hover { filter: brightness(1.06); background: var(--hover, rgba(127,127,127,.1)); }
.vs-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.vs-tab { border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 4px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.vs-tab:hover { background: var(--hover, rgba(127,127,127,.1)); }
.vs-tab.on { background: var(--brand, #0f766e); border-color: transparent; color: #fff; }
.vs-chart { overflow-x: auto; }
.vs-foot { font-size: 12px; margin-top: 8px; }

/* ---------------- กราฟแนวโน้มแบบโต้ตอบ (trendChart) ---------------- */
.tc-chart { min-height: 250px; }
.tc-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tc-presets { display: flex; flex-wrap: wrap; gap: 5px; }
.tc-pr { border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tc-pr:hover { background: var(--hover, rgba(127,127,127,.1)); }
.tc-pr.on { background: var(--brand, #0f766e); border-color: transparent; color: #fff; }
.tc-reset { border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tc-reset:hover { background: var(--hover, rgba(127,127,127,.1)); }
.tc-plot { position: relative; width: 100%; user-select: none; -webkit-user-select: none; }
.tc-plot .tc-svg { display: block; width: 100%; height: auto; cursor: crosshair; }
.tc-plot .tc-svg text { font-family: var(--font); }
.tc-cross { position: absolute; top: 0; bottom: 30px; width: 0; border-left: 1px dashed var(--text-3, #94a3b8);
  pointer-events: none; opacity: .7; }
.tc-brush { position: absolute; top: 0; bottom: 30px; background: rgba(15,118,110,.14);
  border-left: 1px solid var(--brand, #0f766e); border-right: 1px solid var(--brand, #0f766e); pointer-events: none; }
.tc-tip { position: absolute; z-index: 5; min-width: 92px; max-width: 220px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 6px 9px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); font-size: 12px; line-height: 1.5; }
.tc-tip .tc-tt-d { color: var(--muted); font-size: 11px; }
.tc-tip .tc-tt-v { font-weight: 800; font-size: 14px; }
.tc-tip .tc-tt-2 { color: var(--text-2); font-size: 12px; }
.tc-b { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 999px; vertical-align: middle; }
.tc-b.ok { background: var(--good-soft, #dcfce7); color: var(--good, #15803d); }
.tc-b.hi { background: #fee2e2; color: #dc2626; }
.tc-b.lo { background: #dbeafe; color: #2563eb; }
.tc-hint { font-size: 11px; margin-top: 7px; text-align: center; }

/* ---------------- รายงาน Influenza swab ---------------- */
.sw-tiles { gap: 10px; }
.sw-tiles .dm-kv i { display: block; font-style: normal; font-size: 11.5px; margin-top: 2px; }
.sw-tiles .dm-kv.is-pos b { color: #b91c1c; }
.sw-tiles .dm-kv.is-warn b { color: #b45309; }
.sw-tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.sw-hi { color: #b91c1c; }
.sw-lo { color: #0f766e; }
/* แท่งสัดส่วน: ความกว้างแท่ง = จำนวนที่ส่งตรวจ · ส่วนเข้ม = สัดส่วน positive */
.sw-bar { height: 10px; min-width: 2px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.sw-bar i { display: block; height: 100%; background: #dc2626; border-radius: 999px; }
.sw-cross { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.sw-be { margin-bottom: 12px; font-size: 14px; }
.sw-be b { color: #0f766e; }
.sw-sum { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.sw-sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.sw-sum-row.is-save { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; font-size: 15px; }
.sw-sum-row.is-save b { color: #0f766e; }
.sw-note { margin-top: 12px; font-size: 12px; line-height: 1.6; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sw-hi, :root:not([data-theme="light"]) .sw-tiles .dm-kv.is-pos b { color: #fca5a5; }
  :root:not([data-theme="light"]) .sw-lo, :root:not([data-theme="light"]) .sw-be b, :root:not([data-theme="light"]) .sw-sum-row.is-save b { color: #5eead4; }
  :root:not([data-theme="light"]) .sw-tiles .dm-kv.is-warn b { color: #fdba74; }
}
:root[data-theme="dark"] .sw-hi, :root[data-theme="dark"] .sw-tiles .dm-kv.is-pos b { color: #fca5a5; }
:root[data-theme="dark"] .sw-lo, :root[data-theme="dark"] .sw-be b, :root[data-theme="dark"] .sw-sum-row.is-save b { color: #5eead4; }
:root[data-theme="dark"] .sw-tiles .dm-kv.is-warn b { color: #fdba74; }
.sw-tbl tfoot td { border-top: 2px solid var(--border-strong, var(--border)); background: var(--surface-2); }
.sw-click { cursor: pointer; }
.sw-click:hover td { background: var(--hover, rgba(127,127,127,.09)); }
.sw-go { font-size: 11.5px; color: var(--muted); margin-left: 6px; }
.sw-click:hover .sw-go { color: var(--brand, #0f766e); }
.swc-row { cursor: pointer; }
.swc-u { font-size: 12px; color: var(--text-2); max-width: 340px; }
.sw-rkind { cursor: pointer; }
.sw-rkind:hover { background: var(--hover, rgba(127,127,127,.1)); border-radius: 8px; }
/* ปุ่มเล็กในไทล์สรุป — ให้เห็นชัดว่ากดดูรายเคสได้ */
.sw-mini { display: inline-block; margin-top: 3px; border: 1px solid var(--border); background: var(--surface);
  color: var(--brand, #0f766e); border-radius: 999px; padding: 1px 9px; font-size: 11px; font-weight: 700; cursor: pointer; }
.sw-mini:hover { background: var(--hover, rgba(127,127,127,.12)); }

/* ===== บัญชียาโรงพยาบาล — จัดหมวดตามบัญชียาหลักแห่งชาติ ===== */
.fm-sum { padding: 12px 16px; font-size: 15px; }
.fm-ch h3 small { font-weight: 400; margin-left: 8px; color: var(--muted); }
.fm-tbl td, .fm-tbl th { vertical-align: top; }
.fm-tbl tr.fm-off { opacity: .55; }
.fm-gen { font-size: 12px; margin-top: 1px; }
.fm-acct { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: #e2e8f0; color: #334155; border: 1px solid #cbd5e1; white-space: nowrap; }
.fm-acct.fm-aก { background: #dcfce7; color: #166534; border-color: #86efac; }
.fm-acct.fm-aข { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.fm-acct.fm-aค { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.fm-acct.fm-aง { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.fm-acct.fm-aจ1, .fm-acct.fm-aจ2 { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.fm-acct.fm-a-none { background: transparent; color: var(--muted); border-style: dashed; font-weight: 600; }
.fm-tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700;
  margin: 1px 3px 1px 0; border: 1px solid; white-space: nowrap; }
.fm-tag.is-abx { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.fm-tag.is-had { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.fm-tag.is-preg { background: #fdf2f8; color: #9d174d; border-color: #fbcfe8; }
.fm-tag.is-lact { background: #faf5ff; color: #6b21a8; border-color: #e9d5ff; }
.fm-tag.is-off { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }

/* ===== ป้าย "แตะหน้าจอหนึ่งครั้ง" บนจอทีวี — เบราว์เซอร์บังคับให้มีการแตะก่อนจึงเล่นเสียงได้ ===== */
#tvTapHint { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center;
  background: rgba(2, 44, 34, .93); color: #fff; text-align: center; cursor: pointer;
  animation: tvTapIn .25s ease-out; }
@keyframes tvTapIn { from { opacity: 0; } to { opacity: 1; } }
#tvTapHint .tv-tap-in { padding: 40px 56px; }
#tvTapHint .tv-tap-ic { font-size: clamp(64px, 12vw, 160px); line-height: 1; animation: tvTapPulse 1.5s ease-in-out infinite; }
@keyframes tvTapPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
#tvTapHint .tv-tap-t { font-size: clamp(32px, 6vw, 86px); font-weight: 800; margin-top: 18px; letter-spacing: .5px; }
#tvTapHint .tv-tap-s { font-size: clamp(16px, 2.4vw, 34px); font-weight: 500; margin-top: 14px; opacity: .85; line-height: 1.6; }

/* ===== มาหลายรอบในวันเดียว — รายการยาของ visit ก่อนหน้า ===== */
.pc-vn-time { font-size: 12.5px; font-weight: 700; color: #0f766e; background: #ccfbf1; border: 1px solid #5eead4;
  padding: 1px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.pc-dc-only { font-size: 12.5px; font-weight: 800; color: #9a3412; background: #ffedd5; border: 1px solid #fdba74;
  padding: 1px 9px; border-radius: 999px; margin-left: 4px; vertical-align: middle; }
.pc-sdv { margin-top: 10px; padding: 10px 12px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; }
.pc-sdv-h { font-weight: 800; color: #9a3412; margin-bottom: 6px; }
.pc-sdv-v { padding: 6px 0; border-top: 1px dashed #fdba74; }
.pc-sdv-v:first-of-type { border-top: 0; }
.pc-sdv-t { font-weight: 700; color: #7c2d12; margin-bottom: 3px; }
.pc-sdv-d { font-size: 13px; padding: 1px 0 1px 6px; }
.pc-sdv-u { font-size: 12px; color: #78350f; padding-left: 12px; }
.pc-sdv-n { margin-top: 6px; font-size: 12px; font-weight: 700; color: #9a3412; }

/* ===== ทบทวนยาตอนจำหน่าย ===== */
.pc-dcr-btn { margin-left: 8px; vertical-align: middle; }
.dcr-top { padding: 10px 12px; background: var(--surface-2, #f8fafc); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; }
.dcr-ap { display: inline-block; background: #e0f2fe; border: 1px solid #7dd3fc; color: #075985;
  padding: 2px 10px; border-radius: 999px; margin: 2px 6px 2px 0; font-size: 13px; }
.dcr-short td { background: #fef2f2; }

/* ===== เครื่องคำนวณ 50% Magnesium sulfate ===== */
.mg-card h3 small { font-weight: 400; margin-left: 8px; color: var(--muted); }
.mg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 10px 0; }
.mg-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.mg-time { display: flex; gap: 6px; }
.mg-time .input { flex: 1; min-width: 0; }
.mg-time .select { width: 92px; }
.mg-sum { font-size: 16px; padding: 8px 12px; background: #ecfeff; border: 1px solid #a5f3fc; border-radius: 8px; margin-bottom: 10px; }
.mg-rec { font-size: 13px; margin-bottom: 10px; }
.mg-rec ul { margin: 4px 0 0; padding-left: 20px; }
.mg-rec li { margin: 2px 0; }
.mg-chk { display: flex; flex-direction: column; gap: 6px; }
.mg-c { padding: 7px 11px; border-radius: 8px; font-weight: 600; font-size: 13px; border: 1px solid; }
.mg-c.is-ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.mg-c.is-bad { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.mg-c.is-warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.mg-warn { color: #b45309; }
.mg-note { font-size: 11.5px; margin-top: 10px; }

/* ===== เตือนเต็มจอ — เรื่องที่พลาดแล้วกระทบคนไข้ ===== */
#bigWarn { position: fixed; inset: 0; z-index: 99998; display: flex; align-items: center; justify-content: center;
  background: rgba(127, 29, 29, .82); cursor: pointer; animation: bwIn .18s ease-out; }
@keyframes bwIn { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }
#bigWarn .bw-in { background: #fff; border: 5px solid #dc2626; border-radius: 20px; padding: 32px 48px;
  text-align: center; max-width: min(90vw, 680px); box-shadow: 0 24px 64px rgba(0, 0, 0, .4); }
#bigWarn .bw-ic { font-size: clamp(56px, 9vw, 104px); line-height: 1; animation: bwPulse 1s ease-in-out infinite; }
@keyframes bwPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
#bigWarn .bw-t { font-size: clamp(26px, 4.4vw, 44px); font-weight: 900; color: #b91c1c; margin-top: 10px; line-height: 1.25; }
#bigWarn .bw-s { font-size: clamp(15px, 2.1vw, 22px); font-weight: 600; color: #7f1d1d; margin-top: 12px; line-height: 1.6; }
#bigWarn .bw-x { font-size: 13px; color: #78716c; margin-top: 18px; }

/* ===== ปุ่มแว่นขยายบนการ์ดผู้ป่วยใน (ดูข้อมูลโดยไม่เรียกคิว) ===== */
.q-ipd-card { position: relative; display: flex; }
.q-ipd-eye { position: absolute; top: 5px; right: 5px; z-index: 2; width: 26px; height: 26px; padding: 0;
  display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--border); background: var(--card);
  color: var(--accent, #0a7a5f); opacity: .45; transition: opacity .12s, background .12s, border-color .12s; }
.q-ipd-card:hover .q-ipd-eye { opacity: 1; }
.q-ipd-eye:hover { background: var(--accent-soft, #e6f7f1); border-color: var(--accent, #0a7a5f); }
.q-ipd-eye svg { width: 15px; height: 15px; }
.dcr-chg { padding: 6px 0; border-top: 1px dashed #fca5a5; }
.dcr-chg:first-child { border-top: 0; }
.dcr-dir { font-size: 12px; font-weight: 800; background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; padding: 0 7px; border-radius: 999px; }
.dcr-row { font-size: 12.5px; font-weight: 500; padding-left: 8px; }
.dcr-row.is-home { font-weight: 800; }
.dcr-k { display: inline-block; min-width: 92px; color: #7f1d1d; font-weight: 700; }

/* ===== หัวข้อ Home medication ในรายการยาวันนี้ ===== */
.hm-wrap { margin: 2px 0 12px; padding: 11px 13px; background: #f0fdf4; border: 1px solid #86efac; border-radius: 12px; }
.hm-h { font-weight: 800; color: #166534; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hm-h .hm-full { margin-left: auto; }
.hm-load { font-weight: 400; font-size: 12px; }
.hm-appt { font-size: 12.5px; color: #15803d; margin: 5px 0 8px; font-weight: 600; }
.hm-issues { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.hm-i { padding: 8px 11px; border-radius: 9px; border: 1px solid; }
.hm-i.is-bad { background: #fef2f2; border-color: #fecaca; }
.hm-i.is-warn { background: #fffbeb; border-color: #fde68a; }
.hm-it { font-weight: 800; font-size: 13.5px; }
.hm-i.is-bad .hm-it { color: #b91c1c; }
.hm-i.is-warn .hm-it { color: #92400e; }
.hm-is { font-size: 12.5px; font-weight: 500; margin-top: 3px; padding-left: 10px; line-height: 1.55; }
.hm-ok { background: #dcfce7; border: 1px solid #86efac; color: #166534; font-weight: 700; padding: 8px 11px; border-radius: 9px; margin-bottom: 10px; display: flex; gap: 7px; align-items: center; }
.pc-hm { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: #dcfce7; color: #166534; border: 1px solid #86efac; white-space: nowrap; vertical-align: middle; }
.pc-hm.is-short { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.hm-tag { font-size: 11px; font-weight: 700; background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; padding: 0 6px; border-radius: 999px; }
.hm-tag.is-chg { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

/* ===== รายงานผู้ป่วยนอกรายปีงบประมาณ ===== */
.op-tbl td, .op-tbl th { font-size: 13.5px; }
.op-part { font-size: 11px; font-weight: 700; background: #fef9c3; color: #854d0e; border: 1px solid #fde047; padding: 0 7px; border-radius: 999px; }
.op-up { color: #15803d; } .op-down { color: #b91c1c; }
.op-note { font-size: 11.5px; margin-top: 6px; }
.op-bar { display: inline-block; height: 7px; width: var(--w); background: var(--accent-soft, #99e6cf); border-radius: 4px; margin-right: 6px; vertical-align: middle; }
.op-v { display: inline-block; min-width: 46px; text-align: right; }

/* ── โหมดย่อรายการยา (ตรวจก่อนจ่าย) ──────────────────────────────
   บีบให้เหลือบรรทัดเดียวต่อรายการ: ชื่อยา · วิธีใช้ · จำนวน · เฉพาะป้ายที่เป็นปัญหา
   เพื่อให้เห็นยาทั้งใบในหน้าเดียวโดยไม่ต้องเลื่อน กดปุ่มบนหัวการ์ดเพื่อขยายกลับ */
/* ขนาดตัวอักษรทุกอย่างเท่ากับ OPD ทุกประการ — ไม่ย่อฟอนต์เลย
   ที่ประหยัดได้มาจากการเอาวิธีใช้/ป้ายโดสมาต่อท้ายชื่อยาในบรรทัดเดียวกัน แทนที่จะแยกบรรทัดละอัน */
.pc-drugs.is-dense { gap: 3px; }
.pc-drugs.is-dense .pc-drug { padding: 4px 10px; }
/* ไหลต่อกันในบรรทัดเดียวเมื่อพอ ถ้าไม่พอให้ขึ้นบรรทัดใหม่ — ห้ามตัดข้อความทิ้ง
   เพราะวิธีใช้และป้ายโดสเป็นสิ่งที่ต้องอ่านครบก่อนจ่ายยา */
.pc-drugs.is-dense .pc-drug-body { display: flex; align-items: center; gap: 3px 8px; flex-wrap: wrap; }
.pc-drugs.is-dense .pc-drug-body > b { flex: 0 1 auto; min-width: 0; }
.pc-drugs.is-dense .pc-drug-body > span { flex: 0 0 auto; }
.pc-drugs.is-dense .pc-usage { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 3px 7px;
  flex: 1 1 auto; min-width: 0; margin-top: 0; }
.pc-drugs.is-dense .pc-usage-t { min-width: 0; }
.pc-drugs.is-dense .pc-qty-inline { flex: 0 0 auto; }
.pc-drugs.is-dense .pc-dose { flex: 0 1 auto; margin-top: 0; }
/* ซ่อนเฉพาะป้ายที่แปลว่า "ตรวจแล้วไม่มีปัญหา"
   ❓ คิดขนาดยาให้ไม่ได้ (s-unclear) ไม่เข้าข่าย — แปลว่าระบบตรวจให้ไม่ได้ ต้องให้คนตรวจเอง จึงต้องเห็นเสมอ */
.pc-drugs.is-dense .pc-dose.s-ok,
.pc-drugs.is-dense .pc-dose.s-info,
.pc-drugs.is-dense .pc-dose.s-adult,
.pc-drugs.is-dense .pc-auxtag,
.pc-drugs.is-dense .pc-chg { display: none; }
.pc-drugs.is-dense .pc-drug-group { margin: 5px 0 1px; }
.pc-drugs.is-dense .pc-drug-round { padding: 1px 7px; }

/* ── ทางเข้ารายงานที่มีหน้าของตัวเอง (ในหน้ารายงาน) ───────────── */
.rp-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.rp-link { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface-2); color: inherit; text-decoration: none; transition: .12s; }
.rp-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.rp-link .ic { width: 20px; height: 20px; flex: 0 0 auto; color: var(--accent); }
.rp-link span { display: flex; flex-direction: column; min-width: 0; }
.rp-link b { font-size: 14px; }
.rp-link small { color: var(--muted); font-size: 12px; }
.rp-link-go { margin-left: auto; color: var(--muted); font-size: 20px; line-height: 1; }

/* ── ตรวจสอบใบสั่งยาเวรดึก ─────────────────────────────────────── */
/* แถบบอกว่าคืนนั้นใครเข้าเวร — ต้องเห็นชัดตั้งแต่เปิดหน้า */
.nc-duty { display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--accent) 0%, #0f766e 100%); border: 0; color: #fff; }
.nc-duty-l { font-size: 15px; font-weight: 800; opacity: .9; white-space: nowrap; }
.nc-duty-grp { display: flex; flex-direction: column; gap: 3px; }
.nc-duty-rl { font-size: 11.5px; font-weight: 800; letter-spacing: .3px; opacity: .75;
  border-top: 1px solid rgba(255, 255, 255, .3); padding-top: 3px; }
.nc-duty-who { display: flex; gap: 8px 18px; flex-wrap: wrap; align-items: baseline; }
.nc-duty-p b { font-size: 19px; line-height: 1.3; }
.nc-duty .muted { color: rgba(255, 255, 255, .8); }
/* ข้อมูลประกอบการคัดกรอง: น้ำหนัก สัญญาณชีพ วันนัด แพทย์ ค่าแลป */
.nc-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.nc-fact { display: inline-flex; align-items: baseline; gap: 5px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px 10px; }
.nc-fact i { font-style: normal; color: var(--muted); font-size: 11.5px; }
.nc-fact b { font-variant-numeric: tabular-nums; }
.nc-fact u { text-decoration: none; color: var(--muted); font-size: 11px; }
.nc-fact.is-bad { background: #fdecec; border-color: #f3c2c2; } .nc-fact.is-bad b { color: #b91c1c; }
.nc-fact.is-ok { background: #eafaf1; border-color: #b7e4c9; } .nc-fact.is-ok b { color: #1a7a4d; }
.nc-labs .nc-fact { background: #eff6ff; border-color: #c7dcfb; }
.nc-sym { margin-bottom: 8px; font-size: 13px; }
.nc-sym summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.nc-sym p { margin: 6px 0 0; }
.nc-sym p b { color: var(--muted); margin-right: 6px; }
.nc-case { border-left: 4px solid var(--border); }
.nc-case.is-ok { border-left-color: #16a34a; }
.nc-case.is-fixed { border-left-color: #2563eb; }
.nc-case.is-problem { border-left-color: #dc2626; }
/* เคสที่มีประวัติแพ้ยา — พื้นแดงอ่อนทั้งใบ + ขอบซ้ายแดง ให้สะดุดตาตั้งแต่กวาดตาผ่าน */
.nc-case.has-allergy { background: #fdf2f2; border-color: #f3c2c2; border-left-color: #dc2626; }
.nc-case.has-allergy .nc-drugs th { background: #fbe9e9; }
.nc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.nc-head .spacer { flex: 1; }
.nc-name { font-size: 16px; }
.nc-tag { font-size: 11.5px; font-weight: 800; padding: 1px 8px; border-radius: 6px; }
.nc-tag.ipd { color: #0e7490; background: #cffafe; }
.nc-tag.opd { color: #92400e; background: #fef3c7; }
.nc-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.nc-allergy { color: #b91c1c; background: #fdecec; border: 1px solid #f3c2c2; border-radius: 8px;
  padding: 6px 11px; font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.nc-alerts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.nc-alert { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.nc-alert.sev-crit { color: #b91c1c; background: #fdecec; }
.nc-alert.sev-warn { color: #96590a; background: #fff6e5; }
.nc-drugs td, .nc-drugs th { font-size: 13px; }
.nc-act { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.nc-act .nc-note { flex: 1; min-width: 220px; font-size: 13px; }
.nc-mark.on.ok { background: #16a34a; border-color: #16a34a; color: #fff; }
.nc-mark.on.fixed { background: #2563eb; border-color: #2563eb; color: #fff; }
.nc-mark.on.problem { background: #dc2626; border-color: #dc2626; color: #fff; }
.nc-by { font-size: 12px; white-space: nowrap; }
@media (max-width: 720px) { .nc-act .nc-note { min-width: 100%; order: 9; } }

/* ---- Spectrum antibiotic — ตารางความครอบคลุมเชื้อ ---- */
.sp-legend { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.sp-legend .sp-cell { width: 20px; height: 18px; line-height: 18px; font-size: 11px; display: inline-block; vertical-align: middle; }
.sp-tbl { border-collapse: separate; border-spacing: 3px; font-size: 12px; width: auto; background: var(--surface); }
.sp-tbl th, .sp-tbl td { border: 0; text-align: center; }
/* หัวกลุ่มเชื้อ (แกรมบวก / anaerobe / …) — แถบสีมุมมน */
.sp-grp { position: sticky; top: 0; z-index: 4; padding: 5px 8px; font-size: 11.5px; font-weight: 800; color: #fff; border-radius: 7px; letter-spacing: .2px; }
.sp-grp-gpos { background: #2563eb; } .sp-grp-ana { background: #16a34a; } .sp-grp-gneg { background: #dc2626; } .sp-grp-atyp { background: #7c3aed; }
.sp-corner { position: sticky; left: 0; top: 0; z-index: 6; background: var(--surface); min-width: 230px; max-width: 250px; text-align: left !important; padding: 6px 10px; font-weight: 800; font-size: 12.5px; box-shadow: 7px 0 7px -7px rgba(0,0,0,.12); }
/* หัวคอลัมน์เชื้อ (ข้อความแนวตั้ง) */
.sp-ohead .sp-org { position: sticky; top: 31px; z-index: 3; height: 132px; width: 40px; min-width: 40px; max-width: 40px; padding: 3px 0; cursor: pointer; vertical-align: bottom; background: var(--surface); border-radius: 6px 6px 0 0; transition: background .12s; }
.sp-ohead .sp-org span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; display: inline-block; font-weight: 600; font-size: 11px; line-height: 1.1; padding-bottom: 3px; }
.sp-org-gpos span { color: #2563eb; } .sp-org-ana span { color: #16a34a; } .sp-org-gneg span { color: #dc2626; } .sp-org-atyp span { color: #7c3aed; }
.sp-org:hover { background: var(--accent-soft, #eef2ff); }
/* ชื่อยา (คอลัมน์ตรึงซ้าย) */
.sp-abx { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left !important; padding: 5px 10px; min-width: 230px; max-width: 250px; font-weight: 600; font-size: 12px; cursor: pointer; border-radius: 6px; box-shadow: 7px 0 7px -7px rgba(0,0,0,.12); transition: background .12s; }
.sp-abx:hover { background: var(--accent-soft, #eef2ff); }
.sp-abx .sp-i { color: var(--muted); font-size: 10.5px; margin-left: 2px; }
/* หัวข้อกลุ่มยา (เพนิซิลลิน ฯลฯ) — แถบบางโปร่ง */
.sp-clsrow td { position: sticky; left: 0; z-index: 1; background: color-mix(in srgb, var(--accent) 9%, var(--surface)); text-align: left !important; font-weight: 800; font-size: 11.5px; padding: 6px 10px; color: var(--accent); letter-spacing: .3px; border-radius: 6px; }
/* เซลล์ผลลัพธ์ = tile มุมมน มีช่องไฟ */
.sp-cell { width: 40px; min-width: 40px; height: 28px; line-height: 28px; font-weight: 800; font-size: 13.5px; border-radius: 5px; }
/* ใส่ !important กันโดน .tbl tbody tr:hover td ทับพื้นหลัง (สีหายตอน hover) */
.sp-g { background: #16a34a !important; color: #fff; box-shadow: 0 1px 2px rgba(21,128,61,.22); }
.sp-v { background: #fde68a !important; color: #92400e; }
.sp-n { background: color-mix(in srgb, var(--muted) 7%, transparent) !important; color: transparent; }
/* เน้นแถว/คอลัมน์เมื่อชี้/เลือก */
.sp-tbl tbody tr:hover .sp-cell:not(.sp-n) { filter: brightness(1.06); }
.sp-tbl tbody tr:hover .sp-abx { background: var(--accent-soft, #eef2ff) !important; }
.sp-cell.sp-col-on { box-shadow: 0 0 0 2px var(--accent); }
th.sp-org.sp-col-on { background: var(--accent-soft, #eef2ff); box-shadow: inset 0 0 0 2px var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sp-v { background: #a16207; color: #fff; }
  :root:not([data-theme="light"]) .sp-n { background: color-mix(in srgb, var(--muted) 14%, transparent); }
}
:root[data-theme="dark"] .sp-v { background: #a16207; color: #fff; }
:root[data-theme="dark"] .sp-n { background: color-mix(in srgb, var(--muted) 14%, transparent); }

/* ---- ปุ่มพิมพ์ฉลากยารายตัว ในหน้าตรวจก่อนจ่าย ---- */
label.pc-drug { position: relative; }
.pc-lbl-btn { position: absolute; top: 6px; right: 8px; background: var(--surface, #fff); border: 1px solid var(--line, #e2e8f0); border-radius: 7px; cursor: pointer; font-size: 14px; line-height: 1; padding: 3px 7px; opacity: .55; transition: opacity .12s, background .12s; z-index: 2; }
.pc-lbl-btn:hover { opacity: 1; background: var(--accent-soft, #eef2ff); }
@media print { .pc-lbl-btn { display: none !important; } }

/* ---- badge "บันทึกจ่ายยาแล้ว" บนการ์ดแจ้งเตือน ---- */
.disp-badge { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; margin-left: 6px; font-size: 12px; font-weight: 700; color: #15803d; background: rgba(34,197,94,.13); padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
.disp-badge.partial { color: var(--warn); background: var(--warn-soft, rgba(217,119,6,.12)); }

/* ---- Spectrum overlay: %ไวจริงของ รพ. (antibiogram) ---- */
.sp-cell.sp-loc { font-size: 11px; font-weight: 800; color: #fff !important; letter-spacing: -.3px; }
.sp-cell.sp-loc-hi { background: #16a34a !important; box-shadow: 0 1px 2px rgba(21,128,61,.22); }
.sp-cell.sp-loc-mid { background: #d97706 !important; }
.sp-cell.sp-loc-lo { background: #dc2626 !important; }

/* ---- ตรวจก่อนจ่าย: ค้นด้วยชื่อ → รายการให้เลือก ---- */
.pc-nsearch { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.pc-ns-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; transition: background .12s, border-color .12s; }
.pc-ns-row:hover { background: var(--accent-soft, #eef2ff); border-color: var(--accent); }
.pc-ns-row .al-photo { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex: none; }
.pc-ns-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.pc-ns-info b { font-size: 15px; }
.pc-ns-go { color: var(--accent); font-weight: 700; white-space: nowrap; }

/* ---- โมดอลวิธีทำ MR ---- */
.mr-howto-box { background: var(--surface, #fff); border-radius: 12px; max-width: none; width: 98vw; height: 96vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.mr-howto-box .labimg-head { position: sticky; top: 0; z-index: 2; background: var(--surface, #fff); }
.mr-howto-body { padding: 14px 20px 20px; }
.mr-case { border: 1px solid var(--line, #e2e8f0); border-radius: 12px; padding: 10px 16px 16px; margin-bottom: 16px; }
.mr-case-h { font-weight: 800; font-size: 15px; padding: 5px 12px; border-radius: 8px; display: inline-block; margin-bottom: 8px; }
.mr-case-a { background: rgba(34,197,94,.14); color: #15803d; }
.mr-case-b { background: rgba(37,99,235,.13); color: #1d4ed8; }
.mr-howto-steps { margin: 0 0 14px; padding-left: 22px; font-size: 15px; line-height: 2; }
.mr-howto-steps li { margin-bottom: 3px; }
.mr-howto-imgs { display: flex; flex-wrap: wrap; gap: 16px; }
.mr-howto-img { margin: 0; flex: 1 1 46%; min-width: 340px; }
.mr-howto-img img { width: 100%; border: 1px solid var(--line, #e2e8f0); border-radius: 8px; display: block; cursor: zoom-in; transition: box-shadow .12s; }
.mr-howto-img img:hover { box-shadow: 0 0 0 3px var(--accent); }
.mr-howto-img figcaption { font-size: 13px; color: var(--muted); margin-top: 5px; text-align: center; }
/* ซูมรูปเต็มจอ (คลิกที่รูป) */
.mr-zoom-ov { position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.mr-zoom-ov img { max-width: 99vw; max-height: 99vh; object-fit: contain; }
.mr-zoom-x { position: fixed; top: 14px; right: 18px; color: #fff; background: rgba(255,255,255,.15); z-index: 10001; }

/* ---- ยาเดิม (MR) ในตรวจก่อนจ่าย ---- */
.pc-mrhome { border-left: 4px solid #0891b2; }
.pc-mrhome-list { margin: 6px 0 0; padding-left: 24px; font-size: 13.5px; line-height: 1.7; }
.pc-mrhome-list li { margin-bottom: 3px; }
.pc-mrhome-sub { border-top: 1px dashed var(--border); padding-top: 8px; }

/* ---- คำเตือน "ยังไม่ได้คีย์" บนสุดของรายการยาวันนี้ ---- */
.pc-notkeyed-top { display: flex; gap: 8px; align-items: flex-start; margin: 2px 0 8px; padding: 9px 13px; background: #fef2f2; border: 1.5px solid #fca5a5; border-radius: 9px; color: #991b1b; font-size: 13.5px; line-height: 1.5; box-shadow: 0 1px 4px rgba(220,38,38,.12); }
.pc-notkeyed-top svg { flex: none; margin-top: 1px; }
.pc-notkeyed-top b { font-weight: 800; }

/* ===== ระบบเบิกยานอกกรอบ (#/drug-request) + แจ้งเตือนกินยา (#/med-reminder) ===== */
.drq-tabs{display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid var(--border);margin-bottom:14px;padding-bottom:0}
.drq-tab{background:none;border:none;border-bottom:3px solid transparent;padding:8px 14px;cursor:pointer;font:inherit;color:var(--text-2);font-weight:600;border-radius:8px 8px 0 0}
.drq-tab:hover{background:var(--surface-2)}
.drq-tab.active{color:var(--accent);border-bottom-color:var(--accent);background:var(--surface-2)}
.drq-card .field{margin-bottom:10px}
.drq-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:start}
.drq-grid .field{margin-bottom:0}
.drq-card .field>label{display:block;font-weight:600;margin-bottom:4px;color:var(--text-2);font-size:13.5px}
.drq-card .input,.drq-card .select{width:100%;box-sizing:border-box}
@media (max-width:640px){.drq-grid{grid-template-columns:1fr;gap:10px}}
.drq-docno{display:flex;align-items:stretch;border:1px solid var(--border-strong);border-radius:8px;overflow:hidden}
.drq-docno .drq-prefix{background:var(--surface-2);padding:0 10px;display:flex;align-items:center;white-space:nowrap;color:var(--text-2);border-right:1px solid var(--border)}
.drq-docno input{border:none;flex:1;border-radius:0}
.drq-subj-btns{display:flex;gap:6px;flex-wrap:wrap}
.drq-subj.active{background:var(--accent);color:#fff;border-color:var(--accent)}
.drq-items td{padding:4px}
.drq-prev-ov{position:fixed;inset:0;background:rgba(15,23,42,.55);z-index:4000;display:none;align-items:center;justify-content:center;padding:16px}
.drq-prev-ov.show{display:flex}
.drq-prev-box{background:#fff;border-radius:14px;max-width:920px;width:100%;max-height:94vh;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.35)}
.drq-prev-head{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid #e2e8f0;background:#f8fafc;color:#0f172a}
.drq-prev-frame{flex:1;width:100%;border:none;background:#e2e8f0;min-height:60vh}
.drq-prev-foot{display:flex;gap:8px;justify-content:flex-end;padding:12px 16px;border-top:1px solid #e2e8f0;background:#f8fafc}
.drq-prev-box .field label{color:#334155}
.drq-prev-box .tbl td,.drq-prev-box .tbl th{color:#0f172a}

/* หน้าต่างเลือกชนิดฉลากยา */
.dl-opt-card{max-width:420px;width:94vw}
.dl-opt-body{display:flex;flex-direction:column;gap:8px;padding:14px 16px}
.dl-kind{display:flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;padding:10px 14px;border:1px solid #cbd5e1;border-radius:10px;background:#fff;cursor:pointer}
.dl-kind:hover{border-color:#2563eb;background:#eff6ff}
.dl-kind b{font-size:15px}
.dl-kind .muted{font-size:12px}

/* แถบเตือนโควตา/ส่งไลน์ไม่สำเร็จ (แจ้งรถยา/ส่งต่อข้อมูล) */
.ward-warn{margin-top:12px;padding:10px 12px;border-radius:9px;font-size:13px;line-height:1.5}
.ward-warn.err{background:#fef2f2;border:1.5px solid #ef4444;color:#991b1b}
.ward-warn.amber{background:#fffbeb;border:1px solid #f59e0b;color:#92400e}

/* ภาระงานห้องยา: แยกในเวลา/นอกเวลาราชการ ให้เห็นต่างกันตั้งแต่สายตาแรก */
.stat-box.wl-in { background: #ecfdf5; border-color: #6ee7b7; }
.stat-box.wl-off { background: #fff7ed; border-color: #fdba74; }
.stat-box.wl-off b { color: #b45309; }

/* รายการผู้ป่วยใน: ป้ายสถานะ MR + ค่าแลปผิดปกติ — อ่านแถวเดียวแล้วรู้เรื่อง */
.cc-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 5px; }
.cc-chip { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; white-space: nowrap; }
.cc-chip.ok { background: #ecfdf5; color: #065f46; border-color: #6ee7b7; }
.cc-chip.warn { background: #fff7ed; color: #9a3412; border-color: #fdba74; }
.cc-chip.bad { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }

/* รายการผู้ป่วยใน: ชื่อยาเป็นชิปไหลต่อกัน (ไม่เอาวิธีใช้) + ช่องรายละเอียดกินพื้นที่ที่เหลือทั้งหมด */
.cc-cell { width: 100%; min-width: 320px; }
.cc-dchips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.cc-dh { font-size: 11.5px; color: #64748b; font-weight: 700; margin-right: 2px; }
.cc-dchip { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: #f8fafc; border: 1px solid #e2e8f0; color: #0f172a; }
.cc-block .cc-line { line-height: 1.45; }
/* ลิ้นชักรายการผู้ป่วย: จอกว้างก็ใช้ให้เต็ม จะได้ไม่ต้องบีบข้อความลงคอลัมน์แคบ ๆ */
.drawer { width: min(1500px, 100vw); }
.cc-clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pc-dispenser.is-disp { color: #166534; }

/* มูลค่ายาที่ประหยัดได้: กดดูรายเคสได้ทุกจุด */
.cs-click { transition: background .12s, box-shadow .12s; border-radius: 8px; }
.cs-click:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
section.cs-click:hover { box-shadow: 0 2px 10px rgba(13,148,136,.18); }
.cs-more { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.cs-note { background: #f0fdfa; border: 1px solid #99f6e4; color: #115e59; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.cs-sum { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.cs-case { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.cs-case-h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cs-amt { margin-left: auto; color: #0f766e; font-size: 16px; }
.cs-case-m { font-size: 12.5px; color: var(--muted); margin: 4px 0 7px; }
.cs-lines th, .cs-lines td { padding: 5px 8px; font-size: 13px; }
.cs-usage { font-size: 11.5px; }
.cs-why td { font-size: 11.5px; color: var(--muted); padding-top: 0 !important; border-top: 0 !important; }
.cs-stop { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.cs-stop-x { color: #991b1b; font-weight: 700; }
.cs-foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* แบนเนอร์ไข้เลือดออก: สรุปผลแลปให้อ่านแล้วตัดสินใจได้ทันที */
.dg-lab { margin-top: 4px; font-size: 12.5px; border-radius: 8px; padding: 4px 8px; background: #f8fafc; border: 1px solid #e2e8f0; }
.dg-lab.dg-confirmed { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.dg-lab.dg-igg { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.dg-lab.dg-negative { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.dg-lab.dg-pending, .dg-lab.dg-none { background: #f1f5f9; border-color: #cbd5e1; color: #334155; }

/* โหมดนำเสนอ: เบลอให้ครบทุกหน้า — รูปจาก API ของผู้ป่วยทุกชนิด + เลขประจำตัวที่เป็นข้อความ */
body.present-mode img[src*="patient-photo"], body.present-mode img[src*="lab-image"],
body.present-mode img[src*="scan-image"], body.present-mode img[src*="drug-photo"] {
  filter: blur(12px) grayscale(.55) !important; }
body.present-mode .pii-num { filter: blur(6px); -webkit-filter: blur(6px); user-select: none; pointer-events: none; }

/* ค่าแลปวิกฤต: ต้องสะดุดตาทันทีแม้มองผ่าน ๆ */
.pc-lab.pc-lab-crit { background: #b91c1c !important; border-color: #7f1d1d !important; color: #fff !important;
  font-weight: 800; box-shadow: 0 0 0 3px rgba(185,28,28,.18); animation: labCrit 1.6s ease-in-out infinite; }
.pc-lab.pc-lab-crit b, .pc-lab.pc-lab-crit .muted, .pc-lab.pc-lab-crit .pc-lab-flag { color: #fff !important; }
.pc-lab.pc-lab-crit .pc-lab-flag { background: rgba(255,255,255,.2); border-radius: 5px; padding: 0 5px; }
@keyframes labCrit { 0%, 100% { box-shadow: 0 0 0 3px rgba(185,28,28,.18); } 50% { box-shadow: 0 0 0 6px rgba(185,28,28,.30); } }
@media (prefers-reduced-motion: reduce) { .pc-lab.pc-lab-crit { animation: none; } }
/* แนวโน้มเทียบค่าครั้งก่อน */
.pc-lab-trend { font-size: 11.5px; font-weight: 700; margin-left: 2px; }
.pc-lab-trend.tr-up { color: #b45309; }
.pc-lab-trend.tr-down { color: #1d4ed8; }
.pc-lab-trend.tr-same { color: var(--muted); }
.pc-lab.pc-lab-crit .pc-lab-trend { color: #fff !important; }

/* ผู้ป่วยในทั้งหมด: บีบให้เห็นทั้งตึกในหน้าเดียว */
.ipd-grid { grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); gap: 6px; }
.ipd-card { padding: 6px 7px 6px 34px; font-size: 11.5px; }
.ipd-body { line-height: 1.3; }
.ipd-name { font-size: 12.5px; }
.ipd-meta, .ipd-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ipd-advice { flex-direction: row; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.ipd-adv-chip { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: #ede9fe; color: #6d28d9;
  border: 1px solid #ddd6fe; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.ipd-adv-chip.w { background: #fff3cd; color: #92610a; border-color: #f0d98a; }
.ipd-readmit { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ipd-rb, .ipd-culture, .ipd-newstart { font-size: 11px; }
.ipd-care-t, .ipd-prob { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ipd-adv-chip { background: #2a2140; color: #c4b5fd; border-color: #3a2f5a; }
  :root:not([data-theme="light"]) .ipd-adv-chip.w { background: #3a2e10; color: #f0c674; border-color: #5a4718; } }

/* แก้การ์ดผู้ป่วยในให้อ่านรู้เรื่อง: เนื้อหาต้องได้ความกว้างพอ ปุ่มไม่เบียด */
.ipd-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 7px; }
@media (min-width: 1900px) { .ipd-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); } }
.ipd-card { padding: 6px 7px 6px 36px; }
.ipd-acts { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; }
.ipd-acts .btn { padding: 2px 7px; min-width: 0; }
.ipd-acts .dos-btn.is-ic { font-size: 14px; line-height: 1.2; }
.ipd-name { min-width: 0; }
/* ชิปต้องอ่านได้ทั้งข้อความ — ขึ้นบรรทัดใหม่ได้ ไม่ตัดกลางคำ */
.ipd-care-t, .ipd-adv-chip { white-space: normal; overflow: visible; text-overflow: clip; max-width: 100%; }
.ipd-adv-chip { border-radius: 8px; line-height: 1.35; }
.ipd-prob { white-space: normal; overflow: visible; text-overflow: clip; }
/* บรรทัดข้อมูล: ยาวเกิน 2 บรรทัดค่อยตัด (ไม่ตัดตั้งแต่คำแรก) */
.ipd-meta { white-space: normal; }
.ipd-line { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* หน้าตรวจผล OCR: รูปซ้าย ข้อความขวา */
.ocr-cmp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
@media (max-width: 900px) { .ocr-cmp { grid-template-columns: 1fr; } }
.ocr-img img { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.ocr-pre { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; line-height: 1.5; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; max-height: 60vh; overflow: auto; margin: 0; }
.ocr-micro { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 12.5px; line-height: 1.55; }
.lo-prev { font-size: 11.5px; color: var(--muted); max-width: 380px; }
.lo-bad { color: #b91c1c; } .lo-warn { color: #b45309; } .lo-ok { color: #047857; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ocr-micro { background: #06281f; border-color: #0f5132; color: #86efac; } }

/* ผล OCR: ตารางผลตรวจที่ใช้งานได้ */
.ocr-res { margin-bottom: 10px; }
.ocr-res > b { display: block; margin-bottom: 4px; }
.ocr-res-t th, .ocr-res-t td { padding: 4px 8px; font-size: 12.5px; }
.ocr-res-t tr.ocr-grp td { background: var(--surface-2); font-weight: 700; font-size: 12px; }
.ocr-susp { color: #b45309; font-weight: 800; cursor: help; }
.ocr-raw summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* แบนเนอร์พร่อง G6PD — ต้องเห็นทุกครั้งที่เปิดเคสนี้ */
.pc-banner.pc-g6pd-b { border-left: 6px solid #7f1d1d; }

/* รูปผลแลป: กดดูฉบับเต็มได้ */
.ocr-img a { display: block; cursor: zoom-in; }
.ocr-img img:hover { box-shadow: 0 0 0 3px rgba(13,148,136,.35); }
.ocr-img-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; text-align: center; }

/* ตารางความไวเชื้อ (S/I/R ต่อเชื้อแต่ละตัว) */
.sus-wrap { margin-top: 6px; overflow-x: auto; }
.sus-t { font-size: 12px; min-width: 100%; }
.sus-t th, .sus-t td { padding: 3px 7px; white-space: nowrap; }
.sus-t td.sus-s { background: #ecfdf5; color: #065f46; }
.sus-t td.sus-i { background: #fff7ed; color: #9a3412; }
.sus-t td.sus-r { background: #fef2f2; color: #991b1b; font-weight: 700; }
.sus-t td.sus-sdd { background: #eff6ff; color: #1e40af; }

/* ต้องสอนเทคนิคการใช้ยา (ยาพ่น/อินซูลินครั้งแรก · กลับมาหลังขาดยานาน) */
.pc-banner.pc-teach { border-left: 6px solid #0369a1; }
.pc-teachtag { display: inline-block; background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc;
  padding: 1px 7px; border-radius: 6px; font-size: .78em; font-weight: 700; white-space: nowrap; }
