/* 시프트군 - 화면 모양 (조용하고, 글자·버튼은 크게) */
:root {
  --ink: #1f2328;
  --sub: #6b7280;
  --line: #dfe3e8;
  --soft: #f3f5f7;
  --accent: #2b6cb0;
  --danger: #b42318;
  --font: "BIZ UDPGothic", "IBM Plex Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
  -webkit-text-size-adjust: 100%;
}
button, select, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
body.dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }

/* ---- 공통 ---- */
.page { max-width: 1200px; margin: 0 auto; padding: 0 14px 40px; }
/* 맨 위 타이틀바: 연한 하늘색 띠 (좌우 끝까지 퍼진다) */
.head { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; gap: 10px; margin-bottom: 6px; background: #e3eefb; color: #164f96; box-shadow: 0 0 0 100vmax #e3eefb; clip-path: inset(0 -100vmax); }
.hl { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; }
.hr { display: flex; align-items: center; gap: 8px; flex: none; }
.pill.sm { min-height: 38px; padding: 0 14px; font-size: 15px; background: #fff; border-color: #9db9dd; color: #164f96; }
.hr .linkbtn { min-height: 38px; font-size: 15px; color: #164f96; }
.hr .me { font-size: 14px; color: #3d6aa3; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 6px; }
.btn.sm { min-height: 38px; padding: 0 16px; font-size: 15px; border-radius: 19px; }
.head h1 { margin: 0; font-size: 22px; font-weight: 700; color: #164f96; line-height: 1.25; }
.status { font-size: 13px; color: #5b7ea8; line-height: 1.3; }
.status.dirty { color: #164f96; font-weight: 700; }
.status.bad { color: var(--danger); font-weight: 700; }

.btn {
  min-height: 50px; padding: 0 20px; border-radius: 12px;
  border: 1px solid #c4cad2; background: #fff; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink);
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: #e7b9b3; }
.pill { border: 1px solid var(--line); background: #fff; border-radius: 20px; min-height: 40px; padding: 0 16px; }
.linkbtn { border: 0; background: none; color: var(--sub); text-decoration: underline; padding: 10px 6px; min-height: 44px; }
.dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; }

/* ---- 이름 카드 ---- */
.cards { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px -14px 6px; padding: 8px 14px; align-items: center; position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid var(--line); }
.pcard {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 0 16px; border-radius: 24px;
  border: 1px solid #c4cad2; background: #fff; font-weight: 500; font-size: 17px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab;
}
.pcard:hover { border-color: #8b95a1; }
.pcard.add { border-style: dashed; color: var(--sub); cursor: pointer; touch-action: manipulation; }
.empty { color: var(--sub); margin: 6px 4px; }
.tablebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 8px; }
.hint { color: var(--sub); font-size: 14px; margin: 0; flex: 1; min-width: 0; white-space: pre-line; }
.hint.changed { color: #164f96; font-weight: 700; }
.tools { display: flex; gap: 8px; flex: none; }
.tools .btn { min-height: 44px; min-width: 0; padding: 0 16px; font-size: 15px; }
.nameinput.short { height: 46px; font-size: 17px; font-weight: 400; margin-top: 10px; }
.linkbtn.danger { color: var(--danger); }
.delrow { text-align: center; margin-top: 4px; }
.delrow.wide { margin-top: 12px; }
.delrow.wide .btn { width: 100%; white-space: nowrap; }
.namehint { color: var(--sub); font-size: 13px; margin: 6px 2px 0; }

@media (max-width: 700px) {
  .pcard { min-height: 40px; padding: 0 12px; font-size: 15px; gap: 6px; }
  .cards { gap: 6px; padding: 6px 14px; }
  .dot { width: 13px; height: 13px; }
  .hint { font-size: 13px; }
  .tablebar { flex-direction: column-reverse; align-items: stretch; gap: 6px; }
  .tools { justify-content: flex-end; }
}

/* ---- 표 (화면용) ---- */
.ehead { overflow: hidden; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; background: #fff; position: sticky; top: var(--cardsH, 0px); z-index: 9; }
.scroller { overflow-x: auto; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; background: #fff; }
.etbl { position: relative; }
.ehdr { display: flex; }
.ecorner { flex: none; position: sticky; left: 0; z-index: 3; background: #fff; border-bottom: 1px solid #c9ccd1; display: flex; align-items: center; justify-content: flex-start; padding-left: 6px; font-size: 12px; color: var(--sub); }
.ehours { display: flex; flex: none; }
.ehours span { flex: none; display: flex; align-items: center; justify-content: center; height: 30px; font-size: 14px; font-weight: 700; border-right: 1px solid #e3e1da; border-bottom: 1px solid #c9ccd1; }
.erow { display: flex; border-bottom: 1px solid #c9ccd1; }
.elabels { flex: none; position: sticky; left: 0; z-index: 3; display: flex; }
.edate { display: flex; align-items: center; justify-content: center; background: #fff; color: #b4b2a9; font-size: 22px; border-right: 1px solid #c9ccd1; }
.elabel { display: flex; align-items: center; justify-content: center; background: #f1efe8; font-size: 22px; font-weight: 700; border-right: 1px solid #c9ccd1; }
.egrid {
  position: relative; flex: none;
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(var(--hw) - 1px), #e8e6df calc(var(--hw) - 1px), #e8e6df var(--hw));
}
.bl { position: absolute; top: 0; bottom: 0; width: 1px; background: #a8a69e; z-index: 0; }
.hlcell { position: absolute; z-index: 1; border-radius: 6px; border: 2px dashed var(--c); pointer-events: none; }
.hlcell.strong { border-style: solid; }
.ea { position: absolute; z-index: 2; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ea svg { position: absolute; left: 0; top: 0; pointer-events: none; }
.ea i { position: absolute; top: 0; bottom: 0; display: block; }
.ea .hl { left: 0; cursor: ew-resize; }
.ea .hr { right: 0; cursor: ew-resize; }
.ea .hm { cursor: grab; }
.ea { transition: opacity 0.12s, transform 0.12s; }
.ea.drag { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35)); z-index: 4; }
.ea.dim { opacity: 0.22; }
.ea.clash { outline: 3px solid #e24b4a; outline-offset: 1px; border-radius: 8px; background: rgba(226,75,74,0.10); }
.ea.emph { outline: 2px solid var(--c); outline-offset: 1px; border-radius: 8px; }
.ea.lift { transform: scale(1.06); filter: drop-shadow(0 5px 9px rgba(0,0,0,0.45)); z-index: 6; outline: 3px solid var(--c); outline-offset: 2px; border-radius: 8px; opacity: 1; }
@media (hover: hover) { .ea:hover { outline: 2px solid var(--c); outline-offset: 1px; border-radius: 8px; } }
.pcard { transition: transform 0.12s, box-shadow 0.12s; }
.pcard.lift { transform: scale(1.1); box-shadow: 0 7px 16px rgba(0,0,0,0.3); border: 2px solid var(--c, var(--accent)); z-index: 12; }
.pehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pehead h2 { margin: 0 !important; }
.pehead .linkbtn { min-height: 36px; padding: 4px 0 4px 8px; font-size: 15px; }

.ghost {
  position: fixed; z-index: 50; pointer-events: none;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 22px;
  background: #fff; border: 2px solid var(--accent); font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.ghost.bad { border-color: #d92d20; color: #d92d20; background: #fff1f0; }
.foot { display: flex; justify-content: space-between; margin-top: 22px; }

/* ---- 팝업 ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.dlgbox { background: #fff; border-radius: 16px; padding: 22px 20px 16px; width: 100%; max-width: 380px; }
.dlgbox h2 { margin: 0 0 8px; font-size: 19px; }
.dlgbox p { margin: 0 0 18px; color: var(--sub); white-space: pre-line; }
.dlgbtns { display: flex; gap: 10px; margin-top: 16px; }
.dlgbtns .btn { flex: 1; padding: 0 10px; }
.nameinput { width: 100%; height: 54px; border: 1px solid #c4cad2; border-radius: 10px; padding: 0 12px; font-size: 20px; font-weight: 500; margin-top: 8px; }
.palette { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #c4cad2; }
.sw.on { box-shadow: 0 0 0 3px var(--ink); }

/* ---- 폰(터치)에서는 끌기 대신 스크롤·누르기 ---- */
@media (pointer: coarse) {
  .pcard, .ea { touch-action: manipulation; }
  .pcard { cursor: pointer; }
  .ea .hm { cursor: pointer; }
}
/* 태블릿(화면 짧은 쪽 600px 이상)은 카드·화살표 위에서 스크롤을 아예 막아서, 꾹 눌러 잡은 뒤 움직여도 화면이 밀리지 않게 한다 */
@media (pointer: coarse) and (min-device-width: 600px) and (min-device-height: 600px) {
  .pcard, .ea { touch-action: none; }
}
.ea .hm, .ea .hl, .ea .hr { -webkit-tap-highlight-color: transparent; }

/* ---- 화살표 하나 고치는 창 ---- */
#aedit .dlgbox { max-width: 420px; }
.aetitle { display: flex; align-items: center; gap: 10px; margin: 0 0 12px !important; font-size: 20px !important; }

/* ---- 사람 설정 팝업의 근무 줄 ---- */
#pedit .dlgbox { max-width: 460px; max-height: 90vh; overflow-y: auto; }
.shiftrow { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.srhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.srhead span { font-size: 14px; color: var(--sub); }
.days { display: flex; gap: 6px; margin-bottom: 10px; }
.daybtn { flex: 1; min-height: 46px; border-radius: 10px; border: 0; background: var(--soft); color: #9aa1ab; font-size: 17px; }
.daybtn.on { background: #e3eefb; color: #164f96; font-weight: 700; }
.times { display: flex; align-items: center; gap: 10px; }
.times select { flex: 1; min-width: 0; height: 50px; border: 1px solid #c4cad2; border-radius: 10px; padding: 0 8px; background: #fff; font-size: 17px; }
.tilde { color: var(--sub); }
.addrow { margin-top: 12px; }
.addshift { text-decoration: none; font-size: 17px; color: var(--accent); }

/* ---- 로그인 화면 ---- */
.center-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.box { width: 100%; max-width: 340px; text-align: center; }
.brand { font-size: 30px; margin: 0 0 6px; }
.lead { color: var(--sub); margin: 0 0 24px; }
.err { color: var(--danger); margin: 0 0 16px; }
.box .btn { width: 100%; margin-bottom: 16px; }

/* ---- 인쇄 (A4 가로 한 장) ---- */
#printArea { display: none; }
@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { background: #fff; }
  .noprint, .overlay, .ghost { display: none !important; }
  #printArea { display: block; }
  #printArea svg { display: block; width: 297mm; height: 210mm; font-family: "BIZ UDPGothic", "Noto Sans CJK JP", "Noto Sans JP", sans-serif; }
}

/* 확인창은 팝업 위에 뜬다 */
#dlg { z-index: 40; }

/* ---- 직원용 보기 화면 ---- */
.ro .pcard { cursor: pointer; touch-action: manipulation; }
.ro .pcard.on { border: 2px solid var(--c); padding: 0 15px; }
.ro .ea { cursor: pointer; touch-action: manipulation; }
.elabel.today { background: #fff0b8; color: #6b4e00 !important; box-shadow: inset 0 0 0 2px #e0b300; }
.gonebox { margin: 40px 6px; padding: 24px 20px; border: 1px solid #e7b9b3; background: #fff5f4; border-radius: 14px; text-align: center; }
.gonebox h2 { margin: 0 0 10px; font-size: 20px; color: var(--danger); }
.gonebox p { margin: 0; white-space: pre-line; font-size: 17px; }
.neterr { margin: 10px 4px; color: var(--danger); font-size: 15px; }

/* ---- 직원용 QR 창 ---- */
#sedit .dlgbox { max-width: 420px; max-height: 92vh; overflow-y: auto; }
.sharemsg { margin: 0 0 12px !important; color: var(--sub); font-size: 15px; white-space: normal !important; }
.qrbox { display: flex; justify-content: center; margin: 4px 0 12px; }
.qrbox svg { border: 1px solid var(--line); border-radius: 8px; }
.urlrow { display: flex; gap: 8px; align-items: center; }
.shareurl { flex: 1; min-width: 0; height: 44px; border: 1px solid #c4cad2; border-radius: 10px; padding: 0 10px; font-size: 13px; }
.urlrow .btn { min-height: 44px; padding: 0 12px; font-size: 14px; flex: none; }

/* ---- 새 내용이 있을 때 「更新」 버튼을 깜빡인다 ---- */
@keyframes blinkbtn {
  0%, 100% { background: #2b6cb0; box-shadow: 0 0 0 0 rgba(217, 45, 32, 0); }
  50% { background: #d92d20; box-shadow: 0 0 0 7px rgba(217, 45, 32, 0.35); }
}
.btn.blink { animation: blinkbtn 1s ease-in-out infinite; color: #fff; border-color: #d92d20; }
.hint.stale { color: #d92d20; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .btn.blink { animation: none; background: #d92d20; } }

/* ---- 폰: 이름 카드 대신 「＋ 시프트 추가」 버튼과 아래에서 올라오는 목록 ---- */
.phoneui .cards { display: none; }
.phoneui .tools { width: 100%; }
.phoneui .tools .btn { min-height: 46px; padding: 0 12px; font-size: 15px; }
.tools .btn.grow { flex: 1; }
.sheetwrap { align-items: flex-end; padding: 0; }
.sheet { background: #fff; border-radius: 18px 18px 0 0; width: 100%; max-width: 560px; max-height: 78vh; overflow-y: auto; overscroll-behavior: contain; padding: 10px 16px 26px; animation: sheetup 0.22s ease-out; }
@keyframes sheetup { from { transform: translateY(100%); } to { transform: none; } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: #c4cad2; margin: 0 auto 8px; }
.sheethead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheethead h2 { margin: 0; font-size: 19px; }
.xbtn { border: 0; background: none; font-size: 24px; min-width: 48px; min-height: 48px; color: var(--sub); }
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sheet .pcard { width: 100%; min-height: 54px; justify-content: flex-start; cursor: pointer; touch-action: manipulation; }
.sheet .pcard .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .pcard.add { justify-content: center; }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

/* ---- 두 손가락 확대·축소: 표 위에서는 브라우저 기본 확대를 끄고 직접 처리한다 ---- */
@media (pointer: coarse) {
  .scroller, .scroller *, .ehead, .ehead * { touch-action: pan-x pan-y; }
}
@media (pointer: coarse) and (min-device-width: 600px) and (min-device-height: 600px) {
  .ea { touch-action: none; }
}

/* ---- 직원용: 삭제된 근무(붉은 점선) / 변경 표시 숨기기 버튼 ---- */
.gx { position: absolute; z-index: 1; pointer-events: none; }
.gx svg { display: block; }
.ro .tablebar { flex-direction: column; align-items: flex-start; gap: 6px; }
.ro #hideDiff { flex: none; white-space: nowrap; }

/* 변경 이력 */
.hrow { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; text-align: left; border: 1px solid var(--line, #d9dee5); background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; min-height: 56px; cursor: pointer; touch-action: manipulation; font: inherit; color: inherit; }
.hrow:hover { border-color: #2b6cb0; }
.hrow.warn { border-color: #e24b4a; background: #fff6f6; }
.hrow .hmeta { font-size: 13px; color: var(--sub, #5f6b7a); }
.hrow .hdesc { font-size: 16px; font-weight: 700; word-break: break-word; }
.hrow .hcnt { font-size: 13px; color: var(--sub, #5f6b7a); }
.dlgbox #dlgText { white-space: pre-line; }
#dlg { z-index: 30; }

/* 확인 창: 버튼 글자가 줄바꿈되지 않게 넉넉하게 (좁은 화면에서는 버튼이 다음 줄로 내려간다) */
#dlg .dlgbox { max-width: 540px; }
.dlgbtns { flex-wrap: wrap; justify-content: flex-end; }
.dlgbtns .btn { flex: 1 1 auto; white-space: nowrap; padding: 0 22px; min-width: 120px; }

/* 로그인 화면: 위는 앱과 같은 하늘색 띠, 아래는 큰 로그인 버튼 */
.login { min-height: 100vh; min-height: 100dvh; background: #fff; }
.lband { background: #e3eefb; color: #164f96; text-align: center; padding: 44px 20px 32px; }
.lband .licon { display: block; margin: 0 auto 14px; width: 76px; height: 76px; border-radius: 18px; }
.lband h1 { margin: 0; font-size: 32px; letter-spacing: 1px; color: #164f96; }
.lband .lsub { margin: 6px 0 0; font-size: 15px; color: #164f96; }
.lbody { max-width: 400px; margin: 0 auto; padding: 34px 22px 40px; text-align: center; }
.lbody .llead { margin: 0 0 20px; font-size: 17px; color: var(--sub); }
.lbody .err { margin: 0 0 16px; }
.lbody .lbtn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 60px; border-radius: 30px; font-size: 19px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.lbody .pill { margin-top: 22px; }

/* 테스트 사본 (진짜 앱과 헷갈리지 않게 위쪽을 주황색으로) */
body.testenv .head { background: #fde6c4; box-shadow: 0 0 0 100vmax #fde6c4; }
body.testenv .head h1 { color: #8a4b00; }
.envtag { display: inline-block; margin-left: 10px; padding: 2px 10px; border-radius: 999px; background: #e8710a; color: #fff; font-size: 14px; font-weight: 700; vertical-align: middle; }
