/* Nurse Clock OS3 — components (card, tile, pill button, seg, chips, list, sheet, toast, switch, input, nav, badges, skeleton) */

/* ---------- หัวหน้าจอ ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 8px 0 16px; min-height: 60px; }
.top .sp { min-width: 0; }
.top h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eyebrow { font-size: 13px; color: var(--sub); font-weight: 500; line-height: 1.3; margin-bottom: 2px; }
.sec { display: flex; align-items: baseline; gap: 10px; margin: 22px 2px 10px; }
.sec h2 { flex: 1; font-size: 17px; }
.sec a, .sec .link { font-size: 14px; font-weight: 600; color: var(--accent); }

/* ---------- การ์ด ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 18px; box-shadow: var(--shadow); margin: 0 0 var(--gap); position: relative; min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card.tight { padding: 14px; }
.card.acc { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.card.acc .sub, .card.acc .num small, .card.acc .eyebrow { color: currentColor; opacity: .72; }
.card.lime { background: var(--lime); border-color: transparent; color: var(--on-lime); }
.card.lime .sub, .card.lime .num small, .card.lime .eyebrow { color: currentColor; opacity: .62; }
.card.soft { background: var(--accent-soft); border-color: var(--accent-line); }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 28px; }
.card-h h2, .card-h .t { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; }
.card-h .ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface2); color: var(--accent); flex: none; }
.card.tap { cursor: pointer; transition: transform var(--dur) var(--ease); }
.card.tap:active { transform: scale(.985); }

/* ---------- ไทล์ข้อมูล (ด้านในการ์ด) ---------- */
.tile { background: var(--surface2); border-radius: var(--r-tile); padding: 12px 14px; min-width: 0; }
.tile .k { font-size: 12.5px; color: var(--sub); font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.25; margin-top: 2px; }
.tile .v small { font-size: .55em; color: var(--sub); font-weight: 500; margin-left: 2px; }
.tile.acc { background: var(--accent-soft); }
.tile.tap { cursor: pointer; text-align: left; width: 100%; transition: background var(--dur) var(--ease); }
.tile.tap:active { background: var(--raised); }
.card.acc .tile, .card.lime .tile { background: #FFFFFF26; }

/* ---------- ปุ่มแคปซูล ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--r-pill);
  background: var(--raised); color: var(--text); font-weight: 600; font-size: 15.5px; white-space: nowrap;
  border: 1px solid transparent; transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur);
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.pri { background: var(--accent); color: var(--on-accent); }
.btn.lime { background: var(--lime); color: var(--on-lime); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ok { background: var(--ok); color: #06120D; }
.btn.sm { min-height: 44px; padding: 0 16px; font-size: 14.5px; }
.btn.xs { min-height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn.lg { min-height: 56px; padding: 0 26px; font-size: 17px; }
.btn.full { width: 100%; }
.btn .i { margin-left: -4px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btns > .btn { flex: 1; }

/* ปุ่มไอคอนกลม */
.ibtn {
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); position: relative;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ibtn:active:not(:disabled) { transform: scale(.94); }
.ibtn.flat { background: transparent; border-color: transparent; }
.ibtn.raised { background: var(--raised); border-color: transparent; }
.ibtn.acc { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.ibtn.lime { background: var(--lime); border-color: transparent; color: var(--on-lime); }
.ibtn.ok { background: var(--ok); border-color: transparent; color: #06120D; }
.ibtn.danger { background: var(--danger); border-color: transparent; color: #FFFFFF; }
.ibtn.lg { width: 64px; height: 64px; }
.ibtn.xl { width: 76px; height: 76px; }

/* ปุ่มลัดแบบไอคอน+ป้าย */
.qa { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--sub); min-width: 64px; }
.qa .ibtn { width: 56px; height: 56px; background: var(--surface2); border-color: transparent; color: var(--text); }
.qa.on .ibtn { background: var(--accent); color: var(--on-accent); }

/* ---------- ปุ่มแบ่งส่วน (seg) — สร้างด้วย ui.seg() ---------- */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-pill); min-width: 0; }
.seg button {
  flex: 1; min-height: 40px; padding: 0 10px; border-radius: var(--r-pill); font-size: 14.5px; font-weight: 600; color: var(--sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg button.on { background: var(--text); color: var(--bg); }
.seg.acc button.on { background: var(--accent); color: var(--on-accent); }
.seg[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* ---------- ชิป ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--surface2); border: 1px solid var(--line); color: var(--text); font-size: 14.5px; font-weight: 600; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chip .d { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.acc.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip.dim { opacity: .45; }
/* ป้ายเวร (สีจาก SH[i].col ผ่าน style="background:…") */
.tag { display: inline-flex; align-items: center; border-radius: 8px; padding: 1px 8px; font-weight: 700; font-size: 13.5px; color: var(--shift-ink); line-height: 1.5; white-space: nowrap; }
.tag.lg { font-size: 17px; padding: 4px 12px; border-radius: 10px; }

/* ---------- ป้ายสถานะ / แบดจ์ ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 11px; border-radius: var(--r-pill); background: var(--surface2); color: var(--sub); font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mut); flex: none; display: inline-block; }
.pill.ok { color: var(--ok); background: var(--ok-soft); } .pill.ok .dot, .dot.ok { background: var(--ok); }
.pill.warn { color: var(--warn); background: var(--warn-soft); } .pill.warn .dot, .dot.warn { background: var(--warn); }
.pill.off, .pill.danger { color: var(--danger); background: var(--danger-soft); } .pill.off .dot, .pill.danger .dot, .dot.off { background: var(--danger); }
.pill.acc { color: var(--accent); background: var(--accent-soft); } .pill.acc .dot { background: var(--accent); }
.pill.live .dot { animation: nc-pulse 1.6s ease-out infinite; }
.badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #FFFFFF; font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.badge.acc { background: var(--accent); color: var(--on-accent); }
.badge.dot { min-width: 9px; width: 9px; height: 9px; padding: 0; }
.ibtn > .badge, .nav-i > .badge { position: absolute; top: 2px; right: 2px; box-shadow: 0 0 0 2px var(--surface); }

/* ---------- รายการ ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 56px; border-top: 1px solid var(--line); min-width: 0; width: 100%; text-align: left; color: inherit; }
.list > .li:first-child, .li.first { border-top: 0; }
.card > .list > .li:first-child { padding-top: 2px; }
.card > .list > .li:last-child { padding-bottom: 2px; }
.li-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface2); color: var(--accent); flex: none; overflow: hidden; }
.li-ic.round { border-radius: 50%; }
.li-t { flex: 1; min-width: 0; }
.li-t b, .li-t .t { display: block; font-weight: 600; font-size: 15.5px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-t span, .li-t .s { display: block; font-size: 13px; color: var(--sub); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-t.wrap b, .li-t.wrap span { white-space: normal; }
.li-e { flex: none; color: var(--sub); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.li.tap { cursor: pointer; }
.li.tap:active { background: var(--surface2); }

/* แถวตั้งค่า: ป้าย + ตัวควบคุม */
.field { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 56px; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; padding-top: 2px; }
.field .lb { flex: 1; min-width: 0; }
.field .lb b { display: block; font-weight: 600; font-size: 15.5px; }
.field .lb span { display: block; font-size: 13px; color: var(--sub); }
.field.col { flex-direction: column; align-items: stretch; }

/* ---------- สวิตช์ — สร้างด้วย ui.sw() ---------- */
.sw { position: relative; width: 52px; height: 32px; flex: none; display: inline-block; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; z-index: 1; cursor: pointer; width: 100%; height: 100%; }
.sw span { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--raised); border: 1px solid var(--line); transition: background var(--dur) var(--ease), border-color var(--dur); }
.sw span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 3px #0000004d; transition: transform var(--dur) var(--ease); }
.sw input:checked + span { background: var(--accent); border-color: var(--accent); }
.sw input:checked + span::after { transform: translateX(20px); }
.sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw input:disabled + span { opacity: .45; }

/* ---------- ช่องกรอก ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 14px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--text); outline: 0;
  transition: border-color var(--dur) var(--ease), background var(--dur);
  -webkit-appearance: none; appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%239A9AA3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 38px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--mut); }
input[type=time] { width: auto; min-width: 124px; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; min-height: 36px; accent-color: var(--accent); background: none; }
.inrow { display: flex; gap: 8px; align-items: center; }
.inrow > input { flex: 1; min-width: 0; }
.search { position: relative; }
.search > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--mut); pointer-events: none; }
.search > input { padding-left: 44px !important; border-radius: var(--r-pill) !important; }
.err { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 20px; }

/* ---------- ข้อความเตือน / ว่าง ---------- */
.note { background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn-soft); border-radius: var(--r-tile); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.note > svg { color: var(--warn); margin-top: 1px; }
.note.acc { background: var(--accent-soft); border-color: var(--accent-line); } .note.acc > svg { color: var(--accent); }
.empty { text-align: center; padding: 32px 16px; color: var(--sub); }
.empty svg { margin: 0 auto 10px; color: var(--mut); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------- กราฟแท่งเล็ก ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 56px; }
.bars > i { flex: 1; min-height: 3px; border-radius: 4px; background: var(--raised); transition: height var(--dur) var(--ease); }
.bars > i.on { background: var(--accent); } .bars > i.lime { background: var(--lime); }
.meter { height: 8px; border-radius: var(--r-pill); background: var(--raised); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--dur) var(--ease); }
.meter.ok > i { background: var(--ok); } .meter.warn > i { background: var(--warn); } .meter.danger > i { background: var(--danger); }

/* ---------- โครงรอโหลด ---------- */
.skel { position: relative; overflow: hidden; background: var(--surface2); border-radius: 10px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, #FFFFFF14, transparent); animation: nc-shimmer 1.3s infinite; }
:root[data-ui="light"] .skel::after { background: linear-gradient(90deg, transparent, #FFFFFF99, transparent); }
.skel-line { height: 14px; margin: 8px 0; }
.skel-line.w60 { width: 60%; } .skel-line.w40 { width: 40%; }
.skel-num { height: 44px; width: 55%; border-radius: 12px; }
.skel-card { height: 140px; border-radius: var(--r-card); margin-bottom: var(--gap); }
.view-loading { padding-top: 70px; }

/* ---------- แถบนำทางลอย (bottom pill nav) ---------- */
.nav {
  position: fixed; z-index: 40; left: 50%; bottom: calc(12px + var(--safe-b)); transform: translateX(-50%);
  width: min(calc(100% - 24px), 460px); height: var(--nav-h);
  display: flex; align-items: center; gap: 2px; padding: 6px;
  background: var(--nav-bg); border: 1px solid var(--line); border-radius: var(--r-pill);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-float);
  transition: transform var(--dur) var(--ease), opacity var(--dur);
}
.nav-i {
  flex: 1; height: 100%; min-width: 0; border-radius: var(--r-pill); position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--sub); font-size: 11px; font-weight: 600; line-height: 1.1; white-space: nowrap;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav-i span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-i.on { color: var(--on-accent); background: var(--accent); }
.nav-i > .badge { top: 4px; right: calc(50% - 22px); box-shadow: 0 0 0 2px var(--nav-bg); }
.nav-i.on > .badge { background: var(--on-accent); color: var(--accent); }
.app.nonav .nav { transform: translate(-50%, 140%); opacity: 0; pointer-events: none; }
@media (max-width: 340px) { .nav-i span { display: none; } }

/* ---------- แถบสถานะเครือข่าย ---------- */
.netbar {
  position: fixed; z-index: 45; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-float); font-size: 13px; font-weight: 600; color: var(--sub);
}
.netbar .dot { background: var(--danger); }
.netbar.busy .dot { background: var(--warn); }

/* ---------- ชีตล่าง — ui.openSheet() ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 60; background: var(--scrim); opacity: 0; transition: opacity var(--dur) var(--ease); }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: 86vh; max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 28px 28px 0 0;
  padding: 8px 18px calc(20px + var(--safe-b)); transform: translateY(100%);
  transition: transform 220ms var(--ease); box-shadow: var(--shadow-float);
}
.sheet.tall { height: 92vh; height: 92dvh; max-height: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--raised); margin: 4px auto 12px; }
.sheet .sheet-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet .sheet-h h2 { flex: 1; min-width: 0; }
.sheet.open { transform: none; }
.sheet-bg.open { opacity: 1; }
.sheet.drag { transition: none; }

/* กล่องยืนยัน — ui.confirmBox() */
.dlg-text { font-size: 17px; font-weight: 500; line-height: 1.5; margin: 6px 2px 18px; white-space: pre-wrap; }

/* ---------- โทสต์ — ui.toast() ---------- */
.toasts { position: fixed; z-index: 80; left: 0; right: 0; bottom: calc(var(--nav-h) + 24px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.app.nonav ~ .toasts, .toasts.low { bottom: calc(20px + var(--safe-b)); }
.toast {
  display: inline-flex; align-items: center; gap: 8px; max-width: min(92vw, 440px); padding: 11px 18px; border-radius: var(--r-pill);
  background: var(--toast-bg); color: var(--toast-tx); font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow-float);
  opacity: 0; transform: translateY(8px) scale(.98); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast > svg { flex: none; }
.toast.ok > svg { color: var(--ok); } .toast.warn > svg { color: var(--warn); } .toast.err > svg { color: var(--danger); }

/* ---------- สายเรียกเข้า (overlay ทั่วแอป) ---------- */
.callov {
  position: fixed; z-index: 70; left: 12px; right: 12px; top: calc(10px + var(--safe-t)); margin: 0 auto; max-width: 480px;
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 28px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-float);
  animation: nc-drop 240ms var(--ease);
}
.callov .av { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; animation: nc-ring 1.2s ease-in-out infinite; }
.callov .t { flex: 1; min-width: 0; }
.callov .t b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.callov .t span { font-size: 13px; color: var(--sub); }
.callov .ibtn { width: 52px; height: 52px; }

/* ---------- แอนิเมชัน ---------- */
.fade-in { animation: nc-fade 180ms var(--ease); }
@keyframes nc-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes nc-shimmer { to { transform: translateX(100%); } }
@keyframes nc-pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 100% { box-shadow: 0 0 0 6px transparent; } }
@keyframes nc-drop { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes nc-ring { 0%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-12deg); } 20%, 40% { transform: rotate(12deg); } 50% { transform: rotate(0); } }

/* สลับมุมมองปฏิทิน ปี | เดือน (หน้า plan + month) */
.vtog { display: inline-flex; flex: none; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface2, #1C1C20); border: 1px solid var(--line, #2A2A30); }
.vtog a { min-width: 56px; height: 38px; padding: 0 14px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 14px; font-weight: 600; color: var(--sub, #9A9AA3); text-decoration: none; -webkit-tap-highlight-color: transparent; }
.vtog a.on { background: var(--text, #F4F4F6); color: var(--bg, #0A0A0B); }
