/* PPK Medical – Overview dashboard. Mobile-first: base rules target phones,
   the >=1024px query lays out the fixed sidebar + right panel seen on desktop. */

:root {
  --navy-900: #0a1830;
  --navy-700: #163a5c;
  /* สีเขียวมิ้นท์หลักของแบรนด์ (ยืนยันจากผู้ใช้ให้ตรงกับภาพอ้างอิง) — ยังใช้ชื่อตัวแปรเดิม (teal-700/900)
     ไว้ตามเดิมเพราะมีคนเรียกใช้กระจายอยู่ทั่วทั้งไฟล์ (nav แถบซ้าย, ไอคอน EKG, ปุ่ม, ตัวเลขสรุป ฯลฯ)
     เปลี่ยนแค่ค่าสีตรงนี้ที่เดียวก็ไล่สีใหม่ไปทุกจุดที่ใช้แล้วโดยไม่ต้องไล่แก้ทีละจุด */
  --teal-700: #14b8a6;
  --teal-900: #0f766e;

  --status-good: #0d9488;
  --status-critical: #dc2626;
  --status-warning: #ca8a04;
  --status-info: #2563eb;
  /* ป้าย "ถอดนาฬิกา" (นาฬิกาขาดการติดต่อ/ไม่ได้สวม) — เทาตั้งใจแยกจากชุดสีวิกฤต/เฝ้าระวัง/ปกติ
     (แดง/เหลือง/เขียว) ข้างบนทั้งหมด (ยืนยันจากผู้ใช้ — สื่อ "ไม่มีข้อมูล/ปิดการทำงาน" ตรงไปตรงมากว่าสีอื่น) */
  --status-offline: #6b7280;

  --accent-green: #16a34a;
  --gender-male: #2563eb;
  --gender-female: #16a34a;

  --surface: #eef1f5;
  --card-bg: #ffffff;
  --ink-900: #111827;
  --ink-600: #4b5563;
  --ink-400: #9ca3af;
  --border: #e5e7eb;

  --radius: 14px;
  --sidebar-w: 264px;
  --panel-w: 270px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--card-bg);
  color: var(--ink-900);
  font-family: 'Prompt', 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* กันไว้อีกชั้น เผื่อ element ไหนในอนาคตดันความกว้างเกินจอ จะโดนตัดแทนที่จะทำให้ทั้งหน้า scroll แนวนอนได้ */
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

.btn-alert-cta { background: var(--accent-green); color: #fff; }
.btn-export { background: var(--accent-green); color: #fff; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot-good { background: var(--status-good); }
.dot-bad { background: var(--status-critical); }
.dot-blue { background: var(--gender-male); }
.dot-green { background: var(--gender-female); }

/* ---------- shell / drawer toggle (no JS: checkbox hack) ---------- */

.drawer-toggle { position: absolute; opacity: 0; pointer-events: none; }

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 48, 0.5);
  z-index: 30;
}

.shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr;
  min-height: 100vh;
}

/* ---------- sidebar ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(84vw, var(--sidebar-w));
  z-index: 40;
  background: var(--card-bg);
  color: var(--ink-900);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 8px rgba(16, 24, 40, 0.04);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.drawer-toggle:checked ~ .drawer-backdrop { display: block; }
.drawer-toggle:checked ~ .shell .sidebar { transform: translateX(0); }

.sidebar-logo { display: flex; justify-content: center; padding: 4px 0 16px; }
.sidebar-logo img { width: 170px; max-width: 100%; height: auto; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--ink-600);
  font-weight: 600;
}

/* บอกว่าอยู่แท็บไหนด้วยเส้นขอบสีเขียว ไม่ใช่พื้นหลังทึบ — พื้นหลังจางๆ ไว้แค่ช่วยให้เห็นขอบเขตปุ่ม */
.nav-item.active {
  background: rgba(20, 184, 166, 0.1);
  color: var(--teal-900);
  box-shadow: inset 0 0 0 1.5px var(--teal-700);
}

/* ไอคอนทุกตัวในเมนูซ้ายใช้กล่องขนาดเท่ากันเสมอ (28x28) ไม่ว่าจะเป็นไอคอนอะไร เพื่อให้แถวเรียงชิด
   แนวเดียวกัน ไม่ขึ้นอยู่กับว่า path ข้างในแต่ละรูปจะกินพื้นที่จริงเท่าไหร่ */
.nav-icon {
  flex: none;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.95;
}

.nav-icon svg { display: block; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-subnav-toggle { position: absolute; opacity: 0; pointer-events: none; }

/* .nav-item-row ต้องมี padding/gap เท่ากับ .nav-item เป๊ะ (แถวนี้แยกไอคอนออกมาเป็น label ต่างหาก
   สำหรับ toggle เมนูย่อย) ไม่งั้นไอคอน/ตัวหนังสือของแถวนี้จะเยื้องซ้ายไม่ตรงกับแถวอื่นที่ไอคอนอยู่
   ในปุ่มเดียวกับข้อความ — เคยเจอปัญหานี้มาแล้ว ระวังอย่าทำให้กลับไปเป็นแบบเดิม */
.nav-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 10px;
}
.nav-item-row .nav-item { flex: 1; padding: 0; }

.nav-item-row.active {
  background: rgba(20, 184, 166, 0.1);
  box-shadow: inset 0 0 0 1.5px var(--teal-700);
}

.nav-item-row.active .nav-item { color: var(--teal-900); }

/* ไอคอนเดียวทำหน้าที่ทั้งแสดงหมวดหมู่และเป็นปุ่มย่อ/ขยายเมนูย่อย (label ของ checkbox hack เดิม)
   แทนลูกศร › แยกต่างหาก ที่ทำให้ดูเป็นสองปุ่มไม่เข้ากัน */
.nav-ekg-icon { cursor: pointer; color: var(--teal-700); }

/* ไอคอนเส้น SVG ของ home/เบาหวาน/หลอดเลือดหัวใจ/เก๊าท์ — สีเดียวกับ nav-ekg-icon ทั้งหมด (เขียวเข้ม
   โทนเดียวกับกราฟสัญญาณชีพ) ไม่มีพื้นหลัง ไม่ใช่ปุ่ม toggle (กลุ่มพวกนี้ไม่มีเมนูย่อย) */
.nav-svg-icon { color: var(--teal-700); }

.nav-subnav-toggle ~ .nav-subnav { display: none; }
.nav-subnav-toggle:checked ~ .nav-subnav { display: flex; }

.nav-subnav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 8px 34px;
}

.nav-subitem {
  position: relative;
  padding: 7px 10px 7px 16px;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--ink-400);
}

.nav-subitem::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  transform: translateY(-50%);
}

.nav-subitem.active {
  color: var(--teal-900);
  font-weight: 600;
  background: var(--surface);
}

.nav-subitem.active::before { opacity: 1; }

.sidebar-status {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--ink-900);
}

.sidebar-status-title { font-weight: 600; margin-bottom: 8px; }
.sidebar-status-row { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.sidebar-status-row strong { margin-left: auto; }

/* แถวลิงก์ "เคสค้างรอปิด" — ใช้โครง .sidebar-status-row เดิม แต่เป็น <a> จึงต้อง reset สีตัวหนังสือ/
   ตัด underline เอง แล้วทำให้อ่านออกว่าเป็นลิงก์เตือนที่กดได้ (สีแดงเหมือน .dot-bad ข้างในบรรทัดเดียวกัน) */
.sidebar-status-row-warning {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--status-critical);
  font-weight: 700;
  text-decoration: none;
}
.sidebar-status-row-warning:hover { text-decoration: underline; }

.sidebar-user {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role { color: var(--ink-600); font-size: 0.75rem; }

.sidebar-user-change-password {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--status-info);
  text-decoration: underline;
}

.sidebar-logout {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 7px 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--ink-600);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-logout:hover { border-color: var(--status-critical); color: var(--status-critical); }

/* ---------- SOS/fall/vital modal (priority alert queue) ---------- */
/* กลางจอ ไม่ใช่แถบบนสุดแบบเดิม (.alert-banner) — โชว์แค่ตัวหน้าคิวตัวเดียวเสมอ (ดู
   core/services.py::build_alert_modal) แสดง/ซ่อนล้วนขับเคลื่อนจาก server (ไม่มี client toggle) จึง
   ไม่ต้องพึ่ง JS — z-index สูงกว่า drawer-backdrop (30) เพราะต้องอยู่บนสุดของหน้าเสมอ */

.sos-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 24, 48, 0.6);
}

/* triage-popup แทน .sos-modal เดิม (กล่องแดงเล็ก ชื่อ+ปุ่มรับทราบ) — ตอนนี้ต้องพอมีที่แสดงข้อมูลคัด
   แยกครบ (โรคประจำตัว/สัญญาณชีพ/ที่ตั้ง/เบอร์ติดต่อ + 4 ปุ่ม action) จึงแยกหัว (สีแดง เร่งด่วน) กับตัว
   เนื้อหา (พื้นขาว อ่านง่าย) แทนที่จะให้ทั้งกล่องเป็นพื้นแดงตัวหนังสือขาวเหมือนเดิม ซึ่งอ่านข้อมูลเยอะๆ
   ไม่ไหว — max-height + overflow-y เพราะเนื้อหาอาจสูงกว่าจอ (โดยเฉพาะจอเตี้ยอย่างแท็บเล็ตแนวนอน) */
.triage-popup {
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: sos-modal-pulse 1.1s ease-in-out infinite;
}

/* กระพริบให้รู้สึกเร่งด่วนจริง — เคยไม่กระพริบแล้วดูเหมือนไม่สำคัญพอ (ผู้ใช้ยืนยันแล้ว) */
@keyframes sos-modal-pulse {
  0%, 100% { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(220, 38, 38, 0.65); }
  50% { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), 0 0 0 18px rgba(220, 38, 38, 0); }
}

.triage-popup-head {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(120deg, #991b1b, var(--status-critical));
  color: #fff;
  border-radius: 16px 16px 0 0;
  padding: 16px 20px;
  position: sticky;
  top: 0;
}

.triage-popup-icon {
  font-size: 1.8rem;
  line-height: 1;
  flex: none;
  animation: sos-modal-icon-blink 1.1s ease-in-out infinite;
}

@keyframes sos-modal-icon-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.triage-popup-head-text { flex: 1; min-width: 0; }
.triage-popup-title { font-weight: 700; font-size: 1rem; line-height: 1.35; }
.triage-popup-sub-link { color: #fecaca; font-size: 0.75rem; text-decoration: none; }
.triage-popup-sub-link:hover { text-decoration: underline; }

.triage-popup-timer {
  flex: none;
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 5px 12px;
}
.triage-popup-timer-label { display: block; font-size: 0.62rem; opacity: 0.85; }
.triage-popup-timer-value { display: block; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.triage-popup-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.triage-popup-identity { display: flex; align-items: center; gap: 12px; }
.triage-popup-meta { display: block; font-size: 0.72rem; font-weight: 400; color: var(--ink-600); margin-top: 2px; }

.triage-popup-block-label { font-size: 0.72rem; font-weight: 600; color: var(--ink-600); margin-bottom: 6px; }

.med-chips, .contact-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.med-chip {
  background: #fff7e6;
  border: 1px solid #ffe082;
  color: #7a5800;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 12px;
  padding: 3px 11px;
}
.med-chip-caution {
  background: #fde8e8;
  border-color: #ffcdd2;
  color: var(--status-critical);
  font-weight: 600;
}

.contact-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--surface);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.72rem;
  color: var(--ink-600);
}
.contact-chip b { color: var(--ink-900); font-size: 0.8rem; }

.triage-popup-location { font-size: 0.8rem; color: var(--ink-900); }

.triage-popup-actions {
  border-top: 1px solid var(--border);
  padding: 12px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* วางปุ่มเรียงคอลัมน์เดียวก่อนบนจอแคบ (ปุ่มมีข้อความยาวอย่าง "เปิดเคสส่งกู้ชีพ" เบียดกันไม่พอถ้าวางคู่
   บนมือถือ) แล้วค่อยขยับเป็น 2 ต่อแถวตั้งแต่ 480px ขึ้นไป */
.triage-popup-row { display: flex; flex-direction: column; gap: 8px; }
.triage-popup-row form { display: flex; }
.triage-popup-row form .btn { width: 100%; }

@media (min-width: 480px) {
  .triage-popup-row { flex-direction: row; }
  .triage-popup-row form { flex: 1; }
  .triage-popup-row > .btn { flex: 1; }
}

/* เฉพาะเคสล้มที่ปลดล็อกปุ่มเพราะหมดเวลารอวัดค่า ไม่ใช่วัดได้ครบจริง (ดู
   core/services.py::build_alert_modal, "vitals_stale") */
.triage-popup-waiting-note {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--status-warning);
  text-align: center;
}

.btn-alert-ack { background: var(--status-info); color: #fff; }
.btn-alert-call { background: #fff; color: var(--accent-green); border: 1.5px solid var(--accent-green); }
.btn-alert-cancel { background: #fff; color: var(--ink-600); border: 1.5px solid var(--border); }
.btn-alert-dispatch { background: var(--status-critical); color: #fff; }
.btn-alert-close { background: var(--accent-green); color: #fff; }

/* ---------- แบนเนอร์ลิงก์ใบงานฉุกเฉิน (patient_detail.html หลังส่งกู้ชีพ) ---------- */
/* ยังไม่มี LINE Official Account จริง (ดู alerts/services.py::queue_dispatch_notification) —
   แบนเนอร์นี้คือจุดที่เจ้าหน้าที่คัดลอกลิงก์ไปส่งเอง วันที่มี LINE API แล้วจะมีปุ่ม "ส่งอัตโนมัติ"
   มาแทนที่ตรงนี้จุดเดียว ไม่ต้องแก้ที่อื่น */
.dispatch-banner {
  border: 2px solid var(--status-info);
  background: #eff6ff;
}
.dispatch-banner-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.dispatch-banner-note {
  font-size: 0.75rem;
  color: var(--ink-600);
  background: #fff7e6;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 10px;
}
.dispatch-banner-field { margin-bottom: 8px; }
.dispatch-banner-label { display: block; font-size: 0.68rem; color: var(--ink-600); margin-bottom: 3px; }
.dispatch-banner-link-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink-900);
}
.dispatch-banner-message {
  white-space: pre-wrap;
  font-size: 0.78rem;
  color: var(--ink-900);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

/* ---------- หน้ายืนยันยกเลิกเคส (cancel_case_confirm.html) ---------- */
.cancel-confirm-card { max-width: 480px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.cancel-confirm-summary { font-size: 0.85rem; font-weight: 600; color: var(--status-critical); }
.cancel-confirm-warning {
  font-size: 0.78rem;
  color: var(--ink-600);
  background: #fff7e6;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 8px 10px;
}
.cancel-confirm-error {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--status-critical);
  background: #fde8e8;
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  padding: 8px 10px;
}
.cancel-confirm-form { display: flex; flex-direction: column; gap: 6px; }
.cancel-confirm-label { font-size: 0.75rem; font-weight: 600; color: var(--ink-600); }
.cancel-confirm-reason {
  font-family: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
}
/* วางคอลัมน์เดียวก่อนบนจอแคบ (ปุ่มข้อความยาวอย่าง "ยกเลิกเคส (False Alarm)" เบียดกันไม่พอถ้าวางคู่บน
   มือถือ) แล้วค่อยขยับเป็น 2 ต่อแถวตั้งแต่ 480px ขึ้นไป — แพทเทิร์นเดียวกับ .triage-popup-row */
.cancel-confirm-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
@media (min-width: 480px) {
  .cancel-confirm-actions { flex-direction: row; }
}
.cancel-confirm-actions .btn { flex: 1; }

/* ---------- หน้าทบทวน/ติดตามสถานะส่งกู้ชีพ (dispatch_case_review.html) ---------- */
/* padding: 0 + overflow: hidden เพราะหัวการ์ด (.dispatch-review-head) ต้องชนขอบการ์ดเต็มความกว้าง
   (bleed) ให้ดูเหมือนแบนเนอร์จริง เนื้อหาด้านล่างถึงมี padding ของตัวเอง (.dispatch-review-body) */
.dispatch-review-card { max-width: 640px; width: 100%; margin: 0 auto; padding: 0; overflow: hidden; }

/* หัวแบนเนอร์สีแดงเหมือน popup แจ้งเตือนกลางจอ (.triage-popup-head) แต่เป็นหน้าเว็บปกติไม่ใช่ overlay
   จึงไม่ sticky/ไม่กระพริบ — ให้หน้านี้ (แยกมาจาก popup เดิม) ยังดูเป็นเรื่องเดียวกัน ไม่ใช่ฟอร์มธรรมดา */
.dispatch-review-head {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(120deg, #991b1b, var(--status-critical));
  color: #fff;
  padding: 16px 20px;
}
.dispatch-review-head-sub { font-size: 0.78rem; color: #fecaca; margin-top: 2px; }
/* ไม่ใช้ .triage-popup-icon เพราะมันกระพริบไม่หยุด (animation: sos-modal-icon-blink) — เหมาะกับ popup
   ที่โผล่แว้บเดียวแล้วต้องปิด แต่หน้านี้เจ้าหน้าที่ต้องอยู่นานกว่าจะกรอก/กดยืนยัน กระพริบตลอดจะน่ารำคาญ */
.dispatch-review-icon { font-size: 1.8rem; line-height: 1; flex: none; }

.dispatch-review-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 12px; }

.dispatch-review-primary { display: block; width: 100%; padding: 13px 12px; font-size: 0.92rem; }

/* ปุ่ม "ยกเลิกเคส" ต้องแยกออกจาก "กลับ ไม่ส่ง" ให้ชัดว่าเป็น action ทำลายล้าง (ปิดเคสทันที) ไม่ใช่แค่
   ย้อนกลับเฉยๆ ทั้งที่ทั้งคู่ใช้ปุ่มเทาเดิม (.btn-alert-cancel) เป็นฐาน */
.dispatch-review-false-alarm { color: var(--status-critical); border-color: rgba(220, 38, 38, 0.35); }

.dispatch-timeline { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.dispatch-timeline-item {
  font-size: 0.82rem;
  color: var(--ink-600);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
}
.dispatch-timeline-done { color: var(--ink-900); background: #e8f5e9; font-weight: 600; }

/* ---------- หน้าเว็บสาธารณะสำหรับทีมกู้ชีพ (ems_status.html) ---------- */
/* หน้ามือถือล้วน ไม่มี sidebar/topbar ของเจ้าหน้าที่ ไม่ผ่าน login เลย */
.ems-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--surface);
  padding: 24px 16px;
}

/* การ์ดข้อความสั้นๆ (ไม่พบใบงาน/ปิดแล้ว) คงความกว้างแคบเดิมไว้ อ่านง่ายกว่าไม่ต้องเต็มจอ */
.ems-card { width: 100%; max-width: 480px; padding: 20px; }

/* สถานะที่มีแบนเนอร์หัวสีแดง (.dispatch-review-head) คือสถานะที่มีรายละเอียดเต็ม (ข้อมูลส่วนตัว/
   ผู้ติดต่อฉุกเฉิน/สัญญาณชีพ) — ยืนยันจากผู้ใช้ให้ขยายเต็มความกว้างหน้าเว็บ (ไม่ตั้ง cap ตายตัวแคบๆ
   เหมือนเดิม) padding:0 ให้แบนเนอร์หัวชนขอบการ์ดเต็มความกว้างเหมือนหน้า dispatch_case_review.html
   ของเจ้าหน้าที่ */
.ems-card-banner { padding: 0; overflow: hidden; max-width: 1100px; }

.ems-actions { display: flex; flex-direction: column; gap: 10px; }
.ems-actions form { display: flex; }

/* ---------- ข้อมูลส่วนตัว/ผู้ติดต่อฉุกเฉิน 2 คอลัมน์ (ems_status.html) ---------- */
/* มือถือก่อน (1 คอลัมน์ เรียงต่อกัน) เหมือนแพทเทิร์น .content-row ในหน้าเจ้าหน้าที่ — ขยับเป็น 2
   คอลัมน์ตอนจอกว้างพอ (640px ขึ้นไป) ผู้ติดต่อฉุกเฉินอยู่ขวาของข้อมูลส่วนตัวเสมอตามที่ผู้ใช้ยืนยัน */
.ems-info-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 14px 0; }
@media (min-width: 640px) {
  .ems-info-grid { grid-template-columns: 1fr 1fr; }
}
.ems-info-block {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 14px;
}
.ems-info-block-label { font-weight: 700; font-size: 0.82rem; color: var(--ink-600); margin-bottom: 6px; }
.ems-info-row { font-size: 0.9rem; margin: 2px 0; }

/* ---------- การ์ดข้อมูลละเอียดหลังกด "ออกเดินทาง" (ems_status.html) ---------- */
/* คนละคลาสกับ .ems-info-block ด้านบนโดยตั้งใจ (หน้าก่อนออกเดินทางต้องคงเดิมเป๊ะๆ ไม่ปนกัน) มีเส้นขอบ
   ให้ดูเป็นการ์ดแยกชัดเจนตามภาพอ้างอิงที่ผู้ใช้ส่งมา ใช้ token สีเดิมชุดเดียวกับ .card บนสุดของหน้า */
.ems-detail-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.ems-detail-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-900);
  margin-bottom: 8px;
}

.ems-departed-form { flex-direction: column; gap: 6px; }
.ems-unit-input {
  font-family: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.ems-status-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px 12px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  cursor: pointer;
}
.ems-status-btn-1 { background: var(--status-info); color: #fff; }
.ems-status-btn-2 { background: var(--accent-green); color: #fff; }
.ems-status-btn-3 { background: #fff; color: var(--status-critical); border: 2px solid var(--status-critical); }
.ems-status-btn-done { background: #e8f5e9; color: var(--accent-green); }

.ems-closed-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 6px; }
.ems-closed-sub { font-size: 0.85rem; color: var(--ink-600); }
.ems-responder-label {
  font-size: 0.8rem;
  color: var(--ink-600);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  margin: 8px 0;
}

.hamburger-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  cursor: pointer;
}

.hamburger-btn span { width: 20px; height: 2px; background: var(--ink-900); border-radius: 2px; }

/* ---------- topbar ---------- */

.topbar {
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
  min-width: 0;
  position: relative;
}
/* ไม่ตั้ง z-index บน .topbar เอง (ตั้งใจ) — ถ้ามี z-index ที่นี่ .topbar จะกลายเป็น stacking context
   ใหม่ ทำให้ z-index ของลูกหลานข้างใน (.open-cases-dropdown=45, .case-status-backdrop=46,
   .case-status-modal=47, .topbar-user-menu=100) ถูกตัดขาดจากลำดับชั้นจริงของหน้า เทียบได้แค่กันเองใน
   .topbar เท่านั้น ไม่ใช่เทียบกับ .open-cases-backdrop(35)/.sidebar(40) ที่อยู่นอก .topbar — บั๊กที่เจอ
   จริง: ตั้ง z-index:20 ไว้ก่อนหน้านี้ ทำให้ .open-cases-backdrop (35, อยู่นอก .topbar) วาดทับ
   .open-cases-dropdown ทั้งก้อน (ถูกตรึงไว้ที่ระดับ 20) สนิท ทำให้กดแถวในดรอปดาวน์ "งานที่ยังไม่จบ" ไม่ได้
   เลย (คลิกไปโดนแค่ backdrop โปร่งใสด้านบน) position: relative เฉยๆ (ไม่มี z-index) ไม่สร้าง stacking
   context ใหม่ จึงยังคงไว้เพื่อเผื่อโค้ดอื่นอ้างอิงอยู่ แต่ปลอดภัยกว่า */

.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-brand h1 { 
  font-size: 1.05rem; 
  font-weight: 800; 
  color: #0f172a; 
  letter-spacing: -0.01em;
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap; 
}

.topbar-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.range-filter-form { margin: 0; }

/* ปุ่มย้อนกลับสไตล์เด่นชัด โต สวยงาม (Back Button) */
.btn-topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  border-radius: 999px;
  background: #ffffff;
  border: 1.5px solid #2563eb;
  color: #2563eb;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  cursor: pointer;
}
.btn-topbar-back:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transform: translateY(-1px);
}
.btn-topbar-back:active {
  transform: translateY(0);
}
.btn-topbar-back svg {
  transition: transform 0.2s ease;
}
.btn-topbar-back:hover svg {
  transform: translateX(-3px);
}

/* User Profile Menu (ย้ายจาก Sidebar มาไว้ Header Topbar) */
.topbar-user-dropdown {
  position: relative;
  display: inline-block;
}
.user-menu-toggle {
  display: none;
}
.topbar-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}
.topbar-user-pill:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}
.topbar-user-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: #1e293b;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-user-chevron {
  color: #64748b;
  transition: transform 0.2s ease;
}
.user-menu-toggle:checked ~ .topbar-user-pill .topbar-user-chevron {
  transform: rotate(180deg);
}

/* Dropdown Menu Box */
.topbar-user-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 220px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.18), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  padding: 10px;
  z-index: 100;
  animation: topbar-menu-slide 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.user-menu-toggle:checked ~ .topbar-user-menu {
  display: block;
}

@keyframes topbar-menu-slide {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.topbar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 10px;
}
.topbar-user-avatar-lg {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: 0 2px 5px rgba(30, 58, 138, 0.25);
}
.topbar-user-details {
  min-width: 0;
}
.topbar-user-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-user-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  margin: 1px 0 0;
}
.topbar-user-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 4px 0 8px;
}

.topbar-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.15s ease;
  text-align: left;
}
.topbar-user-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.topbar-logout-form {
  margin: 2px 0 0;
}
.topbar-user-item-logout {
  color: #dc2626;
}
.topbar-user-item-logout:hover {
  background: #fef2f2;
  color: #b91c1c;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: inherit;
  text-decoration: none;
  font-size: 1.2rem;
  cursor: pointer;
}

.icon-btn .badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--status-critical);
  color: #fff;
  font-size: 0.6rem;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ปุ่มสลับโหมดเต็มจอ (เหมือนกด F11) — อยู่ในไฟล์ include core/_topbar_user.html จึงขึ้นทุกหน้าที่มี topbar
   ผู้ใช้ล็อกอินอัตโนมัติ ไม่ต้องแก้ทีละหน้า ไอคอนสลับเองระหว่างลูกศรกางออก/หุบเข้าตามสถานะจริงของ
   document.fullscreenElement (ผ่าน fullscreenchange event) ไม่ใช่แค่ตอนกดปุ่มนี้ เผื่อผู้ใช้กด Esc/F11 เอง */
.fullscreen-toggle-btn { font-size: 1.1rem; padding: 4px; border-radius: 8px; color: var(--ink-600); }
.fullscreen-toggle-btn:hover { background: rgba(37, 99, 235, 0.1); color: var(--status-info); }

/* ---------- "งานที่ยังไม่จบ" dropdown (checkbox hack แบบเดียวกับ drawer — ไม่มี JS) ---------- */
/* .open-cases-toggle ต้องอยู่นอก .shell เป็น sibling ของมัน (เหมือน .drawer-toggle) ให้ตัวเลือก
   ":checked ~ .shell ..." เอื้อมเข้าไปหา .open-cases-dropdown ที่ซ้อนอยู่ข้างในได้ */
.open-cases-toggle { position: absolute; opacity: 0; pointer-events: none; }

.open-cases-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: transparent;
}

.open-cases-toggle:checked ~ .open-cases-backdrop { display: block; }

.open-cases-widget { position: relative; }

.open-cases-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 10px;
  width: min(360px, 90vw);
  max-height: min(70vh, 480px);
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16);
  z-index: 45;
  padding: 14px;
}

.open-cases-toggle:checked ~ .shell .open-cases-dropdown { display: block; }

.open-cases-dropdown-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  margin-bottom: 10px;
}

.open-cases-dropdown-count {
  background: var(--status-critical);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.open-cases-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}
.open-cases-item:hover { background: var(--surface); }

.open-cases-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.open-cases-item-name { font-weight: 600; font-size: 0.88rem; }
.open-cases-item-sub { font-size: 0.76rem; color: var(--ink-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.open-cases-empty { color: var(--ink-600); font-size: 0.85rem; padding: 8px; }

.open-cases-viewall {
  display: block;
  text-align: center;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-weight: 700;
  color: var(--status-info);
}

/* ---------- popup สถานะรายเคส (กดจากรายการ "งานที่ยังไม่จบ") ---------- */
/* ทรง/สไตล์เดียวกับ .triage-popup (popup แจ้งเตือน SOS/ล้ม) ตามที่ผู้ใช้ยืนยัน แต่ไม่กระพริบ (ไม่ใช่
   เหตุฉุกเฉิน แค่เช็คสถานะ) checkbox-hack แยกต่างหากต่อ 1 เคส (id ผูกกับ case.id) ซ้อนอยู่ใน
   .case-status-trigger เดียวกันทั้ง 3 ส่วน (checkbox/backdrop/modal) เป็น general sibling กัน ทำให้
   ใช้ selector เดียวกันซ้ำได้ทุกเคสโดยไม่ต้องเขียน CSS แยกทีละ id — ต่างจาก .open-cases-toggle ที่ต้อง
   เอื้อมออกไปนอก .shell (ตัวนี้ไม่ต้อง เพราะ backdrop/modal ซ้อนอยู่ในบล็อกเดียวกับ checkbox อยู่แล้ว) */
.case-status-toggle { position: absolute; opacity: 0; pointer-events: none; }

.case-status-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 46;
  background: rgba(10, 24, 48, 0.5);
}

.case-status-toggle:checked ~ .case-status-backdrop { display: block; }

.case-status-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 47;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
}

.case-status-toggle:checked ~ .case-status-modal { display: flex; }

.case-status-modal-inner {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 20px;
  pointer-events: auto;
}

.case-status-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy-700);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---------- content ---------- */

/*
  .content เป็น grid item ของ .shell — ถ้าไม่ set min-width:0 ความกว้าง "1fr" ของ grid track
  จะยอมโดนดันกว้างเกินจอได้ถ้าเนื้อหาข้างในมี min-content ใหญ่ (เช่น tile-row ที่มี 3 การ์ดขั้นต่ำ
  120px ต่อใบ) auto-fit/1fr ที่ตั้งใจให้ reflow ตามพื้นที่จริงจะไม่ทำงานถ้า min-width chain ขาดตอน
*/
.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  min-width: 0;
}

.content-row { min-width: 0; }
.groups { min-width: 0; }
.side-panel { min-width: 0; }

.groups-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.groups-head h2 { font-size: 1.1rem; font-weight: 700; }

.group-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  min-width: 0;
  align-items: stretch;
}

.group-card {
  overflow: hidden;
  scroll-margin-top: 76px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.group-card-head {
  background: #d9f2ef;
  color: var(--teal-900);
  padding: 12px 16px;
}

/* สีพื้นอ่อนต่างกันตามกลุ่มโรค + ตัวหนังสือสีเข้มโทนเดียวกัน (ไม่ใช่พื้นเข้มตัวหนังสือขาวแบบเดิม)
   ให้แยกแยะการ์ดได้เร็วโดยไม่ต้องอ่านหัวข้อ (กลุ่ม 1 คงสีเดิม ใช้ base ด้านบน) */
.group-card-head-diabetes {
  background: linear-gradient(100deg, #d9e9ff 0%, #d7e9ff 58%, #cbf4ec 100%);
  color: #1c3671;
}
.group-card-head-cardio { background: #fee2e2; color: #7f1d1d; }
.group-card-head-gout { background: #ede9fe; color: #4c1d95; }

.group-card-head h3 { font-size: 1.05rem; font-weight: 700; line-height: 1.35; }

.group-card-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; flex: 1; }

/* การ์ดเบาหวานใช้พื้นที่แนวตั้งให้คุ้ม: ข้อมูล 3 บรรทัดกระจายเต็มกล่อง แต่อ่านง่ายและสเกลเท่าการ์ดข้างๆ */
#diabetes .group-card-body {
  justify-content: space-between;
  padding: 10px;
  gap: 8px;
}

#diabetes .stat-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  margin-top: 0;
}

#diabetes .stat-row {
  padding: 10px 0;
}

#diabetes .stat-value {
  font-size: 1.45rem;
}

#diabetes .stat-label {
  font-size: 0.95rem;
}

#diabetes .stat-note {
  font-size: 0.82rem;
}

#diabetes .stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid #e6ebf3;
}

#diabetes .stat-row:last-child {
  border-bottom: 0;
}

#diabetes .stat-label {
  color: #1f3772;
  font-weight: 600;
  font-size: 0.74rem;
}

#diabetes .stat-value {
  color: #0f214a;
  font-weight: 700;
  font-size: 0.95rem;
}

#diabetes .stat-row:first-child .stat-value,
#diabetes .stat-row:nth-child(2) .stat-value {
  color: #0f214a;
}

#diabetes .stat-note {
  grid-column: 1 / -1;
  color: #7a88a8;
  font-size: 0.68rem;
}

#diabetes .trend-sparkline {
  width: 24px;
  height: 12px;
  margin-left: 3px;
}

#diabetes .split-bar {
  margin-top: 0;
}

/* กล่องล่าง 2 ใบ (cardio/gout): สถิติซ้าย กราฟขวา กราฟเต็มพื้นที่ */
#cardio .group-card-body,
#gout .group-card-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px;
}

.group-body-split {
  display: grid;
  grid-template-columns: 0.9fr 1.6fr;
  gap: 4px;
  align-items: stretch;
  min-width: 0;
  flex: 1;
  margin-bottom: 0;
}

.group-body-col-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-start;
  min-width: 0;
}

.group-body-col-chart {
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-width: 0;
  height: 100%;
}

#cardio .group-body-split,
#gout .group-body-split {
  flex: 1;
  min-height: 0;
}

#cardio .chart-box,
#gout .chart-box {
  width: 100%;
  height: 100%;
  max-height: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#cardio .chart-box svg,
#gout .chart-box svg {
  width: 100%;
  height: 100%;
  max-width: 280px;
  max-height: 300px;
}

#gout .chart-box-gout svg {
  max-height: 300px;
  max-width: 280px;
}

#cardio .risk-legend {
  justify-content: flex-start;
  flex-wrap: wrap;
  font-size: 0.66rem;
  gap: 8px;
}

#cardio .split-bar,
#gout .split-bar {
  margin-top: 0;
  padding-top: 0;
}

/* tile-row เป็น flex item ของ .group-card-body ด้วย ต้อง min-width:0 ไม่งั้น auto-fit ข้างในจะไม่ยอม
   reflow เป็นคอลัมน์เดียวบนจอแคบ เพราะพ่อแม่ไม่ยอมบอกความกว้างที่แท้จริงให้ */
.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; min-width: 0; }

.tile {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
}

.tile-label { font-size: 0.72rem; color: var(--ink-600); font-weight: 600; }
.tile-value { font-size: 1.6rem; font-weight: 800; color: var(--teal-900); margin: 4px 0 4px; }
.tile-value-critical { color: var(--status-critical); }
.tile-value-warning { color: var(--status-warning); }
.tile-detail { font-size: 0.68rem; color: var(--ink-400); line-height: 1.5; }

#vitals .tile-value { font-size: 2rem; }
#vitals .tile-detail { font-size: 0.78rem; line-height: 1.45; }
#vitals .tile { padding: 14px 10px; }

.stat-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 0.82rem; }
.stat-label { color: var(--ink-600); }
.stat-value { font-weight: 700; }
.stat-note { color: var(--ink-400); font-size: 0.75rem; }

/* แถบไล่สีเขียว-เหลือง-แดง บอกว่าค่าปัจจุบันอยู่ตรงไหนระหว่างปกติกับผิดปกติ (ใช้กับกลุ่มเก๊าท์)
   scale_pct มาจาก mock data เป็นตำแหน่งเปอร์เซ็นต์ที่กำหนดไว้ล่วงหน้า ไม่ได้คำนวณจากเกณฑ์จริงเพราะ
   ยังไม่มี threshold รูปแบบมาตรฐานเก็บไว้ในระบบ */
.stat-scale-bar {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #eab308, #dc2626);
  margin-top: 6px;
}
.stat-scale-marker {
  position: absolute;
  top: -13px;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: #111827;
  line-height: 1;
}

#gout .stat-scale-bar {
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
}
#gout .stat-scale-marker {
  top: -17px;
  font-size: 0.8rem;
}
.trend { font-size: 0.7rem; margin-left: 2px; }
.trend-sparkline { width: 28px; height: 16px; vertical-align: middle; margin-left: 4px; }
.trend-up { color: var(--status-critical); }
.trend-down { color: var(--status-good); }

.risk-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.75rem; color: var(--ink-600); }

.group-footnote { font-size: 0.75rem; color: var(--ink-600); background: var(--surface); padding: 8px 10px; border-radius: 8px; }

.chart-box { display: flex; justify-content: center; min-width: 0; }
.chart-box svg { width: 100%; max-width: 320px; height: auto; }


.split-bar { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.split-bar-legend { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 0.78rem; font-weight: 600; color: var(--ink-600); }
.split-bar-track { display: flex; height: 32px; border-radius: 999px; overflow: hidden; background: var(--border); }
.split-bar-fill {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
.split-good { background: var(--dash-target-green); }
.split-bad { background: var(--status-critical); }

/* ---------- side panel ---------- */

.side-panel { display: flex; flex-direction: column; gap: 6px; }
.panel-card { padding: 16px; }
.panel-card h3 { font-size: 0.85rem; font-weight: 700; margin-bottom: 12px; }
.panel-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-card-head h3 { margin: 0; }
.panel-card-mock-tag { font-size: 0.7rem; font-weight: 400; color: var(--ink-400); }
/* ไอคอนเดียวกับ .nav-svg-icon ใน _sidebar.html ต่อกลุ่มโรค — ให้ตรงกันทั้งแอปตามที่ผู้ใช้ขอ */
.panel-card-title-icon { display: inline-flex; vertical-align: -3px; margin-right: 4px; color: var(--teal-700); }

/* การ์ดรายกลุ่มโรคในแถบขวาของ Overview มี 4 การ์ด — ถ้าใช้ ".risk-tier-row" แบบเดิม (เรียงบรรทัดละ
   ระดับ ดู vitals_dashboard.html) ความสูงรวมจะเกินจอจนต้องเลื่อน scroll (ผู้ใช้ชี้ปัญหานี้มา) จึงบีบเป็น
   แถวแนวนอน 3 ก้อนต่อการ์ดแทน (ไอคอน+ตัวเลข+label สั้นๆ) ไม่ใช้ ".risk-tier-row" เดิมเลย */
.panel-card-compact { padding: 6px 10px; display: flex; flex-direction: column; }
.panel-card-compact h3 { font-size: 0.76rem; margin-bottom: 3px; line-height: 1.25; }

/* ".risk-tier-compact-row"/"-item" ยืดเต็มความสูงที่เหลือของการ์ด (flex:1 + stretch) แทนที่จะเป็นแถบ
   เตี้ยๆ ลอยอยู่กลางกล่องเปล่าๆ ด้านบน-ล่าง (ผู้ใช้ชี้ว่าดูไม่สวย) — ตัวเลข/ไอคอนจึงอยู่กึ่งกลางแนวตั้ง
   ของกล่องสีที่ขยายเต็มแล้วแทน */
.risk-tier-compact-row { display: flex; align-items: stretch; gap: 6px; flex: 1; min-height: 0; }
.risk-tier-compact-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 10px;
  border-left: none;
  text-align: center;
  text-decoration: none;
}
.risk-tier-compact-item.risk-tier-high { background: rgba(239, 68, 68, 0.07); }
.risk-tier-compact-item.risk-tier-medium { background: rgba(234, 179, 8, 0.08); }
.risk-tier-compact-item.risk-tier-low { background: rgba(34, 197, 94, 0.07); }
a.risk-tier-compact-item:hover { filter: brightness(0.96); }
/* ลดขนาด/ความอิ่มสีลงจากเดิม (1.2rem, พื้นหลังเข้มกว่านี้) — ยืนยันจากผู้ใช้ว่าตัวเลขใหญ่+สีจัดเกินไป
   จนดูดึงดูดสายตาเกินความจำเป็น แต่ยังคงความกว้าง/สัดส่วนกล่องเท่าเดิม ไม่ลดพื้นที่อ่านค่า */
.risk-tier-compact-icon { font-size: 1rem; line-height: 1; }
.risk-tier-compact-count { font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.risk-tier-compact-item.risk-tier-high .risk-tier-compact-count { color: var(--dash-sos); }
.risk-tier-compact-item.risk-tier-medium .risk-tier-compact-count { color: var(--dash-fall); }
.risk-tier-compact-item.risk-tier-low .risk-tier-compact-count { color: var(--dash-target-green); }
.risk-tier-compact-label { font-size: 0.72rem; color: var(--ink-600); white-space: nowrap; }

.link-muted { font-size: 0.78rem; color: var(--status-info); font-weight: 600; }

/* ---------- patient list (group detail page) ---------- */

.patient-list { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/*
  .patient-row เป็น flex column และลูกทุกตัว (id/stats/updated) เป็น flex item ที่ต้องกาง
  ให้เต็มความกว้าง flex/grid item ค่าเริ่มต้นคือ min-width:auto (ยึดความกว้างเนื้อหาข้างในเป็นอย่างน้อย)
  ถ้าไม่ set min-width:0 ทับไว้ทุกชั้น การ์ดจะดันกว้างเกินจอมือถือได้ (เจอจริงบนมือถือ ไม่ใช่แค่ทฤษฎี)
*/
.patient-row {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-left: 4px solid transparent;
  min-width: 0;
}

.status-edge-critical { border-left-color: var(--status-critical); }
.status-edge-warning { border-left-color: var(--status-warning); }
.status-edge-normal { border-left-color: var(--status-good); }

/* ระดับความเสี่ยง "ตามเคส" (core/services.py::case_level — high/medium/low จากเหตุการณ์จริง เกณฑ์
   เดียวกับหน้ารายงานผู้ป่วยเสี่ยงสูง) ใช้กับหน้ารายชื่อผู้ป่วยเท่านั้น (group_detail.html) — สีขอบใช้
   โทเคนเดียวกับ .status-edge-* เดิม (แดง/เหลือง/เขียว) ส่วนพื้นหลังใช้ค่าโปร่งแสงต่ำ (0.08-0.10 —
   ปรับตามที่ผู้ใช้ขอหลังลองที่ 0.10-0.13 แล้วเข้มไปนิด) ให้ยังอ่านตัวหนังสือ/ไอคอนในการ์ดออกชัดเจน
   ไม่ใช่สีทึบเหมือนป้าย hr-level-pill */
.risk-edge-high { border-left-color: var(--status-critical); }
.risk-edge-medium { border-left-color: var(--status-warning); }
.risk-edge-low { border-left-color: var(--status-good); }
.risk-edge-offline { border-left-color: var(--status-offline); }

.risk-bg-high { background: rgba(239, 68, 68, 0.1); }
.risk-bg-medium { background: rgba(234, 179, 8, 0.1); }
.risk-bg-low { background: rgba(34, 197, 94, 0.08); }
.risk-bg-offline { background: rgba(107, 114, 128, 0.08); }

.patient-row-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.patient-row-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.patient-name { font-size: 0.95rem; font-weight: 700; white-space: normal; overflow-wrap: break-word; }

/* ผู้ป่วยที่มีเคสค้างอยู่ (ทีมกู้ชีพยังไม่ปิด) — กระพริบทั้งการ์ดเป็นวงแหวนแดง (ไม่ใช่แค่ชื่อ — ลองแบบ
   กระพริบเฉพาะชื่อก่อนแล้วผู้ใช้แจ้งว่ามองข้ามง่ายไป การ์ดทั้งใบเห็นชัดกว่ามากในตารางที่มีหลายแถว)
   box-shadow ring แบบเดียวกับ sos-modal-pulse ของ popup กลางจอ แต่วงแคบกว่าเพราะการ์ดเล็กกว่ามาก */
.patient-row-blink {
  animation: patient-row-blink 1.1s ease-in-out infinite;
}

@keyframes patient-row-blink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.status-pill {
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  /* ไม่ใส่ nowrap: ข้อความแจ้งเตือนบางอันยาว (เช่น "SOS: ตรวจพบการล้ม") ถ้าบังคับบรรทัดเดียว
     จะดันความกว้างการ์ดทั้งใบเกินจอ ยอมให้ตัดบรรทัดเป็น 2 บรรทัดดีกว่า */
  max-width: 100%;
}

.status-critical { background: var(--status-critical); }
.status-warning { background: var(--status-warning); }
.status-normal { background: var(--status-good); }
/* ใช้กับ risk_level (build_patient_vitals_detail) — เสี่ยงต่ำ คนละสีกับ .status-warning/.status-critical
   ที่ patient.status ใช้อยู่แล้ว เพื่อแยกให้เห็นชัดว่าเป็นคนละความหมาย */
.status-info { background: var(--status-info); }

.abnormal-count {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--status-critical);
}

/* สถานะตัวนาฬิกา (แบต/สัญญาณ) ตั้งใจให้ตัวเล็กและจางกว่าค่าสัญญาณชีพ เพราะไม่ใช่ข้อมูลทางคลินิก
   บุคลากรไม่ควรเสียเวลาสแกนอ่านพร้อมกับค่าที่ตัดสินใจเรื่องคนไข้ได้ */
.device-status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.68rem;
  color: var(--ink-400);
}

.patient-row-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  min-width: 0;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 0;
}

.stat-chip-abnormal {
  background: rgba(220, 38, 38, 0.08);
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.3);
}

/* การ์ดผู้ป่วยในหน้ารายชื่อมีพื้นหลังสีอ่อนตามระดับความเสี่ยงอยู่แล้ว (.risk-bg-*) — --surface เดิม
   (สีเทาอ่อนกลางๆ) ความสว่างใกล้กับสีพื้นหลังนั้นเกินไป ทำให้กล่องค่าสัญญาณชีพกลืนไปกับการ์ด ใช้สีเข้ม
   โปร่งแสงทับแทนแทนที่จะเลือกสีเทาคงที่ ให้ตัดกับพื้นหลังชัดเจนไม่ว่าการ์ดจะเป็นสีแดง/เหลือง/เขียว
   .stat-chip-abnormal ต้องมี selector 2 คลาสเท่ากัน (.patient-row .stat-chip-abnormal) ไม่งั้นแพ้
   specificity ให้ rule ด้านบนทั้งที่มาทีหลังในไฟล์ (สีแดงเตือนค่าผิดปกติจะหายไปเงียบๆ) */
.patient-row .stat-chip { background: rgba(17, 24, 39, 0.08); }
.patient-row .stat-chip-abnormal {
  background: rgba(220, 38, 38, 0.14);
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.4);
}

.stat-chip-icon { font-size: 1.05rem; flex: none; line-height: 1; }
.stat-chip-text { display: flex; flex-direction: column; min-width: 0; }
.stat-chip-value { font-size: 0.85rem; font-weight: 700; color: var(--ink-900); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-chip-label { font-size: 0.63rem; color: var(--ink-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.patient-row-updated { font-size: 0.7rem; color: var(--ink-400); display: flex; align-items: center; }
.patient-row-online { color: var(--status-good); font-weight: 600; }
.patient-row-online .dot { margin-right: 4px; }

.patient-row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* patient-row เป็น <a> คลิกได้ทั้งการ์ด ต้อง reset ให้ยังดูเป็น block/card เหมือนเดิม */
a.patient-row {
  display: flex;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

a.patient-row:hover,
a.patient-row:focus-visible {
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.12);
  transform: translateY(-1px);
}

/* ---------- ค้นหา/กรอง (หน้ารายชื่อผู้ป่วย) ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-input,
.filter-select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 42px;
  height: 42px;
  font-size: 0.88rem;
  line-height: 1.5;
  font-family: inherit;
  color: #0f172a;
  background: #ffffff;
  box-sizing: border-box;
}

.filter-input { flex: 1 1 200px; min-width: 0; }
.filter-select { flex: 0 0 auto; }
.filter-clear { flex: 0 0 auto; }

.btn-icon-submit {
  flex: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--card-bg);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.empty-state {
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--ink-600);
  font-size: 0.85rem;
}

/* ---------- หน้ารายละเอียดผู้ป่วยรายคน ---------- */

.patient-profile {
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-left: 4px solid transparent;
}

.open-case-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--status-critical);
  /* ย้ายมาอยู่นอก .patient-profile แล้ว (แสดงหลังการ์ด "ค่าล่าสุดจากนาฬิกา" แทนบนสุดของหน้า) เลยไม่ได้
     ระยะห่างจาก flex gap ของ .patient-profile อีกต่อไป ต้องกำหนดเอง ให้เท่ากับ .patient-current ฯลฯ */
  margin-top: 14px;
}

.open-case-banner form { flex: none; }

/* แบนเนอร์ "ติดตามด่วน/ทบทวนเคส" บนหน้า patient_detail — ย้ายมาจากคอลัมน์ Action เดิมของหน้ารายงาน
   ผู้ป่วยเสี่ยงสูง ใช้โครง flex เดียวกับ .open-case-banner ด้านบน ต่างกันแค่สี (แดง=เกิน SLA ต้องรีบ,
   เหลือง=ถึงเกณฑ์ทบทวนเคส ไม่เร่งด่วนเท่า) */
.risk-followup-banner,
.risk-reassess-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.8rem;
  margin-top: 14px;
}
.risk-followup-banner form,
.risk-reassess-banner form { flex: none; }

.risk-followup-banner {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: var(--status-critical);
}

.risk-reassess-banner {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.5);
  color: #92400e;
}

.btn-risk-reassess { background: #eab308; color: #1f2937; }

.risk-note-link { display: inline-block; margin-top: 14px; font-size: 0.8rem; }

.patient-profile-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.patient-profile-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.patient-profile .patient-name { font-size: 1.1rem; }

.avatar-lg { width: 52px; height: 52px; font-size: 1.05rem; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; flex: none; }

.profile-fact-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.profile-fact {
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-fact-label { font-size: 0.65rem; color: var(--ink-600); }
.profile-fact-value { font-size: 0.85rem; font-weight: 700; }

.patient-current,
.patient-history,
.patient-vital-history,
.patient-location {
  padding: 16px;
  margin-top: 14px;
}

.section-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 12px; }

.location-coords { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.location-updated { font-size: 0.78rem; color: var(--ink-600); margin-bottom: 10px; }

.patient-row-stats-standalone { grid-template-columns: repeat(2, 1fr); }

.history-table-wrap { overflow-x: auto; }

.history-table { border-collapse: collapse; width: 100%; font-size: 0.78rem; white-space: nowrap; }
.history-table th,
.history-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.history-table th { color: var(--ink-600); font-weight: 600; font-size: 0.72rem; }
.history-table tbody tr:first-child td { font-weight: 700; }

.vital-history-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.vital-history-header .section-title { margin-bottom: 0; }
.vital-history-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.akr-btn-refresh {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--ink-900);
  cursor: pointer;
}
.akr-btn-refresh:hover { border-color: var(--status-info); color: var(--status-info); }

/* สลับ "ประวัติ"/"วิเคราะห์สุขภาพ" ด้วย radio ล้วนๆ (ไซต์นี้ไม่มี JS ตามกติกาเดิม — เหมือน mobile nav
   drawer ที่ใช้ checkbox hack) .vital-tab-radio ซ่อนไว้ ให้ label ทำหน้าที่เป็นปุ่มแท็บแทน */
.vital-tab-radio { position: absolute; opacity: 0; pointer-events: none; }
.vital-tab-switch { display: flex; gap: 4px; background: var(--surface); border-radius: 999px; padding: 3px; }
.vital-tab-label {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-600);
  cursor: pointer;
  white-space: nowrap;
}
#vital-tab-history:checked ~ .vital-history-header .vital-tab-label[for="vital-tab-history"],
#vital-tab-summary:checked ~ .vital-history-header .vital-tab-label[for="vital-tab-summary"] {
  background: var(--card-bg);
  color: var(--teal-900);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1);
}
.vital-tab-panel-summary { display: none; }
#vital-tab-summary:checked ~ .vital-tab-panel-history { display: none; }
#vital-tab-summary:checked ~ .vital-tab-panel-summary { display: block; }

/* ---------- สรุปผลวิเคราะห์สุขภาพ (build_health_summary) ---------- */
.health-summary-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface);
}
.health-summary-banner-text { font-size: 0.85rem; color: var(--ink-900); line-height: 1.6; }
.health-summary-news2-period { display: block; margin-top: 3px; color: var(--ink-600); font-size: 0.76rem; }
.health-summary-status-pill {
  flex: none;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.health-summary-status-normal { background: #ecfdf5; color: var(--teal-900); }
.health-summary-status-watch { background: #fef9c3; color: #854d0e; }
.health-summary-status-critical { background: #fee2e2; color: var(--status-critical); }
.health-summary-banner-normal { border-left: 4px solid var(--status-good); }
.health-summary-banner-watch { border-left: 4px solid var(--status-warning); }
.health-summary-banner-critical { border-left: 4px solid var(--status-critical); }

.health-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}
@media (min-width: 700px) {
  .health-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.health-summary-tile {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafbfc;
}
.health-summary-tile-watch { background: #fffbeb; border-color: #fde68a; }
.health-summary-tile-critical { background: #fef2f2; border-color: #fecaca; }
.health-summary-tile-icon { flex: none; font-size: 1.05rem; margin-top: 1px; }
.health-summary-tile-body { flex: 1; min-width: 0; }
.health-summary-tile-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  margin-bottom: 3px;
}
.health-summary-tile-label { font-size: 0.82rem; font-weight: 700; color: var(--ink-900); }
.health-summary-tile-value { font-size: 0.78rem; font-weight: 600; color: var(--ink-600); font-variant-numeric: tabular-nums; }
.health-summary-tile-sentence { font-size: 0.82rem; color: var(--ink-600); line-height: 1.55; }
.health-summary-tile-range { font-size: 0.74rem; color: var(--ink-400); margin-top: 2px; font-variant-numeric: tabular-nums; }
.health-summary-trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 6px;
}
/* ยืนยันจากผู้ใช้: สีของป้ายแนวโน้มต้องขึ้นกับว่าทิศทางนั้นน่ากังวลจริงไหม (trend_is_concerning จาก
   build_health_summary) ไม่ใช่ up=เหลืองเสมอ/down=เหลืองเสมอแบบเดิม — อุณหภูมิลดลงคือปลอดภัย (เขียว)
   แต่เพิ่มขึ้นน่ากังวล (เหลือง), SpO2 กลับด้านกัน ป้ายแนวโน้มไม่ใช้สีแดงเพื่อไม่ให้ความหมาย "แดง=ผิดปกติ
   ตอนนี้จริง" ของการ์ดเจือจางลง */
.health-summary-trend-concerning { background: #fef9c3; color: #854d0e; }
.health-summary-trend-safe { background: #ecfdf5; color: var(--teal-900); }
.health-summary-trend-stable { background: #ecfdf5; color: var(--teal-900); }

.health-summary-abnormal-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.health-summary-abnormal-list-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-400);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.health-summary-abnormal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.76rem;
}
.health-summary-abnormal-time { color: var(--ink-600); font-variant-numeric: tabular-nums; }
/* ค่า+ส่วนต่างจากเกณฑ์ต้องอยู่ติดกันเสมอ (คนละความหมายกับเวลา) — margin-left:auto ดันไปชิดขวาตอนพอที่
   แต่พอพื้นที่ไม่พอ (จอแคบ) ทั้งคู่ตกไปบรรทัดใหม่ด้วยกัน ไม่ใช่แยกกันคนละบรรทัดแบบสุ่มเหมือนก่อนหน้านี้
   (ยืนยันจากผู้ใช้ให้ปรับ responsive หน้านี้) */
.health-summary-abnormal-reading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
}
.health-summary-abnormal-value {
  font-weight: 700;
  color: var(--status-critical);
  font-variant-numeric: tabular-nums;
}
.health-summary-abnormal-delta { color: var(--status-critical); font-variant-numeric: tabular-nums; }

@media (max-width: 420px) {
  .health-summary-tile { padding: 10px 12px; gap: 10px; }
  .health-summary-abnormal-row { font-size: 0.72rem; padding: 6px 8px; }
  .health-summary-abnormal-reading { margin-left: 0; width: 100%; justify-content: space-between; }
}

.health-summary-watchbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.82rem;
  color: #78350f;
  line-height: 1.6;
  margin-top: 14px;
}

.health-summary-disclaimer {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.72rem;
  color: var(--ink-400);
  line-height: 1.6;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  margin-top: 14px;
}

.vital-chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 14px;
}
@media (min-width: 860px) {
  .vital-chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.vital-chart-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.vital-chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.vital-chart-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  font-size: 0.76rem;
  color: var(--ink-600);
}
.vital-chart-legend .dot { margin-right: 4px; }
.vital-chart-title { font-size: 0.85rem; font-weight: 700; }
.vital-chart-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.vital-chart-badge-bp { background: rgba(13, 148, 136, 0.12); color: var(--status-good); }
.vital-chart-badge-hr { background: rgba(220, 38, 38, 0.1); color: var(--status-critical); }
.vital-chart-badge-spo2 { background: rgba(37, 99, 235, 0.12); color: var(--status-info); }
.vital-chart-badge-temp { background: rgba(234, 88, 12, 0.12); color: #c2410c; }

.vital-chart svg { width: 100%; height: auto; display: block; }
.vital-chart-line { stroke-width: 2.5; }
.vital-chart-line-sys { stroke: var(--status-good); }
.vital-chart-line-dia { stroke: var(--status-warning); }
.vital-chart-line-hr { stroke: var(--status-critical); }
.vital-chart-line-spo2 { stroke: var(--status-info); }
.vital-chart-line-temp { stroke: #c2410c; }
/* จุดกราฟ (circle) ถูกเอาออกจาก SVG แล้วตามที่ผู้ใช้ยืนยัน — เหลือแค่สีสวอตช์ของ legend (<i> ธรรมดา ใช้
   background เท่านั้น ไม่ใช่ fill เพราะ HTML element ไม่รู้จัก fill) */
.vital-chart-dot-sys { background: var(--status-good); }
.vital-chart-dot-dia { background: var(--status-warning); }
.vital-chart-dot-hr { background: var(--status-critical); }
.vital-chart-dot-spo2 { background: var(--status-info); }
.vital-chart-dot-temp { background: #c2410c; }

.vital-chart-mini-table-wrap { margin-top: 12px; max-height: 220px; overflow-y: auto; }
.vital-chart-mini-table th { position: sticky; top: 0; background: var(--card-bg); }

/* ---------- >=1024px: fixed sidebar + right panel, matches the reference layout ---------- */

@media (min-width: 1024px) {
  .drawer-backdrop { display: none !important; }
  .hamburger-btn { display: none; }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    transform: none;
    grid-row: 1 / -1;
  }

  .shell {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: auto 1fr;
  }

  /* modal SOS/ล้ม/สัญญาณชีพผิดปกติ (.sos-modal-backdrop) เป็น position:fixed ไม่กินพื้นที่ grid เลย
     (ต่างจาก .alert-banner เดิมที่เคยเป็นแถวบนสุดของ .shell และต้องกันแถวเปล่าไว้เผื่อไม่มีแบนเนอร์)
     จึงเหลือแค่ 2 แถว: topbar แล้วก็ content */
  .topbar {
    grid-column: 2;
    grid-row: 1;
  }

  .content { grid-column: 2; grid-row: 2; padding: 24px 28px; }

  .content-row { display: grid; grid-template-columns: 1fr var(--panel-w); gap: 20px; align-items: start; }

  .group-grid { grid-template-columns: 1fr 1fr; }

  .side-panel { position: sticky; top: 20px; }

  .patient-row {
    flex-direction: row;
    align-items: center;
    gap: 20px;
  }

  .patient-row-id { flex: 0 0 260px; }

  .patient-row-stats {
    flex: 1;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .patient-row-footer { flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 4px; }
  .patient-row-updated { white-space: nowrap; }

  .profile-fact-row { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Overview desktop layout: เต็มหน้า + กล่องเท่ากัน + กระจายเนื้อหา ---------- */

@media (min-width: 1024px) {
  .overview-shell {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
  }

  .overview-shell .topbar {
    padding: 2px 14px;
    height: 38px;
    flex: 0 0 38px;
    box-sizing: border-box;
  }
  .overview-shell .topbar-brand h1 {
    font-size: 0.82rem;
    font-weight: 700;
  }
  .overview-shell .topbar-user-pill {
    padding: 1px 6px;
    border-radius: 999px;
  }
  .overview-shell .topbar-user-name {
    font-size: 0.72rem;
    max-width: 90px;
  }
  .overview-shell .topbar-user-dropdown .avatar-sm {
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
  }
  .overview-shell .icon-btn {
    font-size: 0.9rem;
  }

  .overview-shell .content {
    height: calc(100vh - 38px);
    max-height: calc(100vh - 38px);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 3px 10px 6px;
    gap: 3px;
    overflow: hidden;
    box-sizing: border-box;
  }

  .overview-shell .content-row {
    flex: 1;
    align-items: stretch;
    gap: 5px;
    min-height: 0;
  }

  .overview-shell .groups {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .overview-shell .group-grid {
    flex: 1;
    min-height: 0;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .overview-shell .group-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .overview-shell .group-card-head {
    padding: 4px 10px;
  }

  .overview-shell .group-card-head h3 {
    font-size: 0.86rem;
  }

  .overview-shell .group-card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 3px;
    padding: 4px 6px;
  }

  .overview-shell #cardio .chart-box,
  .overview-shell #gout .chart-box {
    max-height: 240px;
  }

  .overview-shell #cardio .chart-box svg,
  .overview-shell #gout .chart-box svg {
    max-height: 240px;
    max-width: 240px;
    width: 100%;
    height: 100%;
  }

  .overview-shell .split-bar {
    margin-top: auto;
    gap: 2px;
  }

  .overview-shell .split-bar-track {
    height: 20px;
  }

  .overview-shell .split-bar-legend {
    font-size: 0.64rem;
  }

  .overview-shell .split-bar-fill {
    font-size: 0.64rem;
  }

  /* กล่องซ้ายบน: 3 tiles เรียงแถวเดียว */
  .overview-shell #vitals .tile-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .overview-shell #vitals .tile {
    padding: 4px 6px;
  }

  .overview-shell .tile-value {
    font-size: 1.05rem;
  }

  .overview-shell .tile-detail {
    font-size: 0.56rem;
    line-height: 1.2;
  }

  .overview-shell .stat-row {
    font-size: 0.72rem;
  }

  .overview-shell .stat-value {
    font-size: 0.85rem;
  }

  .overview-shell .side-panel {
    display: grid;
    /* เดิม repeat(4, minmax(0, 1fr)) บังคับทุกการ์ดสูงเท่ากันเสมอ (เต็ม 1/4 ของพื้นที่จอเสมอ แม้เนื้อหา
       จะสั้นกว่านั้นมาก) — เปลี่ยนเป็น auto ให้แต่ละการ์ดสูงตามเนื้อหาจริง (ยืนยันจากผู้ใช้ให้บาลานซ์
       สัดส่วนกว้าง/สูงใหม่ตอนลดความกว้างแผงเหลือ 270px ไม่งั้นกล่องจะกว้างแคบแต่สูงเท่าเดิม ดูยืดเป็นแท่ง)
       ที่ว่างที่เหลือไปกองอยู่ท้ายแผงแทนที่จะยืดทุกการ์ดให้เต็ม */
    grid-template-rows: repeat(4, auto);
    gap: 14px;
    align-content: start;
    min-height: 0;
  }

  .overview-shell .panel-card {
    min-height: 0;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
  }

  .overview-shell .panel-card h3 {
    font-size: 0.92rem;
    margin-bottom: 4px;
    line-height: 1.3;
  }

  .overview-shell .panel-card-title-icon svg { width: 14px; height: 14px; }

  .overview-shell .risk-tier-compact-item { padding: 3px 2px; font-size: 0.7rem; }
}

/* ---------- หน้า dashboard กลุ่ม 1 (ติดตามสัญญาณชีพ) — การ์ดรายงาน/กราฟแท่ง/ผู้ป่วยเสี่ยงสูง
   ธีมขาวให้ตรงกับหน้า Overview ตามที่ผู้ใช้ยืนยัน (เดิมเคยเป็นกรมท่าเข้ม) — คงกรอบ/ไอคอนสี
   ตามหมวด (เหลือง/ส้ม/แดง) ไว้เหมือนเดิม เปลี่ยนแค่พื้นหลัง/สีตัวอักษรของการ์ดให้เป็นโทนสว่าง */

:root {
  --dash-navy: var(--card-bg);
  --dash-navy-soft: var(--border);
  --dash-fall: #eab308;
  --dash-vital: #f97316;
  --dash-sos: #ef4444;
  --dash-info-purple: #8b5cf6;
  --dash-target-green: #22c55e;
}

.report-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 16px;
  min-width: 0;
}

.report-row-secondary { grid-template-columns: 1fr; }

.report-card, .trend-card, .high-risk-card, .target-group-card {
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  min-width: 0;
  box-sizing: border-box;
  background: #ffffff;
  color: var(--ink-900);
  border-radius: 16px;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.05);
  border: 1px solid #e5e7eb;
  border-left: 4px solid var(--teal-700);
}

.report-card-fall,
.report-card-vital,
.report-card-sos,
.trend-card,
.high-risk-card,
.target-group-card {
  border: 1px solid #e5e7eb;
  border-left: 4px solid var(--teal-700);
}

.report-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.report-card-icon {
  flex: none;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  box-shadow: none !important;
}
.report-card-icon svg, .report-card-icon-img { width: 46px; height: 46px; object-fit: contain; display: block; }

.report-card-icon-fall, .report-card-fall .report-card-icon { background: transparent; }
.report-card-icon-vital, .report-card-vital .report-card-icon { background: transparent; }
.report-card-icon-sos, .report-card-sos .report-card-icon { background: transparent; }
.report-card-icon-trend, .trend-card .report-card-icon { background: transparent; }
.report-card-icon-highrisk, .high-risk-card .report-card-icon { background: transparent; }
.report-card-icon-target, .target-group-card .report-card-icon { background: transparent; }

.report-card-title { font-weight: 800; font-size: 0.96rem; color: #0a1830; letter-spacing: -0.01em; }
.report-card-subtitle { color: #64748b; font-size: 0.75rem; font-weight: 500; margin-top: 1px; }

.report-card-badge {
  margin-left: auto;
  flex: none;
  padding: 5px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

.report-card-badge-fall { background: #fbbf24; color: #000000; }
.report-card-badge-vital { background: #f97316; color: #ffffff; }
.report-card-badge-sos { background: #ef4444; color: #ffffff; }
.report-card-badge-target { background: #14b8a6; color: #ffffff; }

.report-chart { margin-top: 16px; min-width: 0; }
.report-chart svg { width: 100%; height: auto; display: block; }

.report-chart-with-axis { display: flex; align-items: stretch; gap: 6px; }
.chart-y-axis-labels {
  flex: none;
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
  padding: 1px 0;
  font-size: 0.62rem;
  color: var(--ink-400);
  text-align: right;
}
.report-chart-body { flex: 1; min-width: 0; }

.report-card-footer-link {
  display: block;
  margin-top: auto;
  padding-top: 14px;
  color: var(--status-info);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.report-card-footer-link:hover { text-decoration: underline; }

.report-card-footer-btn {
  display: block;
  margin-top: auto;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid #22d3ee;
  background: #ffffff;
  color: #0891b2;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.report-card-footer-btn:hover { background: #ecfeff; border-color: #06b6d4; color: #0e7490; }

.risk-footer-btn {
  background: #f5f3ff;
  border: 1.5px solid #c4b5fd;
  color: #7c3aed;
}
.risk-footer-btn:hover {
  background: #7c3aed;
  color: #ffffff;
  border-color: #7c3aed;
}

.chart-gridline { stroke: rgba(17, 24, 39, 0.08); stroke-width: 1; }

.bar.bar-fall { fill: #f59e0b; }
.bar.bar-vital { fill: #f97316; }
.bar.bar-sos { fill: #ef4444; }
.bar-label { font-size: 7px; fill: var(--ink-600); font-weight: 700; }

.report-chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.65rem;
  color: var(--ink-400);
}
.report-chart-axis span { flex: 1; text-align: center; }

.trend-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--ink-600);
}
.trend-legend .dot { margin-right: 5px; vertical-align: middle; }
/* fill (SVG) ไม่ใช่ background — ดูคอมเมนต์ใน trend_report.html ตรงจุด legend สำหรับสาเหตุ */
.trend-legend .legend-dot-fall { fill: #f59e0b; }
.trend-legend .legend-dot-vital { fill: #f97316; }
.trend-legend .legend-dot-sos { fill: #ef4444; }

.high-risk-summary-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #6b7280;
  margin: 12px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.high-risk-summary-news2 {
  font-weight: 700;
  color: #1f2937;
}

.risk-tier-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

.risk-tier-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid #e2e8f0;
  border-left: 4px solid transparent;
  box-sizing: border-box;
  overflow: hidden;
}
.risk-tier-high { border-left-color: #ef4444; background: #fef2f2; border-color: #fecaca; }
.risk-tier-medium { border-left-color: #eab308; background: #fefce8; border-color: #fef08a; }
.risk-tier-low { border-left-color: #22c55e; background: #f0fdf4; border-color: #bbf7d0; }

.risk-tier-row-icon { flex: none; font-size: 1.15rem; line-height: 1; }
.risk-tier-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.risk-tier-row-top { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.risk-tier-row-label { font-size: 0.88rem; font-weight: 800; line-height: 1.1; margin: 0; }
.risk-tier-high .risk-tier-row-label { color: #dc2626; }
.risk-tier-medium .risk-tier-row-label { color: #ca8a04; }
.risk-tier-low .risk-tier-row-label { color: #16a34a; }
.risk-tier-row-count { font-size: 0.78rem; color: #334155; font-weight: 600; line-height: 1.1; margin: 0; }
.risk-tier-row-response {
  font-size: 0.68rem;
  color: #475569;
  line-height: 1.25;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.risk-tier-row-action {
  flex: none;
  padding: 5px 14px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-size: 0.76rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.15s ease;
}
.risk-tier-row-action:hover { border-color: #2563eb; color: #ffffff; background: #2563eb; }

/* Target Group Card Warning Banner */
.target-group-warning {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  font-size: 0.82rem;
  font-weight: 700;
}

.target-group-list-wrap {
  margin-top: 10px;
  min-width: 0;
  overflow-x: auto;
}

.target-group-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  font-size: 0.8rem;
}
.target-group-table th {
  text-align: left;
  color: #111827;
  font-weight: 700;
  padding: 6px 4px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}
.target-group-table-unit {
  display: block;
  font-size: 0.7em;
  font-weight: 400;
  color: #9ca3af;
}
.target-group-table td {
  padding: 11px 4px;
  white-space: nowrap;
  color: #111827;
  font-weight: 700;
  border-top: 2px solid transparent;
  border-bottom: 2px solid transparent;
}
.target-group-table td:first-child {
  border-left: 4px solid transparent;
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  padding-left: 10px;
}
.target-group-table td:last-child {
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  padding-right: 10px;
}
.target-group-table tr.risk-bg-high,
.target-group-table tr.risk-bg-medium,
.target-group-table tr.risk-bg-low,
.target-group-table tr.risk-bg-offline {
  background: transparent;
}
.target-group-table tr.risk-bg-high td { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.1); }
.target-group-table tr.risk-bg-medium td { background: rgba(234, 179, 8, 0.1); border-color: rgba(234, 179, 8, 0.1); }
.target-group-table tr.risk-bg-low td { background: rgba(34, 197, 94, 0.08); border-color: rgba(34, 197, 94, 0.08); }
.target-group-table tr.risk-bg-offline td { background: rgba(107, 114, 128, 0.08); border-color: rgba(107, 114, 128, 0.08); }
.target-group-table tr.risk-bg-high td:first-child { border-left-color: var(--status-critical); }
.target-group-table tr.risk-bg-medium td:first-child { border-left-color: var(--status-warning); }
.target-group-table tr.risk-bg-low td:first-child { border-left-color: var(--status-good); }
.target-group-table tr.risk-bg-offline td:first-child { border-left-color: var(--status-offline); }
.hr-level-dot-high { background: var(--status-critical); }
.hr-level-dot-medium { background: var(--status-warning); }
.hr-level-dot-low { background: var(--status-good); }
.hr-level-dot-offline { background: var(--status-offline); }

.patient-name-cell {
  font-weight: 600;
  color: #1f2937;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-block {
  display: block;
  text-align: center;
  margin-top: auto;
  padding: 10px 0;
  border-radius: 999px;
  background: #14b8a6;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
}
.btn-block:hover { background: #0d9488; }

@media (min-width: 1024px) {
  .report-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* เท่ากับแถวบนเสมอ ไม่ใช้ 1.2fr ให้แถวบน/ล่าง เพื่อให้เส้นแบ่งการ์ดตรงกันเป็นตารางเดียวกัน */
  .report-row-secondary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- หน้าติดตามสัญญาณชีพ (vitals_dashboard.html) desktop: บีบให้พอดีจอเดียว ไม่ต้องเลื่อน
   scroll เมาส์ขึ้นลงทั้งหน้า (ผู้ใช้ชี้ปัญหาเดียวกับที่แก้ไว้แล้วในหน้า Overview — ดู .overview-shell
   ด้านบน) การ์ด "กลุ่มเป้าหมาย" (target-group-card) เป็นข้อยกเว้นเดียว — ตารางผู้ป่วยอาจมีแถวมากเกิน
   พื้นที่จริง จึงให้เลื่อนได้ "ภายในกล่องตัวเอง" แทนตัดข้อมูลทิ้ง ต่างจากทั้งหน้าที่ต้องไม่มี scroll เลย */
@media (min-width: 1024px) and (min-height: 680px) {
  .vitals-dashboard-shell .content {
    min-height: calc(100vh - 72px);
    max-height: calc(100vh - 72px);
    display: flex;
    flex-direction: column;
    padding: 6px 16px 10px;
    gap: 10px;
    overflow: hidden;
  }

  .vitals-dashboard-shell .topbar { padding: 4px 16px; }

  /* ทั้งแถวบนและแถบล่างแบ่งความสูง 50:50 เท่ากันสมบูรณ์แบบ */
  .vitals-dashboard-shell .report-row {
    flex: 1;
    min-height: 0;
    gap: 10px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* การ์ดทั้ง 6 กล่องขยายเต็มพื้นที่ความสูงอย่างสมดุลเท่ากันทุกกล่อง */
  .vitals-dashboard-shell .report-card,
  .vitals-dashboard-shell .trend-card,
  .vitals-dashboard-shell .high-risk-card,
  .vitals-dashboard-shell .target-group-card {
    height: 100%;
    min-height: 0;
    padding: 12px 16px;
    box-sizing: border-box;
  }

  .vitals-dashboard-shell .report-card-icon { width: 48px; height: 48px; background: transparent !important; box-shadow: none !important; }
  .vitals-dashboard-shell .report-card-icon svg, .vitals-dashboard-shell .report-card-icon-img { width: 44px; height: 44px; object-fit: contain; }
  .vitals-dashboard-shell .report-card-title { font-size: 0.88rem; font-weight: 800; color: #0a1830; }
  .vitals-dashboard-shell .report-card-subtitle { font-size: 0.68rem; color: #475569; font-weight: 600; }
  .vitals-dashboard-shell .report-card-badge { padding: 4px 12px; font-size: 0.72rem; }

  .vitals-dashboard-shell .report-chart { flex: 1; min-height: 0; margin-top: 6px; margin-bottom: 8px; }
  .vitals-dashboard-shell .report-chart-body { display: flex; flex-direction: column; min-height: 0; }
  .vitals-dashboard-shell .report-chart svg { flex: 1; min-height: 0; width: 100%; height: auto; }
  .vitals-dashboard-shell .report-chart-axis { margin-top: 4px; flex: none; }

  .vitals-dashboard-shell .trend-legend { margin-top: 6px; font-size: 0.7rem; }

  .vitals-dashboard-shell .high-risk-summary-title { margin: 4px 0 4px; font-size: 0.8rem; }

  .vitals-dashboard-shell .risk-tier-list { gap: 6px; margin-top: 4px; flex: 1; min-height: 0; }
  .vitals-dashboard-shell .risk-tier-row { flex: 1; min-height: 0; padding: 5px 10px; gap: 8px; box-sizing: border-box; }
  .vitals-dashboard-shell .risk-tier-row-icon { font-size: 1rem; }
  .vitals-dashboard-shell .risk-tier-row-label { font-size: 0.78rem; margin: 0; }
  .vitals-dashboard-shell .risk-tier-row-count { font-size: 0.7rem; margin: 0; }
  .vitals-dashboard-shell .risk-tier-row-response { font-size: 0.6rem; line-height: 1.2; }
  .vitals-dashboard-shell .risk-tier-row-action { padding: 4px 10px; font-size: 0.68rem; }

  .vitals-dashboard-shell .report-card-footer-link,
  .vitals-dashboard-shell .report-card-footer-btn {
    margin-top: 8px;
    padding-top: 6px;
    font-size: 0.75rem;
  }

  .vitals-dashboard-shell .target-group-warning { margin-top: 6px; padding: 6px 10px; font-size: 0.7rem; }
  .vitals-dashboard-shell .target-group-list-wrap {
    margin-top: 6px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  .vitals-dashboard-shell .target-group-table th { padding: 6px; font-size: 0.72rem; }
  .vitals-dashboard-shell .target-group-table td { padding: 7px 6px; font-size: 0.75rem; }
  .vitals-dashboard-shell .target-group-table-unit { font-size: 0.85em; }

  .vitals-dashboard-shell .btn-block { margin-top: 8px; padding: 8px 0; font-size: 0.8rem; }
}

/* ---------- หน้าแนวโน้มการเกิดเหตุ (trend_report.html) desktop: บีบทั้งหน้าให้พอดีจอเดียว
   ไม่ต้องเลื่อน scroll เมาส์ เหมือนที่ทำไว้แล้วกับ .overview-shell/.vitals-dashboard-shell ด้านบน
   หัวข้อ/สถิติสรุป/กราฟ/แนวโน้มสำคัญ บีบพื้นที่ให้พอดีบนจอเดียวกันหมด กราฟใช้ flex ขยายเต็มพื้นที่ที่เหลือ */
@media (min-width: 1024px) and (min-height: 680px) {
  .trend-report-shell .content {
    height: calc(100vh - 61px);
    max-height: calc(100vh - 61px);
    display: flex;
    flex-direction: column;
    padding: 10px 24px 12px;
    gap: 8px;
    overflow: hidden;
    box-sizing: border-box;
  }

  .trend-report-shell .topbar { padding: 6px 24px; }

  .trend-report-shell .akr-header { margin-bottom: 0; flex: none; }
  .trend-report-shell .hr-scope-note { margin: 0; font-size: 0.72rem; flex: none; }

  .trend-report-shell .akr-stat-row { margin-bottom: 0; flex: none; }
  .trend-report-shell .akr-stat-card { padding: 10px 16px; }

  .trend-report-shell .trend-report-chart-card {
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
  .trend-report-shell .trend-legend { flex: none; margin-bottom: 4px; }
  .trend-report-shell .report-chart { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 0; }
  .trend-report-shell .report-chart svg { flex: 1; min-height: 0; width: 100%; height: auto; }
  .trend-report-shell .report-chart-axis { flex: none; }

  .trend-report-shell .trend-insight-row { margin-bottom: 0; flex: none; }
  .trend-report-shell .trend-insight-card { padding: 10px 14px; }
}

/* ---------- หน้ารายละเอียดเหตุการณ์รายตัว (Fall/Vital Signs/SOS Alert Report) ที่กดเข้าจาก
   การ์ดสรุปในหน้า dashboard กลุ่ม 1 — ธีมเดียวกับการ์ด dashboard (กรมท่าเข้ม + สีตามหมวด) ---------- */

.akr-page { min-width: 0; }

.akr-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.akr-header-title { display: flex; align-items: center; gap: 12px; min-width: 0; }

.akr-header-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
}
.akr-fall .akr-header-icon { background: rgba(234, 179, 8, 0.15); border: 2px solid var(--dash-fall); }
.akr-vital .akr-header-icon { background: rgba(249, 115, 22, 0.15); border: 2px solid var(--dash-vital); }
.akr-sos .akr-header-icon { background: rgba(239, 68, 68, 0.15); border: 2px solid var(--dash-sos); }

.akr-header-title h2 { font-size: 1.15rem; font-weight: 700; }
.akr-header-en { font-weight: 400; color: var(--ink-400); font-size: 0.85rem; }

.akr-range-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.akr-range-pill {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--dash-navy);
  border: 1px solid var(--border);
  color: var(--ink-900);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.akr-header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ปุ่มดาวโหลดรายงาน — ย้ายมาไว้ข้างกล่องช่วงวันที่แทนปุ่มที่เคยอยู่ท้ายหน้า ขนาด/รูปทรงตั้งใจให้ใกล้เคียง
   กับ .akr-range-pill เพื่อให้ดูเป็นกลุ่มเดียวกัน */
.akr-btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid #bfdbfe;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.akr-btn-download:hover { background: #bfdbfe; }

/* ไอคอน Lucide (SVG) ที่วางในบรรทัดเดียวกับข้อความ — ปุ่ม/ป้ายช่วงวันที่/ปุ่มพิมพ์ในหน้ารายงาน */
.akr-inline-icon { flex: none; vertical-align: -0.2em; }
.akr-range-pill { display: inline-flex; align-items: center; gap: 6px; }

.akr-stat-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.akr-stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--dash-navy);
  color: var(--ink-900);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

.akr-stat-icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
}

.akr-stat-icon-img { width: 30px; height: 30px; object-fit: contain; display: block; }

.akr-stat-total .akr-stat-icon { background: rgba(234, 179, 8, 0.15); border: 2px solid var(--dash-fall); }
.akr-fall .akr-stat-total .akr-stat-icon { background: rgba(234, 179, 8, 0.15); border: 2px solid var(--dash-fall); }
.akr-vital .akr-stat-total .akr-stat-icon { background: rgba(249, 115, 22, 0.15); border: 2px solid var(--dash-vital); }
.akr-sos .akr-stat-total .akr-stat-icon { background: rgba(239, 68, 68, 0.15); border: 2px solid var(--dash-sos); }
.akr-stat-handled .akr-stat-icon { background: rgba(34, 197, 94, 0.15); border: 2px solid var(--dash-target-green); }
.akr-stat-unhandled .akr-stat-icon { background: rgba(239, 68, 68, 0.15); border: 2px solid var(--dash-sos); }

.akr-stat-label { font-size: 0.78rem; color: var(--ink-600); margin-bottom: 2px; }
.akr-stat-value { font-size: 1.5rem; font-weight: 700; }
.akr-fall .akr-stat-total .akr-stat-value { color: var(--dash-fall); }
.akr-vital .akr-stat-total .akr-stat-value { color: var(--dash-vital); }
.akr-sos .akr-stat-total .akr-stat-value { color: var(--dash-sos); }
.akr-stat-handled .akr-stat-value { color: var(--dash-target-green); }
.akr-stat-unhandled .akr-stat-value { color: var(--dash-sos); }
.akr-stat-value span { font-size: 0.8rem; font-weight: 400; color: var(--ink-400); }

.akr-table-wrap {
  overflow-x: auto;
  background: var(--dash-navy);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

.akr-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; color: var(--ink-900); }
.akr-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--ink-600);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.akr-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.akr-table a { color: var(--status-info); font-weight: 600; }
.akr-elapsed-warning { color: var(--status-critical); font-weight: 700; }
.akr-detail-cell strong { color: var(--dash-vital); font-weight: 400; white-space: nowrap; line-height: 1.6; font-size: 0.9em; }

.akr-status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.akr-status-handled { background: rgba(34, 197, 94, 0.15); color: #15803d; }
.akr-status-unhandled { background: rgba(239, 68, 68, 0.15); color: #b91c1c; }

.akr-empty {
  background: var(--dash-navy);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-600);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}
.akr-empty-note { margin-top: 8px; font-size: 0.8rem; color: var(--ink-400); }
.akr-mock-notice {
  margin: 0 0 12px;
  padding: 8px 12px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 10px;
  color: #92400e;
}

@media (min-width: 720px) {
  .akr-stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.trend-report .akr-header-icon { background: rgba(37, 99, 235, 0.15); border: 2px solid var(--status-info); }

.trend-stat-fall .akr-stat-value { color: var(--dash-fall); }
.trend-stat-vital .akr-stat-value { color: var(--dash-vital); }
.trend-stat-sos .akr-stat-value { color: var(--dash-sos); }

.trend-stat-fall .akr-stat-icon { background: rgba(234, 179, 8, 0.15); border: 2px solid var(--dash-fall); }
.trend-stat-vital .akr-stat-icon { background: rgba(249, 115, 22, 0.15); border: 2px solid var(--dash-vital); }
.trend-stat-sos .akr-stat-icon { background: rgba(239, 68, 68, 0.15); border: 2px solid var(--dash-sos); }

.trend-report-chart-card {
  background: var(--dash-navy);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

.trend-report-chart-card .bar-label { font-size: 10px; }

.trend-insight-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.trend-insight-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 12px;
  background: var(--dash-navy);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-900);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

.trend-insight-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.trend-insight-label .trend-insight-icon { background: rgba(234, 179, 8, 0.15); border: 2px solid var(--dash-fall); }
.trend-insight-up .trend-insight-icon { background: rgba(239, 68, 68, 0.15); border: 2px solid var(--dash-sos); }
.trend-insight-down .trend-insight-icon { background: rgba(34, 197, 94, 0.15); border: 2px solid var(--dash-target-green); }
.trend-insight-flat .trend-insight-icon { background: rgba(37, 99, 235, 0.15); border: 2px solid var(--status-info); }

@media (min-width: 900px) {
  .trend-insight-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.akr-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.akr-btn-summary, .akr-btn-print {
  flex: 1;
  min-width: 160px;
  justify-content: center;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}
.akr-btn-summary { background: var(--dash-target-green); cursor: pointer; }
.akr-btn-print { background: var(--status-info); cursor: pointer; }

.high-risk-report .akr-header-icon { background: rgba(239, 68, 68, 0.15); border: 2px solid var(--dash-sos); color: #dc2626; }

.hr-stat-high .akr-stat-value { color: var(--dash-sos); }
.hr-stat-medium .akr-stat-value { color: var(--dash-fall); }
.hr-stat-low .akr-stat-value { color: var(--dash-target-green); }

/* Refactor: ไอคอนสถานะ NEWS2 (วิกฤต/เฝ้าระวัง/ปกติ) เลิกใช้อิโมจิ/กรอบสีเข้ม เปลี่ยนเป็นไอคอนเส้น
   (Lucide-style, stroke-width 2) บนพื้นสีอ่อน soft-tint (โทน 50) คู่กับสีไอคอน/ขอบเข้มกว่า (600/100)
   ให้ดู minimal สมกับ professional medical dashboard — ดู svg ที่แม็ปตาม card.level ใน
   high_risk_report.html */
.hr-stat-high .akr-stat-icon { background: #fef2f2; color: #dc2626; border: 1px solid #fee2e2; border-radius: 16px; }
.hr-stat-medium .akr-stat-icon { background: #fffbeb; color: #d97706; border: 1px solid #fef3c7; border-radius: 16px; }
.hr-stat-low .akr-stat-icon { background: #ecfdf5; color: #059669; border: 1px solid #d1fae5; border-radius: 16px; }

.hr-stat-active.hr-stat-high { box-shadow: 0 0 0 2px var(--dash-sos); }
.hr-stat-active.hr-stat-medium { box-shadow: 0 0 0 2px var(--dash-fall); }
.hr-stat-active.hr-stat-low { box-shadow: 0 0 0 2px var(--dash-target-green); }

.hr-scope-note { margin-bottom: 12px; }

.hr-level-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.hr-level-high { background: rgba(239, 68, 68, 0.15); color: #b91c1c; }
.hr-level-medium { background: rgba(234, 179, 8, 0.18); color: #92400e; }
.hr-level-low { background: rgba(34, 197, 94, 0.15); color: #15803d; }
/* ถอดนาฬิกา/ขาดการติดต่อ — เทา ตั้งใจแยกจาก 3 สีข้างบน (ดู --status-offline ใน :root) */
.hr-level-offline { background: rgba(107, 114, 128, 0.15); color: #374151; }
/* กำลังดำเนินการ (ทีมกู้ชีพระบุตัวตนแล้ว) — ดู .open-cases-item ด้านล่าง คนละความหมายกับระดับความเสี่ยง
   3 สีข้างบน จึงตั้งชื่อแยก ไม่ใช้ hr-level-medium (เหลือง สื่อ "ความเสี่ยง" ไม่ใช่ "กำลังทำงานอยู่") */
.hr-level-active { background: rgba(37, 99, 235, 0.15); color: #1d4ed8; }

.akr-table a.hr-detail-btn {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #38bdf8;
  padding: 7px 18px;
  font-size: 0.78rem;
  font-weight: 700;
}

.akr-table a.hr-detail-btn:hover { background: rgba(56, 189, 248, 0.22); }

/* คอลัมน์ "สถานะ" ของระบบติดตามผู้ป่วยกลุ่มเสี่ยง (SLA/Re-assess) — สีแยกจาก .hr-level-pill (ระดับ
   ความเสี่ยง NEWS2) ตั้งใจ เพราะเป็นคนละมิติกัน (ระดับความเสี่ยงทางคลินิก vs สถานะการตอบสนองของ
   เจ้าหน้าที่) */
.risk-sla-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.risk-sla-sla_breach { background: rgba(239, 68, 68, 0.15); color: #b91c1c; }
.risk-sla-reassess_due { background: rgba(234, 179, 8, 0.18); color: #92400e; }
.risk-sla-ok { background: rgba(34, 197, 94, 0.12); color: #15803d; }
.risk-sla-urgent { background: rgba(239, 68, 68, 0.15); color: #b91c1c; }
.risk-sla-watch { background: rgba(234, 179, 8, 0.18); color: #92400e; }
.risk-sla-normal { background: rgba(34, 197, 94, 0.12); color: #15803d; }

/* หน้ารายงานความเสี่ยงมีคอลัมน์เยอะกว่าตารางอื่นที่ใช้ .akr-table ร่วมกัน (open_case_tracking.html) —
   บีบ padding แนวนอน (ระยะห่างระหว่างคอลัมน์) เฉพาะตารางนี้ กันล้นจนต้องเลื่อนแนวนอนบนจอทั่วไป โดยไม่ลด
   ขนาดตัวอักษร (อ่านยาก) แทนที่จะบีบ .akr-table เองซึ่งจะกระทบตารางอื่นที่ไม่ได้มีปัญหานี้ — ค่าในตาราง
   จัดกึ่งกลางคอลัมน์ (ไม่ใช่ชิดซ้ายแบบ .akr-table ปกติ) ตามที่ผู้ใช้ขอ */
.high-risk-report .akr-table th,
.high-risk-report .akr-table td { padding: 8px 4px; text-align: center; }

/* ---------- หน้าเข้าสู่ระบบ / เปลี่ยนรหัสผ่าน (staff/templates/staff/) ----------
   ไม่มี .shell/sidebar/topbar เหมือนหน้าอื่น เพราะยังไม่รู้ว่าใครเป็นใครตอนอยู่หน้านี้ — การ์ดกลาง
   จอบนพื้นหลังไล่สีของแบรนด์ ใช้ .card เดิมเป็นฐาน */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--navy-900), var(--teal-900));
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 26px 26px;
  text-align: center;
}

.auth-logo { width: 128px; max-width: 60%; height: auto; margin-bottom: 18px; }
.auth-title { font-size: 1.1rem; font-weight: 700; }
.auth-sub { margin-top: 6px; font-size: 0.85rem; color: var(--ink-600); }

.auth-error {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.08);
  color: var(--status-critical);
  font-size: 0.82rem;
  text-align: left;
}

.auth-form { margin-top: 20px; text-align: left; }

.auth-label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-600);
}

.auth-input {
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--ink-900);
  font: inherit;
  font-size: 0.9rem;
}

.auth-input:focus { outline: 2px solid var(--status-info); outline-offset: 1px; }

.btn-auth-submit {
  width: 100%;
  margin-top: 6px;
  padding: 11px 18px;
  border: 0;
  background: var(--navy-700);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
}

.btn-auth-submit:hover { background: var(--navy-900); }

.auth-note { margin-top: 18px; font-size: 0.78rem; color: var(--ink-400); }

.auth-hint {
  margin-top: 18px;
  padding-left: 18px;
  list-style: disc;
  text-align: left;
  font-size: 0.78rem;
  color: var(--ink-600);
}

.auth-hint li { padding: 2px 0; }

/* ---------- พิมพ์ / Export Report (ปุ่ม "Export Report" เรียก window.print() ตรงๆ ไม่มี
   PDF library ฝั่งเซิร์ฟเวอร์ ใช้ browser save-as-PDF แทน ไม่ต้องเพิ่ม dependency ใหม่) ---------- */

@media print {
  .sidebar,
  .drawer-toggle,
  .drawer-backdrop,
  .hamburger-btn,
  .sos-modal-backdrop,
  .topbar-actions,
  .btn-export,
  .filter-bar,
  .link-muted,
  .akr-footer,
  .akr-range-form {
    display: none !important;
  }

  /* รายงานพิมพ์ต้องมีครบทุกคอลัมน์ (ยืนยันจากผู้ใช้ ไม่ตัดค่าใดออก) จึงลดขนาดตัวอักษร/ระยะห่างของตาราง
     รายงานความเสี่ยงและให้ป้ายในตารางขึ้นบรรทัดใหม่ได้ เพื่อให้ 8 คอลัมน์พอดีหน้ากระดาษแทนการซ่อนคอลัมน์ */
  .high-risk-report .akr-table { font-size: 0.7rem; }
  .high-risk-report .akr-table th,
  .high-risk-report .akr-table td { padding: 6px 3px; }
  .high-risk-report .akr-table .hr-level-pill,
  .high-risk-report .akr-table .risk-sla-pill { white-space: normal; text-align: center; padding: 3px 8px; }

  body { background: #fff; overflow-x: visible; }
  .shell { display: block; min-height: 0; }
  .content { padding: 0; }
  .content-row { display: block; }
  .group-grid { display: block; }
  .group-card { break-inside: avoid; margin-bottom: 16px; }
  .side-panel { margin-top: 16px; }
  .akr-table tr { break-inside: avoid; }

  /* browser ปิดพื้นหลัง/ไล่สีตอนพิมพ์เป็นค่าเริ่มต้น เพื่อประหยัดหมึก แต่หัวการ์ดกลุ่มโรค/การ์ดสรุปตัวเลข/
     ป้ายระดับความเสี่ยง/แท่งกราฟแนวโน้มของหน้ารายงาน (trend_report/high_risk_report และหน้าสรุป) ใช้สี
     เป็นตัวบอกความหมาย (ระดับวิกฤต/เฝ้าระวัง/ปกติ/ถอดนาฬิกา, ชนิดเหตุการณ์ในกราฟ) ต้องบังคับให้พิมพ์
     ออกมาจริงไม่งั้นจะอ่านความหมายไม่ออก — ใช้ * แทนไล่รายชื่อ class ทีละตัว (บั๊กจริงที่เจอ: รายชื่อเดิม
     ครอบแค่ .akr-stat-card/.hr-level-pill/.risk-sla-pill/.trend-insight-card เอง ไม่ครอบ
     .akr-stat-icon/.legend-dot-*/.bar (fill สี SVG ของแท่งกราฟ) เลยออกมาขาวดำ และพลาดง่ายทุกครั้งที่
     เพิ่ม element สีใหม่ เช่น .hr-level-offline — บังคับทั้งหน้าไปเลยตัดปัญหานี้ทั้งหมด) */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* บั๊กจริงที่เจอ (ยืนยันจากผู้ใช้): แม้ตั้ง print-color-adjust: exact ทั้งหน้าแล้ว เครื่องพิมพ์/ตัวแสดง
     ตัวอย่างก่อนพิมพ์ของบางเบราว์เซอร์ยังคงไม่แสดงพื้นหลังโปร่งแสง (rgba กับ alpha < 1) ของป้ายวงรีให้
     เต็มเหมือนบนจอ — เหลือแต่สีตัวอักษรเข้ม (เช่น #92400e ของ .hr-level-medium/.risk-sla-watch) ลอยอยู่
     บนพื้นขาวเปล่าๆ โดยไม่มีพื้นหลังเหลืองอ่อนช่วยให้ตีความสีถูก ทำให้ "เฝ้าระวัง" ดูเหมือนสีแดง/น้ำตาล
     ไม่ใช่เหลืองเหมือนตอนดูบนจอ ทั้งที่เป็นค่าสี/ระดับเดียวกันทุกประการ — บังคับพื้นหลังทึบกว่าเดิมเฉพาะ
     ตอนพิมพ์ (ไม่กระทบตอนดูบนจอปกติ) กันปัญหานี้แทนที่จะพึ่ง print-color-adjust อย่างเดียว */
  .hr-level-pill,
  .risk-sla-pill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 1px solid currentColor;
  }
  .hr-level-high,
  .risk-sla-sla_breach,
  .risk-sla-urgent { background: #fee2e2 !important; }
  .hr-level-medium,
  .risk-sla-reassess_due,
  .risk-sla-watch { background: #fef3c7 !important; }
  .hr-level-low,
  .risk-sla-ok,
  .risk-sla-normal { background: #dcfce7 !important; }
  .hr-level-offline { background: #e5e7eb !important; }
  .hr-level-active { background: #dbeafe !important; }
}
