/* ============================================
   스타트업 관리비 운영 플랫폼 — 디자인 시스템
   테마: 화이트 미니멀 (White Minimal)
   기준: sample/UI-design.md
   ============================================ */

/* ===== 글로벌 리셋 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    system-ui, Roboto, "Helvetica Neue", "Segoe UI",
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic",
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  background: #ffffff;
  color: #1f2937;
  min-height: 100vh;
}

/* ===== 사이드바 ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 100vh;
  background: #f8f9fa;
  border-right: 1px solid #e5e7eb;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-header h1 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #111827;
  letter-spacing: -0.02em;
}

.sidebar-header p {
  font-size: 0.68rem;
  color: #9ca3af;
  margin-top: 0.2rem;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  font-size: 13px;
  font-weight: 500;
  color: #4b5563;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sidebar-link:hover {
  background: #ffffff;
  color: #1f2937;
}

.sidebar-link.active {
  background: #ffffff;
  color: #1f2937;
  font-weight: 700;
  border-left-color: #e91e63;
}

.sidebar-link svg {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0.5rem 1rem;
}

.sidebar-section-label {
  font-size: 0.63rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.75rem 1rem 0.35rem;
}

/* 관리자 전용 메뉴 */
.admin-only {
  display: none;
}
.admin-only.visible {
  display: block;
}

/* ===== 메인 콘텐츠 ===== */
.main-content {
  margin-left: 200px;
  padding: 2rem 3rem;
  min-height: 100vh;
}

/* ===== KPI 카드 ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  padding: 1.5rem;
  transition: box-shadow 0.2s ease;
}

.kpi-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.09);
}

.kpi-card--featured {
  background: #f9f9f9;
  border-color: #e0e0e0;
}

.kpi-card-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.kpi-card-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: #111827;
  letter-spacing: -0.03em;
}

.kpi-card-value.small {
  font-size: 1.25rem;
}

.kpi-card-sub {
  font-size: 0.68rem;
  font-weight: 600;
  color: #9ca3af;
  margin-top: 0.3rem;
}

/* ===== 테이블 래퍼 ===== */
.table-wrap {
  background: #ffffff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-header-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
}

.table-body {
  overflow-x: auto;
}

.table-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table-body thead tr {
  text-align: left;
  font-size: 0.72rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #f0f0f0;
}

.table-body thead th {
  padding: 0.75rem 1rem;
  font-weight: 600;
  white-space: nowrap;
}

.table-body tbody tr {
  border-bottom: 1px solid #f8f8f8;
  transition: background 0.15s;
}

.table-body tbody tr:hover {
  background: #fafafa;
}

.table-body tbody td {
  padding: 0.75rem 1rem;
  color: #374151;
  white-space: nowrap;
}

.table-body tbody td.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== 상태 뱃지 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-billing {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-settled {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #86efac;
}

.badge-receivable {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.badge-receivable-settled {
  background: #fff7ed;
  color: #92400e;
  border: 1px solid #fdba74;
}

/* 검증 뱃지 */
.badge-ok {
  background: #f0fdf4;
  color: #166534;
}

.badge-error {
  background: #fef2f2;
  color: #dc2626;
}

/* ===== 버튼 ===== */
.btn {
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary {
  background: #6366f1;
  color: #ffffff;
}
.btn-primary:hover {
  background: #4f46e5;
}

.btn-secondary {
  background: #ffffff;
  color: #374151;
  border: 1px solid #e5e7eb;
}
.btn-secondary:hover {
  background: #f3f4f6;
}

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.btn-danger:hover {
  background: #fee2e2;
}

.btn-edit {
  padding: 0.3rem 0.75rem;
  background: #eef2ff;
  color: #4f46e5;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-edit:hover {
  background: #e0e7ff;
}

/* ===== 폼 입력 ===== */
.form-input {
  padding: 0.45rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #374151;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-select {
  padding: 0.45rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #374151;
  background: #ffffff;
  outline: none;
  cursor: pointer;
}

.form-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* ===== 검색바 ===== */
.search-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

/* ===== 모달 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: #ffffff;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-width: 42rem;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #f0f0f0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ===== 차트 컨테이너 ===== */
.chart-wrap {
  background: #ffffff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.chart-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
  padding-bottom: 1rem;
  border-bottom: 1px solid #f2f2f2;
  margin-bottom: 1rem;
}

/* ===== 탭 네비게이션 ===== */
.tab-nav {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 1.5rem;
}

.tab-link {
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab-link:hover {
  color: #374151;
}

.tab-link.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== 툴팁 ===== */
.tooltip-trigger {
  position: relative;
  cursor: pointer;
}

.tooltip-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #ffffff;
  font-size: 0.72rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.tooltip-trigger:hover .tooltip-content {
  opacity: 1;
}

/* ===== 업로드 영역 ===== */
.upload-area {
  border: 2px dashed #e5e7eb;
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #6366f1;
  background: #f5f3ff;
}

.upload-area-icon {
  font-size: 2rem;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}

.upload-area-text {
  font-size: 0.85rem;
  color: #6b7280;
}

/* ===== 로딩 스피너 ===== */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 50%;
  border-top-color: #6366f1;
  animation: spin 0.6s linear infinite;
}

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

/* ===== 빈 상태 ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #9ca3af;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state-text {
  font-size: 0.85rem;
  font-weight: 500;
}

/* ===== 수정 이력 마커 ===== */
.edit-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 50%;
  font-size: 0.55rem;
  color: #92400e;
  margin-left: 4px;
  cursor: pointer;
}

/* ===== 토스트 상태표시 ===== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 0.82rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  animation: toastIn 0.3s ease;
  transition: opacity 0.3s ease;
}

.toast-success {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.toast-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.toast-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.toast-loading {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #374151;
}

.toast-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.toast-body {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}

.toast-detail {
  font-size: 0.75rem;
  color: inherit;
  opacity: 0.8;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== 모바일 토글 ===== */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 90;
}

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    padding: 1rem 1.5rem;
    padding-top: 4rem;
  }
  .mobile-menu-toggle {
    display: block;
  }
  .sidebar-overlay.active {
    display: block;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  /* 검색바 세로 배치 */
  .search-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-bar > div {
    width: 100%;
  }
  .search-bar .form-select,
  .search-bar .form-input {
    width: 100%;
  }
  /* 탭 스크롤 */
  .tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab-link {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0.65rem 1rem;
    font-size: 0.8rem;
  }
  /* 대시보드 상단 1컬럼 */
  #dashboard-top {
    grid-template-columns: 1fr !important;
  }
  /* 테이블 가로 스크롤 */
  .table-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-body table {
    min-width: 700px;
  }
  /* 테이블 헤더 세로 배치 */
  .table-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }
  /* 모달 전체 너비 */
  .modal-box {
    width: 95%;
    max-height: 90vh;
  }
  /* 차트 축소 */
  .chart-wrap {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 0.75rem 1rem;
    padding-top: 4rem;
  }
  .kpi-card {
    padding: 1rem;
  }
  .kpi-card-value {
    font-size: 1.35rem;
  }
  .kpi-card-value.small {
    font-size: 1.1rem;
  }
  .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
  }
}

/* ===== 프린트 ===== */
@media print {
  .sidebar, .mobile-menu-toggle { display: none; }
  .main-content { margin-left: 0; }
}
