:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e5ea;
  --primary: #2f6fed;
  --primary-hover: #2559c7;
  --danger: #e5484d;
  --radius: 10px;

  --cat-breakfast: #d97706;
  --cat-lunch: #16a34a;
  --cat-dinner: #2563eb;
  --cat-late: #7c3aed;
  --cat-snack: #db2777;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card-bg: #1d2026;
    --text: #e7e9ee;
    --muted: #9aa1ad;
    --border: #2b2f37;
    --primary: #5b8ef0;
    --primary-hover: #7ba3f5;
  }
}

/* 환경설정에서 시스템 설정과 무관하게 테마를 고정했을 때 - OS 설정보다 이 값이 우선한다 */
:root[data-theme="dark"] {
  --bg: #14161a;
  --card-bg: #1d2026;
  --text: #e7e9ee;
  --muted: #9aa1ad;
  --border: #2b2f37;
  --primary: #5b8ef0;
  --primary-hover: #7ba3f5;
}

:root[data-theme="light"] {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e5ea;
  --primary: #2f6fed;
  --primary-hover: #2559c7;
}

/* 저시력 지원 옵션(문의 5) - 글자 확대(zoom) + 고대비(진한 글자색/굵은 테두리), 계정에 저장되어
   다음 로그인부터도 계속 적용됨(views/settings.ejs, api.js의 applyLowVision 참고). */
:root[data-low-vision="1"] {
  --text: #000000;
  --muted: #3a3a3a;
  --border: #7a7a7a;
}
@media (prefers-color-scheme: dark) {
  :root[data-low-vision="1"]:not([data-theme="light"]) {
    --text: #ffffff;
    --muted: #dcdcdc;
    --border: #9a9a9a;
  }
}
:root[data-theme="dark"][data-low-vision="1"] {
  --text: #ffffff;
  --muted: #dcdcdc;
  --border: #9a9a9a;
}
[data-low-vision="1"] body { zoom: 1.2; }
[data-low-vision="1"] .card,
[data-low-vision="1"] input,
[data-low-vision="1"] textarea,
[data-low-vision="1"] table,
[data-low-vision="1"] th,
[data-low-vision="1"] td {
  border-width: 2px !important;
}
[data-low-vision="1"] th,
[data-low-vision="1"] td,
[data-low-vision="1"] label,
[data-low-vision="1"] .icon-btn-label {
  font-weight: 600;
}

/* 다운로드/인쇄 저장 안내 토스트(문의 3) - export.js의 showToast가 사용 */
.export-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  max-width: 90vw;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--card-bg);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 3000;
}
.export-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media print {
  .export-toast { display: none !important; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.card h1 {
  font-size: 20px;
  margin: 0 0 20px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}

input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

input[type="date"] {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

input:focus { outline: 2px solid var(--primary); }

button {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.link-row {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.link-row a { color: var(--primary); text-decoration: none; }

.disclaimer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

.error-msg {
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  min-height: 16px;
}

/* Dashboard */
.app-wrap { max-width: 960px; margin: 0 auto; padding: 24px; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.app-header h1 { font-size: 18px; margin: 0; }

.app-header .employee-id { color: var(--muted); font-size: 13px; }

.logout-btn {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.logout-btn:hover { background: var(--border); }

.filter-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-row .field { flex: 0 0 auto; }
.filter-row label { margin: 0 0 6px; }
.filter-row input { width: auto; }

/* 조회 가능 기간 안내(2026-09-18) - 시작일/종료일 아래 작은 회색 문구, 매일 자동 갱신(JS 계산) */
.range-hint {
  color: var(--muted);
  font-size: 12px;
  margin: -12px 0 16px;
}

.filter-row button {
  width: auto;
  margin-top: 0;
  padding: 10px 16px;
}

.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.search-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.category-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.category-chip {
  width: auto;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.category-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 24px; }

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.stat-card .label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card .value { font-size: 22px; font-weight: 700; margin-top: 4px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bar-row .bar-label { flex: 0 0 48px; font-size: 13px; color: var(--muted); }
.bar-row .bar-track { flex: 1; background: var(--border); border-radius: 6px; overflow: hidden; height: 10px; }
.bar-row .bar-fill { height: 100%; background: var(--primary); }
.bar-row .bar-count { flex: 0 0 32px; font-size: 13px; text-align: right; }

.card.section { margin-bottom: 24px; }
.card.section h2 { font-size: 15px; margin: 0 0 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }

.empty-msg { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }

/* Calendar */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: -21px;
  margin-bottom: 16px;
}

.month-nav #month-label {
  font-weight: 800;
  font-size: 22.5px;
  min-width: 100px;
  text-align: center;
  color: var(--primary);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.calendar-weekdays .sunday,
.calendar-day .day-num.sunday {
  color: var(--danger);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 24px;
}

.calendar-day {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  min-height: 84px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calendar-day.empty { visibility: hidden; }
.calendar-day.muted { opacity: 0.35; cursor: default; }
.calendar-day.selected { border-color: var(--primary); border-width: 2px; }
.calendar-day .day-num { font-size: 15px; font-weight: 700; color: var(--text); }
.calendar-day .day-badges { display: flex; flex-wrap: wrap; gap: 4px; }

.meal-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  white-space: nowrap;
}

.meal-badge.cat-breakfast { background: var(--cat-breakfast); }
.meal-badge.cat-lunch { background: var(--cat-lunch); }
.meal-badge.cat-dinner { background: var(--cat-dinner); }
.meal-badge.cat-late { background: var(--cat-late); }
.meal-badge.cat-snack { background: var(--cat-snack); }

.meal-summary {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.meal-summary .summary-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 4px;
  text-align: center;
  min-width: 0;
}

.meal-summary .summary-item .summary-label { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-summary .summary-item .summary-value { font-size: 17px; font-weight: 700; margin-top: 4px; }
.meal-summary .summary-item.total .summary-value { color: var(--primary); }
.meal-summary .summary-item.total { border-top: 3px solid var(--primary); }
.meal-summary .summary-item.cat-breakfast { border-top: 3px solid var(--cat-breakfast); }
.meal-summary .summary-item.cat-lunch { border-top: 3px solid var(--cat-lunch); }
.meal-summary .summary-item.cat-dinner { border-top: 3px solid var(--cat-dinner); }
.meal-summary .summary-item.cat-late { border-top: 3px solid var(--cat-late); }
.meal-summary .summary-item.cat-snack { border-top: 3px solid var(--cat-snack); }

/* Notice popup */
.notice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.notice-modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 100%;
}

.notice-modal h2 { font-size: 15px; margin: 0 0 10px; }
.notice-modal .notice-content { font-size: 14px; line-height: 1.6; white-space: pre-wrap; color: var(--text); margin: 0 0 18px; }

/* 공지 여러 개 동시 게시(2026-09-17) - 각 공지마다 개별 "오늘 다시 보지 않음" 체크박스가 붙는다 */
.notice-modal .notice-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.notice-modal .notice-item:last-child { border-bottom: none; }
.notice-modal .notice-item-content { font-size: 14px; line-height: 1.6; white-space: pre-wrap; color: var(--text); margin: 0 0 8px; }
.notice-modal .notice-dismiss-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.notice-modal .notice-dismiss-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.notice-modal button { width: auto; padding: 8px 16px; margin-top: 0; }

/* 주간 식단표 확대뷰어 (2026-09-17) - login.ejs/dashboard.ejs 공용, menu-zoom.js 참고 */
.zoomable-menu-img { cursor: zoom-in; touch-action: pinch-zoom; }

.weekly-menu-zoom-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text);
  opacity: 0.55;
  text-align: center;
}

.menu-zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  flex-direction: column;
  z-index: 2000;
}

.menu-zoom-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.menu-zoom-btn {
  width: auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.menu-zoom-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.menu-zoom-close-btn {
  margin-left: auto;
  color: var(--danger, #c6412a);
  border-color: var(--danger, #c6412a);
}

.menu-zoom-scroll {
  flex: 1;
  overflow: auto;
  touch-action: pan-x pan-y pinch-zoom;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

.menu-zoom-img {
  width: 100%;
  max-width: none;
  display: block;
  margin: 0 auto;
  transition: width 0.15s ease;
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

textarea:focus { outline: 2px solid var(--primary); }

.notice-status { font-size: 13px; color: var(--muted); margin: 10px 0 14px; }
.notice-status.active { color: var(--danger); }

/* Settings */
.theme-options { display: flex; flex-direction: column; gap: 10px; }

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.theme-option input { width: auto; margin: 0; }

.theme-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

@media print {
  /* 브라우저가 기본적으로 배경색/배경그림을 인쇄에서 빼버려서, 배경색에 기대는 흰 글씨(예: 조식/석식
     뱃지, 다크 테마 텍스트)가 흰 종이 위에서 안 보이는 문제(2026-09-07 실측 발견) - 두 가지로 대응:
     1) 가능한 브라우저는 배경색을 그대로 인쇄하게 강제, 2) 그래도 안 되는 경우를 대비해 뱃지/본문
     텍스트를 아예 인쇄 전용 색(검정 계열)으로 덮어써서 테마와 무관하게 항상 읽히게 함. */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .logout-btn, .filter-row, .month-nav, #admin-link, .app-header-actions { display: none !important; }
  body, .card, table, th, td, h1, h2, h3, .stat-card .label, .stat-card .value {
    background: #fff !important;
    color: #17211C !important;
  }
  .card, .stat-card { border: 1px solid #ccc; }
  .meal-badge {
    background: transparent !important;
    color: #17211C !important;
    border: 1px solid #888;
  }
}

@media (max-width: 640px) {
  .app-wrap { padding: 14px; }
  .app-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .calendar-day { min-height: 66px; padding: 5px; }
  .meal-badge { font-size: 10px; padding: 1px 5px; }
  table { font-size: 12px; }
  th, td { padding: 6px 4px; }
  .filter-row { gap: 8px; }
  .meal-summary { gap: 4px; }
  .meal-summary .summary-item { padding: 6px 2px; }
  .meal-summary .summary-item .summary-label { font-size: 10px; }
  .meal-summary .summary-item .summary-value { font-size: 14px; }
}
