: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;
}

* { 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: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; }

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

.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(200px, 1fr)); gap: 16px; margin-bottom: 24px; }

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

.stat-card .label { font-size: 13px; color: var(--muted); }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }

.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-bottom: 16px;
}

.month-nav #month-label { font-weight: 600; font-size: 15px; min-width: 100px; text-align: center; }

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

.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: 6px;
  min-height: 64px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.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: 12px; color: var(--muted); }
.calendar-day .day-badges { display: flex; flex-wrap: wrap; gap: 3px; }

.meal-badge {
  font-size: 10px;
  padding: 1px 5px;
  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; }
.notice-modal button { width: auto; padding: 8px 16px; margin-top: 0; }

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; }

@media print {
  .logout-btn, .filter-row, .month-nav, #admin-link { display: none !important; }
  body { background: #fff; }
  .card, .stat-card { border: 1px solid #ccc; }
}

@media (max-width: 640px) {
  .app-wrap { padding: 14px; }
  .app-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .calendar-day { min-height: 48px; padding: 4px; }
  .meal-badge { font-size: 9px; padding: 1px 4px; }
  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; }
}
