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

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0a0;
  --accent: #e94560;
  --accent-hover: #ff6b6b;
  --success: #4ade80;
  --warning: #fbbf24;
  --info: #60a5fa;
  --border: #2d3748;
  
  /* 상태 색상 */
  --status-wait: #6b7280;
  --status-progress: #3b82f6;
  --status-review: #f59e0b;
  --status-done: #10b981;
  --status-hold: #ef4444;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* 헤더 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* 버튼 */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* 탭 */
.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 8px 20px;
  border: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.tab.active {
  color: var(--text-primary);
  background: var(--bg-primary);
  font-weight: 600;
}

.tab-wrapper {
  display: flex;
  align-items: center;
  position: relative;
}

.tab-delete {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

.tab-wrapper:hover .tab-delete {
  display: flex;
}

.tab-delete:hover {
  background: var(--accent);
  color: white;
}

.tab-wrapper .tab {
  padding-right: 24px;
}

/* 메인 */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  flex: 1;
  overflow: hidden;
}

.view.active {
  display: flex;
  flex-direction: column;
}

/* 툴바 */
.toolbar {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.search-input {
  flex: 1;
  max-width: 300px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
}

/* 테이블 */
.table-container {
  flex: 1;
  overflow: auto;
  padding: 0 24px 24px;
}

#data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#data-table th,
#data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

#data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

#data-table tbody tr:hover {
  background: var(--bg-card);
}

/* 컬럼 너비 */
.col-actions { width: 50px; min-width: 50px; }
.col-type { width: 100px; min-width: 100px; }
.col-version { width: 70px; min-width: 70px; }
.col-resource { width: 160px; min-width: 160px; }
.col-service { width: 120px; min-width: 120px; }
.col-jira { width: 80px; min-width: 80px; }
.col-start { width: 80px; min-width: 80px; }
.col-end { width: 80px; min-width: 80px; }
.col-status { width: 70px; min-width: 70px; }
.col-note { width: 90px; min-width: 90px; }
.col-itemcode { width: 80px; min-width: 80px; }
.col-img { width: 90px; min-width: 90px; }
.col-prefab { width: 60px; min-width: 60px; }
.col-etc { width: 70px; min-width: 70px; }
.col-qa { width: 100px; min-width: 100px; }
.col-qa-status { width: 90px; min-width: 90px; }

/* 상태 뱃지 */
.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.status-대기, .status-기획중 { background: var(--status-wait); color: white; }
.status-제작중 { background: var(--status-progress); color: white; }
.status-감수중, .status-수정중 { background: var(--status-review); color: black; }
.status-완료 { background: var(--status-done); color: white; }
.status-보류, .status-취소 { background: var(--status-hold); color: white; }

/* 분리 색상 */
.section-인게임 { color: #60a5fa; }
.section-UI { color: #a78bfa; }
.section-영상 { color: #f472b6; }

/* 편집 가능 셀 */
.editable-date, .editable-status, .editable-jira, .editable-text, .editable-type, .editable-img, .editable-qa-status {
  cursor: pointer;
  position: relative;
}

.editable-date:hover, .editable-status:hover, .editable-jira:hover, .editable-text:hover, .editable-type:hover, .editable-img:hover, .editable-qa-status:hover {
  background: var(--bg-card);
}

/* QA 검수 현황 배지 */
.qa-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
}

.qa-검수-대기 {
  background: #3d3d3d;
  color: #aaa;
}

.qa-검수-진행중 {
  background: #1e3a5f;
  color: #4dabf7;
}

.qa-검수-완료 {
  background: #1e4620;
  color: #69db7c;
}

.qa-검수-대상-외 {
  background: #4a4a4a;
  color: #888;
}

/* 행 액션 */
.row-actions {
  text-align: center;
  padding: 4px !important;
  white-space: nowrap;
}

.btn-row-delete {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  opacity: 0.5;
  transition: all 0.15s;
  display: inline-block;
  vertical-align: middle;
}

tr:hover .btn-row-delete {
  opacity: 1;
}

.btn-row-delete:hover {
  background: var(--accent);
  color: white;
}

.drag-handle {
  cursor: grab;
  color: var(--text-secondary);
  opacity: 0.5;
  margin-right: 2px;
  font-size: 10px;
  letter-spacing: -3px;
  display: inline-block;
}

tr:hover .drag-handle {
  opacity: 0.7;
}

.drag-handle:active {
  cursor: grabbing;
}

tr.dragging {
  opacity: 0.5;
  background: var(--bg-card);
}

tr.drag-over {
  border-top: 2px solid var(--accent) !important;
}

/* 분류 팝오버 */
.popover-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.popover-add-section,
.popover-add-type {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
}

.popover-add-section input,
.popover-add-type input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
}

.popover-add-section input:focus,
.popover-add-type input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-add-section,
.btn-add-type {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 14px;
}

/* 행 추가 */
.add-row td {
  padding: 12px !important;
  text-align: center;
  border: none !important;
}

.btn-add-row {
  padding: 8px 20px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.btn-add-row:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.placeholder {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 11px;
}

/* 팝오버 */
.popover {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1000;
  min-width: 140px;
  overflow: hidden;
}

.popover-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.popover-option {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.popover-option:hover {
  background: var(--bg-card);
}

.popover-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.option-text {
  flex: 1;
  cursor: pointer;
}

.btn-delete-section,
.btn-delete-type {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.15s;
}

.popover-option:hover .btn-delete-section,
.popover-option:hover .btn-delete-type {
  opacity: 1;
}

.btn-delete-section:hover,
.btn-delete-type:hover {
  background: var(--accent);
  color: white;
}

.popover-option.selected {
  background: var(--accent);
  color: white;
}

.popover-option .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.popover-date {
  padding: 12px;
}

.popover-date input[type="date"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
}

.popover-date input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

.popover-date-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.popover-date-actions button {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.popover-date-actions .btn-clear {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.popover-date-actions .btn-apply {
  background: var(--accent);
  color: white;
}

/* 팝오버 화살표 */
.popover::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 20px;
  width: 12px;
  height: 12px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}

/* 이미지 썸네일 */
.thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
}

.thumb-placeholder {
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.image-cell {
  text-align: center;
}

/* 간트 뷰 */
.gantt-container {
  flex: 1;
  overflow: auto;
  padding: 24px;
}

.gantt-header {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 10;
}

.gantt-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.gantt-label {
  width: 250px;
  min-width: 250px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  position: sticky;
  left: 0;
  z-index: 5;
}

.gantt-bars {
  display: flex;
  flex: 1;
  position: relative;
  height: 36px;
}

.gantt-day {
  width: 30px;
  min-width: 30px;
  height: 100%;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-secondary);
}

.gantt-day.weekend {
  background: rgba(255,255,255,0.03);
}

.gantt-day.today {
  background: rgba(233, 69, 96, 0.2);
  border-color: var(--accent);
}

.gantt-bar {
  position: absolute;
  height: 24px;
  border-radius: 4px;
  top: 6px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-bar.status-대기 { background: var(--status-wait); }
.gantt-bar.status-제작중 { background: var(--status-progress); }
.gantt-bar.status-감수중 { background: var(--status-warning); }
.gantt-bar.status-완료 { background: var(--status-done); }

/* 모달 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 90%;
  max-width: 600px;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.modal-body p {
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.modal-body .hint {
  font-size: 12px;
  color: var(--accent);
}

.modal-body textarea {
  width: 100%;
  height: 200px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* 매칭 안 된 일감 다이얼로그 */
.unmatched-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unmatched-item:last-child {
  border-bottom: none;
}

.unmatched-issue {
  display: flex;
  align-items: center;
  gap: 10px;
}

.unmatched-issue a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  min-width: 80px;
}

.unmatched-issue a:hover {
  text-decoration: underline;
}

.unmatched-summary {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.unmatched-match {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 90px;
}

.match-score {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.match-score.high {
  background: #1e4620;
  color: #69db7c;
}

.match-score.mid {
  background: #4a3f00;
  color: #ffd43b;
}

.match-select {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
}

.unmatched-list {
  background: var(--bg-card);
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* 이미지 팝오버 */
.popover-img {
  min-width: 280px;
}

.popover-img-content {
  padding: 12px;
}

.img-preview-box {
  width: 100%;
  height: 120px;
  background: var(--bg-card);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  overflow: hidden;
}

.img-preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.img-preview-box .no-img {
  color: var(--text-secondary);
  font-size: 12px;
}

.img-filename-row {
  margin-bottom: 12px;
}

.img-filename-row label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.img-filename-row input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
}

.img-filename-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.img-actions-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-upload {
  flex: 1;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  transition: all 0.15s;
}

.btn-upload:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-preview {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
}

.btn-preview:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-preview:not(:disabled):hover {
  border-color: var(--accent);
}

/* 이미지 모달 */
.img-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-modal-content {
  max-width: 90%;
  max-height: 90%;
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
}

.img-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.img-modal-header span {
  font-size: 14px;
  font-weight: 600;
}

.img-modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  border-radius: 4px;
}

.img-modal-close:hover {
  background: var(--accent);
  color: white;
}

.img-modal-body {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-modal-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

/* 반응형 */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 12px;
  }
  
  .toolbar {
    flex-wrap: wrap;
  }
  
  .search-input {
    max-width: 100%;
  }
}
