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

/* B-2: input[type=number] spinner 숨김 (수직 화살표 제거) */
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
}

/* 로그인 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
}

.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 10px;
  width: 350px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
}

/* 폼 요소 */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #1a73e8;
}

/* 버튼 */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: #1a73e8;
  color: #fff;
}

.btn-primary:hover {
  background: #1557b0;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

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

.btn-secondary:hover {
  background: #ddd;
}

.btn-danger {
  background: #e53935;
  color: #fff;
}

.btn-danger:hover {
  background: #c62828;
}

.btn-success {
  background: #0a8d48;
  color: #fff;
}

.btn-success:hover {
  background: #097a3e;
}

/* 엑셀 업로드 드래그앤드롭 영역 */
#importDropzone { transition: border-color .15s, background .15s; }
#importDropzone.dragover {
  border-color: #1a73e8 !important;
  background: #e8f0fe !important;
}

/* 토글 스위치 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #1a73e8;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* 자동완성 */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.autocomplete-list.show {
  display: block;
}

.autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

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

/* 키보드(↑↓)로 선택된 자동완성 항목 */
.autocomplete-item.active {
  background: #e3f0ff;
}

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

.autocomplete-item small {
  color: #888;
  font-size: 12px;
}

/* 앱 레이아웃 */
.app-wrap {
  display: none;
}

.header {
  background: linear-gradient(135deg, #1a73e8, #4285f4);
  color: #fff;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
}

.header a {
  color: #fff;
  text-decoration: none;
}

.header a:hover {
  text-decoration: underline;
}

/* 메뉴 */
.menu {
  background: #fff;
  padding: 0 20px;
  border-bottom: 1px solid #ddd;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.menu-item {
  cursor: pointer;
  padding: 15px 15px;
  position: relative;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  transition: all 0.2s;
}

.menu-item:hover {
  color: #1a73e8;
  background: #f5f5f5;
}

.menu-item.active {
  color: #1a73e8;
  border-bottom: 3px solid #1a73e8;
}

.submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #ddd;
  min-width: 140px;
  z-index: 100;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.menu-item:hover .submenu {
  display: block;
}

.submenu div {
  padding: 12px 15px;
  cursor: pointer;
  font-weight: normal;
}

.submenu div:hover {
  background: #f5f5f5;
}

/* 콘텐츠 영역 */
.content {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.card:has(.split-layout) {
  height: calc(100vh - 160px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card:has(.split-layout) .toolbar {
  flex-shrink: 0;
}

.card:has(.split-layout) .split-layout {
  flex: 1;
  height: auto;
  min-height: 0;
}

.card h2 {
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

/* 대시보드 통계 */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.stat-box {
  background: #fff;
  padding: 25px 20px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 0.2s;
}

.stat-box:hover {
  transform: translateY(-2px);
}

.stat-box h3 {
  font-size: 32px;
  color: #1a73e8;
  font-weight: 700;
  margin-bottom: 5px;
}

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

/* 테이블 */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  border: 2px solid #bbb;
  border-top: none;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

th, td {
  padding: 12px 10px;
  text-align: center;
  vertical-align: middle;
  border-right: 1px solid #ccc;
  border-bottom: 1px solid #ddd;
}

th:first-child, td:first-child {
  border-left: none;
}

th:last-child, td:last-child {
  border-right: none;
}

th {
  background: #f5f5f5;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  border-top: 2px solid #bbb;
  border-bottom: 2px solid #aaa;
  border-right: 1px solid #aaa;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 20px;
}

th.sortable:hover {
  background: #e8e8e8;
}

th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 5px;
  opacity: 0.3;
  font-size: 12px;
}

th.sortable.asc::after {
  content: '▲';
  opacity: 1;
}

th.sortable.desc::after {
  content: '▼';
  opacity: 1;
}

tr:hover {
  background: #fafafa;
}

.table-loading {
  text-align: center;
  padding: 40px;
  color: #888;
}

/* 툴바 */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbar input[type="text"],
.toolbar input[type="date"] {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

/* 모달 */
.modal-bg {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-bg.show {
  display: flex;
}

.modal {
  background: #fff;
  padding: 20px 25px 25px;
  border-radius: 12px;
  width: 420px;
  max-height: 95vh;
  overflow-y: auto;
  overflow-x: visible;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  /* B-1: 모달 열기 200~250ms ease-out */
  animation: modal-in 220ms ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 모달 내 자동완성이 모달 밖으로 나올 수 있도록 */
.autocomplete-list.fixed-pos {
  position: fixed;
  top: auto;
  left: auto;
  right: auto;
  min-width: 200px;
  max-height: 250px;
  z-index: 2000;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.modal h3 {
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.modal .form-group {
  margin-bottom: 12px;
}

.modal-footer {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 토스트 */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 15px 25px;
  background: #333;
  color: #fff;
  border-radius: 8px;
  display: none;
  z-index: 9999;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast.show {
  display: block;
  animation: slideIn 0.3s ease;
}

.toast.error {
  background: #e53935;
}

@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 로딩 */
.loading {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.9);
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading.show {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #ddd;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.inline-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #eee;
  border-top: 2px solid #1a73e8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

/* 경고 표시 */
.dup-warning {
  color: #e53935;
  font-weight: bold;
}

/* 그리드 레이아웃 */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* 구분선 */
hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 15px 0;
}

/* 반응형 */
@media (max-width: 1024px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .menu {
    padding: 10px;
  }

  .menu-item {
    padding: 10px;
    font-size: 13px;
  }

  .content {
    padding: 15px;
  }

  .modal {
    width: 95%;
    margin: 10px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right {
    flex-wrap: wrap;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 8px 5px;
  }
}

@media (max-width: 480px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .login-box {
    width: 90%;
    padding: 30px 20px;
  }

  .header h1 {
    font-size: 16px;
  }
}

/* 페이지 숨김 */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* 분할 레이아웃 (입고/출고용) */
.split-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 15px;
  height: calc(100vh - 220px);
  min-height: 400px;
}

.split-left {
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.split-left-header {
  padding: 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.split-left-list {
  flex: 1;
  overflow-y: auto;
}

.split-left-item {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  font-size: 13px;
}

.split-left-item:hover {
  background: #f5f7fa;
}

.split-left-item.active {
  background: #e3f2fd;
  color: #1a73e8;
  font-weight: 500;
}

.split-left-item small {
  display: block;
  color: #888;
  font-size: 11px;
  margin-top: 2px;
}

.split-right {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.split-right .toolbar {
  margin-bottom: 10px;
  flex-shrink: 0;
}

.split-right .table-wrapper {
  flex: 1;
  overflow: auto;
}

/* 입력용 테이블 스타일 */
.entry-table input,
.entry-table select {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  width: 100%;
  min-width: 60px;
}

.entry-table input:focus,
.entry-table select:focus {
  outline: none;
  border-color: #1a73e8;
}

.entry-table td {
  padding: 6px 4px;
}

/* 체크박스는 텍스트 input 스타일(너비 100% 등)에서 제외 */
.entry-table input[type="checkbox"] {
  width: auto;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: none;
  vertical-align: middle;
  cursor: pointer;
}

/* No. + 체크박스 열 정렬 */
.entry-table .no-cell {
  text-align: center;
  white-space: nowrap;
}
.entry-table .no-cell input[type="checkbox"] {
  margin-right: 5px;
}
.entry-table .no-cell span {
  vertical-align: middle;
}

.entry-table .btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

/* 인라인 자동완성 */
.inline-autocomplete {
  position: relative;
}

.inline-autocomplete input {
  width: 100%;
}

.inline-autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.inline-autocomplete-list.show {
  display: block;
}

.inline-autocomplete-list .autocomplete-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  font-size: 12px;
}

.inline-autocomplete-list .autocomplete-item:hover {
  background: #f5f5f5;
}

.inline-autocomplete-list .autocomplete-item small {
  color: #888;
  font-size: 11px;
}

/* NEW 뱃지 */
.new-badge {
  display: inline-block;
  background: #4caf50;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
}

/* 입력 행 스타일 */
.si-new-row,
.so-new-row,
.res-new-row {
  background: #fffde7 !important;
}

.si-new-row:hover,
.so-new-row:hover,
.res-new-row:hover {
  background: #fff9c4 !important;
}

/* + 새 제목 버튼 */
.add-title-btn {
  color: #1a73e8 !important;
  font-weight: 600 !important;
  text-align: center !important;
  border-bottom: none !important;
}

.add-title-btn:hover {
  background: #e3f2fd !important;
}

/* 테이블 내 행 추가 버튼 */
.si-add-row td,
.so-add-row td,
.res-add-row td {
  padding: 4px !important;
  border: none !important;
}

.btn-add-row {
  width: 100%;
  padding: 6px 0;
  border: 2px dashed #ccc;
  border-radius: 6px;
  background: #fafafa;
  color: #888;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-add-row:hover {
  border-color: #1a73e8;
  color: #1a73e8;
  background: #e3f2fd;
}

/* 둥근 + 버튼 */
.btn-icon-round {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #1a73e8;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-icon-round:hover {
  background: #1557b0;
}

/* + 아이콘 버튼 */
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  color: #1a73e8;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
  transition: background 0.15s;
}

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

/* 커스텀 달력 */
.custom-calendar {
  flex-shrink: 0;
  user-select: none;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
}

.cal-header .cal-title {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.cal-header button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #555;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.cal-header button:hover {
  background: #e0e0e0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 4px;
  gap: 1px;
}

.cal-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: #888;
  padding: 4px 0;
}

.cal-dow:first-child { color: #e53935; }
.cal-dow:last-child { color: #1a73e8; }

.cal-day {
  position: relative;
  text-align: center;
  font-size: 12px;
  padding: 5px 0 8px;
  cursor: pointer;
  border-radius: 4px;
  color: #333;
  transition: background 0.15s;
}

.cal-day:hover {
  background: #f0f0f0;
}

.cal-day.other-month {
  color: #ccc;
}

.cal-day.today {
  font-weight: 700;
  color: #1a73e8;
}

.cal-day.selected {
  background: #1a73e8;
  color: #fff;
  font-weight: 600;
}

.cal-day.selected:hover {
  background: #1557b0;
}

.cal-day.has-data::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  background: #1a73e8;
  border-radius: 50%;
}

.cal-day.selected.has-data::after {
  background: #fff;
}

.cal-day.other-month.has-data::after {
  background: #bbb;
}

.cal-day.sun { color: #e53935; }
.cal-day.sat { color: #1a73e8; }
.cal-day.selected.sun,
.cal-day.selected.sat { color: #fff; }
.cal-day.other-month.sun,
.cal-day.other-month.sat { color: #ccc; }

/* 필터 영역 */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 6px;
}

.filter-row select,
.filter-row input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  min-width: 120px;
}

/* 반응형 분할 레이아웃 */
@media (max-width: 900px) {
  .split-layout {
    grid-template-columns: 1fr;
  }

  .split-left {
    max-height: 200px;
  }

  .split-left-list {
    max-height: 150px;
  }
}

/* 입고/출고/결의서/재고 풀스크린 */
.content:has(#page-stockIn.active),
.content:has(#page-stockOut.active),
.content:has(#page-resolutions.active),
.content:has(#page-inventory.active) {
  max-width: none;
  padding: 10px;
}

.content:has(#page-stockIn.active) .card,
.content:has(#page-stockOut.active) .card,
.content:has(#page-resolutions.active) .card,
.content:has(#page-inventory.active) .card {
  height: calc(100vh - 120px);
  margin-bottom: 0;
  border-radius: 8px;
}

.content:has(#page-stockIn.active) .split-layout,
.content:has(#page-stockOut.active) .split-layout,
.content:has(#page-resolutions.active) .split-layout {
  height: calc(100vh - 180px);
}

/* 재고관리 테이블 높이 */
.content:has(#page-inventory.active) .card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content:has(#page-inventory.active) .toolbar,
.content:has(#page-inventory.active) .filter-row {
  flex-shrink: 0;
}

.content:has(#page-inventory.active) .table-wrapper {
  flex: 1;
  overflow: auto;
}

/* 도움말 버튼 */
.help-btn { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #1a73e8; background: #fff; color: #1a73e8; font-weight: bold; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; margin-left: 8px; vertical-align: middle; }
.help-btn:hover { background: #1a73e8; color: #fff; }
.help-section { margin-bottom: 14px; }
.help-section h4 { margin-bottom: 4px; color: #1a73e8; font-size: 14px; }
.help-section p, .help-section li { font-size: 13px; color: #444; line-height: 1.7; }
.help-section ul { padding-left: 18px; margin: 4px 0; }
.help-example { background: #f5f7fa; border-left: 3px solid #1a73e8; padding: 8px 12px; margin: 6px 0; font-size: 13px; color: #333; border-radius: 0 4px 4px 0; }
