* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
}

/* 앱 컨테이너 */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* 사이드바 */
.sidebar {
  width: 280px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar.hidden {
  transform: translateX(-100%);
  position: absolute;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
}

.sidebar-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.sidebar-actions {
  padding: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.btn-new-report {
  width: 100%;
  padding: 10px;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-new-report:hover {
  background: #333;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: #f0f0f0;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-item {
  padding: 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-item:hover {
  background: #f5f5f5;
}

.history-item-content {
  flex: 1;
  min-width: 0;
}

.btn-delete {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  flex-shrink: 0;
}

.history-item:hover .btn-delete {
  opacity: 1;
}

.btn-delete:hover {
  background: #fee;
  color: #c00;
}

.history-item.active {
  background: #f0f0f0;
  border-color: #333;
}

.history-item-title {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  font-size: 12px;
  color: #888;
}

.history-context {
  margin-bottom: 8px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}

.history-context:last-child {
  border-bottom: none;
}

.history-item.revision {
  margin-left: 16px;
  padding: 8px 12px;
  background: #fafafa;
  border-left: 2px solid #ddd;
}

.history-item.revision .history-item-title {
  font-size: 13px;
  color: #666;
}

.history-item.revision .history-item-meta {
  font-size: 11px;
}

.empty-message {
  color: #999;
  text-align: center;
  padding: 20px;
  font-size: 14px;
}

/* 메인 콘텐츠 */
.main-content {
  flex: 1;
  overflow-y: auto;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.header-row > div {
  text-align: center;
}

#showSidebar {
  display: none;
}

@media (max-width: 1024px) {
  #showSidebar {
    display: flex;
    position: absolute;
    left: 20px;
  }
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

header .subtitle {
  color: #666;
  font-size: 14px;
}

main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.input-section,
.output-section {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
}

.form-group select,
.form-group textarea,
.form-group input[type="text"] {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group select:focus,
.form-group textarea:focus,
.form-group input[type="text"]:focus {
  outline: none;
  border-color: #333;
}

.form-group textarea {
  resize: vertical;
  min-height: 200px;
}

/* 파일 업로드 */
.file-upload-area {
  position: relative;
  border: 2px dashed #ddd;
  border-radius: 6px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.file-upload-area:hover,
.file-upload-area.dragover {
  border-color: #333;
  background: #fafafa;
}

.file-upload-area input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-label {
  color: #888;
  font-size: 14px;
}

.file-list {
  margin-top: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f5f5f5;
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 13px;
}

.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  color: #888;
  font-size: 12px;
  margin: 0 10px;
}

.file-item-remove {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.file-item-remove:hover {
  color: #c00;
}

.btn-primary {
  padding: 14px;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #333;
}

.btn-primary:disabled {
  background: #999;
  cursor: not-allowed;
}

#generateBtn {
  width: 100%;
}

.btn-secondary {
  padding: 8px 16px;
  background: #fff;
  color: #333;
  border: 1px solid #333;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #333;
  color: #fff;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.output-header h2 {
  font-size: 18px;
}

.download-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.font-notice {
  font-size: 11px;
  color: #888;
  margin-top: 8px;
  text-align: right;
}

.font-notice a {
  color: #666;
  text-decoration: underline;
}

.font-notice a:hover {
  color: #000;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #ddd;
  margin-bottom: 16px;
}

.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: #000;
  border-bottom-color: #000;
  font-weight: 600;
}

.tab-content {
  min-height: 400px;
}

#previewFrame {
  width: 100%;
  height: 500px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
}

#jsonOutput {
  background: #f9f9f9;
  padding: 16px;
  border-radius: 4px;
  font-size: 12px;
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 수정 요청 섹션 */
.revise-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.revise-input-row {
  display: flex;
  gap: 10px;
}

.revise-input-row input {
  flex: 1;
}

.revise-input-row .btn-primary {
  width: auto;
  padding: 12px 24px;
}

.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #ddd;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  color: #666;
  font-size: 14px;
}

/* 태블릿 (1024px 이하) */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .container {
    padding: 30px 16px;
  }

  main {
    gap: 24px;
  }

  .input-section,
  .output-section {
    padding: 20px;
  }
}

/* 모바일 (768px 이하) */
@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
  }

  header {
    margin-bottom: 24px;
  }

  header h1 {
    font-size: 24px;
  }

  .container {
    padding: 20px 12px;
  }

  .input-section,
  .output-section {
    padding: 16px;
    border-radius: 6px;
  }

  .form-group textarea {
    min-height: 150px;
  }

  #previewFrame {
    height: 400px;
  }

  .tab-content {
    min-height: 300px;
  }

  .output-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .download-buttons {
    width: 100%;
  }

  .download-buttons .btn-secondary {
    flex: 1;
    text-align: center;
  }

  .revise-input-row {
    flex-direction: column;
  }

  .revise-input-row .btn-primary {
    width: 100%;
  }
}

/* 소형 모바일 (480px 이하) */
@media (max-width: 480px) {
  header h1 {
    font-size: 20px;
  }

  header .subtitle {
    font-size: 12px;
  }

  .container {
    padding: 16px 10px;
  }

  .form-group select,
  .form-group textarea {
    padding: 10px;
    font-size: 13px;
  }

  .btn-primary {
    padding: 12px;
    font-size: 14px;
  }

  .tab {
    padding: 8px 12px;
    font-size: 13px;
  }

  #previewFrame {
    height: 350px;
  }

  #jsonOutput {
    font-size: 11px;
    padding: 12px;
    max-height: 350px;
  }
}

/* 보고서 유형 버튼 */
.report-type-buttons {
  display: flex;
  gap: 10px;
}

.btn-type,
.btn-mode {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #ddd;
  background: #fff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-type:hover,
.btn-mode:hover {
  border-color: #999;
}

.btn-type.active,
.btn-mode.active {
  border-color: #000;
  background: #000;
  color: #fff;
}

/* 보고 기간 입력 */
.period-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.period-row.period-manual {
  margin-top: 8px;
}

/* 주차 목록 */
.week-item.week-current {
  border-left: 3px solid #4a7cf7;
}

.week-item.week-future {
  opacity: 0.55;
}

.week-status {
  color: #888;
}

.week-status.done {
  color: #2a9d5c;
  font-weight: 600;
}

.save-indicator {
  font-size: 12px;
  color: #2a9d5c;
  margin: 4px 0 0 0;
  min-height: 15px;
}

.save-indicator.save-error {
  color: #d33;
}

/* 작성 담당자 표시 */
.writer-note {
  font-size: 12px;
  color: #4a7cf7;
  margin: 8px 0 0 0;
}

.writer-note.writer-note-warn {
  color: #c47f00;
}

.week-check {
  display: flex;
  align-items: center;
  padding: 4px;
  flex-shrink: 0;
  cursor: pointer;
}

.roster-check {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2a9d5c;
}

/* 부서별 입력 */
.field-hint {
  font-size: 12px;
  color: #888;
  margin: 0 0 10px 0;
}

.dept-group {
  margin-bottom: 16px;
}

.dept-group-title {
  font-size: 12px;
  font-weight: 700;
  color: #666;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.dept-block {
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 6px;
  background: #fff;
}

.dept-block.has-content {
  border-color: #4a7cf7;
}

.dept-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  list-style: none;
}

.dept-summary::-webkit-details-marker {
  display: none;
}

.dept-summary::before {
  content: "▸";
  margin-right: 8px;
  color: #999;
  font-size: 11px;
}

.dept-block[open] .dept-summary::before {
  content: "▾";
}

.dept-name {
  flex: 1;
}

.dept-badge {
  font-size: 11px;
  color: #4a7cf7;
}

.dept-body {
  padding: 0 12px 12px 12px;
}

.dept-field-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin: 8px 0 4px 0;
}

.dept-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.dept-input:focus {
  outline: none;
  border-color: #4a7cf7;
}

.period-row input {
  flex: 1;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.period-row span {
  color: #666;
}

/* ICC 보고서 스타일 */
.btn-add {
  background: #f0f0f0;
  border: 1px dashed #999;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  color: #666;
  margin-top: 8px;
}
.btn-add:hover {
  background: #e0e0e0;
  border-color: #666;
}

.icc-dept-block {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.icc-dept-header {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.icc-dept-header input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.icc-dept-items {
  margin-left: 12px;
}

.icc-item-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.icc-item-row input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
}

.btn-remove {
  background: #ff5252;
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.btn-remove:hover {
  background: #d32f2f;
}

.btn-add-item {
  background: transparent;
  border: none;
  color: #1976d2;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 0;
}
.btn-add-item:hover {
  text-decoration: underline;
}

.icc-discussion-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.icc-discussion-row input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* 확정본 보관함 */
.btn-archive {
  width: 100%;
  padding: 10px 8px;
  margin-top: 8px;
  background: #fff;
  color: #000;
  border: 1px solid #000;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-archive:hover {
  background: #000;
  color: #fff;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-desc {
  font-size: 13px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 16px;
}
.modal-desc code {
  background: #f2f2f2;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.confirmed-upload {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.confirmed-upload input[type="file"] {
  flex: 1;
  font-size: 13px;
}
.confirmed-upload-hint {
  font-size: 12px;
  color: #d32f2f;
  min-height: 16px;
  margin-bottom: 12px;
}

.confirmed-list {
  border-top: 1px solid #eee;
  padding-top: 8px;
}
.confirmed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid #f0f0f0;
}
.confirmed-item.invalid {
  background: #fff8e1;
}
.confirmed-item-name {
  font-size: 13px;
  font-weight: 500;
  word-break: break-all;
}
.confirmed-item-meta {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}
.confirmed-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.confirmed-item-actions a.btn-secondary {
  text-decoration: none;
  font-size: 12px;
  padding: 6px 10px;
}
.btn-delete-confirmed {
  background: transparent;
  border: none;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.btn-delete-confirmed:hover {
  color: #d32f2f;
}

/* 확정본으로 추가 모달 */
.modal.modal-sm {
  max-width: 420px;
}
.ca-preview {
  font-size: 12px;
  color: #333;
  background: #f2f2f2;
  padding: 8px 10px;
  border-radius: 4px;
  word-break: break-all;
  margin: 4px 0 6px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
