/* ===== 생산량 탭 공통 ===== */
#tab-inventory { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#tab-inventory.hidden { display: none; }

/* 헤더 분리 (스크롤은 콘텐츠에서만 동작) */
#tab-inventory > .page-header { flex-shrink: 0; }
#tab-inventory > .row {
  flex-shrink: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}

/* 공통 툴바 (◀ 라벨 ▶) */
.cal-toolbar { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 14px 0 14px; flex-shrink: 0; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.cal-month-label {
  font-size: 20px; font-weight: 700; min-width: 160px; text-align: center; color: var(--text);
  cursor: pointer; padding: 6px 16px; border-radius: 8px; user-select: none;
  transition: background .15s ease;
}
.cal-month-label:hover { background: var(--bg-soft); color: var(--brand); }
.cal-month-input-hidden {
  position: absolute; opacity: 0; width: 0; height: 0; padding: 0; border: 0;
  pointer-events: none;
}
.cal-year-select {
  font-size: 20px; font-weight: 700; min-width: 130px; text-align: center;
  color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 14px; cursor: pointer;
  transition: all .15s ease;
  text-align-last: center;
}
.cal-year-select:hover { background: var(--bg-soft); border-color: var(--brand); color: var(--brand); }
.cal-year-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.cal-nav-btn {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 14px; cursor: pointer; font-size: 16px; font-weight: 600;
  transition: all .15s ease;
}
.cal-nav-btn:hover { background: var(--bg-soft); border-color: var(--brand); color: var(--brand); }
.cal-today-btn {
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.cal-today-btn:hover { background: var(--brand-600); }

/* ===== 출고량 탭: 생산량 탭과 동일하게 높이 채움 ===== */
#tab-outbound { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#tab-outbound.hidden { display: none; }
#tab-outbound > .page-header { flex-shrink: 0; }
#outCalendarView { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ===== 일간 달력 ===== */
#invCalendarView { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; flex-shrink: 0; }
.cal-weekdays span { text-align: center; font-weight: 600; padding: 8px 0; color: var(--sub); font-size: 13px; letter-spacing: .5px; }
.cal-weekdays span.sat { color: var(--brand); }
.cal-weekdays span.sun { color: var(--danger); }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px; flex: 1; min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
}
.cal-cell {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; transition: all .15s ease;
  position: relative; overflow: hidden;
  min-height: 0;
}
.cal-cell.empty { background: transparent; cursor: default; border-color: transparent; }
.cal-cell:not(.empty):hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.cal-cell.today { border-color: var(--brand); border-width: 2px; background: var(--brand-soft); }
.cal-cell.has-data .cal-day { color: var(--brand); }
.cal-day { font-weight: 700; font-size: 14px; line-height: 1; flex-shrink: 0; }
.cal-cell.sun .cal-day { color: var(--danger); }
.cal-cell.sat .cal-day { color: var(--brand); }
.cal-cell.has-data.sun .cal-day,
.cal-cell.has-data.sat .cal-day { color: var(--brand); }
.cal-cell.empty .cal-day { display: none; }

.cal-items { display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow: hidden; }
.cal-item {
  display: flex; justify-content: space-between; align-items: center; gap: 4px;
  font-size: 11px; line-height: 1.25;
  background: var(--brand-soft); padding: 2px 6px; border-radius: 4px;
}
.cal-item-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-weight: 500;
}
.cal-item-qty { color: var(--brand); font-weight: 700; flex-shrink: 0; }
.cal-more { font-size: 10px; color: var(--sub); text-align: right; padding-right: 4px; font-weight: 600; }

/* ===== 주간 카드 뷰 ===== */
#invWeeklyView { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#invWeeklyView.hidden { display: none; }
#invWeeklyView .cal-toolbar {
  flex-shrink: 0;
  padding: 14px 0 18px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 4px 8px -8px rgba(15,23,42,.18);
}
.week-list {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; overflow-x: hidden;
  padding: 18px 8px 8px 2px;
  scrollbar-gutter: stable;
}
.week-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
  flex-shrink: 0;
}
.week-card.has-data:hover { border-color: var(--brand); box-shadow: var(--shadow-md); }
.week-card.current { border-color: var(--brand); border-width: 2px; background: var(--brand-soft); }
.week-card-header {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px; cursor: pointer;
  user-select: none;
}
.week-card-header:hover { background: var(--bg-soft); }
.week-card.current .week-card-header:hover { background: rgba(29,78,216,.06); }
.week-range { font-size: 16px; font-weight: 700; min-width: 150px; color: var(--text); }
.week-previews { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; align-items: center; }
.week-preview-item {
  background: var(--brand-soft); padding: 4px 12px; border-radius: 14px; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.week-preview-item .name { color: var(--text); font-weight: 500; }
.week-preview-item .qty { color: var(--brand); font-weight: 700; }
.week-more { font-size: 12px; color: var(--sub); font-weight: 600; padding: 0 4px; }
.week-empty-mini { font-size: 13px; color: var(--muted); font-style: italic; }
.week-total {
  font-size: 18px; font-weight: 700; color: var(--brand);
  min-width: 110px; text-align: right;
}
.week-total.zero { color: var(--muted); font-weight: 500; }
.week-toggle { color: var(--sub); transition: transform .25s ease; font-size: 12px; width: 16px; text-align: center; }
.week-card.expanded .week-toggle { transform: rotate(180deg); color: var(--brand); }
.week-detail {
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease;
}
.week-card.expanded .week-detail {
  max-height: 1200px;
  border-top: 1px solid var(--line-soft);
}
.week-detail-inner { padding: 18px 22px; }
.week-detail-table { width: 100%; }
.week-detail-table th, .week-detail-table td { padding: 10px 14px; font-size: 14px; }
.week-empty-detail { padding: 18px 22px; color: var(--sub); font-size: 14px; text-align: center; }

/* ===== 월간 그리드 뷰 ===== */
#invMonthlyView { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#invMonthlyView.hidden { display: none; }
#invMonthlyView .cal-toolbar {
  flex-shrink: 0;
  padding: 14px 0 18px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 4px 8px -8px rgba(15,23,42,.18);
}
.month-grid {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  padding: 18px 4px 8px;
}
.month-cell {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  cursor: pointer; transition: all .15s ease;
  overflow: hidden; min-height: 0;
}
.month-cell:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.month-cell.current { border-color: var(--brand); border-width: 2px; background: var(--brand-soft); }
.month-cell-header {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-shrink: 0;
}
.month-cell-name { font-size: 18px; font-weight: 700; color: var(--text); }
.month-cell.has-data .month-cell-name { color: var(--brand); }
.month-cell-total { font-size: 16px; font-weight: 700; color: var(--brand); }
.month-cell-total.zero { color: var(--muted); font-weight: 500; }
.month-cell-items {
  display: flex; flex-direction: column; gap: 4px;
  min-height: 0; overflow: hidden;
}
.month-cell-item {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  background: var(--brand-soft); padding: 4px 10px; border-radius: 6px;
  font-size: 12px; line-height: 1.3;
}
.month-cell-item .name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-weight: 500;
}
.month-cell-item .qty { color: var(--brand); font-weight: 700; flex-shrink: 0; }
.month-cell-empty {
  font-size: 12px; color: var(--muted); font-style: italic;
  text-align: center; margin: auto 0; padding: 4px 0;
}

/* ===== 일간 상세 모달 ===== */
.day-detail-box { min-width: 600px; max-width: 760px; padding: 36px; gap: 20px; }
.day-detail-box h3 { font-size: 24px; }
.day-detail-table { width: 100%; font-size: 16px; }
.day-detail-table th, .day-detail-table td { padding: 14px 16px; font-size: 16px; }
.day-detail-table .total-row td { font-size: 18px; font-weight: 700; }
.day-detail-empty { padding: 32px; text-align: center; color: var(--sub); font-size: 16px; }
.day-detail-box .modal-footer button { font-size: 15px; padding: 10px 20px; }

/* ===== 미디어 쿼리 (생산량 탭) ===== */
@media (max-width: 1100px) {
  .month-grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .cal-grid { grid-auto-rows: minmax(90px, 1fr); }
  .cal-item { font-size: 10px; padding: 2px 5px; }
  .day-detail-box { min-width: 480px; padding: 28px; }
  .day-detail-box h3 { font-size: 20px; }
  .day-detail-table th, .day-detail-table td { padding: 12px 14px; font-size: 15px; }
}
@media (max-width: 700px) {
  .cal-grid { gap: 4px; grid-auto-rows: minmax(70px, 1fr); }
  .cal-cell { padding: 4px 5px; border-radius: 8px; gap: 3px; }
  .cal-day { font-size: 12px; }
  .cal-item { font-size: 9px; padding: 1px 4px; gap: 2px; }
  .cal-month-label { font-size: 16px; min-width: 130px; padding: 4px 10px; }

  .week-card-header { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .week-range { font-size: 14px; min-width: 110px; }
  .week-preview-item { font-size: 11px; padding: 3px 9px; }
  .week-total { font-size: 15px; min-width: 80px; }
  .week-detail-inner { padding: 14px; }

  .month-grid { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(6, 1fr); gap: 8px; padding: 14px 2px; }
  .month-cell { padding: 12px 14px; gap: 6px; }
  .month-cell-name { font-size: 15px; }
  .month-cell-total { font-size: 14px; }
  .month-cell-item { font-size: 11px; padding: 3px 8px; }

  .day-detail-box { min-width: auto; width: 94vw; padding: 20px; gap: 14px; }
  .day-detail-box h3 { font-size: 18px; }
  .day-detail-table th, .day-detail-table td { padding: 10px 12px; font-size: 14px; }
  .day-detail-table .total-row td { font-size: 15px; }
}
