/* 누티 월간식단·알레르기 관리 */
.meal-converter-view[data-meal-tab="allergy"] .meal-converter-shell,
.meal-converter-view[data-meal-tab="allergy"] .meal-posting-preview,
.meal-converter-view[data-meal-tab="posting"] .meal-converter-shell,
.meal-converter-view[data-meal-tab="posting"] .mal-panel,
.meal-converter-view[data-meal-tab="converter"] .mal-panel,
.meal-converter-view[data-meal-tab="converter"] .meal-posting-preview {
  display: none !important;
}

.meal-converter-view .mal-panel { display: grid; gap: 18px; min-width: 0; max-width: 100%; color-scheme: light; color: #212529; }
.meal-converter-view .mal-card {
  padding: 22px; border: 1px solid var(--border-color, #e9ecef); border-radius: 16px; background: #fff;
  box-shadow: 0 8px 26px rgba(33, 37, 41, 0.05); min-width: 0; max-width: 100%;
}
.meal-converter-view .mal-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.meal-converter-view .mal-card h3 { margin: 0; font-size: 18px; color: #1d3b2f; }
.meal-converter-view .mal-card h4 { margin: 0 0 8px; font-size: 15px; color: #1d3b2f; }
.meal-converter-view .mal-count { font-size: 13px; font-weight: 600; color: #6b7d73; margin-left: 4px; }
.meal-converter-view .mal-help { margin: 0 0 12px; font-size: 13px; line-height: 1.6; color: #5b6b62; word-break: keep-all; }
.meal-converter-view .mal-muted { color: #868e96; font-size: 13px; }
.meal-converter-view .mal-empty { margin: 6px 0; padding: 14px; border-radius: 10px; background: #f8f9fa; color: #495057; font-size: 14px; line-height: 1.6; }
.meal-converter-view .mal-error-text { color: #c92a2a; font-size: 14px; }

.meal-converter-view .mal-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.meal-converter-view .mal-btn {
  min-height: 40px; padding: 8px 14px; border: 1px solid #ced4da; border-radius: 10px; background: #fff;
  color: #343a40; font-size: 14px; font-weight: 700; cursor: pointer;
}
.meal-converter-view .mal-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.meal-converter-view .mal-btn-primary { background: #12b886; border-color: #12b886; color: #fff; }
.meal-converter-view .mal-btn-danger { color: #c92a2a; border-color: #f1b0b0; }
.meal-converter-view .mal-btn-sm { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.meal-converter-view .mal-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #495057; min-height: 40px; }
.meal-converter-view .mal-month-select { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #495057; }
.meal-converter-view .mal-month-select select { min-height: 36px; border: 1px solid #ced4da; border-radius: 8px; padding: 4px 8px; background: #fff; color: #212529; }

.meal-converter-view .mal-message { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: #f1f3f5; color: #343a40; font-size: 14px; line-height: 1.5; }
.meal-converter-view .mal-message.is-error { background: #fff5f5; color: #c92a2a; }
.meal-converter-view .mal-message.is-success { background: #ebfbee; color: #2b8a3e; }
.meal-converter-view .mal-warnings { margin: 8px 0; padding: 10px 14px; border: 1px solid #ffd8a8; border-radius: 10px; background: #fff9db; color: #7c4a03; font-size: 13px; line-height: 1.6; }
.meal-converter-view .mal-warnings ul { margin: 0; padding-left: 18px; }

/* 알레르기 항목은 항상 빨간 글씨 */
.meal-converter-view .mal-allergen { display: inline-block; margin: 1px 4px 1px 0; color: #e03131; font-weight: 800; white-space: nowrap; }
.meal-converter-view .mal-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.meal-converter-view .mal-badge-review { background: #fff4e6; color: #d9480f; border: 1px solid #ffc078; }
.meal-converter-view .mal-badge-none { background: #f1f3f5; color: #6c757d; }

/* 오늘의 주의 학생 */
.meal-converter-view .mal-today { border: 2px solid #ffa8a8; background: #fffafa; }
.meal-converter-view .mal-today-date { font-size: 14px; font-weight: 700; color: #c92a2a; }
.meal-converter-view .mal-review-note { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: #fff4e6; color: #d9480f; font-size: 13px; font-weight: 600; }
.meal-converter-view .mal-today-students { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.meal-converter-view .mal-today-students li { padding: 10px 12px; border-radius: 10px; background: #fff; border: 1px solid #ffe3e3; }
.meal-converter-view .mal-today-students strong { font-size: 15px; color: #212529; }
.meal-converter-view .mal-today-items { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; font-size: 13.5px; }
.meal-converter-view .mal-today-menu { color: #495057; margin-right: 6px; }
.meal-converter-view .mal-today-menus { margin-top: 12px; font-size: 14px; }
.meal-converter-view .mal-today-menus summary { cursor: pointer; font-weight: 700; color: #495057; min-height: 32px; }
.meal-converter-view .mal-today-meal ul { margin: 4px 0 8px; padding-left: 18px; line-height: 1.7; }

/* 학생 명단 */
.meal-converter-view .mal-student-form { margin: 10px 0; padding: 14px; border: 1px solid #dee2e6; border-radius: 12px; background: #f8f9fa; }
.meal-converter-view .mal-form-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.meal-converter-view .mal-form-row label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; color: #495057; }
.meal-converter-view .mal-form-row input,
.meal-converter-view .mal-form-row select { min-height: 40px; padding: 6px 10px; border: 1px solid #ced4da; border-radius: 8px; font-size: 15px; background: #fff; color: #212529; min-width: 0; }
.meal-converter-view .mal-allergen-picks { margin: 12px 0 0; padding: 10px; border: 1px solid #dee2e6; border-radius: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 4px 8px; background: #fff; }
.meal-converter-view .mal-allergen-picks legend { font-size: 13px; font-weight: 700; color: #495057; padding: 0 4px; }
.meal-converter-view .mal-allergen-picks label { display: flex; align-items: center; gap: 6px; min-height: 34px; font-size: 14px; cursor: pointer; }
.meal-converter-view .mal-form-error { min-height: 1em; margin: 8px 0 0; color: #c92a2a; font-size: 13px; }
.meal-converter-view .mal-student-list { max-height: 520px; overflow: auto; border-radius: 10px; }
.meal-converter-view .mal-student-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.meal-converter-view .mal-student-table th,
.meal-converter-view .mal-student-table td { padding: 8px 10px; border-bottom: 1px solid #f1f3f5; text-align: left; vertical-align: middle; }
.meal-converter-view .mal-student-table th { position: sticky; top: 0; background: #f8f9fa; font-size: 13px; color: #495057; z-index: 1; }
.meal-converter-view .mal-row-actions { white-space: nowrap; }
.meal-converter-view .mal-row-actions .mal-btn + .mal-btn { margin-left: 4px; }

.meal-converter-view .mal-import { margin: 10px 0; padding: 14px; border: 1px solid #a5d8ff; border-radius: 12px; background: #f3f9ff; font-size: 14px; }
.meal-converter-view .mal-import-counts { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; margin: 0 0 8px; padding: 0; }
.meal-converter-view .mal-import-counts .is-error { color: #c92a2a; }
.meal-converter-view .mal-dup-mode { display: grid; gap: 4px; margin: 8px 0; padding: 8px 10px; border: 1px solid #d0ebff; border-radius: 10px; background: #fff; }
.meal-converter-view .mal-dup-mode label { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.meal-converter-view .mal-import-errors,
.meal-converter-view .mal-import-notices,
.meal-converter-view .mal-import-changes { margin: 8px 0; max-height: 200px; overflow: auto; font-size: 13px; line-height: 1.6; }
.meal-converter-view .mal-import-errors { color: #c92a2a; }
.meal-converter-view .mal-import-errors ul,
.meal-converter-view .mal-import-notices ul,
.meal-converter-view .mal-import-changes ul { margin: 4px 0 0; padding-left: 18px; }

/* 월간 요약표 */
.meal-converter-view .mal-stats { margin: 4px 0 10px; font-size: 13px; color: #495057; }
.meal-converter-view .mal-summary { display: grid; gap: 10px; }
.meal-converter-view .mal-day { border: 1px solid #e9ecef; border-radius: 12px; overflow: hidden; }
.meal-converter-view .mal-day header { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: #f8f9fa; font-weight: 800; color: #343a40; }
.meal-converter-view .mal-day-meal { font-size: 12.5px; padding: 1px 8px; border-radius: 999px; background: #e6fcf5; color: #087f5b; }
.meal-converter-view .mal-day ul { list-style: none; margin: 0; padding: 0; }
.meal-converter-view .mal-menu { padding: 8px 12px; border-top: 1px solid #f1f3f5; }
.meal-converter-view .mal-menu-title { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.meal-converter-view .mal-menu-name { font-weight: 700; color: #212529; word-break: break-all; }
.meal-converter-view .mal-group { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin: 4px 0 0 10px; font-size: 13.5px; }
.meal-converter-view .mal-group-students { display: flex; flex-wrap: wrap; gap: 4px; }
.meal-converter-view .mal-student-tag { padding: 1px 8px; border-radius: 6px; background: #fff; color: #212529; border: 1px solid #ffd43b; white-space: nowrap; }
.meal-converter-view .mal-badge-except { background: #fff9db; color: #7c4a03; border: 1px solid #ffd8a8; }
.meal-converter-view .mal-summary-actions { width: 100%; }
.meal-converter-view .mal-exception-open { margin-left: auto; }
.meal-converter-view .mal-exception-modal[hidden] { display: none !important; }
.meal-converter-view .mal-exception-modal { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 16px; }
.meal-converter-view .mal-exception-backdrop { position: absolute; inset: 0; background: rgba(33, 37, 41, 0.45); }
.meal-converter-view .mal-exception-dialog {
  position: relative; z-index: 1; width: min(520px, 100%); max-height: min(80vh, 640px); overflow: auto;
  padding: 20px; border-radius: 16px; background: #fff; color: #212529; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
.meal-converter-view .mal-exception-input { min-height: 40px; padding: 6px 10px; border: 1px solid #ced4da; border-radius: 8px; font-size: 15px; background: #fff; color: #212529; min-width: 140px; flex: 1 1 160px; }
.meal-converter-view .mal-exception-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.meal-converter-view .mal-exception-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 10px; border-radius: 999px; background: #fff9db; border: 1px solid #ffd8a8; color: #5c4800; font-size: 14px; font-weight: 700; }
.meal-converter-view .mal-exception-chip button { border: 0; background: transparent; color: #7c4a03; font-size: 16px; line-height: 1; cursor: pointer; min-width: 24px; min-height: 24px; }

.mal-print-frame { position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; visibility: hidden; }

@media (max-width: 600px) {
  .meal-converter-view .mal-tabs button { flex: 1 1 0; padding: 10px 8px; font-size: 14px; }
  .meal-converter-view .mal-card { padding: 16px 14px; border-radius: 14px; }
  .meal-converter-view .mal-actions .mal-btn { flex: 1 1 calc(50% - 8px); }
  .meal-converter-view .mal-exception-open { margin-left: 0; flex: 1 1 100%; }
  .meal-converter-view .mal-form-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .meal-converter-view .mal-form-row label:first-child { grid-column: 1 / -1; }
  .meal-converter-view .mal-allergen-picks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meal-converter-view .mal-student-list { max-height: none; overflow: visible; }
  .meal-converter-view .mal-student-table thead { display: none; }
  .meal-converter-view .mal-student-table,
  .meal-converter-view .mal-student-table tbody,
  .meal-converter-view .mal-student-table tr,
  .meal-converter-view .mal-student-table td { display: block; width: 100%; }
  .meal-converter-view .mal-student-table tr { padding: 8px 0; border-bottom: 1px solid #e9ecef; }
  .meal-converter-view .mal-student-table td { padding: 2px 4px; border: 0; }
  .meal-converter-view .mal-student-table td[data-label]::before { content: attr(data-label) ' '; font-size: 12px; color: #868e96; margin-right: 4px; }
  .meal-converter-view .mal-row-actions { margin-top: 4px; }
  .meal-converter-view .mal-group { margin-left: 0; }
}

/* 식단 월 확인 창 */
.meal-converter-view .mal-month-confirm h3 { margin: 0 0 8px; font-size: 18px; }
.meal-converter-view .mal-month-choices { display: grid; gap: 8px; margin: 12px 0 16px; }
.meal-converter-view .mal-month-choice { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid #dee2e6; border-radius: 10px; cursor: pointer; background: #fff; }
.meal-converter-view .mal-month-choice:has(input:checked) { border-color: #12b886; background: #e6fcf5; }
.meal-converter-view .mal-month-choice input { width: 18px; height: 18px; accent-color: #12b886; }
.meal-converter-view .mal-month-confirm-actions { justify-content: flex-end; }
.meal-converter-view .mal-month-select select:disabled { opacity: 0.6; }

/* 알레르기 학생 명단: 기본 접힘 */
.meal-converter-view .mal-roster-details > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; user-select: none; min-height: 32px; }
.meal-converter-view .mal-roster-details > summary::-webkit-details-marker { display: none; }
.meal-converter-view .mal-roster-details > summary h3 { margin: 0; }
.meal-converter-view .mal-roster-details > summary:focus-visible { outline: 2px solid #12b886; outline-offset: 4px; border-radius: 6px; }
.meal-converter-view .mal-roster-toggle { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #495057; }
.meal-converter-view .mal-roster-toggle::before { content: ''; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform 0.15s ease; }
.meal-converter-view .mal-roster-details[open] .mal-roster-toggle::before { transform: translateY(2px) rotate(-135deg); }
.meal-converter-view .mal-roster-details > summary:hover .mal-roster-toggle { background: #f1f3f5; }
.meal-converter-view .mal-roster-body { margin-top: 12px; }

/* 오늘의 알레르기 주의 학생: 좌우 끝 날짜 이동 화살표 */
.meal-converter-view .mal-today { position: relative; padding-left: 64px; padding-right: 64px; }
.meal-converter-view .mal-day-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid #ffc9c9; background: #fff; color: #c92a2a;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 2px 6px rgba(201, 42, 42, 0.08);
}
.meal-converter-view .mal-day-prev { left: 12px; }
.meal-converter-view .mal-day-next { right: 12px; }
.meal-converter-view .mal-day-nav::before { content: ''; width: 10px; height: 10px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; }
.meal-converter-view .mal-day-prev::before { transform: translateX(2px) rotate(45deg); }
.meal-converter-view .mal-day-next::before { transform: translateX(-2px) rotate(-135deg); }
.meal-converter-view .mal-day-nav:hover { background: #fff5f5; }
.meal-converter-view .mal-day-nav:focus-visible { outline: 2px solid #c92a2a; outline-offset: 2px; }
.meal-converter-view .mal-today-head-right { display: inline-flex; align-items: center; gap: 8px; }
@media (max-width: 600px) {
  .meal-converter-view .mal-today { padding-left: 44px; padding-right: 44px; }
  .meal-converter-view .mal-day-nav { width: 32px; height: 32px; }
  .meal-converter-view .mal-day-prev { left: 6px; }
  .meal-converter-view .mal-day-next { right: 6px; }
}

/* 오늘의 알레르기 주의 학생: 요약표와 같은 메뉴별 보기 */
.meal-converter-view .mal-today-alerts { display: grid; gap: 10px; }
.meal-converter-view .mal-today-day { background: #fff; }

/* 상단 탭 (meal-tool-tabs.js) */
.meal-tool-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 20px; }
.meal-tool-tabs button { border: 1px solid #d6e3da; background: #fff; border-radius: 12px; padding: 12px 16px; font-weight: 700; color: #52665a; cursor: pointer; font-size: 14px; }
.meal-tool-tabs button[aria-selected="true"] { background: #e8f5ed; border-color: #2d9663; color: #196b43; }
.meal-converter-view .meal-converter-shell[hidden], .meal-pairing-frame[hidden] { display: none !important; }
.meal-converter-view[data-meal-tab="pairing"] .mal-panel,
.meal-converter-view[data-meal-tab="pairing"] .meal-converter-shell { display: none !important; }
.meal-pairing-frame { display: block; width: 100%; height: 900px; min-height: 400px; border: 0; background: transparent; }
@media (max-width: 600px) { .meal-tool-tabs button { flex: 1; min-width: 135px; } }

/* 주간·일간 식단표 출력 탭 (누티스쿨과 같은 화면) */
.meal-posting-preview[hidden] { display: none !important; }
.meal-converter-view[data-meal-tab="posting"] .mal-panel,
.meal-converter-view[data-meal-tab="posting"] .meal-converter-shell { display: none !important; }
.meal-posting-preview { background: #fff; border: 1px solid #dce8e0; border-radius: 18px; padding: 24px; max-width: 1100px; box-shadow: 0 3px 16px rgba(20, 75, 40, .04); }
.meal-posting-preview h3 { font-size: 21px; color: #1e533b; margin: 0 0 12px; }
.meal-posting-preview p { font-size: 14px; line-height: 1.8; color: #43574a; }
.meal-posting-instruction { background: #fff7e6; border: 1px solid #f1d39b; border-radius: 12px; padding: 17px 20px; color: #3b4f43 !important; font-weight: 600; }
.meal-posting-workflow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.meal-posting-step { min-width: 0; background: #f8fbf9; border: 1px solid #dce8e0; border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.meal-posting-step h4 { display: flex; align-items: center; gap: 9px; margin: 0; color: #1e533b; font-size: 16px; }
.meal-posting-step h4 b { display: inline-grid; place-items: center; background: #e0f4e7; color: #176c44; width: 26px; height: 26px; border-radius: 50%; }
.meal-posting-step p { margin: 0; flex: 1; font-size: 13px; }
.meal-posting-step button { border: 1px solid #cbded1; background: #e7eee9; color: #64746a; border-radius: 10px; padding: 11px; font-weight: 700; cursor: not-allowed; }
.meal-posting-step button:not(:disabled) { background: #24895b; border-color: #24895b; color: #fff; cursor: pointer; }
.meal-posting-step small { color: #66796b; line-height: 1.5; }
.meal-posting-upload-label { display: block; text-align: center; padding: 11px; border-radius: 10px; background: #268758; color: #fff; font-weight: 700; cursor: pointer; }
.meal-posting-step input[type=file] { max-width: 100%; font-size: 12px; }
.meal-posting-upload-result { font-size: 12px; line-height: 1.6; color: #1c6242; overflow-wrap: anywhere; }
.meal-posting-origins { display: grid; grid-template-columns: 1fr; gap: 7px; max-height: 400px; overflow: auto; padding-right: 4px; }
.meal-posting-origin-field { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 6px; align-items: center; color: #3b5145; font-size: 12px; }
.meal-posting-origin-field input { width: 100%; box-sizing: border-box; border: 1px solid #cdded1; border-radius: 7px; padding: 7px 6px; font-size: 12px; min-width: 0; }
@media (max-width: 800px) { .meal-posting-workflow { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .meal-posting-preview { padding: 16px; } }
