* { box-sizing: border-box; }
    body {
      font-family: -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
      margin: 0; padding: 20px; background: #f5f6f8; color: #222;
    }
    h1 { font-size: 20px; margin: 0 0 16px; }
    .tabs { display: flex; gap: 8px; margin-bottom: 16px; }
    .tab-btn { padding: 8px 16px; border: 1px solid #ccc; background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; }
    .tab-btn.active { background: #2b6cb0; color: #fff; border-color: #2b6cb0; }
    .panel { display: none; background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
    .panel.active { display: block; }
    .row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
    input, select { padding: 6px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }
    button.action { padding: 6px 14px; border: none; background: #2b6cb0; color: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; }
    button.action.secondary { background: #718096; }
    button.action.danger { background: #c53030; }
    table { border-collapse: collapse; font-size: 12px; }
    th, td { border: 1px solid #e2e8f0; padding: 4px 6px; text-align: center; vertical-align: middle; white-space: nowrap; }
    th { background: #edf2f7; position: sticky; top: 0; z-index: 2; }
    th.time-col, td.time-col { background: #edf2f7; font-weight: bold; }
    td.empty { background: #f8fafc; color: #cbd5e0; cursor: pointer; min-width: 64px; }
    td.empty:hover { background: #ebf4ff; color: #2b6cb0; }
    td.booked { background: #e6fffa; cursor: pointer; min-width: 64px; }
    td.booked:hover { background: #fff5f5; }
    td.na { background: #f7fafc; color: #e2e8f0; }
    /* 치료별로 살짝 다른 연한 색상 */
    .grp-0.empty { background: #eef6ff; } .grp-0.booked { background: #dceafe; }
    .grp-1.empty { background: #fff8e8; } .grp-1.booked { background: #ffedbd; }
    .grp-2.empty { background: #f5f0ff; } .grp-2.booked { background: #e5d9ff; }
    .grp-3.empty { background: #fff0f1; } .grp-3.booked { background: #ffd9dc; }
    .grp-4.empty { background: #eefdf3; } .grp-4.booked { background: #d3f7e0; }
    .grp-5.empty { background: #eefcff; } .grp-5.booked { background: #cdf1fb; }
    .pain-a.empty { background: #fff0f1; } .pain-a.booked { background: #ffd9dc; }
    .pain-b.empty { background: #fff8e8; } .pain-b.booked { background: #ffedbd; }
    .pain-c.empty { background: #eefdf3; } .pain-c.booked { background: #d3f7e0; }
    .cell-name { font-weight: bold; font-size: 12px; text-align: center; }
    .cell-memo { font-size: 10px; color: #718096; }
    .deficit-high { color: #c53030; font-weight: bold; }
    .deficit-ok { color: #2f855a; }
    .grid-wrap { max-height: 620px; overflow: auto; border: 1px solid #e2e8f0; border-radius: 6px; }
    .muted { color: #718096; font-size: 12px; }
    #errorBanner { display: none; background: #fff5f5; border: 1px solid #feb2b2; color: #c53030; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
    .modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; }
    .modal-overlay.show { display: flex; }
    .modal-box { background: #fff; border-radius: 10px; padding: 20px; width: 380px; max-width: 90%; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
    .modal-box h3 { margin: 0 0 12px; font-size: 16px; }
    .modal-box .modal-info { font-size: 13px; color: #4a5568; margin-bottom: 12px; }
    #alertModalMsg { white-space: pre-line; max-height: 300px; overflow-y: auto; }
    .modal-box label { display: block; font-size: 13px; margin: 10px 0 4px; color: #4a5568; }
    .modal-box input { width: 100%; }
    .modal-box .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
    .modal-box .error-text { color: #c53030; font-size: 12px; margin-top: 8px; display: none; }
    .calendar-grid { margin: 12px 0; }
    .cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; font-weight: bold; text-align: center; font-size: 13px; color: #4a5568; }
    .cal-body { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
    .cal-day { border: 1px solid #e2e8f0; border-radius: 6px; min-height: 90px; padding: 4px; font-size: 11px; background: #fff; }
    .cal-day.empty-day { background: transparent; border: none; }
    .cal-day-num { font-weight: bold; font-size: 12px; margin-bottom: 4px; }
    .name-col { max-width: 90px; word-break: break-all; white-space: normal; }
    .cal-item { background: #ebf8ff; border-radius: 4px; padding: 2px 4px; margin-bottom: 2px; white-space: normal; }
    .cal-item.program { cursor: pointer; }
    .cal-item.program:hover { background: #fed7d7 !important; }
    .prog-0 { background: #f0e6ff; } .prog-1 { background: #e6f7ff; } .prog-2 { background: #fff0e6; }
    .prog-3 { background: #e6fff0; } .prog-4 { background: #fff5e6; } .prog-5 { background: #ffe6f0; }
    .prog-6 { background: #e6fffa; } .prog-7 { background: #f5e6ff; } .prog-8 { background: #fffbe6; }
    .program-chip { display: flex; align-items: center; gap: 4px; font-size: 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 4px 8px; }
    .cal-memo { margin-top: 4px; padding: 2px 4px; border-top: 1px dashed #e2e8f0; cursor: pointer; color: #744210; white-space: normal; min-height: 14px; }
    .cal-memo:hover { background: #fffbea; }
    .cancelled-row { display: flex; gap: 10px; margin-bottom: 16px; overflow-x: auto; align-items: flex-start; }
    .cancelled-col { flex: 0 0 170px; width: 170px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px; background: #fff; }
    .cancelled-col h4 { margin: 0 0 8px; font-size: 13px; color: #2b6cb0; border-bottom: 1px solid #e2e8f0; padding-bottom: 6px; }
    .cancelled-week-label { font-size: 11px; font-weight: bold; color: #718096; margin: 8px 0 3px; }
    .cancelled-item { font-size: 11px; padding: 5px 0; border-bottom: 1px dashed #f0f0f0; }
    .cancelled-item .ci-top { display: flex; justify-content: space-between; font-weight: bold; }
    .cancelled-item .ci-reason { color: #744210; cursor: pointer; margin-top: 2px; }
    .cancelled-item .ci-reason:hover { background: #fffbea; }
    .cancelled-item .ci-actions { display: flex; gap: 4px; margin-top: 3px; }
    .cancelled-item .ci-actions button { font-size: 10px; padding: 2px 6px; border: none; border-radius: 4px; cursor: pointer; }
    .ci-restore { background: #c6f6d5; color: #22543d; }
    .ci-delete { background: #fed7d7; color: #822727; }
    .msg-card { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fff; }
    .msg-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
    .msg-card-name { font-weight: bold; font-size: 14px; }
    .msg-card textarea { width: 100%; min-height: 140px; font-family: inherit; font-size: 13px; padding: 8px; border: 1px solid #e2e8f0; border-radius: 6px; resize: vertical; white-space: pre-wrap; }
    #printArea { display: none; }
    @media print {
      body * { visibility: hidden; }
      #printArea, #printArea * { visibility: visible; }
      #printArea { display: block; position: absolute; top: 0; left: 0; width: 100%; }
      #printArea h2 { margin: 0 0 12px; font-size: 18px; }
      #printArea .cal-memo { cursor: default; }
    }
    .week-cell { cursor: pointer; min-width: 90px; }
    .week-cell.full { background: #fff5f5; }
    .week-cell.partial { background: #fffaf0; }
    .week-cell.free { background: #f0fff4; }
    .week-cell:hover { outline: 2px solid #2b6cb0; outline-offset: -2px; }
    .week-cell .cap-label { font-weight: bold; }
    .week-cell .names-label { font-size: 10px; color: #4a5568; white-space: normal; }


/* ── 로그인 / 세션 (재구축 시 추가된 부분) ───────────────── */
#authOverlay {
  position: fixed; inset: 0; z-index: 9999;
  background: #edf2f7;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 12px; padding: 28px 26px;
  width: 100%; max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}
.auth-card h2 { margin: 0 0 6px; font-size: 19px; color: #2b6cb0; }
.auth-card label {
  display: block; margin: 14px 0 4px; font-size: 12px;
  font-weight: bold; color: #4a5568;
}
.auth-card input {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid #cbd5e0; border-radius: 8px;
}
.auth-card input:focus { outline: 2px solid #2b6cb0; outline-offset: -1px; }
.auth-btn {
  width: 100%; margin-top: 18px; padding: 11px;
  background: #2b6cb0; color: #fff; border: 0; border-radius: 8px;
  font-size: 15px; font-weight: bold; cursor: pointer;
}
.auth-btn:hover { background: #2c5282; }
.auth-hint { margin: 8px 0 0; font-size: 12px; color: #718096; line-height: 1.5; }
.auth-error { margin-top: 10px; font-size: 13px; color: #c53030; min-height: 18px; }

#sessionBar {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #4a5568;
  margin-left: auto;              /* 제목과 로고 사이에서 오른쪽으로 밀착 */
  flex-wrap: wrap; justify-content: flex-end;
}
#sessionBar button {
  padding: 5px 10px; font-size: 12px; cursor: pointer;
  background: #fff; border: 1px solid #cbd5e0; border-radius: 6px;
}
#sessionBar button:hover { background: #f7fafc; }

/* ── 관리자 설정 화면 (admin.html) ───────────────────────── */
body.admin-page { padding: 18px 22px; }
.admin-gate { padding: 40px; text-align: center; color: #4a5568; }
.admin-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 14px;
}
.admin-header h1 { margin: 0 0 2px; font-size: 21px; }
.admin-header .muted { margin: 0; }
.admin-header-actions { display: flex; gap: 8px; align-items: center; }
.admin-header-actions .action { text-decoration: none; display: inline-block; }

.card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 16px 18px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 6px; font-size: 15px; color: #2b6cb0; }
.card > .muted { margin-top: 0; line-height: 1.6; }
.card code {
  background: #edf2f7; padding: 1px 5px; border-radius: 4px; font-size: 12px;
}

.form-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 12px 0;
}
.form-row label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; font-weight: bold; color: #4a5568;
}
.form-row label.checkbox {
  flex-direction: row; align-items: center; gap: 6px; font-weight: normal;
}
.form-row input, .form-row select {
  padding: 7px 9px; font-size: 13px; font-weight: normal;
  border: 1px solid #cbd5e0; border-radius: 6px; min-width: 130px;
}
.form-row input[type="checkbox"] { min-width: 0; }

.table-wrap { overflow-x: auto; margin-top: 10px; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 13px; }
.table-wrap th, .table-wrap td {
  border: 1px solid #e2e8f0; padding: 6px 9px; text-align: left; white-space: nowrap;
}
.table-wrap th { background: #f7fafc; font-size: 12px; color: #4a5568; }
.table-wrap td.num { text-align: right; }
.table-wrap td.empty { color: #a0aec0; text-align: center; padding: 18px; }
.table-wrap select { padding: 3px 6px; font-size: 12px; }

.badge { padding: 2px 7px; border-radius: 10px; font-size: 11px; }
.badge.ok { background: #f0fff4; color: #276749; }
.badge.off { background: #fff5f5; color: #c53030; }
.badge.warn { background: #fffaf0; color: #b7791f; }

button.mini {
  padding: 3px 8px; font-size: 12px; cursor: pointer; margin-right: 3px;
  background: #fff; border: 1px solid #cbd5e0; border-radius: 5px;
}
button.mini:hover { background: #f7fafc; }
button.mini.danger { color: #c53030; border-color: #feb2b2; }
button.mini.danger:hover { background: #fff5f5; }

.admin-toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 900; padding: 10px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.14);
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.admin-toast.show { opacity: 1; }
.admin-toast.ok { background: #276749; color: #fff; }
.admin-toast.error { background: #c53030; color: #fff; }

#adminLink { text-decoration: none; }

/* ── 조회 전용 역할 (스케줄 편집 권한 없음) ──────────────── */
body.schedule-readonly #dayoffToggleBtn { display: none; }
body.schedule-readonly #panel-today td.empty,
body.schedule-readonly #panel-today td.booked {
  pointer-events: none;
}
body.schedule-readonly #panel-today td.empty { color: #cbd5e0; }

/* 비밀번호 변경 창의 보조 버튼 (취소) */
.auth-btn-sub {
  margin-top: 8px;
  background: #fff;
  color: #4a5568;
  border: 1px solid #cbd5e0;
}
.auth-btn-sub:hover { background: #f7fafc; }

/* ── 상단 헤더 (제목 · 세션 · 로고) ─────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;               /* 화면이 좁으면 줄바꿈 (로고가 잘리지 않게) */
  margin-bottom: 4px;
}
.app-header h1 { margin: 0; }

/* 로고: 줄어들거나 잘리지 않게 원본 비율 유지 */
.app-logo {
  height: 48px;
  width: auto;
  max-width: 100%;
  flex-shrink: 0;
  object-fit: contain;
  display: block;
}

@media (max-width: 900px) {
  .app-logo { height: 36px; }
}

/* 겸임을 체크하면 쓰지 않는 칸을 감추지 않고 흐리게만 만든다.
   감추면 창이 확 줄어들어 다른 창이 뜬 것처럼 보인다. */
.opt-disabled {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(1);
}
