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

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;
}

/* 토글 스위치 */
.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: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 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: collapse;
  font-size: 13px;
  border: 2px solid #bbb;
}

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

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

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;
  box-shadow: 0 10px 40px 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;
}
