/* =============================================
   보노 인트라넷 스타일시트
   다크 테마 기반 / Salesforce 스타일 레이아웃
   색상이나 크기를 바꾸려면 :root 변수를 수정하세요
   ============================================= */

/* ===== CSS 변수 (색상/크기 설정) ===== */
:root {
  /* 주요 색상 */
  --color-bg: #0d1117;
  --color-sidebar: #161b22;
  --color-card: #1c2128;
  --color-border: #30363d;
  --color-primary: #5865f2;
  --color-primary-hover: #4752c4;
  --color-success: #2ea043;
  --color-danger: #f85149;
  --color-warning: #d29922;

  /* 텍스트 색상 */
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;

  /* 사이드바 크기 */
  --sidebar-width: 240px;

  /* 기타 */
  --border-radius: 8px;
  --transition: 0.2s ease;
}

/* ===== 라이트 테마 ===== */
[data-theme="light"] {
  --color-bg: #f0f2f5;
  --color-sidebar: #ffffff;
  --color-card: #ffffff;
  --color-border: #d8dde6;
  --color-primary: #5865f2;
  --color-primary-hover: #4752c4;
  --color-success: #1a7f37;
  --color-danger: #cf222e;
  --color-warning: #9a6700;

  --text-primary: #1a1f2e;
  --text-secondary: #57606a;
  --text-muted: #8c959f;
}

/* ===== 기본 리셋 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* =============================================
   로그인/회원가입 페이지 스타일
   ============================================= */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  overflow-y: auto;
  background: radial-gradient(ellipse at top, #1a1f2e 0%, var(--color-bg) 60%);
  position: relative;
}

[data-theme="light"] .auth-page {
  background: radial-gradient(ellipse at top, #e8ebf0 0%, var(--color-bg) 60%);
}

/* 로그인 페이지 설정 버튼 */
.auth-settings-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.auth-settings-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  transform: scale(1.05);
}

.auth-container {
  width: 100%;
  max-width: 400px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* 로고 영역 */
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.logo-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.logo-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.logo-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 탭 버튼 */
.auth-tabs {
  display: flex;
  background: var(--color-sidebar);
  border-radius: var(--border-radius);
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.tab-btn.active {
  background: var(--color-primary);
  color: #fff;
}

.tab-btn:hover:not(.active) {
  background: var(--color-border);
  color: var(--text-primary);
}

/* 폼 공통 스타일 */
.form-group {
  margin-bottom: 16px;
}

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

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

/* Caps Lock 경고 메시지 */
.capslock-warning {
  font-size: 12px;
  color: var(--color-warning);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.capslock-warning.hidden {
  display: none;
}

/* 메시지 표시 영역 */
.form-message {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  display: none;
}

.form-message.error {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--color-danger);
  display: block;
  white-space: pre-wrap;
}

.form-message.success {
  background: rgba(46, 160, 67, 0.1);
  border: 1px solid rgba(46, 160, 67, 0.3);
  color: var(--color-success);
  display: block;
}

/* 알림이 뜰 때마다 한 번 재생되는 깔끔한 강조 효과 (같은 메시지 반복 시에도 인지 가능) */
@keyframes message-attention {
  0% { opacity: 1; box-shadow: 0 0 0 0 rgba(88, 101, 242, 0.25); }
  40% { box-shadow: 0 0 0 8px rgba(88, 101, 242, 0); }
  100% { opacity: 1; box-shadow: 0 0 0 0 rgba(88, 101, 242, 0); }
}

.form-message.animate-attention {
  animation: message-attention 0.5s ease-out;
}

/* 회원가입 안내 문구 */
.auth-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* 로그인 폼 하단 By. BONO */
.auth-footer {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* 페이지 하단 작은 글씨 (메인 + 각 앱 페이지) */
.site-footer {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 24px;
  margin-bottom: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}
.auth-page .site-footer {
  margin-top: 16px;
}

/* ===== 다크모드 팝업 ===== */
.theme-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 80px 20px 20px;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.theme-popup.hidden {
  display: none;
}

.profile-edit-popup {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.profile-edit-popup .theme-popup-content {
  transform-origin: center;
  animation: popupFadeIn 0.2s ease;
}

@keyframes popupFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.theme-popup-content {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  overflow: hidden;
  animation: popupSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: top right;
}

@keyframes popupSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px) translateY(-10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
}

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

.theme-popup-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.theme-popup-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  padding: 0;
}

.theme-popup-close:hover {
  background: var(--color-border);
  color: var(--text-primary);
}

.theme-popup-body {
  padding: 16px 20px;
}

.theme-popup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.theme-popup-info {
  flex: 1;
}

.theme-popup-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.theme-popup-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* =============================================
   앱 페이지 레이아웃 (대시보드/보고서/관리자)
   ============================================= */
.app-page {
  overflow: hidden;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  height: 100vh; /* 메인 영역만 스크롤되도록 높이 고정 */
}

/* ===== 사이드바 ===== */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  min-height: 100vh;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow: hidden;
}

/* 사이드바 헤더 */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo {
  font-size: 22px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo:hover {
  opacity: 0.85;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

/* 사이드바 유저 정보 */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  min-height: 68px;
  flex-shrink: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-faction {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-secondary);
}

/* 사이드바 네비게이션 */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--border-radius);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  transition: var(--transition);
}

.nav-item:hover {
  background: var(--color-border);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(88, 101, 242, 0.15);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* 확장 가능 네비게이션 그룹 (관리자 페이지 등) */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--border-radius);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  text-align: left;
}
.nav-group-btn:hover {
  background: var(--color-border);
  color: var(--text-primary);
}
.nav-group-btn.active {
  background: rgba(88, 101, 242, 0.15);
  color: var(--color-primary);
  font-weight: 600;
}
.nav-chevron {
  margin-left: auto;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  opacity: 0.9;
  transition: transform 0.2s;
  line-height: 1;
}
.nav-group-btn:hover .nav-chevron,
.nav-group.expanded .nav-chevron {
  color: var(--color-primary);
  opacity: 1;
}
.nav-sub {
  display: none;
  flex-direction: column;
  padding-left: 12px;
  margin-left: 20px;
  border-left: 1px solid var(--color-border);
  gap: 2px;
}
.nav-group.expanded .nav-sub {
  display: flex;
}
.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  text-align: left;
}
.nav-sub-item:hover {
  background: var(--color-border);
  color: var(--text-primary);
}
.nav-sub-item.active {
  background: rgba(88, 101, 242, 0.15);
  color: var(--color-primary);
  font-weight: 500;
}
.nav-sub-item .badge {
  margin-left: auto;
  min-width: 20px;
  text-align: center;
}

/* 설정+로그아웃 버튼 영역: 맨 아래에서 버튼 1개 높이만큼 위로 띄움 */
.sidebar-bottom {
  padding-bottom: 52px;
}

/* 설정 버튼 */
.sidebar-settings {
  margin: 0 12px 6px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.sidebar-settings:hover {
  background: rgba(88, 101, 242, 0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.sidebar-settings.active {
  background: rgba(88, 101, 242, 0.15);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* 로그아웃 버튼 */
.sidebar-logout {
  margin: 0 12px 12px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 24px);
}

.sidebar-logout:hover {
  background: rgba(248, 81, 73, 0.1);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* 아바타 프로필 사진 */
.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ===== 테이블 순위 닉네임 아바타 ===== */
.rank-nickname-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rank-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}

.rank-avatar--letter {
  background: var(--color-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== 이미지 편집 모달 ===== */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-modal.hidden {
  display: none;
}

.crop-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
}

.crop-modal-dialog {
  position: relative;
  z-index: 1;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  animation: popupSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

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

.crop-modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.crop-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.crop-hint {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

.crop-viewport {
  position: relative;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 0 4px rgba(88, 101, 242, 0.2);
}

.crop-viewport canvas {
  display: block;
  cursor: grab;
  border-radius: 50%;
}

.crop-viewport canvas:active {
  cursor: grabbing;
}

.crop-zoom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.crop-zoom-label {
  font-size: 16px;
}

#crop-zoom-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-border);
  border-radius: 4px;
  outline: none;
}

#crop-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
}

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

/* ===== 설정 페이지 ===== */
.settings-content {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.settings-section {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  margin-bottom: 20px;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--color-border);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  gap: 24px;
  transition: background var(--transition);
}

.settings-item + .settings-item {
  border-top: 1px solid var(--color-border);
}

.settings-item-info { flex: 1; }

.settings-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.settings-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.settings-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 토글 스위치 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 24px;
  transition: 0.25s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: 0.25s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #ffffff;
}

/* 프로필 미리보기 */
.settings-avatar-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}

.settings-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

input[type="file"]#profile-file-input {
  display: none;
}

/* 비밀번호 변경 필드 검증 상태 */
.input-error {
  border-color: var(--color-error, #e74c3c) !important;
  box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2);
}

.input-ok {
  border-color: var(--color-success, #27ae60) !important;
}

.password-hint {
  font-size: 12px;
  margin-top: 6px;
}

.password-hint-error {
  color: var(--color-error, #e74c3c);
}

.password-hint-ok {
  color: var(--color-success, #27ae60);
}

/* ===== 메인 컨텐츠 ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 0; /* flex 자식이 스크롤 영역으로 줄어들 수 있게 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 페이지 헤더 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-sidebar);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  display: none; /* 모바일에서만 표시 */
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-date {
  font-size: 13px;
  color: var(--text-secondary);
}

/* =============================================
   대시보드 컨텐츠
   ============================================= */
.dashboard-content,
.report-content,
.admin-content {
  padding: 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.calc-content {
  padding: 24px 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* 통계 카드 그리드 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--color-primary);
}

/* 카드 왼쪽 테두리 색상 구분 */
.stat-card--primary { border-left: 3px solid var(--color-primary); }
.stat-card--blue    { border-left: 3px solid #58a6ff; }
.stat-card--green   { border-left: 3px solid var(--color-success); }

.stat-icon {
  font-size: 28px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== 판매 계산기 ===== */
.calc-card {
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.25);
  border-radius: 20px;
  max-width: 1200px;
  margin: 0 auto;
  font-family: 'HS새마을체', 'HS새마을', 'HS Saemul', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
}

.calc-table-wrap {
  overflow-x: auto;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calc-table col.col-name  { width: 24%; }
.calc-table col.col-price { width: 24%; }
.calc-table col.col-qty   { width: 20%; }
.calc-table col.col-amt   { width: 32%; }

.calc-table th {
  padding: 13px 18px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--color-border);
  background: rgba(255,255,255,0.025);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calc-table th:first-child { text-align: left; }
.calc-table th:last-child  { text-align: right; }

.calc-table td {
  padding: 12px 18px;
  font-size: 15px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(48, 54, 61, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-table tbody tr:hover td {
  background: rgba(255,255,255,0.025);
}

.calc-table td.calc-name  { text-align: left; }
.calc-table td.calc-unit  { text-align: right; color: var(--text-secondary); }
.calc-table td.calc-qty   { text-align: center; }
.calc-table td.calc-amount {
  text-align: right;
  font-weight: 600;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.calc-table td.calc-amount.zero { color: var(--text-secondary); font-weight: 400; }

.calc-table .calc-qty input {
  width: 100px;
  padding: 5px 10px;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}

.calc-table .calc-qty input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* 검은돈 행 */
.calc-table tr.blackmoney-row td {
  background: rgba(210, 153, 34, 0.06);
  border-top: 1px solid var(--color-border);
  border-bottom: none;
  padding-top: 13px;
  padding-bottom: 13px;
}

.calc-blackmoney-label-cell {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-warning);
}

.calc-blackmoney-price-cell {
  text-align: right;
  font-size: 13px;
  color: var(--text-secondary);
}

.calc-blackmoney-readable {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.calc-blackmoney-result-cell {
  text-align: right;
}

.calc-blackmoney-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-warning);
  display: block;
}

.calc-blackmoney-value-sub {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.calc-actions {
  padding: 16px 18px;
  border-top: 1px solid var(--color-border);
  background: rgba(255,255,255,0.01);
}

.calc-summary {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--color-border);
}

.calc-summary-box {
  flex: 1;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calc-summary-box + .calc-summary-box {
  border-left: 1px solid var(--color-border);
}

.calc-summary-sales {
  background: rgba(88, 101, 242, 0.07);
}

.calc-summary-sales .calc-summary-value {
  color: #7c8ff5;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.calc-summary-exchange {
  background: rgba(210, 153, 34, 0.07);
}

.calc-summary-exchange .calc-summary-value {
  color: var(--color-warning);
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.calc-summary-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.calc-summary-sub {
  font-size: 17px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* ===== 섹션 카드 ===== */
.section-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
  transition: box-shadow var(--transition);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255,255,255,0.015);
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-sub-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-week-range {
  font-size: 12px;
  color: var(--text-secondary);
}

.section-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.section-desc {
  padding: 12px 20px 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== 위험 영역 (초기화) ===== */
.danger-zone-card {
  background: var(--color-card);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-left: 3px solid var(--color-danger);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.danger-zone-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(248, 81, 73, 0.15);
}

.danger-zone-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-danger);
  margin: 0;
}

.danger-zone-desc {
  padding: 14px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  border-bottom: 1px solid rgba(248, 81, 73, 0.1);
}

.danger-action-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.danger-action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(248, 81, 73, 0.04);
  border: 1px solid rgba(248, 81, 73, 0.15);
  border-radius: 8px;
  gap: 16px;
}

.danger-action-info { flex: 1; }

.danger-action-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.danger-action-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.danger-action-message {
  font-size: 12px;
  margin-top: 6px;
}

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

.rank-table {
  width: 100%;
  border-collapse: collapse;
}

.rank-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255,255,255,0.02);
}

.rank-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.rank-table tr:last-child td {
  border-bottom: none;
}

.rank-table tr:hover td {
  background: rgba(255,255,255,0.03);
}

.loading-row {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px !important;
}

/* 상납금 입금 확인 테이블 (admin-table) */
.admin-table.deposit-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.admin-table.deposit-table col.col-rank    { width: 10%; }
.admin-table.deposit-table col.col-nickname { width: 22%; }
.admin-table.deposit-table col.col-gonggeum { width: 38%; }
.admin-table.deposit-table col.col-deposit  { width: 30%; }

.admin-table.deposit-table th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255,255,255,0.02);
}

.admin-table.deposit-table th:nth-child(1) { text-align: center; }
.admin-table.deposit-table th:nth-child(2) { text-align: left; }
.admin-table.deposit-table th:nth-child(3) { text-align: right; }
.admin-table.deposit-table th:nth-child(4) { text-align: center; }

.admin-table.deposit-table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.admin-table.deposit-table td:nth-child(1) { text-align: center; }
.admin-table.deposit-table td:nth-child(2) { text-align: left; }
.admin-table.deposit-table td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table.deposit-table td:nth-child(4) { text-align: center; }

.admin-table.deposit-table tbody tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* 순위 뱃지 */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.rank-badge--1 { background: #ffd700; color: #000; }
.rank-badge--2 { background: #c0c0c0; color: #000; }
.rank-badge--3 { background: #cd7f32; color: #fff; }
.rank-badge--other { background: var(--color-border); color: var(--text-secondary); }

/* =============================================
   알피 보고서 페이지
   ============================================= */
.report-card .section-header {
  border-bottom: none;
}

.report-form-area {
  padding: 0 20px 20px;
}

/* 결과 선택 버튼 (승리 = 파랑, 패배 = 빨강) */
.result-buttons {
  display: flex;
  gap: 12px;
}

.result-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
  background: var(--color-sidebar);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.result-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.result-btn--win.active {
  background: rgba(88, 101, 242, 0.15);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.result-btn--lose.active {
  background: rgba(248, 81, 73, 0.15);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.result-badge { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 4px; }
.result-badge--win { background: rgba(88, 101, 242, 0.2); color: var(--color-primary); }
.result-badge--lose { background: rgba(248, 81, 73, 0.2); color: var(--color-danger); }

.report-remarks-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
}

.report-remarks-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* 커스텀 드롭다운 */
.custom-select-wrapper {
  position: relative;
}

.custom-select-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  text-align: left;
}

.custom-select-btn:hover,
.custom-select-btn.open {
  border-color: var(--color-primary);
}

.select-arrow {
  transition: transform var(--transition);
  color: var(--text-secondary);
  font-size: 11px;
}

.select-arrow.rotated {
  transform: rotate(180deg);
}

/* 최소 5개 항목이 보이도록 높이 고정, 나머지는 스크롤. fixed로 스크롤 영역에 안 잘리게 + 최상위 표시 */
.custom-select-dropdown {
  position: fixed;
  max-height: 220px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  z-index: 9999;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  /* top, left, width는 report.js에서 열 때 버튼 위치 기준으로 설정 */
}

.dropdown-option {
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.dropdown-option:hover {
  background: rgba(88, 101, 242, 0.1);
  color: var(--color-primary);
}

.dropdown-option.selected {
  background: rgba(88, 101, 242, 0.15);
  color: var(--color-primary);
  font-weight: 500;
}

/* 선택된 보고서 종류 표시 */
.report-selected {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(88, 101, 242, 0.08);
  border: 1px solid rgba(88, 101, 242, 0.3);
  border-radius: var(--border-radius);
}

.selected-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-right: 8px;
}

.selected-type {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
}

/* =============================================
   관리자 페이지
   ============================================= */
/* 관리자 탭 메뉴 */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0;
}

.admin-tab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
}

.admin-tab-btn:hover {
  color: var(--text-primary);
}

.admin-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* 알림 뱃지 */
.badge {
  background: var(--color-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.badge:empty,
.badge[data-count="0"] {
  display: none;
}

/* 파싱 액션 영역 */
.parse-actions {
  padding: 12px 20px 20px;
  display: flex;
  gap: 12px;
}

/* =============================================
   모달 팝업
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  padding: 20px;
}

.modal-box {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

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

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
}

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

/* =============================================
   버튼 스타일
   ============================================= */
.btn-primary {
  padding: 10px 20px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

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

.btn-primary.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-secondary {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--color-border);
  color: var(--text-primary);
}

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

/* 승인/거절 버튼 */
.btn-approve {
  padding: 5px 12px;
  background: rgba(46, 160, 67, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(46, 160, 67, 0.3);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

.btn-approve:hover {
  background: rgba(46, 160, 67, 0.2);
}

.btn-reject {
  padding: 5px 12px;
  background: rgba(248, 81, 73, 0.1);
  color: var(--color-danger);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

.btn-reject:hover {
  background: rgba(248, 81, 73, 0.2);
}

/* =============================================
   유틸리티 클래스
   ============================================= */
.hidden {
  display: none !important;
}

/* =============================================
   반응형 (모바일 지원)
   ============================================= */
@media (max-width: 768px) {
  /* 사이드바 숨김 처리 */
  .sidebar {
    transform: translateX(-100%);
  }

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

  /* 메인 컨텐츠 전체 너비 */
  .main-content {
    margin-left: 0;
  }

  /* 모바일 햄버거 버튼 표시 */
  .sidebar-toggle {
    display: block;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-content,
  .report-content,
  .admin-content,
  .calc-content {
    padding: 16px;
  }
}

/* =============================================
   회원 관리 버튼 및 모달
   ============================================= */

/* 회원 관리 버튼들 */
.member-action-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.member-action-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: #fff;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.member-action-btn:hover {
  opacity: 0.85;
}

.member-action-btn-nickname {
  background: #9b59b6; /* 보라색 */
}

.member-action-btn-fivem-id {
  background: #3498db; /* 하늘색 */
}

.member-action-btn-rp {
  background: #2ecc71; /* 연두색 */
}

.member-action-btn-password {
  background: #e67e22; /* 주황색 */
}

.member-action-btn-delete {
  background: #e74c3c; /* 빨간색 */
}

/* RP 점수 링크 */
.member-rp-link {
  color: #3498db;
  text-decoration: underline;
  cursor: pointer;
}

.member-rp-link:hover {
  color: #2980b9;
}

/* 관리자 모달 */
.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-modal.hidden {
  display: none;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
}

.admin-modal-dialog {
  position: relative;
  z-index: 1;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  animation: popupSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.admin-modal-icon {
  text-align: center;
  font-size: 48px;
  margin: 20px 0 10px;
}

.admin-modal-title {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px;
  padding: 0 20px;
}

.admin-modal-message {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 20px;
  padding: 0 20px;
  line-height: 1.5;
}

.admin-modal-input-wrapper {
  padding: 0 20px 20px;
}

.admin-modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-sidebar);
  color: var(--text-primary);
  font-size: 14px;
  box-sizing: border-box;
}

.admin-modal-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.admin-modal-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.admin-modal-buttons {
  display: flex;
  gap: 10px;
  padding: 0 20px 20px;
  justify-content: center;
}

.admin-modal-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  min-width: 80px;
}

.admin-modal-btn:hover {
  opacity: 0.9;
}

.admin-modal-btn-cancel {
  background: #7f8c8d; /* 회색 */
  color: #fff;
}

.admin-modal-btn-confirm {
  background: #3498db; /* 파란색 */
  color: #fff;
}

/* ===== AI 고객센터 채팅 위젯 ===== */
.ai-chat-fab {
  position: fixed;
  bottom: 36px;
  right: 72px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.9rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 9998;
}
.ai-chat-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(88, 101, 242, 0.5);
}

.ai-chat-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0;
  pointer-events: none;
}
.ai-chat-modal:not(.hidden) {
  pointer-events: auto;
}
.ai-chat-modal.hidden {
  display: none;
}
.ai-chat-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.ai-chat-modal-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px 12px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
  margin-right: 20px;
  margin-bottom: 90px;
}
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.ai-chat-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.ai-chat-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.ai-chat-close:hover {
  color: var(--text-primary);
}
.ai-chat-desc {
  padding: 12px 20px;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--color-border);
}
.ai-chat-messages {
  flex: 1;
  min-height: 120px;
  max-height: 280px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.ai-chat-msg-user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
}
.ai-chat-msg-bot {
  align-self: flex-start;
  background: var(--color-sidebar);
  color: var(--text-primary);
  border: 1px solid var(--color-border);
}
.ai-chat-thinking {
  opacity: 0.7;
}
.ai-chat-login-required {
  padding: 24px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
}
.ai-chat-login-required.hidden {
  display: none;
}
.ai-chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
}
.ai-chat-input-wrap textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--text-primary);
  font-size: 14px;
  resize: none;
  font-family: inherit;
}
.ai-chat-input-wrap textarea::placeholder {
  color: var(--text-muted);
}
.ai-chat-send {
  padding: 10px 16px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.ai-chat-send:hover:not(:disabled) {
  background: var(--color-primary-hover);
}
.ai-chat-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
