:root{--bg:#f4f7fb;--surface:#fff;--text:#132238;--muted:#6d7d90;--line:#dbe4ee;--accent:#2f6feb;--slot:42px}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:14px system-ui,-apple-system,"Segoe UI",sans-serif}button,input,select,textarea{font:inherit}button{border:1px solid var(--line);background:#fff;border-radius:10px;padding:9px 12px;cursor:pointer}.primary{background:var(--accent);color:#fff;border-color:var(--accent)}.danger{color:#b42318}.brand{display:flex;flex-direction:column;min-width:150px}.brand small{color:var(--muted)}header{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:14px;padding:12px 18px;background:#fffffff2;border-bottom:1px solid var(--line);backdrop-filter:blur(10px)}nav{display:flex;gap:4px;background:#edf2f7;padding:4px;border-radius:12px}nav button{border:0;background:transparent}nav button.active{background:#fff}.actions{margin-left:auto;display:flex;gap:7px}.toolbar{display:flex;align-items:center;gap:8px;padding:12px 18px}.toolbar h1{font-size:20px;margin:0 0 0 8px}main{padding:0 18px 28px}.week{display:grid;grid-template-columns:64px repeat(7,minmax(160px,1fr));min-width:1180px;background:#fff;border:1px solid var(--line);border-radius:14px;overflow:hidden}.scroll{overflow:auto}.head,.time,.daycol{border-right:1px solid var(--line)}.head{padding:10px;text-align:center;font-weight:700;background:#f8fafc}.head select{width:100%;margin-top:7px}.time{position:relative;height:calc(24 * var(--slot));background:#fbfcfe}.time span{position:absolute;right:8px;transform:translateY(-7px);font-size:11px;color:var(--muted)}.daycol{position:relative;height:calc(24 * var(--slot));background:repeating-linear-gradient(to bottom,#fff 0,#fff calc(var(--slot) - 1px),#e9eef4 calc(var(--slot) - 1px),#e9eef4 var(--slot))}.slot{position:absolute;left:0;right:0;height:var(--slot);cursor:pointer}.event{position:absolute;left:5px;right:5px;border-radius:9px;color:#fff;padding:6px 8px;overflow:hidden;box-shadow:0 3px 9px #0002;touch-action:none}.event b,.event small{display:block}.event small{opacity:.9}.eventBody{height:100%;position:relative}.handle,.moveHint{display:none}.event.editing{z-index:15;outline:3px solid #fff;box-shadow:0 0 0 3px #2f6feb,0 10px 28px #0005;overflow:visible;touch-action:none}.event.editing .handle{display:flex;position:absolute;left:-3px;right:-3px;height:28px;background:#10243c;color:#fff;align-items:center;justify-content:center;font-size:10px;font-weight:800;z-index:3;touch-action:none}.event.editing .topHandle{top:-28px;border-radius:9px 9px 0 0}.event.editing .bottomHandle{bottom:-28px;border-radius:0 0 9px 9px}.event.editing .moveHint{display:block;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);background:#ffffffee;color:#132238;border-radius:8px;padding:6px 9px;font-size:10px;font-weight:800;white-space:nowrap;box-shadow:0 2px 8px #0003}.event.editing .eventBody{cursor:grab;touch-action:none}.event.editing .eventBody:active{cursor:grabbing}.nightrow{display:grid;grid-template-columns:64px repeat(7,minmax(160px,1fr));min-width:1180px;background:#eef4f9;border:1px solid var(--line);border-top:0}.nightlabel,.night{padding:10px;border-right:1px solid var(--line)}.night{min-height:86px}.night .room{padding:5px;border-radius:7px;background:#fff;margin-bottom:5px;cursor:pointer}.dayView{display:grid;grid-template-columns:64px 1fr 1fr;min-width:700px;background:#fff;border:1px solid var(--line);border-radius:14px;overflow:hidden}.month{display:grid;grid-template-columns:repeat(7,1fr);background:#fff;border:1px solid var(--line);border-radius:14px;overflow:hidden}.month>div{min-height:110px;border:1px solid #edf1f5;padding:7px}.month .muted{opacity:.4}.chip{font-size:11px;color:#fff;border-radius:5px;padding:3px 5px;margin:3px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}dialog{border:0;border-radius:18px;padding:0;width:min(680px,calc(100% - 24px));box-shadow:0 24px 80px #0005}dialog::backdrop{background:#12203388}form{padding:20px}form h2{margin-top:0}.grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}label{display:flex;flex-direction:column;gap:5px;color:#516276;font-size:12px}input,select,textarea{width:100%;border:1px solid #ccd7e3;border-radius:9px;padding:10px;background:#fff;color:var(--text)}.dialogActions{display:grid;grid-template-columns:auto 1fr auto auto;gap:8px;margin-top:18px}.mobileDays,.roomTabs{display:none}
@media(max-width:700px){.event{padding-bottom:34px;overflow:visible}.event:has(.resize:active){z-index:10;box-shadow:0 8px 24px #0005}header{position:relative;display:grid;grid-template-columns:1fr auto;padding:10px}.brand{min-width:0}nav{grid-column:1/-1;order:3;display:grid;grid-template-columns:repeat(3,1fr)}.actions{margin:0}.actions #googleBtn{font-size:0}.actions #googleBtn:after{content:"G";font-size:14px}.toolbar{padding:8px 10px;flex-wrap:wrap}.toolbar h1{width:100%;margin:4px 0;font-size:18px}main{padding:0 10px 20px}.weekDesktop{display:none}.mobileWeek{display:block}.mobileDays{display:flex;gap:6px;overflow:auto;padding-bottom:8px}.mobileDays button{min-width:58px;padding:8px 5px}.mobileDays button.active{background:var(--accent);color:#fff}.roomTabs{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin:7px 0}.roomTabs button.active{background:#132238;color:#fff}.mobileSchedule{display:grid;grid-template-columns:58px 1fr;background:#fff;border:1px solid var(--line);border-radius:12px;overflow:hidden}.mobileSchedule .daycol{border:0}.mobileNight{margin-top:8px;background:#eef4f9;border-radius:12px;padding:10px}.month>div{min-height:70px;padding:4px;font-size:11px}.month .chip{font-size:0;height:6px;padding:0}.grid{grid-template-columns:1fr}.dialogActions{grid-template-columns:auto 1fr auto}dialog{width:100%;max-width:none;margin:auto 0 0;border-radius:18px 18px 0 0}form{padding:16px;max-height:88vh;overflow:auto}}
.editOk,.editCancel{display:none}.event.editing .editOk,.event.editing .editCancel{display:block;position:absolute;top:50%;transform:translateY(-50%);z-index:6;border:0;font-weight:900;box-shadow:0 2px 8px #0004}.event.editing .editOk{right:-54px;background:#16865b;color:#fff;padding:10px 9px;border-radius:9px}.event.editing .editCancel{left:-40px;background:#fff;color:#b42318;width:32px;height:32px;padding:0;border-radius:50%}.event.editing .handle{background:#fff!important;color:#132238!important;border:2px solid #2f6feb!important;height:32px!important;box-shadow:0 2px 8px #0003}.event.editing .topHandle{top:-32px!important}.event.editing .bottomHandle{bottom:-32px!important}.event.editing .handle span{font-size:11px;font-weight:900}.event.editing .moveHint{background:#132238!important;color:#fff!important}
/* Refined card edit controls */
.event .handle,.event .editOk,.event .editCancel,.event .moveHint{display:none!important}
.event.editing .handle{display:flex!important;position:absolute!important;left:50%!important;right:auto!important;transform:translateX(-50%)!important;width:auto!important;min-width:92px!important;height:24px!important;padding:0 12px!important;align-items:center!important;justify-content:center!important;background:#fff!important;color:#24415f!important;border:1px solid #b9cce0!important;border-radius:999px!important;box-shadow:0 3px 10px #1322382b!important;z-index:8!important;touch-action:none!important}
.event.editing .topHandle{top:-13px!important}
.event.editing .bottomHandle{bottom:-13px!important}
.event.editing .handle span{font-size:10px!important;font-weight:800!important;white-space:nowrap!important}
.event.editing .moveHint{display:block!important;position:absolute!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;background:#ffffffed!important;color:#24415f!important;border:1px solid #d4e0ec!important;border-radius:999px!important;padding:5px 10px!important;font-size:10px!important;font-weight:800!important;white-space:nowrap!important;box-shadow:0 2px 8px #13223822!important}
.event.editing .editOk,.event.editing .editCancel{display:block!important;position:absolute!important;top:auto!important;bottom:-48px!important;transform:none!important;z-index:10!important;height:34px!important;border:0!important;box-shadow:0 4px 12px #13223830!important;font-weight:900!important}
.event.editing .editOk{left:50%!important;right:auto!important;margin-left:3px!important;background:#16865b!important;color:#fff!important;min-width:58px!important;padding:0 12px!important;border-radius:0 999px 999px 0!important}
.event.editing .editCancel{left:auto!important;right:50%!important;margin-right:3px!important;background:#fff!important;color:#a93226!important;width:42px!important;padding:0!important;border-radius:999px 0 0 999px!important}
.event.editing{margin-bottom:52px}

/* Keep edit actions together on the left side of the card */
.event.editing .editCancel,.event.editing .editOk{
  top:50%!important;bottom:auto!important;
  height:34px!important;border-radius:999px!important;
  transform:none!important;margin:0!important;
}
.event.editing .editCancel{
  left:-44px!important;right:auto!important;
  margin-top:-37px!important;width:36px!important;
}
.event.editing .editOk{
  left:-58px!important;right:auto!important;
  margin-top:3px!important;min-width:50px!important;
  padding:0 8px!important;
}


/* Day view */
.dayView .time,.dayView .daycol{margin-top:10px}

/* Weekly controls */
.weekFitToggle{display:inline-flex;align-items:center;gap:6px;width:auto;margin:0 0 8px 2px;font-size:12px;color:var(--muted);user-select:none}
.weekFitToggle input{flex:0 0 16px;width:16px;height:16px;margin:0}
.dayHead{position:relative;padding:8px 5px;text-align:center;font-weight:700;background:#f8fafc;border-right:1px solid var(--line)}
.dayHead select{width:100%;margin:5px 0}
.dayHead>b{text-transform:capitalize;white-space:nowrap}
.roomLabels{display:grid;grid-template-columns:1fr 1fr;gap:2px;color:var(--muted);font-size:10px;font-weight:600}
.dayResize{position:absolute;top:0;right:-7px;width:14px;height:100%;cursor:col-resize;z-index:20;touch-action:none}
.dayResize:after{content:"";position:absolute;top:18%;bottom:18%;left:6px;width:2px;border-radius:2px;background:#b9c7d7;opacity:.35}
.dayResize:hover:after,.dayResize:active:after{background:#2f6feb;opacity:1}

/* Desktop week: one vertical page scroll + persistent viewport-bottom horizontal scrollbar */
@media(min-width:701px){
  html,body{height:auto;min-height:0;overflow-x:hidden;overflow-y:auto}
  body{padding-bottom:0!important}
  main,#calendar{height:auto;min-height:0;max-height:none;overflow:visible;padding-bottom:0!important;margin-bottom:0!important}
  .weekDesktop{display:block;width:100%;height:auto;min-height:0;max-height:none;overflow-x:hidden!important;overflow-y:visible!important;margin-bottom:0}
  .weekTwoRooms{display:grid;grid-template-columns:64px repeat(14,minmax(0,1fr));width:100%;min-width:0;align-items:start}
  .weekTwoRooms>.time{grid-column:1;grid-row:2}
  .weekTwoRooms>.daycol{grid-row:2}
  .nightTwoRooms{display:grid;grid-template-columns:64px repeat(7,minmax(0,1fr));width:100%;min-width:0;margin-bottom:0!important}
  .weekDesktop.contentFit .weekTwoRooms,.weekDesktop.contentFit .nightTwoRooms{max-width:none}
  .weekBottomScroll{display:none;position:fixed;left:22px;right:22px;bottom:0;height:18px;overflow-x:scroll;overflow-y:hidden;z-index:1000;background:#f4f7fb;border-top:1px solid #dbe4ee}
  .weekBottomScroll.active{display:block}
  .weekBottomScrollInner{height:1px}
}
@media(max-width:700px){.weekFitToggle,.weekBottomScroll{display:none!important}}

/* Desktop/mobile week separation and period toggle */
.mobileWeek{display:none!important}
.weekFitToggle{vertical-align:middle;margin:0 0 0 12px!important;font-size:12px;font-weight:500}
@media(max-width:700px){
  .weekDesktop{display:none!important}
  .mobileWeek{display:block!important}
  .weekFitToggle{display:none!important}
}

.weekFitToggle{
  display:inline-flex!important;
  flex-direction:row!important;
  align-items:center!important;
  justify-content:flex-start!important;
  gap:6px!important;
  white-space:nowrap!important;
}
.weekFitToggle input[type="checkbox"]{order:0!important}

/* Room identity colors; user-selected color is marker only */
.event.room1{background:#287f8f!important;color:#fff}
.event.room2{background:#675ca8!important;color:#fff}
.event .colorMark{position:absolute;left:0;top:5px;bottom:5px;width:5px;border-radius:0 4px 4px 0;z-index:2;box-shadow:0 0 0 1px #ffffff55}
.event .eventBody{padding-left:7px}
.daycol[data-room="1"]{background-color:#f7fcfd}
.daycol[data-room="2"]{background-color:#faf8ff}

/* Month view: distinguish rooms and emphasize night monitoring */
.month .chip{position:relative;padding-left:9px}
.month .roomChip1{background:#287f8f!important;color:#fff}
.month .roomChip2{background:#675ca8!important;color:#fff}
.month .miniMark{position:absolute;left:2px;top:2px;bottom:2px;width:4px;border-radius:3px}
.monthNight{margin-top:3px;padding:3px 5px;border-radius:6px;background:#18283d;color:#fff;font-size:10px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* Nurse directory editor */
#nursesDialog{max-width:520px}
#nursesForm{min-width:min(460px,90vw)}
#nursesList{display:flex;flex-direction:column;gap:7px;margin:12px 0}
.nurseRow{display:grid;grid-template-columns:1fr 38px;gap:7px;align-items:center}
.nurseRow input{width:100%}
.nurseRow button{height:38px;border-radius:8px;color:#a93226}
.nurseAdd{display:grid;grid-template-columns:1fr auto;gap:8px;margin-top:12px}
.emptyNurses{color:var(--muted);font-size:13px}
@media(max-width:700px){#nursesForm{min-width:0}.nurseAdd{grid-template-columns:1fr}}

/* Isolated nurse editor */
#nursesDialog{width:min(520px,94vw)}
.nursesEditor{padding:18px;min-width:0}
#nursesList{display:flex;flex-direction:column;gap:7px;margin:12px 0;max-height:55vh;overflow:auto}
.nurseRow{display:grid;grid-template-columns:minmax(0,1fr) 38px;gap:7px;align-items:center}
.nurseRow input{width:100%;min-width:0}
.nurseRow button{height:38px;padding:0;border-radius:8px;color:#a93226}
.nurseAdd{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;margin-top:12px}
.emptyNurses{color:var(--muted);font-size:13px}
@media(max-width:700px){.nurseAdd{grid-template-columns:1fr}.nursesEditor{padding:14px}}

/* Easier card editing */
.event .quickEdit{position:absolute;top:3px;right:3px;z-index:7;width:24px;height:24px;padding:0;border:0;border-radius:7px;background:#ffffffdd;color:#26384c;font-size:14px;line-height:24px;text-align:center;box-shadow:0 1px 5px #0002;opacity:.82}
.event .quickEdit:hover{opacity:1;background:#fff}
.event.editing .quickEdit{display:none}
.event.editing .bottomHandle{height:30px!important;min-width:118px!important;bottom:-16px!important}
.event.editing .bottomHandle:before{content:"";position:absolute;left:-18px;right:-18px;top:-12px;bottom:-14px}
@media(max-width:700px){
  .event .quickEdit{width:28px;height:28px;line-height:28px;font-size:15px}
  .event.editing .bottomHandle{height:34px!important;min-width:132px!important;bottom:-18px!important}
  .event.editing .bottomHandle:before{left:-28px;right:-28px;top:-16px;bottom:-18px}
}

/* Pencil is an icon-only inline-edit trigger */
.event .quickEdit,.event .quickEdit:hover,.event .quickEdit:active{
  background:transparent!important;
  border:0!important;
  box-shadow:none!important;
  color:inherit!important;
  opacity:.72;
  padding:0!important;
}
.event .quickEdit:hover{opacity:1}

/* Night room identity follows cabinet colors */
.night .nightRoom.room1{background:#287f8f!important;color:#fff;border-color:#287f8f!important}
.night .nightRoom.room2{background:#675ca8!important;color:#fff;border-color:#675ca8!important}
.night .nightRoom b{color:inherit}
.night .nightRoom:hover{filter:brightness(1.06)}
.dayNurse{display:flex;align-items:center;gap:10px;margin:0 0 8px 64px;padding:7px 10px;border:1px solid var(--line);border-radius:9px;background:#f8fafc;width:max-content;max-width:calc(100% - 64px)}
.dayNurse span{font-size:12px;font-weight:700;color:var(--muted);white-space:nowrap}
.dayNurse select{min-width:180px}
@media(max-width:700px){.dayNurse{margin-left:0;max-width:100%;width:100%;justify-content:space-between}.dayNurse select{min-width:0;flex:1}}

/* Dark night band in week/day views, matching month night styling */
.nightrow,.mobileNight{
  background:#18283d!important;
  color:#fff;
  border-radius:9px;
}
.nightrow{padding:7px 6px}
.mobileNight{padding:7px 6px;margin-top:6px}
.nightrow .night,.mobileNight .night{background:#18283d!important;color:#fff}
.nightrow .nightlabel{background:#18283d!important;color:#fff;border-color:#30445d!important}
.nightrow select,.mobileNight select{background:#243851;color:#fff;border-color:#405774}
.nightrow select option,.mobileNight select option{color:#111;background:#fff}

/* Day nurse inline with current date */
.dayNurseInline{display:inline-flex;align-items:center;gap:7px;margin-left:14px;vertical-align:middle;font-size:12px;font-weight:500;color:var(--muted)}
.dayNurseInline>span{white-space:nowrap}
.dayNurseInline select{min-width:160px;max-width:220px}
@media(max-width:700px){.dayNurseInline{margin-left:8px;gap:4px}.dayNurseInline>span{display:none}.dayNurseInline select{min-width:120px;max-width:155px}}

/* Month view: explicit room 1 / room 2 sections, no event truncation */
.monthDate{display:block;margin-bottom:3px}
.monthRooms{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:3px;align-items:start}
.monthRoom{min-width:0;border-radius:5px;padding:2px}
.monthRoom.room1{background:#287f8f12}
.monthRoom.room2{background:#675ca812}
.monthRoomTitle{display:block;font-size:9px;font-weight:800;margin:0 2px 2px;color:var(--muted)}
.monthRoom .chip{margin:2px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@media(max-width:700px){.monthRooms{grid-template-columns:1fr}.monthRoomTitle{font-size:8px}}

/* Compact month cells: room 1 events first, room 2 below; color only */
.month .monthRooms{display:block!important}
.month .monthRoom,.month .monthRoomTitle{display:none!important}
.month .monthRooms .chip{display:block;margin:2px 0;border:0!important;border-radius:5px;padding-top:3px;padding-bottom:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.monthRoomLabel{display:block;margin:4px 1px 2px;font-size:9px;font-weight:800;line-height:1;color:var(--muted)}
.monthRoomLabel.roomLabel1{color:#287f8f}
.monthRoomLabel.roomLabel2{color:#675ca8}

/* Month fit-to-content mode */
.monthFitToggle{display:inline-flex!important;flex-direction:row!important;align-items:center!important;gap:6px!important;margin-left:12px!important;vertical-align:middle;font-size:12px;font-weight:500;color:var(--muted);white-space:nowrap}
.monthFitToggle input{width:16px!important;height:16px!important;margin:0!important;flex:0 0 16px}
.monthScroll{width:100%;overflow-x:auto;overflow-y:visible}
.monthScroll.windowFit .month{width:100%;min-width:0}
.monthScroll.contentFit .month{width:max-content;min-width:max-content;grid-template-columns:repeat(7,minmax(190px,max-content))}
@media(max-width:700px){.monthFitToggle{margin-left:7px!important;font-size:10px}.monthScroll.contentFit .month{grid-template-columns:repeat(7,minmax(165px,max-content))}}

/* Month toggle aligned like week; unchecked mode always fits viewport */
.monthFitToggle{
  margin-left:18px!important;
  position:relative;
  top:-1px;
}
.monthScroll.windowFit{
  width:100%!important;
  max-width:100%!important;
  overflow-x:hidden!important;
}
.monthScroll.windowFit .month{
  display:grid!important;
  grid-template-columns:repeat(7,minmax(0,1fr))!important;
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
}
.monthScroll.windowFit .month>div{
  min-width:0!important;
  overflow:hidden;
}
.monthScroll.contentFit{
  overflow-x:auto!important;
}
@media(max-width:700px){
  .monthFitToggle{margin-left:10px!important}
}

/* deployment refresh */

/* production deployment retry */

/* Keep event text clipped while edit handles may extend outside */
.event .eventBody{
  position:absolute!important;
  left:7px!important;
  right:3px!important;
  top:3px!important;
  bottom:3px!important;
  overflow:hidden!important;
  min-height:0!important;
}
.event.editing .eventBody{
  bottom:8px!important;
  overflow:hidden!important;
}
.event .eventBody>*{
  max-width:100%;
}
.event .eventBody small,.event .eventBody b{
  overflow:hidden;
  text-overflow:ellipsis;
}

/* Research report */
.reportView{display:grid;gap:18px;padding:4px 0 20px}
.reportView section{background:var(--card);border:1px solid var(--line);border-radius:12px;overflow:hidden}
.reportView h3{margin:0;padding:11px 14px;border-bottom:1px solid var(--line);font-size:14px}
.reportView h3 span{display:inline-block;margin-left:6px;padding:1px 7px;border-radius:10px;background:#eef2f6;color:var(--muted);font-size:11px}
.reportScroll{width:100%;overflow-x:auto}
.reportTable{width:100%;border-collapse:collapse;font-size:13px}
.reportTable th,.reportTable td{padding:9px 12px;text-align:left;border-bottom:1px solid var(--line)}
.reportTable th{background:#f7f9fb;font-size:11px;white-space:nowrap;cursor:pointer;user-select:none}
.reportTable th:hover{background:#eef2f6}
.reportTable tr:last-child td{border-bottom:0}
.reportTable td:nth-child(2),.reportTable td:nth-child(3){white-space:nowrap}
@media(max-width:700px){.reportTable{min-width:620px}.reportView{gap:12px}.reportTable th,.reportTable td{padding:8px 9px}}

/* Report month navigation */
.reportPeriod{display:inline-flex;align-items:center;gap:8px}
.reportPeriod b{min-width:150px;text-align:center;text-transform:capitalize}
.reportPeriod button{height:30px;padding:3px 9px;border-radius:7px}
#reportToday{margin-left:4px;font-size:11px}
@media(max-width:700px){.reportPeriod{gap:4px}.reportPeriod b{min-width:112px;font-size:12px}.reportPeriod button{padding:2px 7px}#reportToday{font-size:10px}}

/* Editable report rows */
.reportRow{cursor:pointer}
.reportRow:hover td{background:#f8fafc}
.reportNurse{width:100%;min-width:140px;max-width:220px;padding:5px 7px;font-size:12px}
.reportRow td:first-child{font-weight:600}

/* Compact report with resizable columns and nurse totals */
.reportLayout{display:grid;grid-template-columns:minmax(520px,1fr) minmax(300px,380px);gap:14px;align-items:start}
.reportLayout .reportView{min-width:0}
.reportTable{width:auto!important;min-width:0;table-layout:fixed}
.reportTable th{position:relative}
.colResize{position:absolute;right:-4px;top:0;width:9px;height:100%;cursor:col-resize;touch-action:none;z-index:3}
.colResize:after{content:"";position:absolute;right:4px;top:20%;bottom:20%;width:1px;background:var(--line)}
.nurseSummary{position:sticky;top:8px;background:var(--card);border:1px solid var(--line);border-radius:12px;overflow:hidden}
.nurseSummary h3{margin:0;padding:11px 12px;border-bottom:1px solid var(--line);font-size:14px}
.nurseSummary table{width:100%;border-collapse:collapse;font-size:12px}
.nurseSummary th,.nurseSummary td{padding:7px 8px;border-bottom:1px solid var(--line);text-align:right;white-space:nowrap}
.nurseSummary th:first-child,.nurseSummary td:first-child{text-align:left}
.nurseSummary tr:last-child td{border-bottom:0}
.nightHours{min-width:68px;padding:4px 5px;font-size:12px}
@media(max-width:850px){.reportLayout{display:block}.nurseSummary{position:static;margin-top:14px}.reportLayout .reportView{overflow:hidden}}

/* Per-night duration controls and report calendar links */
.nightRoom{position:relative;display:flex!important;align-items:stretch;justify-content:space-between;gap:5px;padding-right:2px!important}
.nightText{min-width:0;flex:1;padding:5px 2px;overflow:hidden;text-overflow:ellipsis}
.nightHourChoices{display:flex;flex-direction:column;gap:1px;flex:0 0 20px;align-self:center}
.nightHourBtn{width:19px!important;height:17px!important;min-width:19px!important;padding:0!important;border:1px solid #ffffff55!important;border-radius:3px!important;background:#ffffff18!important;color:inherit!important;font-size:9px!important;line-height:15px!important}
.nightHourBtn.selected{background:#fff!important;color:#222!important;border-color:#fff!important;font-weight:800}
.goCalendar{width:28px;height:26px;padding:0!important;border-radius:6px;font-size:15px}
.calendarFlash{outline:3px solid currentColor!important;outline-offset:2px;animation:calendarFlash 1.8s ease}
@keyframes calendarFlash{0%,100%{filter:none}25%,75%{filter:brightness(1.45)}}
.reportTable th:last-child,.reportTable td:last-child{padding-left:5px;padding-right:5px;text-align:center}

/* Two-row night duration / PSG selector */
.nightHourChoices{display:grid!important;grid-template-columns:repeat(3,22px)!important;grid-template-rows:repeat(2,19px);gap:2px!important;flex:0 0 70px!important;align-content:center}
.nightHourBtn{width:22px!important;height:19px!important;min-width:22px!important;line-height:17px!important}
.nightHourBtn.psgBtn{font-size:8px!important;background:#5bbce633!important;border-color:#7bd2f5!important;color:#bfeeff!important}
.nightHourBtn.psgBtn.selected{background:#6ecdf2!important;border-color:#9ee3ff!important;color:#07384b!important}

/* Dark theme */
:root[data-theme="dark"]{
  --bg:#11151b;
  --card:#1a2029;
  --line:#303947;
  --text:#e7edf5;
  --muted:#9ba8b8;
}
:root[data-theme="dark"] body{background:#11151b;color:#e7edf5}
:root[data-theme="dark"] header,
:root[data-theme="dark"] .toolbar,
:root[data-theme="dark"] dialog,
:root[data-theme="dark"] .reportView section,
:root[data-theme="dark"] .nurseSummary{background:#1a2029;color:#e7edf5;border-color:#303947}
:root[data-theme="dark"] button,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea{background:#222a35;color:#e7edf5;border-color:#3a4656}
:root[data-theme="dark"] button:hover{background:#2c3643}
:root[data-theme="dark"] nav button.active,
:root[data-theme="dark"] button.primary{background:#376b82;color:#fff}
:root[data-theme="dark"] .slot,
:root[data-theme="dark"] .daycol,
:root[data-theme="dark"] .dayHead,
:root[data-theme="dark"] .head,
:root[data-theme="dark"] .month>div{border-color:#303947}
:root[data-theme="dark"] .dayHead,
:root[data-theme="dark"] .head,
:root[data-theme="dark"] .reportTable th{background:#202731;color:#dbe4ef}
:root[data-theme="dark"] .reportTable td,
:root[data-theme="dark"] .reportTable th,
:root[data-theme="dark"] .nurseSummary td,
:root[data-theme="dark"] .nurseSummary th{border-color:#303947}
:root[data-theme="dark"] .reportRow:hover td{background:#222b36}
:root[data-theme="dark"] .reportView h3 span{background:#2b3542;color:#b7c3d1}
:root[data-theme="dark"] .muted{color:#697789}
:root[data-theme="dark"] .monthNight,
:root[data-theme="dark"] .nightrow,
:root[data-theme="dark"] .nightRoom{background:#151b24}
:root[data-theme="dark"] .weekBottomScroll{background:#11151b}
:root[data-theme="dark"] ::-webkit-scrollbar-track{background:#151a21}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb{background:#465363;border-radius:8px}
#themeBtn{min-width:36px;font-size:17px}

/* Dark theme hard overrides for legacy white surfaces */
:root[data-theme="dark"] nav,
:root[data-theme="dark"] nav button,
:root[data-theme="dark"] .week,
:root[data-theme="dark"] .month,
:root[data-theme="dark"] .monthScroll,
:root[data-theme="dark"] .scroll,
:root[data-theme="dark"] .calendar,
:root[data-theme="dark"] #calendar,
:root[data-theme="dark"] .reportScroll,
:root[data-theme="dark"] .reportTable,
:root[data-theme="dark"] .reportTable tbody,
:root[data-theme="dark"] .reportTable tr,
:root[data-theme="dark"] .reportTable td,
:root[data-theme="dark"] .nurseSummary table,
:root[data-theme="dark"] .nurseSummary tbody,
:root[data-theme="dark"] .nurseSummary tr,
:root[data-theme="dark"] .nurseSummary td{
  background:#1a2029!important;
  color:#e7edf5!important;
}
:root[data-theme="dark"] nav button{
  background:#222a35!important;
  color:#cbd5e1!important;
  border-color:#3a4656!important;
}
:root[data-theme="dark"] nav button:hover{background:#2d3745!important}
:root[data-theme="dark"] nav button.active{
  background:#376b82!important;
  color:#fff!important;
  border-color:#4f8da8!important;
}
:root[data-theme="dark"] .reportTable th,
:root[data-theme="dark"] .nurseSummary th{
  background:#202731!important;
  color:#dbe4ef!important;
}
:root[data-theme="dark"] .reportRow:hover td{background:#242e3a!important}
:root[data-theme="dark"] .month>div{background:#1a2029!important}
:root[data-theme="dark"] .month>div.muted{background:#151a21!important}

/* Complete dark calendar surface overrides */
:root[data-theme="dark"] header{background:#171d25f2!important}
:root[data-theme="dark"] .time{background:#171d25!important}
:root[data-theme="dark"] .daycol{
  background:repeating-linear-gradient(to bottom,#1a2029 0,#1a2029 calc(var(--slot) - 1px),#303947 calc(var(--slot) - 1px),#303947 var(--slot))!important;
}
:root[data-theme="dark"] .daycol[data-room="1"],
:root[data-theme="dark"] .daycol[data-room="2"]{background:repeating-linear-gradient(to bottom,#1a2029 0,#1a2029 calc(var(--slot) - 1px),#303947 calc(var(--slot) - 1px),#303947 var(--slot))!important}
:root[data-theme="dark"] .dayView,
:root[data-theme="dark"] .mobileSchedule{background:#1a2029!important;border-color:#303947!important}
:root[data-theme="dark"] .mobileDays button,
:root[data-theme="dark"] .roomTabs button{background:#222a35!important;color:#dbe4ef!important}
:root[data-theme="dark"] .mobileDays button.active,
:root[data-theme="dark"] .roomTabs button.active{background:#376b82!important;color:#fff!important}
:root[data-theme="dark"] .dayNurse,
:root[data-theme="dark"] .dayNurseInline select{background:#202731!important;color:#e7edf5!important;border-color:#3a4656!important}
:root[data-theme="dark"] label{color:#aeb9c7!important}
:root[data-theme="dark"] dialog form{background:#1a2029!important;color:#e7edf5!important}
:root[data-theme="dark"] .monthFitToggle,
:root[data-theme="dark"] .weekFitToggle{color:#aeb9c7!important}

/* Force complete dark background for day/week timetable */
:root[data-theme="dark"] .weekDesktop,
:root[data-theme="dark"] .weekTwoRooms,
:root[data-theme="dark"] .dayView,
:root[data-theme="dark"] .mobileWeek,
:root[data-theme="dark"] .mobileSchedule,
:root[data-theme="dark"] .week .time,
:root[data-theme="dark"] .dayView .time,
:root[data-theme="dark"] .mobileSchedule .time{
  background:#1a2029!important;
}
:root[data-theme="dark"] .week .daycol,
:root[data-theme="dark"] .dayView .daycol,
:root[data-theme="dark"] .mobileSchedule .daycol,
:root[data-theme="dark"] .weekTwoRooms .daycol{
  background-color:#1a2029!important;
  background-image:repeating-linear-gradient(to bottom,#1a2029 0,#1a2029 calc(var(--slot) - 1px),#303947 calc(var(--slot) - 1px),#303947 var(--slot))!important;
}
:root[data-theme="dark"] .slot{
  background:transparent!important;
  border-color:#303947!important;
}
:root[data-theme="dark"] .week,
:root[data-theme="dark"] .dayView,
:root[data-theme="dark"] .mobileSchedule{
  border-color:#303947!important;
  box-shadow:none!important;
}

/* Three-day Day view */
.threeDayView{
  display:grid!important;
  grid-template-columns:64px repeat(6,minmax(150px,1fr))!important;
  min-width:980px!important;
  width:100%;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:14px 14px 0 0;
  overflow:hidden;
}
.threeDayView>.time{grid-column:1;grid-row:2}
.threeDayView>.daycol{grid-row:2}
.threeDayHead.currentDay{box-shadow:inset 0 3px 0 var(--accent)}
.threeDayNights{display:grid;grid-template-columns:64px repeat(3,minmax(300px,1fr));min-width:980px;background:#18283d;color:#fff;border-radius:0 0 12px 12px;overflow:hidden}
.threeDayNight{min-width:0;border-left:1px solid #30445d}
.threeDayNight.currentDay{box-shadow:inset 0 -3px 0 var(--accent)}
.threeDayNight .night{display:grid;grid-template-columns:1fr 1fr auto;gap:5px;min-height:86px;padding:7px;background:#18283d!important}
.threeDayNight .night .dayNurseInline{display:none}
.threeDayScroll{overflow-x:auto!important;overflow-y:visible!important}
:root[data-theme="dark"] .threeDayView{background:#1a2029!important;border-color:#303947!important}
:root[data-theme="dark"] .threeDayHead.currentDay{background:#263443!important}
@media(max-width:700px){
 .threeDayView{grid-template-columns:52px repeat(6,150px)!important;min-width:952px!important}
 .threeDayNights{grid-template-columns:52px repeat(3,300px)!important;min-width:952px!important}
 .threeDayScroll{margin-left:0;margin-right:0}
}

/* Multi-user access */
.accessGate{min-height:420px;display:grid;place-items:center;padding:32px}
.accessGate[hidden]{display:none!important}
.accessGate>div{max-width:420px;text-align:center;padding:28px;border:1px solid var(--line);border-radius:16px;background:var(--surface,#fff)}
.userBadge{font-size:11px;color:var(--muted);white-space:nowrap;align-self:center}
.readOnly .quickEdit,.readOnly .editOk,.readOnly .editCancel,.readOnly .handle,.readOnly .nightHourChoices,.readOnly .reportNurse,.readOnly .nightHours{display:none!important}
:root[data-theme="dark"] .accessGate>div{background:#1a2029;color:#e7edf5;border-color:#303947}

/* Date range synchronization */
#syncDialog{max-width:520px}
#syncRangeForm{padding:20px}
.syncHint{font-size:12px;line-height:1.45;color:var(--muted);margin:14px 0 2px}
:root[data-theme="dark"] #syncRangeForm{background:#1a2029;color:#e7edf5}

/* Admin user management */
#usersDialog{width:min(680px,calc(100% - 24px));max-width:680px}
.usersPanel{padding:20px}
.addUserForm{display:grid;grid-template-columns:minmax(180px,1fr) 150px auto;gap:8px;margin:12px 0 16px}
.usersTable{width:100%;border-collapse:collapse;font-size:13px}
.usersTable th,.usersTable td{padding:8px;border-bottom:1px solid var(--line);text-align:left}
.usersTable th:nth-child(2),.usersTable td:nth-child(2){width:155px}
.usersTable th:last-child,.usersTable td:last-child{width:85px}
.usersTable small{color:var(--muted)}
:root[data-theme="dark"] .usersPanel,.usersTable{background:#1a2029;color:#e7edf5}
@media(max-width:600px){.addUserForm{grid-template-columns:1fr}.usersTable th:nth-child(2),.usersTable td:nth-child(2){width:auto}}
