/* =====================================================================
   진료표 화면 모양
   - 색은 모두 아래 변수(:root)에 모아 두고, 다크 모드는 [data-theme="dark"]에서 덮어쓴다.
   - 글자 크기는 rem(기준 글자 크기의 몇 배) 단위. 기준은 [data-size]로 작게 14px / 보통 16px / 크게 18px.
   - 진료과 색: 정형 = 파랑, 재활 = 초록, 한방 = 주황. "내 진료"은 진료과 색과 겹치지 않게
     가장 진한 반전색(일반 모드는 거의 검정, 다크 모드는 거의 흰색) + ★ 표시.
   - 그 밖의 달력 색: 선택함 = 남색(채움), 휴일 = 회색, 운영미정 = 연보라 빗금, 미배정 = 빨강 점선,
     특별 시작 시간 = 노랑. 진료과 색(파랑·초록·주황)과 겹치지 않게 골랐다.
   ===================================================================== */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e9ebef;
  --line: #e2e5e9;
  --line-strong: #c6ccd4;
  --text: #1f2328;
  --text-2: #444c56;
  --text-3: #636c76;
  --text-4: #9aa1aa;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-pop: 0 10px 30px rgba(16, 24, 40, .16);

  --primary: #4f46e5;          /* 버튼, 선택함 */
  --primary-hover: #4338ca;
  --primary-ink: #ffffff;      /* primary 위 글자 */
  --accent: #4338ca;           /* 강조 글자, 테두리 */
  --primary-soft: #eef0ff;
  --primary-line: #c3c7f7;
  --focus: #4f46e5;

  --danger: #c5221f;
  --danger-soft: #fdeeed;
  --danger-line: #f0b3ae;
  --danger-strong: #d93025;    /* 빨간 숫자 배지 */
  --ok: #137333;
  --ok-soft: #e6f4ea;
  --ok-line: #a8dab5;
  --ok-strong: #188038;        /* 확정 버튼 */
  --yel: #7a5600;              /* 특별 시작 시간, 주의(저장 전 등) */
  --yel-soft: #fef6d8;
  --yel-line: #eccf6f;

  --sun: #d93025;              /* 일요일·공휴일 날짜 숫자 */
  --sat: #3367d6;              /* 토요일 날짜 숫자 */

  /* 진료과 */
  --ort-bg: #e8f0fe; --ort-line: #a6c4f7; --ort-fg: #174ea6; --ort-dot: #1a73e8;   /* 정형 = 파랑 */
  --reh-bg: #e6f4ea; --reh-line: #9fd3ad; --reh-fg: #0d652d; --reh-dot: #1e8e3e;   /* 재활 = 초록 */
  --kom-bg: #feefe1; --kom-line: #f8c08f; --kom-fg: #9a4600; --kom-dot: #e8710a;   /* 한방 = 주황 */
  --etc-bg: #eef1f5; --etc-line: #cfd5dd; --etc-fg: #3c4652; --etc-dot: #7b8794;   /* 진료과 미지정 */

  /* 달력 상태 */
  --mine-bg: #1f2328; --mine-fg: #ffffff; --mine-star: #fbbc04; --mine-ring: #4f46e5;
  --hol-bg: #f1f3f4; --hol-line: #e8eaed; --hol-fg: #80868b;
  --und-a: #f4effb; --und-b: #e8def8; --und-line: #d2c2ef; --und-fg: #5b3f9e;
  --unas-bg: #fff7f6; --unas-line: #e06b63; --unas-fg: #b3261e;

  --cell-h: 4.75rem;           /* 달력 칸 높이 (글자가 많아도 바뀌지 않음) */
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111316;
  --surface: #1b1e23;
  --surface-2: #23272d;
  --surface-3: #2d3238;
  --line: #33383f;
  --line-strong: #4b525c;
  --text: #e8eaed;
  --text-2: #c4c9d0;
  --text-3: #9ba2ac;
  --text-4: #6d7480;
  --shadow: none;
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, .55);

  --primary: #5b5fef;
  --primary-hover: #6d71f5;
  --primary-ink: #ffffff;
  --accent: #a9b1ff;
  --primary-soft: #252a4d;
  --primary-line: #4a4f9a;
  --focus: #a9b1ff;

  --danger: #f28b82;
  --danger-soft: #3a1f1e;
  --danger-line: #8c3b36;
  --danger-strong: #e2453b;
  --ok: #81c995;
  --ok-soft: #1a3324;
  --ok-line: #2f6b44;
  --ok-strong: #23874a;
  --yel: #f5cf5c;
  --yel-soft: #352c12;
  --yel-line: #6e5a1e;

  --sun: #f28b82;
  --sat: #8ab4f8;

  --ort-bg: #1b2c47; --ort-line: #33568c; --ort-fg: #a8c7fa; --ort-dot: #6ea4f5;
  --reh-bg: #17321f; --reh-line: #2f6a41; --reh-fg: #a3d9b1; --reh-dot: #57bb75;
  --kom-bg: #3a2512; --kom-line: #75461b; --kom-fg: #fcc58f; --kom-dot: #f0913f;
  --etc-bg: #262b33; --etc-line: #434a55; --etc-fg: #c4c9d0; --etc-dot: #8c96a3;

  --mine-bg: #f1f3f4; --mine-fg: #111316; --mine-star: #b06000; --mine-ring: #a9b1ff;
  --hol-bg: #202328; --hol-line: #2a2e34; --hol-fg: #7d848e;
  --und-a: #29233a; --und-b: #332a49; --und-line: #4d3f70; --und-fg: #cdb9f5;
  --unas-bg: #2a1a1a; --unas-line: #e06b63; --unas-fg: #f6aea8;
}

/* 글자 크기 3단계: 모든 글자가 rem이라 함께 커지고 작아진다 */
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-size="s"] { font-size: 87.5%; }
html[data-size="l"] { font-size: 112.5%; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  line-height: 1.45;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
strong, b { font-weight: 700; }
/* 일수·횟수·인원 같은 핵심 숫자 */
.num { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ----- 페이지 틀 ----- */
.page {
  min-height: calc(100vh - 61px);
  padding: 16px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: center;
}
body.in-app .page { align-items: flex-start; }
.card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  box-shadow: var(--shadow);
}
.stack { width: 100%; max-width: 760px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.stack > .card { max-width: none; }

h1 { margin: 0 0 4px; font-size: 1.375rem; }
h2 { margin: 0 0 12px; font-size: 1.1875rem; }
h3 { font-size: 1.0625rem; }
.sub { margin: 0 0 20px; color: var(--text-3); font-size: .875rem; }
.hint { margin: 8px 0 0; font-size: .8125rem; color: var(--text-3); line-height: 1.55; }
.note { margin: 16px 0 0; padding: 12px 14px; font-size: .875rem; background: var(--surface-2); border-radius: 10px; color: var(--text-2); line-height: 1.55; }
.status { padding: 14px; border-radius: 10px; font-weight: 600; }
.status.wait { background: var(--surface-2); color: var(--text-2); }
.msg { min-height: 1.4em; margin: 12px 0 0; font-size: .875rem; color: var(--danger); }
.msg.ok { color: var(--ok); }

/* ----- 상단바 ----- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
body:not(.in-app) .in-app-only { display: none !important; }
.brand { flex: 0 1 auto; min-width: 0; font-weight: 800; font-size: 1.0625rem; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h1 { word-break: keep-all; }
.top-space { flex: 1 1 0; min-width: 0; }
.who { flex: 0 1 auto; min-width: 0; font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.5;
  background: var(--primary-soft); color: var(--accent); vertical-align: middle;
}
.badge-muted { background: var(--surface-3); color: var(--text-3); }
.top-btn, .bell-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 10px; flex: none; }
.disp-icon { font-weight: 800; font-size: 1rem; line-height: 1; }

/* ----- 입력 요소 ----- */
label { display: block; margin: 14px 0 6px; font-size: .875rem; font-weight: 600; }
/* 아이폰은 입력 글자가 16px보다 작으면 누를 때 화면을 확대하므로 항상 16px 이상 */
input, select, textarea { font-family: inherit; color: var(--text); }
input[type=email], input[type=password] {
  width: 100%; min-height: 44px; padding: 10px 12px; font-size: max(16px, 1rem);
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
fieldset { margin: 0 0 20px; padding: 0; border: 0; min-width: 0; }
legend { margin-bottom: 8px; padding: 0; font-size: .9375rem; font-weight: 600; }
.btn {
  width: 100%; min-height: 44px; margin-top: 8px; padding: 10px 16px; font: inherit; font-size: 1rem; font-weight: 600;
  color: var(--primary-ink); background: var(--primary); border: 0; border-radius: 10px; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--primary-hover); }
#login-btn { margin-top: 18px; }
.btn:disabled { background: var(--text-4); color: var(--surface); cursor: default; }
.btn-small { width: auto; margin: 0; padding: 8px 16px; font-size: .875rem; }
.btn-ghost {
  min-height: 44px; padding: 8px 12px; font: inherit; font-size: .875rem; color: var(--text-2); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost:disabled { color: var(--text-4); cursor: default; }

/* 요일/시간 선택 칩 (누르면 남색으로 바뀜) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { margin: 0; position: relative; font-weight: 500; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 52px; min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; user-select: none;
}
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 700; }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ----- 상단 팝업 창 공통 (알림, 화면 설정) ----- */
.bell-wrap, .disp-wrap { position: relative; flex: none; }
.pop-panel, .notify-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  max-height: 70vh; overflow: auto; padding: 12px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-pop);
}
.notify-panel { width: min(360px, calc(100vw - 24px)); }

/* 화면 설정 */
.disp-panel { width: min(310px, calc(100vw - 24px)); }
.disp-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.disp-name { font-size: .8125rem; font-weight: 700; color: var(--text-2); }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button {
  flex: 1; min-height: 44px; padding: 6px 8px; font: inherit; font-size: .875rem; border: 0; cursor: pointer;
  background: var(--surface); color: var(--text-2);
}
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.seg .seg-s { font-size: .75rem; }
.seg .seg-l { font-size: 1.0625rem; }
.disp-panel .hint { margin: 0 0 8px; }

/* ----- (M6) 상단 알림 ----- */
.bell-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger-strong); color: #fff;
  font-size: .75rem; font-weight: 700; line-height: 20px; text-align: center;
}
.notify-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.notify-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.notify-item {
  width: 100%; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; font: inherit; text-align: left;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text-2); cursor: pointer;
}
.notify-item.unread { background: var(--danger-soft); border-color: var(--danger-line); color: var(--text); }
.notify-top { display: flex; align-items: center; gap: 8px; font-size: .75rem; }
.notify-type { font-weight: 700; color: var(--accent); }
.notify-at { color: var(--text-3); }
.notify-dot { margin-left: auto; padding: 0 6px; border-radius: 999px; background: var(--danger-strong); color: #fff; font-size: .6875rem; font-weight: 700; }
.notify-text { font-size: .875rem; line-height: 1.45; }
.notify-empty { padding: 10px; font-size: .875rem; color: var(--text-3); }
.notify-row { display: flex; align-items: stretch; gap: 4px; }
.notify-row .notify-item { flex: 1; min-width: 0; }
.notify-del {
  flex: none; width: 40px; font-size: 1.125rem; line-height: 1; color: var(--text-3); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.notify-del:hover { color: var(--danger); border-color: var(--danger-line); }
.notify-keep { margin-top: 8px; font-size: .75rem; }
.notify-panel .msg { margin-top: 6px; min-height: 0; }
.notify-panel .msg:empty { display: none; }
@media (max-width: 560px) {
  .topbar { gap: 6px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .bell-text, .top-text { display: none; }
  .top-btn, .bell-btn { min-width: 44px; padding: 6px 8px; }
  #logout-btn { padding: 6px 10px; }
  .topbar .btn-ghost { white-space: nowrap; flex: none; }   /* "로그아웃"이 두 줄로 꺾이지 않게 (이름 쪽이 대신 줄어듦) */
  .notify-panel, .pop-panel { position: fixed; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top)); width: auto; }
}
/* 로그인 후 휴대폰: 상단바에 버튼이 많아 이름("의학실 스케줄러")은 숨긴다 (로그인 화면에서는 보임) */
@media (max-width: 560px) {
  body.in-app .brand { display: none; }
}

/* ----- 탭 ----- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface-3); padding: 4px; border-radius: 12px; }
.tab {
  flex: 1 0 auto; min-height: 44px; padding: 8px 10px; font: inherit; font-size: .9375rem; border: 0; border-radius: 9px; white-space: nowrap;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.tab-count {
  display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 999px;
  background: var(--danger-strong); color: #fff; font-size: .75rem; font-weight: 700; line-height: 18px;
}
.tab.active { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

/* ----- 첫 로그인 안내 ----- */
.banner { padding: 14px 16px; border-radius: 14px; background: var(--yel-soft); border: 1px solid var(--yel-line); font-size: .875rem; line-height: 1.55; }
.banner p { margin: 0 0 10px; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----- 월 달력 (의사 달력, 관리자 취합/배정·날짜 지정 달력 공통) ----- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-title { margin: 0; font-size: 1.25rem; }
.cal-nav { min-width: 44px; font-size: 1.25rem; line-height: 1; }
.cal-nav:disabled { opacity: .4; cursor: default; }
.cal-status { margin: 10px 0 12px; padding: 10px 12px; font-size: .875rem; line-height: 1.55; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.cal-status.open { background: var(--primary-soft); color: var(--accent); }

/* 주말 칸은 조금 좁게 (진료는 평일만). minmax(0, …)라서 글자가 길어도 칸 너비가 늘지 않는다 */
.cal-grid { display: grid; grid-template-columns: minmax(0, .7fr) repeat(5, minmax(0, 1fr)) minmax(0, .7fr); gap: 4px; }
.cal-grid.dim { opacity: .5; }
.dow { padding: 4px 0; text-align: center; font-size: .8125rem; font-weight: 600; color: var(--text-3); }
.dow.sun, .day.sun .dnum { color: var(--sun); }
.dow.sat, .day.sat .dnum { color: var(--sat); }

/* 칸 크기 고정: 높이는 --cell-h, 넘치는 글자는 한 줄 말줄임(…) */
.day {
  position: relative; min-width: 0; height: var(--cell-h); overflow: hidden;
  padding: 5px 3px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 1px;
  font: inherit; text-align: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text);
}
.day > span { flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.day.empty { border: 0; background: transparent; }
.dnum { font-size: .9375rem; font-weight: 700; }
.dlabel { font-size: .75rem; }
.dtag { font-size: .6875rem; padding: 0 6px; border-radius: 999px; background: var(--primary-soft); color: var(--accent); }
.dtime { font-size: .6875rem; font-weight: 700; color: var(--yel); }
.dsub { font-size: .6875rem; color: var(--text-3); }
/* 칸 오른쪽 위 작은 표시 (ⓘ 사유, ✔ 완료) — 칸 높이를 늘리지 않는다 */
.day > .dcorner {
  position: absolute; top: 3px; right: 3px; min-width: 1.05rem; height: 1.05rem; padding: 0 2px; border-radius: 999px;
  font-size: .6875rem; font-weight: 700; line-height: 1.05rem; text-align: center;
}

button.day { cursor: pointer; }
button.day:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.day:disabled { cursor: default; }
button.day:hover:not(:disabled) { border-color: var(--line-strong); }
.day.open { border-color: var(--line-strong); }
.day.open .dlabel { color: var(--text-3); }
.day.rec { background: var(--primary-soft); border: 1px dashed var(--primary-line); }
.day.picked { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.day.picked .dnum, .day.picked .dtime, .day.picked .dlabel { color: var(--primary-ink); }
.day.picked .dlabel { font-weight: 700; }
.day.picked .dtag { background: rgba(255, 255, 255, .2); color: var(--primary-ink); }
.day.holiday { background: var(--hol-bg); border-color: var(--hol-line); }
.day.holiday .dlabel { color: var(--hol-fg); }
.day.holiday:not(.sat) .dnum { color: var(--sun); }
.day.undecided { background: repeating-linear-gradient(45deg, var(--und-a), var(--und-a) 6px, var(--und-b) 6px, var(--und-b) 12px); border-color: var(--und-line); }
.day.undecided .dlabel { color: var(--und-fg); font-weight: 700; }
.day.closed, .day.confirmed { background: var(--surface-2); }
.day.closed .dlabel, .day.confirmed .dlabel { color: var(--text-2); }
.day.before { background: var(--surface); border-color: var(--line); }
.day.before .dnum, .day.before .dlabel { color: var(--text-4); }

.day.blocked { background: var(--surface-2); border-color: var(--line); }
.day.blocked .dlabel, .day.blocked .dnum { color: var(--text-4); }

/* ----- 진료과 색 (정형 = 파랑, 재활 = 초록, 한방 = 주황, 미지정 = 회색) -----
   .sp-ort / .sp-reh / .sp-kom 을 붙이면 아래 --sp-* 값이 정해지고, 칸·배지·점이 그 색을 쓴다 */
.sp-ort { --sp-bg: var(--ort-bg); --sp-line: var(--ort-line); --sp-fg: var(--ort-fg); --sp-dot: var(--ort-dot); }
.sp-reh { --sp-bg: var(--reh-bg); --sp-line: var(--reh-line); --sp-fg: var(--reh-fg); --sp-dot: var(--reh-dot); }
.sp-kom { --sp-bg: var(--kom-bg); --sp-line: var(--kom-line); --sp-fg: var(--kom-fg); --sp-dot: var(--kom-dot); }
.sp-etc { --sp-bg: var(--etc-bg); --sp-line: var(--etc-line); --sp-fg: var(--etc-fg); --sp-dot: var(--etc-dot); }
.badge.sp, .dtag.sp, .name-chip.sp { background: var(--sp-bg, var(--etc-bg)); color: var(--sp-fg, var(--etc-fg)); }
.dot::before {
  content: ""; display: inline-block; width: .55em; height: .55em; margin-right: .3em; border-radius: 50%;
  background: var(--sp-dot, var(--etc-dot)); vertical-align: .05em;
}

/* (M5) 확정된 달: 내 진료(가장 눈에 띄게) / 다른 사람 진료(진료과 색) / 미배정(경고) */
.day.mine {
  background: var(--mine-bg); border: 2px solid var(--mine-ring); color: var(--mine-fg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.day.mine .dnum, .day.mine .dtime, .day.mine .dlabel { color: var(--mine-fg); }
.day.mine .dlabel { font-weight: 800; }
/* ★는 칸 왼쪽 위 (글자 줄에 넣으면 좁은 휴대폰에서 "내 진료"이 잘림) */
.day.mine::before {
  content: "★"; position: absolute; top: 3px; left: 4px; color: var(--mine-star);
  font-size: .75rem; line-height: 1;
}
.day.mine > .dcorner.done { background: var(--mine-fg); color: var(--mine-bg); }
.day.duty { background: var(--sp-bg, var(--etc-bg)); border-color: var(--sp-line, var(--etc-line)); }
.day.duty .dlabel { color: var(--sp-fg, var(--etc-fg)); font-weight: 700; }
.day.duty .dsub { color: var(--sp-fg, var(--etc-fg)); opacity: .85; }
.day.unassigned { background: var(--unas-bg); border: 1.5px dashed var(--unas-line); }
.day.unassigned .dlabel { color: var(--unas-fg); font-weight: 800; }

/* (M5) 내 진료 목록의 일정 완료 체크 */
.done-label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: 0; font-size: .875rem; font-weight: 600; cursor: pointer; }
.done-label input { width: 22px; height: 22px; flex: none; accent-color: var(--primary); }
.done-label.off { color: var(--text-4); cursor: default; }
.duty-row.done { background: var(--ok-soft); border-color: var(--ok-line); }
.duty-row.done .row-tag { background: var(--surface); color: var(--ok); }
.cal-mine .msg { margin-top: 8px; }

/* (M6) 변경 요청: 내 진료 목록의 요청 버튼·입력란, 요청 목록 */
.req-line { flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.req-tag { font-size: .75rem; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.req-tag.wait { background: var(--yel-soft); color: var(--yel); }
.req-tag.no { background: var(--surface-3); color: var(--text-2); }
.req-form { flex-basis: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); }
.req-form label { margin-top: 0; }
.req-form .hint { margin: 6px 0 10px; }
.req-card .plain { margin: 6px 0 0; word-break: break-all; }
.req-reason { white-space: pre-line; }
.req-reply { padding: 8px 10px; border-radius: 10px; background: var(--primary-soft); color: var(--accent); white-space: pre-line; }
.req-meta { color: var(--text-3); font-size: .8125rem; }
.rq-card.done { background: var(--surface-2); }
.rq-sub { width: 100%; max-width: 100%; }
.rq-preview { margin-top: 10px; background: var(--yel-soft); border-color: var(--yel-line); }
.rq-preview .plain { margin: 4px 0 0; }
.rq-list { margin-top: 8px; }

/* 이번 달 진료 가능한 날 없음 */
.none-box { margin-top: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.none-box.on { border-color: var(--danger-line); background: var(--danger-soft); }
.none-label { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; font-size: .9375rem; cursor: pointer; }
.none-label input { width: 22px; height: 22px; flex: none; accent-color: var(--primary); }
.none-box .hint { margin-top: 4px; }

.dinfo { color: var(--und-fg); }
button.day.infoable, button.day.tipable { cursor: help; }
.cal-info { margin: 10px 0 0; padding: 10px 12px; font-size: .875rem; line-height: 1.55; border-radius: 10px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); }
.cal-summary { margin: -12px 0 14px; }

.cal-mine { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.cal-mine h3 { margin: 0; font-size: 1rem; }
.cal-mine .hint { margin-bottom: 10px; }
.cal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cal-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: .875rem; background: var(--surface); }
.cal-row.empty { color: var(--text-3); }
.row-date { min-width: 6.5em; font-weight: 700; }
.row-time { color: var(--text-2); }
.row-time.fixed { color: var(--yel); font-weight: 700; }
.row-tag:empty { display: none; }
.row-tag { margin-left: auto; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--yel-soft); color: var(--yel); }
.time-select {
  max-width: 100%; min-height: 44px; padding: 6px 10px; font-size: max(16px, 1rem);
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
}

.cal-actions { margin-top: 16px; }
.cal-count { margin: 0 0 10px; font-size: .9375rem; font-weight: 600; }
.cal-count.dirty { color: var(--yel); }
.cal-actions .hint { margin-bottom: 8px; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; font-size: .75rem; color: var(--text-2); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { display: inline-block; flex: none; width: 15px; height: 15px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--surface); }
.sw.open { border-color: var(--line-strong); }
.sw.rec { background: var(--primary-soft); border: 1px dashed var(--primary-line); }
.sw.picked { background: var(--primary); border-color: var(--primary); }
.sw.holiday { background: var(--hol-bg); border-color: var(--line-strong); }
.sw.undecided { background: repeating-linear-gradient(45deg, var(--und-a), var(--und-a) 3px, var(--und-line) 3px, var(--und-line) 6px); border-color: var(--und-line); }
.sw.closed { background: var(--surface-2); border-color: var(--line-strong); }
.sw.before { border-color: var(--line); }
.sw.mine { background: var(--mine-bg); border: 2px solid var(--mine-ring); }
.sw.duty { background: var(--sp-bg, var(--etc-bg)); border-color: var(--sp-line, var(--etc-line)); }
.sw.unassigned { background: var(--unas-bg); border: 1.5px dashed var(--unas-line); }

/* 휴대폰: 칸이 좁으니 여백과 글자를 줄인다 (칸 높이는 고정) */
@media (max-width: 560px) {
  .page { padding: 10px max(8px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .card { padding: 18px; }
  .stack > .card { padding: 14px 12px; }
  .cal-grid { gap: 3px; }
  :root { --cell-h: 4.25rem; }
  .day { padding: 4px 1px; border-radius: 8px; }
  .dnum { font-size: .875rem; }
  .dlabel { font-size: .6875rem; }
  .dtag, .dtime, .dsub { font-size: .625rem; }
  .dtag { padding: 0 4px; }
  .day > .dcorner { top: 2px; right: 2px; min-width: .9rem; height: .9rem; line-height: .9rem; font-size: .5625rem; }
  .day.mine::before { top: 2px; left: 2px; font-size: .625rem; }
  .day { padding-left: 0; padding-right: 0; }
  .day > span { letter-spacing: -.02em; }
  .dtime-x { display: none; }                       /* "13:30 시작" → "13:30" */
  html[data-size="l"] .dsub { display: none; }       /* 크게: "일정 확정"은 색으로 대신 (칸을 누르면 글로 보임) */
  .cal-legend { gap: 6px 10px; }
}

/* 손가락으로 누르는 기기: 작은 버튼도 44px 이상 */
@media (pointer: coarse) {
  .btn-tiny { min-height: 44px; }
  .notify-del { width: 44px; }
}

/* ----- 관리자: 의사 목록 ----- */
.list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.row-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-label { margin: 14px 0 6px; font-size: .8125rem; font-weight: 700; color: var(--text-2); }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.time-input { min-height: 44px; padding: 8px 10px; font-size: max(16px, 1rem); border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.row-card .msg { margin-top: 8px; }

/* (M6 보완) 의사 설정: 진료과별 묶음 + 관리자 메모 */
.as-group { margin-top: 4px; }
.as-group-head {
  min-height: 44px; padding: 10px 12px; font-size: .9375rem; font-weight: 700; color: var(--text); cursor: pointer;
  background: var(--sp-bg, var(--surface-3)); border-left: 4px solid var(--sp-dot, var(--line-strong)); border-radius: 10px; list-style-position: inside;
}
.as-group-list { margin-top: 10px; }
.as-memo-label { margin: 14px 0 6px; }
.as-memo { background: var(--yel-soft); border-color: var(--yel-line); }
.as-save-row { margin-top: 10px; }
.as-memo-at { font-size: .75rem; color: var(--text-3); }

/* ----- 화면 위에 뜨는 창 (확인 창, 공지, 도움말) ----- */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: center; background: rgba(15, 23, 42, .5);
}
.modal {
  width: 100%; max-width: 420px; max-height: 100%; overflow: auto;
  padding: 20px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-pop);
}
.modal-text { margin: 0 0 18px; font-size: .9375rem; line-height: 1.65; white-space: pre-line; word-break: keep-all; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* (M6-2) 로그인 공지 팝업 */
.notice-modal { max-width: 480px; display: flex; flex-direction: column; }
.notice-h { margin: 0 0 12px; font-size: 1.125rem; }
.notice-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; overflow: auto; }
.notice-item { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.notice-title { margin: 0 0 4px; font-size: 1rem; word-break: break-all; }
.notice-period { margin: 0 0 8px; font-size: .75rem; color: var(--text-3); }
.notice-body { margin: 0; font-size: .875rem; line-height: 1.65; white-space: pre-line; word-break: break-all; }
.notice-modal .hint { margin: -6px 0 12px; }
.notice-link { margin: -12px 0 14px; }
.nt-card.editing { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-line); }
.nt-card .plain { margin: 6px 0 0; }
.nt-card .row-actions { margin-top: 8px; }
.nt-card-title { word-break: break-all; }

/* (디자인) 의사 도움말: 항목별 접기/펼치기 */
.help-modal { max-width: 560px; display: flex; flex-direction: column; padding: 18px 16px 16px; }
.help-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.help-head h2 { margin: 0; font-size: 1.125rem; flex: 1; }
.help-x { min-width: 44px; font-size: 1.25rem; line-height: 1; }
.help-modal > .hint { margin: 0 0 12px; }
.help-list { display: flex; flex-direction: column; gap: 6px; overflow: auto; margin-bottom: 14px; }
.help-item { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.help-item[open] { border-color: var(--line-strong); background: var(--surface-2); }
.help-item summary {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 12px; cursor: pointer;
  font-size: .9375rem; font-weight: 700; list-style: none;
}
.help-item summary::-webkit-details-marker { display: none; }
.help-item summary::after { content: "▾"; margin-left: auto; color: var(--text-3); transition: transform .15s; }
.help-item[open] summary::after { transform: rotate(180deg); }
.help-no { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--primary-soft); color: var(--accent); font-size: .8125rem; }
.help-body { padding: 0 14px 12px; font-size: .875rem; line-height: 1.65; color: var(--text-2); }
.help-body p { margin: 0 0 6px; }
.help-body ul { margin: 0 0 6px; padding-left: 1.2em; }
.help-body li { margin: 2px 0; }
.help-legend { list-style: none; padding: 0 !important; display: flex; flex-direction: column; gap: 6px; }
.help-legend li { display: flex; align-items: center; gap: 8px; }

/* ----- 관리자: 공통 상자/입력 ----- */
.box { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.box > .field-label:first-child { margin-top: 0; }
.plain { margin: 0 0 8px; font-size: .875rem; line-height: 1.55; }
.ok-text { color: var(--ok); }
.field-input {
  width: 100%; min-height: 44px; padding: 10px; font: inherit; font-size: max(16px, 1rem);
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
}
textarea.field-input { resize: vertical; line-height: 1.55; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.form-row label { margin-top: 0; }
.form-actions { margin-top: 14px; }
.btn-tiny { min-height: 36px; padding: 4px 12px; font-size: .8125rem; }
.list-title { margin: 20px 0 8px; font-size: 1rem; }
.list-title:empty { display: none; }
.detail-title { margin: 0; font-size: 1.125rem; }

/* A1 기간 목록과 상태 */
.period-list { display: flex; flex-wrap: wrap; gap: 8px; }
.period-item {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px; font: inherit; font-size: .875rem;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer;
}
.period-item.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-line); font-weight: 700; }
.period-detail { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.period-detail .note { margin: 10px 0 12px; }
.badge.st-draft { background: var(--surface-3); color: var(--text-2); }
.badge.st-open { background: var(--ok-soft); color: var(--ok); }
.badge.st-closed { background: var(--yel-soft); color: var(--yel); }
.badge.st-confirmed { background: var(--primary-soft); color: var(--accent); }
.stepper { display: flex; gap: 4px; margin: 12px 0 0; padding: 0; list-style: none; font-size: .75rem; }
.stepper li { flex: 1; min-width: 0; padding: 6px 4px; text-align: center; border-radius: 8px; background: var(--surface-2); color: var(--text-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper li.done { background: var(--primary-soft); color: var(--accent); }
.stepper li.now { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.mini-list { margin: 0 0 10px; padding-left: 18px; font-size: .8125rem; line-height: 1.65; color: var(--text-2); }
.name-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.name-chip { padding: 3px 10px; border-radius: 999px; font-size: .8125rem; background: var(--surface-3); color: var(--text-2); }
.name-chips.missing .name-chip { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.name-chips.off .name-chip { background: var(--und-a); color: var(--und-fg); font-weight: 600; }
.name-chips.all .name-chip { background: var(--surface); border: 1px solid var(--line); }
.plain.muted { color: var(--text-4); }
#pm-list .period-list { margin-top: 10px; }
.announce { margin-top: 8px; }

/* A4 날짜 지정 달력 */
.day.special { background: var(--yel-soft); border-color: var(--yel-line); }
.day.special .dlabel { color: var(--yel); font-weight: 700; }
.day.sel { outline: 3px solid var(--primary); outline-offset: -1px; }
.sw.special { background: var(--yel-soft); border-color: var(--yel-line); }
.sw.sel { border: 2px solid var(--primary); }
.badge.ty-공휴일 { background: var(--danger-soft); color: var(--danger); }
.badge.ty-운영미정 { background: var(--und-a); color: var(--und-fg); }
.badge.ty-특별시간 { background: var(--yel-soft); color: var(--yel); }
.ds-row { align-items: flex-start; }
.ds-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 200px; min-width: 0; color: var(--text-2); word-break: break-all; }
.ds-note { font-size: .75rem; color: var(--text-3); }
.ds-btns { display: flex; gap: 6px; margin-left: auto; }

/* A2 취합/배정 (한눈에 달력: 칸 색 = 신청 인원, 이름표 색 = 배정된 사람의 진료과) */
.inline-label { display: inline; margin: 0; font-size: .875rem; }
#ag-body.dim { opacity: .5; }
.warn-text { color: var(--danger); }
.muted-2 { color: var(--text-3); }
.ag-grid { margin-top: 16px; }
.day.ag-many { background: var(--yel-soft); border-color: var(--yel-line); }
.day.ag-many .dlabel { color: var(--yel); font-weight: 700; }
.day.ag-one { background: var(--surface); border-color: var(--line-strong); }
.day.ag-one .dlabel { color: var(--text-2); }
.day.ag-gap { background: var(--unas-bg); border: 1.5px dashed var(--unas-line); }
.day.ag-gap .dlabel { color: var(--unas-fg); font-weight: 800; }
.day.ag-done .dtag:not(.sp) { background: var(--primary); color: var(--primary-ink); }
.day.ag-done .dtag { font-weight: 700; }
.day.ag-changed { outline: 2px dashed var(--yel); outline-offset: -2px; }
.dtag.ag-tag-none { background: var(--danger-soft); color: var(--danger); }
.dtag.ag-tag-warn { background: var(--danger); color: var(--surface); }
.day.ag-alert { outline: 2px solid var(--danger); outline-offset: -2px; }
.badge.ag-b-done { background: var(--ok-soft); color: var(--ok); }
.badge.ag-b-undone { background: var(--surface-3); color: var(--text-3); }
.day > .dcorner.ag-tag-done { background: var(--ok); color: var(--surface); }
.sw.ag-many { background: var(--yel-soft); border-color: var(--yel-line); }
.sw.ag-one { background: var(--surface); border-color: var(--line-strong); }
.sw.ag-gap { background: var(--unas-bg); border: 1.5px dashed var(--unas-line); }
.ag-filter-row { margin-top: 18px; }
.ag-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.ag-day { padding: 12px 14px; scroll-margin-top: 72px; transition: box-shadow .3s; }
.ag-day.flash { box-shadow: 0 0 0 3px var(--primary-line); }
.ag-day.ag-off { background: var(--surface-2); }
.ag-day .plain { margin: 8px 0 0; }
.ag-now { margin-left: auto; font-size: .875rem; font-weight: 700; color: var(--accent); display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ag-now.none { color: var(--danger); }
.ag-now .row-tag { margin-left: 0; }
.badge.ag-b-many { background: var(--yel-soft); color: var(--yel); }
.badge.ag-b-one { background: var(--surface-3); color: var(--text-2); }
.badge.ag-b-gap { background: var(--danger-soft); color: var(--danger); }
.ag-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ag-opt {
  display: flex; align-items: flex-start; gap: 10px; min-height: 44px; margin: 0; padding: 8px 10px;
  font-weight: 400; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
label.ag-opt { cursor: pointer; }
.ag-opt input { margin: 3px 0 0; width: 20px; height: 20px; flex: none; accent-color: var(--primary); }
.ag-opt.on { border-color: var(--primary); background: var(--primary-soft); }
.ag-opt-none { align-items: center; color: var(--text-2); }
.ag-mark { width: 18px; flex: none; color: var(--accent); font-weight: 700; }
.ag-lines { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.ag-name { font-size: .9375rem; font-weight: 700; }
.ag-meta { font-size: .8125rem; color: var(--text-2); }
.ag-direct-row { margin-top: 8px; }
.ag-bar {
  position: sticky; bottom: env(safe-area-inset-bottom, 0px); z-index: 5; margin: 16px -4px 0; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 -2px 12px rgba(0, 0, 0, .1);
}
.ag-bar .cal-count { margin: 0 auto 0 0; }
.ag-bar .msg { margin-top: 6px; min-height: 0; }
.ag-bar .msg:empty { display: none; }
.ag-confirm { margin-left: auto; background: var(--ok-strong); }
.ag-confirm:hover:not(:disabled) { background: var(--ok-strong); filter: brightness(1.08); }

@media (max-width: 560px) {
  .ag-now { margin-left: 0; width: 100%; }
  .ag-confirm { margin-left: 0; }
  .ag-bar { padding: 8px 10px; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .form-row > div + div label { margin-top: 12px; }
  .box { padding: 12px; }
  .row-card { padding: 12px; }
}
