/* ═══════════════════════════════════════════════════════
   한투글로벌 투자분석도구 — styles.css
   Apps Script에서 독립 SPA로 분리
   ═══════════════════════════════════════════════════════ */

:root {
  /* 브랜드 */
  --primary: #1E88E5;
  --primary-dark: #1565C0;
  --bg: #F8F9FA;
  --card: #FFFFFF;
  --text: #1A237E;
  --sub: #546E7A;
  --border: #E0E4EA;
  --input-bg: #F5F9FF;

  /* 시맨틱 색상 (수익/손실/주의/정보) */
  --green: #2E7D32;
  --green-bg: #E8F5E9;
  --red: #C62828;
  --red-bg: #FFEBEE;
  --orange: #E65100;
  --orange-bg: #FFF3E0;
  --blue: #1565C0;
  --blue-bg: #E3F2FD;
  --purple: #7B1FA2;
  --neutral: #546E7A;

  /* 등급 */
  --grade-s: #2E7D32;
  --grade-a: #E65100;
  --grade-b: #1565C0;
  --grade-c: #7B1FA2;
  --grade-d: #C62828;

  /* 간격 체계 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* 모션 */
  --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;
  --duration-slow: 0.4s;
}

/* ═══ 글로벌 전환 애니메이션 ═══ */
/* 모든 스크롤: 부드러운 관성 */
html { scroll-behavior: smooth; }
.pages-panel { scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }

/* 모든 인터랙티브 요소: 부드러운 전환 */
a, button, input, select, textarea,
.section, .kpi-card, .nav-item, .sidebar-item, .page-tab, .guide-btn, .macro-btn, .chip,
.kb-project-card, .kb-quick-btn, .kb-source-item, .kb-output-btn, .pm-preset {
  -webkit-transition: all 0.25s var(--ease-smooth);
  transition: all 0.25s var(--ease-smooth);
}

/* 모션 감소 설정 사용자는 애니메이션 비활성화 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { -webkit-animation-duration: 0.01ms !important; animation-duration: 0.01ms !important; -webkit-transition-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html, .pages-panel { scroll-behavior: auto; }
}

/* 페이지/탭 전환: 페이드 슬라이드 */
@-webkit-keyframes fadeIn { from { opacity: 0; -webkit-transform: translateY(8px) scale(0.99); } to { opacity: 1; -webkit-transform: translateY(0) scale(1); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
.tab-panel.active { -webkit-animation: fadeIn 0.35s var(--ease-out-expo); animation: fadeIn 0.35s var(--ease-out-expo); }
.main { -webkit-animation: fadeIn 0.3s var(--ease-out-expo); animation: fadeIn 0.3s var(--ease-out-expo); }

/* 카드 등장: 부드럽게 올라오며 등장 */
@-webkit-keyframes slideUp { from { opacity: 0; -webkit-transform: translateY(12px); } to { opacity: 1; -webkit-transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.section { -webkit-animation: slideUp 0.4s var(--ease-out-expo) both; animation: slideUp 0.4s var(--ease-out-expo) both; }
.section:nth-child(2) { -webkit-animation-delay: 0.06s; animation-delay: 0.06s; }
.section:nth-child(3) { -webkit-animation-delay: 0.12s; animation-delay: 0.12s; }
.section:nth-child(4) { -webkit-animation-delay: 0.18s; animation-delay: 0.18s; }
.section:nth-child(5) { -webkit-animation-delay: 0.24s; animation-delay: 0.24s; }

/* KPI 숫자 카운트업 효과용 */
@-webkit-keyframes countPop { from { -webkit-transform: scale(0.9); opacity: 0.5; } to { -webkit-transform: scale(1); opacity: 1; } }
@keyframes countPop { from { transform: scale(0.9); opacity: 0.5; } to { transform: scale(1); opacity: 1; } }

/* 채팅 메시지 등장 */
@-webkit-keyframes msgSlide { from { opacity: 0; -webkit-transform: translateY(8px); } to { opacity: 1; -webkit-transform: translateY(0); } }
@keyframes msgSlide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg { -webkit-animation: msgSlide 0.2s ease-out; animation: msgSlide 0.2s ease-out; }

/* 스켈레톤 로딩 */
@-webkit-keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }
.loading { background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 400px 100%; -webkit-animation: shimmer 1.5s infinite; animation: shimmer 1.5s infinite; }

* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', '맑은 고딕', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--bg); color: var(--text); font-size: clamp(14px, 3.5vw, 16px); line-height: 1.6; letter-spacing: -0.01em; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ═══ 네비게이션 ═══ */
.nav { background: var(--primary); padding: 0 24px; display: flex; align-items: center; height: 56px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); position: sticky; top: 0; z-index: 100; }
.nav-logo { color: #fff; font-size: 18px; font-weight: bold; cursor: pointer; }
.nav-item { color: rgba(255,255,255,0.7); padding: 8px 16px; border-radius: 8px 8px 0 0; font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none; transition: all 0.2s; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-item.active { color: #fff; background: rgba(255,255,255,0.2); position: relative; }
.nav-item.active::after { content: ''; position: absolute; bottom: 0; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); width: 60%; height: 2px; background: #fff; border-radius: 1px; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-btn { padding: 6px 14px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.3); color: #fff; font-size: 12px; cursor: pointer; background: transparent; margin-left: 8px; }
.nav-btn:hover { background: rgba(255,255,255,0.15); }
.nav-sub { background: #0D47A1; padding: 4px 24px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 11px; color: rgba(255,255,255,0.7); }
.nav-sub-role { background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 10px; font-size: 10px; }

/* ═══ 레이아웃: 사이드바 + 콘텐츠 ═══ */
.app-layout { display: -webkit-box; display: -ms-flexbox; display: flex; height: calc(100vh - 78px); overflow: hidden; }
.sidebar { width: 180px; background: #1B2A4A; padding: 16px 0; flex-shrink: 0; position: sticky; top: 78px; height: calc(100vh - 78px); overflow-y: auto; transition: width 0.25s, padding 0.25s; }
.sidebar.collapsed { width: 0; padding: 0; overflow: hidden; }
.sidebar-toggle { display: none; }
.sidebar-top { padding: 8px 10px 4px; }
.sidebar-top-btn { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); color: rgba(255,255,255,0.6); font-size: 11px; cursor: pointer; padding: 6px 12px; border-radius: 6px; width: 100%; display: flex; align-items: center; gap: 6px; transition: all 0.2s; }
.sidebar-top-btn:hover { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.25); }
#sidebarArrow { font-size: 10px; transition: transform 0.25s; }
#sidebarLabel { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; }
.sidebar-expand-btn { position: fixed; left: 0; top: 58px; z-index: 200; background: #1B2A4A; color: #fff; border: none; border-radius: 0 8px 8px 0; padding: 10px 8px; cursor: pointer; font-size: 12px; display: none; box-shadow: 2px 2px 8px rgba(0,0,0,0.15); transition: all 0.2s; }
.sidebar-expand-btn:hover { background: #263B6A; padding-right: 14px; }
.sidebar-title { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.5); padding: 14px 14px 6px; text-transform: uppercase; letter-spacing: 1.5px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.sidebar-title .toggle-arrow { font-size: 10px; transition: transform 0.2s; }
.sidebar-title .toggle-arrow.closed { transform: rotate(-90deg); }
.sidebar-group { overflow: hidden; transition: max-height 0.25s; max-height: 500px; }
.sidebar-group.collapsed { max-height: 0; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-size: 12.5px; color: rgba(255,255,255,0.8); cursor: pointer; -webkit-transition: all 0.15s; transition: all 0.15s; text-decoration: none; border-left: 3px solid transparent; white-space: nowrap; }
.sidebar-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-item.active { background: rgba(255,255,255,0.1); color: #fff; font-weight: 700; border-left-color: #4FC3F7; }
.sidebar-item .si-icon { font-size: 14px; width: 22px; text-align: center; color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.08); border-radius: 6px; padding: 4px 0; }
.sidebar-item.active .si-icon { color: #4FC3F7; background: rgba(79,195,247,0.15); }
.sidebar-item .si-badge { margin-left: auto; background: #4FC3F7; color: #1B2A4A; font-size: 10px; padding: 2px 7px; border-radius: 8px; font-weight: 700; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 12px 16px; }

/* 파이프라인 스텝 넘버 + 연결선 */
.sb-step { display: flex; align-items: center; padding: 0 14px; position: relative; }
.sb-step-num {
  width: 20px; height: 20px; border-radius: 50%; background: rgba(79,195,247,0.2);
  color: #4FC3F7; font-size: 10px; font-weight: 800; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; border: 1.5px solid rgba(79,195,247,0.4);
  position: relative; z-index: 2;
}
.sb-step-line {
  position: absolute; left: 23px; top: 20px; width: 2px; height: 28px;
  background: linear-gradient(180deg, rgba(79,195,247,0.4), rgba(79,195,247,0.1));
  z-index: 1;
}
.sub-arrow { display: inline-block; font-size: 10px; transition: transform 0.2s; margin-right: 2px; }
.sidebar-sub.open ~ .sidebar-item .sub-arrow, .sidebar-item[data-open] .sub-arrow { transform: rotate(180deg); }
.sidebar-sub { padding-left: 40px; overflow: hidden; max-height: 0; transition: max-height 0.25s ease; }
.sidebar-sub.open { max-height: 300px; }
.sidebar-sub .sidebar-item { font-size: 12px; padding: 7px 14px 7px 0; color: rgba(255,255,255,0.7); }
.sidebar-sub .sidebar-item:hover { color: rgba(255,255,255,0.85); }
.sidebar-sub .sidebar-item.active { color: #4FC3F7; }
.content-area { flex: 1; overflow: hidden; }
.pages-panel { flex: 1; min-width: 0; overflow-y: auto; height: 100%; }
.main { max-width: 100%; margin: 0; padding: 20px 24px; }
/* page-dashboard는 pages-panel 내부에서 일반 main 처럼 표시 */

/* ═══ KPI 카드 ═══ */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi-card { background: var(--card); border-radius: var(--radius-md); padding: 16px 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); border-top: 3px solid var(--primary); position: relative; overflow: hidden; -webkit-transition: -webkit-transform var(--duration-normal) var(--ease-smooth), box-shadow var(--duration-normal) var(--ease-smooth); transition: transform var(--duration-normal) var(--ease-smooth), box-shadow var(--duration-normal) var(--ease-smooth); }
.kpi-card:hover { -webkit-transform: translateY(-2px); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.08); }
.kpi-card:nth-child(1) { border-top-color: var(--green); }
.kpi-card:nth-child(2) { border-top-color: var(--red); }
.kpi-card:nth-child(3) { border-top-color: var(--blue); }
.kpi-card:nth-child(4) { border-top-color: var(--purple); }
.kpi-label { font-size: 13px; color: var(--neutral); margin-bottom: 6px; font-weight: 500; }
.kpi-value { font-size: clamp(24px, 4vw, 36px); font-weight: 800; color: var(--text); line-height: 1.1; letter-spacing: -0.03em; }
.kpi-sub { font-size: 12px; color: var(--neutral); margin-top: 6px; }

/* ═══ 섹션 카드 ═══ */
.section { background: var(--card); border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); -webkit-transition: box-shadow var(--duration-normal) var(--ease-smooth); transition: box-shadow var(--duration-normal) var(--ease-smooth); }
.section:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.07); }
.section-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; line-height: 1.4; letter-spacing: -0.02em; }
.section-title .icon { font-size: 18px; }

/* ═══ 2열 레이아웃 ═══ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ═══ 테이블 ═══ */
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th { background: var(--bg); color: var(--sub); font-weight: 600; padding: 8px 10px; text-align: center; border-bottom: 2px solid var(--border); }
.table td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--border); }
.table tr:hover { background: #F5F9FF; }
.table .addr { text-align: left; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══ 등급 뱃지 ═══ */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.badge-S { background: #E8F5E9; color: #2E7D32; }
.badge-A { background: #FFF3E0; color: #E65100; }
.badge-B { background: #E3F2FD; color: #1565C0; }
.badge-C { background: #FFF3E0; color: #EF6C00; }
.badge-D { background: #FFEBEE; color: #C62828; }

/* ═══ 파이프라인 ═══ */
.pipeline { display: flex; gap: 4px; }
.pipe-step { flex: 1; text-align: center; padding: 10px 6px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.pipe-step .count { font-size: 18px; display: block; margin-top: 4px; }
.pipe-1 { background: #E3F2FD; color: #1565C0; }
.pipe-2 { background: #E8F5E9; color: #2E7D32; }
.pipe-3 { background: #FFF8E1; color: #F57F17; }
.pipe-4 { background: #FBE9E7; color: #BF360C; }
.pipe-5 { background: #F3E5F5; color: #7B1FA2; }
.pipe-arrow { display: flex; align-items: center; color: var(--sub); font-size: 16px; }

/* ═══ 채널 현황 ═══ */
.channel-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.channel-row:last-child { border-bottom: none; }
.channel-name { font-size: 12px; color: var(--sub); }
.channel-count { font-size: 14px; font-weight: 700; color: var(--text); }
.channel-icon { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* ═══ 매크로 버튼 ═══ */
.action-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.action-btn { padding: 8px 16px; border: none; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; color: #fff; transition: transform 0.1s; }
.action-btn:hover { transform: translateY(-1px); }
.action-btn:active { transform: translateY(0); }

/* ═══ 바로가기 ═══ */
.shortcut-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.shortcut { text-align: center; padding: 12px; background: var(--bg); border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer; text-decoration: none; transition: background 0.15s; }
.shortcut:hover { background: #DCEEFB; }

/* ═══ 로딩 ═══ */
.loading { text-align: center; padding: 40px; color: var(--sub); }

/* ═══ 검색 페이지 전용 스타일 ═══ */
.search-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search-form .form-group { display: flex; flex-direction: column; gap: 4px; }
.search-form .form-group.full { grid-column: 1 / -1; }
.search-form label { font-size: 12px; font-weight: 700; color: var(--text); }
.search-form input,
.search-form select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--text); background: var(--input-bg);
  transition: border-color 0.2s;
}
.search-form input:focus,
.search-form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,136,229,0.12); }
.range-group { display: flex; align-items: center; gap: 6px; }
.range-group input { flex: 1; }
.range-sep { font-size: 12px; color: var(--sub); font-weight: 600; }

/* ═══ 물건종류 칩 ═══ */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border); background: #fff;
  color: var(--sub); transition: all 0.15s; user-select: none;
}
.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip:hover { border-color: var(--primary); }

/* ═══ 검색 액션 영역 ═══ */
.search-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; align-items: center; }
.btn-search {
  padding: 10px 28px; border: none; border-radius: 8px; font-size: 14px;
  font-weight: 700; cursor: pointer; color: #fff; background: var(--primary);
  transition: background 0.2s, transform 0.1s;
}
.btn-search:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-search:disabled { background: var(--sub); cursor: not-allowed; transform: none; }
.btn-reset {
  padding: 10px 20px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; background: #fff; color: var(--sub);
  transition: border-color 0.2s;
}
.btn-reset:hover { border-color: var(--primary); color: var(--primary); }

/* ═══ 결과 상태 바 ═══ */
.result-status {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; font-size: 13px; color: var(--sub);
}
.result-count { font-weight: 700; color: var(--text); }
.result-count em { color: var(--primary); font-style: normal; }

/* ═══ 결과 테이블 ═══ */
.result-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.result-table thead th {
  background: var(--primary); color: #fff; font-weight: 600;
  padding: 10px 8px; text-align: center; position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
.result-table tbody td {
  padding: 9px 8px; text-align: center; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.result-table tbody tr:hover { background: #E3F2FD; cursor: pointer; }
.result-table tbody tr:nth-child(even) { background: #FAFCFF; }
.result-table tbody tr:nth-child(even):hover { background: #E3F2FD; }
.result-table .col-addr { text-align: left; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-table .col-price { font-weight: 700; }
.result-table .col-discount { font-weight: 700; }
.discount-high { color: var(--green); }
.discount-mid { color: var(--orange); }
.discount-low { color: var(--red); }

.table-wrap { max-height: 520px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }

/* ═══ 행 액션 버튼 ═══ */
.row-action { padding: 3px 8px; border: none; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.row-fav { background: #FFF8E1; color: #F57F17; }
.row-fav:hover { background: #FFECB3; }
.row-detail { background: #E3F2FD; color: #1565C0; }
.row-detail:hover { background: #BBDEFB; }

/* ═══ 주소 3단 셀렉트 ═══ */
.addr-selects { display: flex; gap: 6px; }
.addr-selects select { flex: 1; }

/* ═══ 검색 통계 카드 ═══ */
.search-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--input-bg); border-radius: 10px; padding: 12px 16px; text-align: center; }
.stat-label { font-size: 11px; color: var(--sub); margin-bottom: 2px; }
.stat-value { font-size: 20px; font-weight: 800; color: var(--text); }

/* ═══ 관심물건 페이지 ═══ */
.fav-empty { text-align: center; padding: 60px 20px; color: var(--sub); }
.fav-empty-icon { font-size: 48px; margin-bottom: 12px; }
.fav-empty-text { font-size: 14px; }

/* ═══ 대시보드 차트 영역 ═══ */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }

/* 가로 막대 차트 */
.bar-chart { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-label { font-size: 13px; font-weight: 700; color: var(--text); min-width: 70px; text-align: right; }
.bar-track { flex: 1; background: var(--bg); border-radius: var(--radius-sm); height: 28px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: var(--radius-sm); transition: width 0.8s var(--ease-out-expo); display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; min-width: 32px; }
.bar-fill span { font-size: 12px; font-weight: 700; color: #fff; }

/* 파이 차트 (conic-gradient) */
.pie-container { display: flex; align-items: center; gap: 28px; justify-content: center; }
.pie-circle { width: 160px; height: 160px; border-radius: 50%; position: relative; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.pie-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80px; height: 80px; background: var(--card); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.pie-legend { display: flex; flex-direction: column; gap: 8px; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.pie-legend-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.pie-legend-pct { font-weight: 800; margin-left: auto; min-width: 40px; text-align: right; color: var(--text); }

/* 수평 막대 (지역별 TOP 5) */
.rank-list { display: flex; flex-direction: column; gap: 12px; }
.rank-item { display: flex; align-items: center; gap: 12px; }
.rank-num { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-num.r2 { background: var(--blue); }
.rank-num.r3 { background: var(--orange); }
.rank-num.r4 { background: var(--purple); }
.rank-num.r5 { background: var(--sub); }
.rank-name { font-size: 13px; font-weight: 700; color: var(--text); min-width: 80px; }
.rank-bar-track { flex: 1; background: var(--bg); border-radius: var(--radius-sm); height: 24px; overflow: hidden; }
.rank-bar-fill { height: 100%; border-radius: var(--radius-sm); background: var(--primary); transition: width 0.8s var(--ease-out-expo); display: flex; align-items: center; padding-left: 10px; }
.rank-bar-fill span { font-size: 12px; font-weight: 700; color: #fff; }

/* 주간 트렌드 (막대 그래프) */
.trend-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 12px; }
.trend-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-bar { width: 100%; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); transition: height 0.8s var(--ease-out-expo); min-height: 4px; position: relative; }
.trend-bar-val { font-size: 12px; font-weight: 800; color: var(--primary); }
.trend-bar-day { font-size: 11px; color: var(--neutral); font-weight: 600; }

/* 투자 성과 요약 */
.perf-grid { display: flex; flex-direction: column; gap: 14px; }
.perf-item { display: flex; flex-direction: column; gap: 4px; }
.perf-header { display: flex; justify-content: space-between; align-items: center; }
.perf-label { font-size: 12px; font-weight: 600; color: var(--text); }
.perf-value { font-size: 14px; font-weight: 800; color: var(--primary); }
.perf-bar-track { width: 100%; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.perf-bar-fill { height: 100%; border-radius: 5px; transition: width 0.6s ease; }

/* 타임라인 */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.tl-item:not(:last-child) { border-bottom: 1px solid var(--border); }
.tl-dot-wrap { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 24px; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 4px; }
.tl-dot.tl-green { background: var(--green); }
.tl-dot.tl-orange { background: var(--orange); }
.tl-dot.tl-red { background: var(--red); }
.tl-dot.tl-purple { background: var(--purple); }
.tl-content { flex: 1; }
.tl-title { font-size: 12px; font-weight: 700; color: var(--text); }
.tl-desc { font-size: 11px; color: var(--sub); margin-top: 2px; }
.tl-time { font-size: 10px; color: var(--sub); margin-top: 2px; }

/* ═══ 채널 관제 센터 ═══ */
.ch-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.ch-kpi-card { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); text-align: center; }
.ch-kpi-label { font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.ch-kpi-value { font-size: 28px; font-weight: 800; color: var(--text); }
.ch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.ch-card { background: var(--card); border-radius: 10px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); cursor: pointer; transition: box-shadow 0.15s, transform 0.1s; border: 2px solid transparent; position: relative; }
.ch-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.ch-card.ch-selected { border-color: var(--primary); box-shadow: 0 4px 12px rgba(30,136,229,0.2); }
.ch-card-name { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.ch-card-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.ch-type-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: #E3F2FD; color: #1565C0; }
.ch-priority-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 8px; color: #fff; }
.ch-priority-P0 { background: #1E88E5; }
.ch-priority-P1 { background: #4CAF50; }
.ch-priority-P2 { background: #FFA726; }
.ch-priority-P3 { background: #9E9E9E; }
.ch-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); margin-bottom: 8px; }
.ch-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ch-status-dot.ready { background: var(--green); }
.ch-status-dot.todo { background: #BDBDBD; }
.ch-status-dot.error { background: var(--red); }
.ch-status-dot.running { background: var(--orange); animation: chPulse 1s infinite; }
@keyframes chPulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.ch-count { font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.ch-run-btn { width: 100%; padding: 6px 0; border: none; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; color: #fff; background: var(--primary); transition: background 0.15s; }
.ch-run-btn:hover { background: var(--primary-dark); }
.ch-run-btn:disabled { background: #BDBDBD; cursor: not-allowed; }
.ch-detail-section { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.ch-detail-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.ch-detail-empty { text-align: center; padding: 40px; color: var(--sub); font-size: 13px; }

/* ═══ 로그인 게이트 ═══ */
.login-gate { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #0D47A1 0%, #1565C0 30%, #1E88E5 60%, #42A5F5 100%); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.login-box { background: #fff; border-radius: 20px; padding: 40px 36px; text-align: center; box-shadow: 0 24px 80px rgba(0,0,0,0.25); max-width: 420px; width: 90%; -webkit-animation: slideUp 0.5s var(--ease-out-expo); animation: slideUp 0.5s var(--ease-out-expo); }
.login-logo { margin-bottom: 8px; display: flex; justify-content: center; align-items: center; }
.login-logo img { max-width: 280px; width: 100%; height: auto; }
.login-sub { font-size: 15px; color: var(--sub); margin-bottom: 28px; font-weight: 500; letter-spacing: 2px; }
.login-status { font-size: 13px; color: var(--sub); margin-top: 16px; }
.login-email { font-size: 14px; color: var(--primary); font-weight: 600; margin: 12px 0; }
.login-spinner { width: 36px; height: 36px; border: 3px solid #E0E0E0; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.app-content { display: none; }

/* 로그인/회원가입 폼 */
.auth-form { text-align: left; margin-top: 20px; }
.auth-form label { font-size: 12px; font-weight: 600; color: var(--text); display: block; margin-bottom: 4px; margin-top: 12px; }
.auth-form input { width: 100%; padding: 12px 14px; border: 1px solid #E0E0E0; border-radius: 8px; font-size: 14px; transition: border-color 0.2s, box-shadow 0.2s; }
.auth-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,136,229,0.1); }
.auth-btn { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 20px; transition: background 0.2s; }
.auth-btn:hover { background: var(--primary-dark); }
.auth-btn:disabled { background: #B0BEC5; cursor: not-allowed; }
.auth-link { text-align: center; margin-top: 16px; font-size: 13px; color: var(--sub); }
.auth-link a { color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }
.auth-error { background: #FFEBEE; color: #C62828; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-top: 12px; display: none; }
.signup-success { background: #E8F5E9; border: 1px solid #C8E6C9; border-radius: 10px; padding: 20px; margin-top: 20px; text-align: center; }
.signup-success-title { font-size: 16px; font-weight: 700; color: #2E7D32; margin-bottom: 8px; }
.signup-success-text { font-size: 13px; color: #4CAF50; line-height: 1.5; }

/* ═══ AI 챗봇 위젯 ═══ */
/* ═══ 에이전틱 좌우 분할 레이아웃 ═══ */
.agentic-layout {
  display: -webkit-box; display: -ms-flexbox; display: flex; gap: 0; height: calc(100vh - 78px); overflow: hidden;
}
.ai-panel {
  width: 400px; min-width: 280px; max-width: 600px; background: #fff;
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  height: 100%; flex-shrink: 0; position: relative;
}
.ai-panel.collapsed { width: 0; min-width: 0; overflow: hidden; border: none; }
.ai-panel-resize {
  position: absolute; top: 0; right: -4px; width: 8px; height: 100%;
  cursor: col-resize; z-index: 50; background: transparent;
}
.ai-panel-resize::after {
  content: ''; position: absolute; top: 50%; right: 2px;
  -webkit-transform: translateY(-50%); transform: translateY(-50%);
  width: 3px; height: 28px; border-radius: 2px;
  background: rgba(0,0,0,0.08);
  -webkit-transition: background 0.2s, height 0.2s; transition: background 0.2s, height 0.2s;
}
.ai-panel-resize:hover::after { background: rgba(30,136,229,0.25); height: 40px; }
.ai-panel-resize.dragging::after { background: rgba(30,136,229,0.4); height: 40px; }
.ai-panel-reopen {
  display: none; position: absolute; left: 0; top: 8px; z-index: 60;
  background: linear-gradient(135deg, #0D47A1, #1E88E5); color: #fff;
  border: none; border-radius: 0 8px 8px 0; padding: 10px 8px 10px 6px;
  cursor: pointer; font-size: 13px; font-weight: 700; box-shadow: 2px 2px 8px rgba(0,0,0,0.15);
  writing-mode: vertical-rl; letter-spacing: 2px;
}
.ai-panel-reopen:hover { -webkit-filter: brightness(1.15); filter: brightness(1.15); }
.ai-panel.collapsed ~ .dashboard-panel .ai-panel-reopen { display: block; }
.ai-panel-header {
  background: linear-gradient(135deg, #0D47A1, #1E88E5); color: #fff;
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; font-size: 15px; font-weight: 700;
}
.ai-panel-toggle {
  background: none; border: none; color: rgba(255,255,255,0.8); font-size: 14px;
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.ai-panel-toggle:hover { background: rgba(255,255,255,0.2); color: #fff; }
.ai-panel-macros {
  display: flex; gap: 6px; padding: 10px 12px; flex-wrap: wrap; justify-content: flex-end;
  border-bottom: 1px solid var(--border); background: #F5F9FF; flex-shrink: 0;
}
.attach-btn {
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--sub); padding: 4px; border-radius: 6px; flex-shrink: 0; transition: color 0.2s;
}
.attach-btn:hover { color: var(--primary); }
.ai-panel-messages {
  flex: 1; overflow-y: auto; padding: 14px; display: flex;
  flex-direction: column; gap: 10px; background: #FAFBFC;
}
.ai-panel-input {
  display: flex; align-items: center; padding: 10px 12px;
  border-top: 1px solid var(--border); background: #fff; flex-shrink: 0; gap: 8px;
}
.ai-panel-input input {
  flex: 1; border: 1px solid #D0D5DD; border-radius: 20px;
  padding: 9px 14px; font-size: 13px; outline: none; background: #F5F9FF; color: var(--text);
}
.ai-panel-input input:focus { border-color: var(--primary); }
.ai-panel-input button {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ai-panel-input button:hover { background: var(--primary-dark); }
/* dashboard-panel은 pages-panel로 통합됨 */

/* ═══ AI 챗봇 (플로팅 — 비대시보드 페이지) ═══ */
#chatbot-toggle {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: #1E88E5; color: #fff; font-size: 28px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(30,136,229,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
#chatbot-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(30,136,229,0.5); }

#chatbot-window {
  position: fixed; bottom: 96px; right: 24px; z-index: 9001;
  width: 420px; height: 85vh; max-height: 920px; min-height: 600px; border-radius: 16px;
  background: #fff; box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: none; flex-direction: column; overflow: hidden;
  font-family: '맑은 고딕', -apple-system, sans-serif;
}
@-webkit-keyframes chatOpen { from { opacity: 0; -webkit-transform: translateY(20px) scale(0.95); } to { opacity: 1; -webkit-transform: translateY(0) scale(1); } }
@keyframes chatOpen { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
#chatbot-window.open { display: flex; -webkit-animation: chatOpen 0.35s var(--ease-out-expo); animation: chatOpen 0.35s var(--ease-out-expo); }

/* 매크로 버튼 영역 */
#chatbot-macros {
  display: flex; gap: 6px; padding: 8px 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); background: #F5F9FF; flex-shrink: 0;
}
.macro-btn {
  font-size: 11px; padding: 5px 10px; border-radius: 16px;
  border: 1px solid var(--primary); color: var(--primary); background: #fff;
  cursor: pointer; font-weight: 600; white-space: nowrap; transition: all 0.15s;
}
.macro-btn:hover { background: var(--primary); color: #fff; }

#chatbot-header {
  background: #1E88E5; color: #fff; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
#chatbot-header span { font-size: 15px; font-weight: 700; }
#chatbot-close {
  background: none; border: none; color: #fff; font-size: 22px;
  cursor: pointer; line-height: 1; padding: 0 2px;
}
#chatbot-close:hover { opacity: 0.7; }

#chatbot-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 10px; background: #F8F9FA;
}
.chat-msg { max-width: 85%; padding: 12px 16px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.7; word-break: break-word; white-space: pre-wrap; color: #1A237E; }
.chat-msg.ai { align-self: flex-start; background: #F0F2F8; color: #1A237E; border-bottom-left-radius: 4px; position: relative; margin-top: 22px; margin-left: 10px; }
.chat-msg.ai span, .chat-msg.ai div { color: #37474F; }
.chat-msg.ai strong { color: #0D47A1; }
/* 미니 한그리 캐릭터 (말풍선 위 왼쪽 — 마이페이지 캐릭터와 동일 디자인) */
.chat-msg.ai::before {
  content: ''; position: absolute; top: -18px; left: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--hangri-color, linear-gradient(135deg, #42A5F5, #1E88E5));
  box-shadow: 0 1px 4px rgba(30,136,229,0.3);
  -webkit-animation: hangriIdle 4s ease-in-out infinite; animation: hangriIdle 4s ease-in-out infinite;
}
/* 한그리 눈 */
.chat-msg.ai::after {
  content: ''; position: absolute; top: -13px; left: 9px;
  width: 4px; height: 4px; border-radius: 50%; background: #fff;
  box-shadow: 7px 0 0 0 #fff, 1px -1px 0 0 rgba(26,35,126,0.6), 8px -1px 0 0 rgba(26,35,126,0.6);
}
/* 말풍선 꼬리 (왼쪽 삼각형) */
.chat-msg.ai .bubble-tail,
.chat-msg.ai > span:first-child { display: none; }

.chat-msg { position: relative; }
.chat-msg.ai { border-bottom-left-radius: 4px; }

/* 사용자 말풍선 꼬리 (오른쪽) */
.chat-msg.user { position: relative; margin-right: 6px; }
.chat-msg.user::before {
  content: ''; position: absolute; right: -6px; top: 10px;
  width: 0; height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 7px solid #1E88E5;
}

/* AI 말풍선 왼쪽 꼬리 */
.chat-msg.ai { margin-left: 14px; }
.chat-msg.ai .ai-tail {
  position: absolute; left: -6px; top: 12px;
  width: 0; height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 7px solid #F0F2F8;
}

.chat-msg.ai strong { color: #0D47A1; }
.chat-msg.ai br + br { content: ''; display: block; margin-top: 4px; }
.chat-msg.user { align-self: flex-end; background: #1E88E5; color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.typing { align-self: flex-start; background: #F0F2F8; color: #78909C; font-style: italic; border-bottom-left-radius: 4px; }

#chatbot-input-area {
  display: flex; align-items: center; padding: 10px 12px;
  border-top: 1px solid #EAEDF0; background: #fff; flex-shrink: 0; gap: 8px;
}
#chatbot-input {
  flex: 1; border: 1px solid #D0D5DD; border-radius: 24px;
  padding: 10px 16px; font-size: 13.5px; outline: none;
  background: #F5F9FF; color: #1A237E;
}
#chatbot-input:focus { border-color: #1E88E5; }
#chatbot-send {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: #1E88E5; color: #fff; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s;
}
#chatbot-send:hover { background: #1565C0; }
#chatbot-send:disabled { background: #B0BEC5; cursor: default; }

/* ═══════════════════════════════════════════════════════
   반응형 — 태블릿 (768px ~ 1023px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  .sidebar { width: 160px; min-width: 160px; }
  .ai-panel { width: 320px; min-width: 320px; max-width: 320px; }
  .nav-item { padding: 6px 12px; font-size: 13px; }
  .kb-sources { width: 200px; min-width: 200px; }
  .kb-outputs { width: 180px; min-width: 180px; }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════════════════════════════════════════════════════
   반응형 — 모바일 (≤767px) — Base: 390px
   360~430px 범위 커버 (iPhone 15/16, Galaxy S24, Pixel 8 등)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .ai-panel-resize { display: none; }
  /* ── 네비게이션 ── */
  .nav {
    padding: 0 clamp(8px, 3vw, 16px);
    padding-top: env(safe-area-inset-top, 0px);
    height: clamp(44px, 12vw, 56px);
  }
  .nav-logo { font-size: clamp(12px, 3.5vw, 15px); }
  .nav-menu {
    gap: 2px; margin-left: 6px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .nav-menu::-webkit-scrollbar { display: none; }
  .nav-item {
    padding: 6px 8px; font-size: clamp(10px, 2.8vw, 12px);
    white-space: nowrap; flex-shrink: 0;
    min-height: 44px;
    display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex;
    -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  }
  .nav-right { gap: 2px; }
  .nav-btn { padding: 6px 10px; font-size: 11px; min-height: 44px; }
  .nav-sub {
    padding: 3px clamp(8px, 3vw, 16px); font-size: 10px;
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }

  /* ── 레이아웃: 사이드바 오버레이 ── */
  .app-layout { height: calc(100vh - 62px); }
  .sidebar {
    position: fixed; top: calc(62px + env(safe-area-inset-top, 0px));
    left: 0; z-index: 300;
    width: 75vw; max-width: 280px;
    height: calc(100vh - 62px - env(safe-area-inset-top, 0px));
    -webkit-transform: translateX(-100%); transform: translateX(-100%);
    -webkit-transition: -webkit-transform 0.25s ease; transition: transform 0.25s ease;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .sidebar:not(.collapsed) {
    -webkit-transform: translateX(0); transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0,0,0,0.3);
  }
  .sidebar.collapsed { -webkit-transform: translateX(-100%); transform: translateX(-100%); }
  .sidebar-expand-btn { top: calc(50px + env(safe-area-inset-top, 0px)); z-index: 301; display: block !important; min-height: 44px; min-width: 44px; }
  .sidebar-item { min-height: 44px; padding: 12px 14px; }

  /* ── AI 패널: 모바일 하단 시트 ── */
  .agentic-layout {
    -webkit-box-orient: vertical; -webkit-box-direction: normal;
    -ms-flex-direction: column; flex-direction: column;
    height: auto; min-height: calc(100vh - 44px);
  }
  .ai-panel {
    width: 100vw !important; min-width: 100vw !important; max-width: 100vw !important;
    height: auto; max-height: 50vh; min-height: 0;
    border-right: none; border-top: 2px solid var(--primary);
    order: 1; overflow: hidden; flex-shrink: 0;
  }
  .ai-panel.collapsed { max-height: 0; border-top: none; }
  .ai-panel-header { padding: 10px 14px; font-size: 14px; }
  .ai-panel-messages {
    max-height: 30vh; padding: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .ai-panel-input {
    padding: 8px clamp(8px, 3vw, 14px);
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }
  .ai-panel-input input {
    padding: 9px 14px; font-size: 16px; /* iOS 줌 방지 */
  }
  .ai-panel-macros { gap: 4px; padding: 8px 10px; }
  .ai-panel-reopen { display: none !important; }
  .pages-panel { order: 2; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* ── 모바일 AI 토글 버튼 ── */
  .mobile-ai-toggle {
    display: flex !important;
    min-height: 44px; min-width: 44px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  /* ── 콘텐츠 ── */
  .main {
    padding: clamp(10px, 3vw, 20px) clamp(8px, 3vw, 16px);
    padding-left: max(clamp(8px, 3vw, 16px), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(8px, 3vw, 16px), env(safe-area-inset-right, 0px));
  }
  #page-dashboard { height: auto; overflow: visible; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: clamp(6px, 2vw, 12px); }
  .kpi-label { font-size: clamp(9px, 2.5vw, 11px); }
  .grid-2, .chart-grid { grid-template-columns: 1fr; }
  .search-form { grid-template-columns: 1fr; }
  .search-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .shortcut-grid { grid-template-columns: repeat(2, 1fr); }
  .result-table { font-size: 11px; }
  #anl-scenarios { grid-template-columns: 1fr !important; }
  .pie-container { flex-direction: column; }
  .ch-kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .ch-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .section { padding: clamp(10px, 3vw, 16px); margin-bottom: 10px; }

  /* ── 파이프라인 ── */
  .pipeline { flex-wrap: wrap; gap: 4px; }
  .pipe-step { font-size: 10px; padding: 6px 8px; min-width: auto; }
  .pipe-arrow { font-size: 10px; }

  /* ── 플로팅 챗봇: 모바일 풀스크린 ── */
  #chatbot-toggle {
    width: 52px; height: 52px; font-size: 24px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
  }
  #chatbot-window {
    width: 100vw; height: 100vh; max-height: 100dvh;
    right: 0; bottom: 0; top: 0; left: 0;
    border-radius: 0;
    z-index: 9999;
  }
  #chatbot-window.open #chatbot-header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  #chatbot-input-area {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  #chatbot-input {
    font-size: 16px; /* iOS 줌 방지 */
  }

  /* ── 테이블 스크롤 ── */
  .table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .result-table-wrap { -webkit-overflow-scrolling: touch; }

  /* ── 터치 타겟 최소 44px ── */
  .chip {
    min-height: 44px;
    display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex;
    -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  }
  .page-tab { min-height: 44px; padding: 10px 14px; font-size: 12px; }
  .guide-btn {
    min-height: 44px; padding: 8px 12px; font-size: 11px;
    display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex;
    -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  }
  .macro-btn { min-height: 44px; padding: 6px 10px; }
  .action-btn { min-height: 44px; }
  .btn-search, .btn-reset { min-height: 44px; }
  .kb-quick-btn { min-height: 44px; }
  .kb-output-btn { min-height: 44px; }
  .row-action { min-height: 36px; padding: 6px 12px; }
  .auth-btn { min-height: 48px; }
  .admin-macro { min-height: 44px; }

  /* ── 입력 필드 iOS 줌 방지 ── */
  .search-form input,
  .search-form select,
  .auth-form input,
  .admin-agent-input input { font-size: 16px; }

  /* ── 지식 베이스 3패널: column 방향 ── */
  .kb-three-panel {
    -webkit-box-orient: vertical; -webkit-box-direction: normal;
    -ms-flex-direction: column; flex-direction: column;
    height: auto;
  }
  .kb-sources, .kb-outputs {
    width: 100%; min-width: 100%; max-height: 200px;
    border-right: none; border-bottom: 1px solid var(--border);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .kb-chat { min-height: 280px; }
  #kb-projects-grid, #kb-spaces-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .kb-quick-btn { font-size: 11px; padding: 8px 10px; }

  /* ── 그리드 유틸 ── */
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-auto-280 { grid-template-columns: 1fr; }

  /* ── 토스트 ── */
  .growth-toast {
    right: 12px; left: 12px; max-width: none;
    font-size: 12px; padding: 12px 16px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  /* ── 어드민 에이전트 패널 ── */
  .admin-agent-panel { max-height: 380px; }
  .admin-agent-input input { font-size: 16px; }

  /* ── 로그인 박스 ── */
  .login-box { padding: 28px 20px; max-width: 92vw; }
}

/* ═══════════════════════════════════════════════════════
   반응형 — 소형 모바일 (≤359px) — 갤럭시 폴드/SE 등
   ═══════════════════════════════════════════════════════ */
@media (max-width: 359px) {
  .nav-logo { font-size: 11px; }
  .nav-menu { display: none; }
  .nav-right #userEmail { display: none; }

  .kpi-row { grid-template-columns: 1fr; gap: 6px; }
  .main { padding: 8px 6px; }
  .section { padding: 8px; }
  .login-box { padding: 20px 14px; }
  .grid-5 { grid-template-columns: repeat(2, 1fr) !important; }

  .ai-panel:not(.collapsed) { max-height: 55vh; }
  .macro-btn { font-size: 10px; padding: 4px 8px; }

  .shortcut-grid { grid-template-columns: 1fr; }
  .ch-grid { grid-template-columns: 1fr; }

  #kb-spaces-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .kb-sources, .kb-outputs { max-height: 160px; }
  .kb-quick-btn { font-size: 10px; padding: 6px 8px; }
}

/* ═══ 어드민 AI 에이전트 패널 (주황 그라데이션) ═══ */
.admin-agent-panel {
  background: #fff; border-radius: 12px; margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(255,152,0,0.15); border: 1px solid #FFE0B2;
  display: flex; flex-direction: column; max-height: 420px; overflow: hidden;
  transition: max-height 0.3s ease;
}
.admin-agent-panel.minimized { max-height: 48px; }
.admin-agent-panel.minimized .admin-agent-macros,
.admin-agent-panel.minimized .admin-agent-messages,
.admin-agent-panel.minimized .admin-agent-input { display: none; }
.admin-agent-header {
  background: linear-gradient(135deg, #E65100, #FF9800, #FFB74D);
  color: #fff; padding: 12px 16px; display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0; border-radius: 12px 12px 0 0;
  font-size: 14px; font-weight: 700;
}
.admin-agent-macros {
  display: flex; gap: 6px; padding: 10px 12px; flex-wrap: wrap;
  border-bottom: 1px solid #FFE0B2; background: #FFF8E1; flex-shrink: 0;
}
.admin-macro {
  font-size: 11px; padding: 5px 10px; border-radius: 16px;
  border: 1px solid #FF9800; color: #E65100; background: #fff;
  cursor: pointer; font-weight: 600; white-space: nowrap; transition: all 0.15s;
}
.admin-macro:hover { background: #FF9800; color: #fff; }
.admin-agent-messages {
  flex: 1; overflow-y: auto; padding: 12px; display: flex;
  flex-direction: column; gap: 8px; background: #FFFBF0; min-height: 120px; max-height: 220px;
}
.admin-agent-input {
  display: flex; align-items: center; padding: 10px 12px;
  border-top: 1px solid #FFE0B2; background: #fff; flex-shrink: 0; gap: 8px;
}
.admin-agent-input input {
  flex: 1; border: 1px solid #FFE0B2; border-radius: 20px;
  padding: 9px 14px; font-size: 13px; outline: none; background: #FFF8E1; color: var(--text);
}
.admin-agent-input input:focus { border-color: #FF9800; }
.admin-agent-input button {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #FF9800; color: #fff; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.admin-agent-input button:hover { background: #E65100; }

/* ═══ 모바일 AI 토글 (기본 숨김) ═══ */
.mobile-ai-toggle {
  display: none; position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 9000; background: linear-gradient(135deg, #0D47A1, #1E88E5); color: #fff;
  border: none; border-radius: 24px; padding: 10px 20px; font-size: 13px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 16px rgba(13,71,161,0.4); white-space: nowrap;
}

/* ═══ 한그리 성장 토스트 알림 ═══ */
.growth-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0D47A1, #1565C0, #1E88E5);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(13, 71, 161, 0.4), 0 2px 8px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  max-width: 420px;
  line-height: 1.4;
}
.growth-toast-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.growth-toast-hide {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
}
.growth-toast-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.growth-toast-text {
  flex: 1;
}
.growth-toast-text strong {
  color: #90CAF9;
}

/* ═══ 투자 지식 베이스 (NotebookLM 스타일 3패널) ═══ */
.kb-three-panel { display: flex; gap: 0; height: calc(100vh - 220px); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.kb-panel { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: #fff; }
.kb-panel:last-child { border-right: none; }
.kb-sources { width: 240px; min-width: 240px; flex-shrink: 0; }
.kb-chat { flex: 1; min-width: 0; }
.kb-outputs { width: 220px; min-width: 220px; flex-shrink: 0; }
.kb-panel-header { padding: 10px 14px; font-size: 13px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #0D47A1, #1E88E5); flex-shrink: 0; }
.kb-outputs .kb-panel-header { background: linear-gradient(135deg, #1B5E20, #4CAF50); }
.kb-output-btn { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; font-size: 11px; text-align: left; transition: all 0.15s; color: var(--text); }
.kb-output-btn:hover { border-color: var(--primary); background: #F5F9FF; }
.kb-source-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; font-size: 11px; color: var(--text); cursor: pointer; transition: background 0.15s; }
.kb-source-item:hover { background: #F5F9FF; }
.kb-source-item input[type="checkbox"] { flex-shrink: 0; }
.kb-source-icon { font-size: 14px; flex-shrink: 0; }
.kb-source-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-source-del { color: var(--sub); cursor: pointer; font-size: 10px; opacity: 0; transition: opacity 0.15s; }
.kb-source-item:hover .kb-source-del, .kb-source-item:hover .kb-source-rename { opacity: 1; }
.kb-project-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; cursor: pointer; -webkit-transition: all 0.2s ease; transition: all 0.2s ease; }
.kb-project-card:hover { border-color: var(--primary); box-shadow: 0 6px 16px rgba(30,136,229,0.15); -webkit-transform: translateY(-3px); transform: translateY(-3px); }
.kb-project-card:active { -webkit-transform: translateY(0); transform: translateY(0); box-shadow: 0 2px 6px rgba(30,136,229,0.1); }
.kb-citation { background: #E3F2FD; color: #0D47A1; padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 700; cursor: pointer; text-decoration: none; }
.kb-citation:hover { background: #BBDEFB; }

/* KB 반응형은 메인 미디어쿼리 블록으로 통합됨 */

/* ═══ 지능 게이지 (무지개 그라데이션 + 충동 유발) ═══ */
.intel-gauge-wrap {
  width: 140px; height: 14px; background: #E8EAF0; border-radius: 7px;
  position: relative; overflow: hidden; border: 1px solid rgba(0,0,0,0.08);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.intel-gauge-bar {
  height: 100%; border-radius: 7px; position: relative; z-index: 1;
  background: linear-gradient(90deg, #EF5350, #FF9800, #FFEB3B, #66BB6A, #42A5F5, #7E57C2, #EC407A);
  background-size: 200% 100%;
  -webkit-animation: gaugeRainbow 3s linear infinite; animation: gaugeRainbow 3s linear infinite;
  -webkit-transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 8px rgba(255,152,0,0.4);
}
.intel-gauge-glow {
  position: absolute; top: -2px; bottom: -2px; right: 0; width: 20px; z-index: 2;
  background: radial-gradient(circle at center, rgba(255,255,255,0.9), transparent 70%);
  border-radius: 50%; opacity: 0;
  -webkit-animation: gaugePulse 1.5s ease-in-out infinite; animation: gaugePulse 1.5s ease-in-out infinite;
}
.intel-gauge-wrap:hover .intel-gauge-bar {
  box-shadow: 0 0 14px rgba(255,152,0,0.6), 0 0 28px rgba(66,165,245,0.3);
}

/* 무지개 흐르기 */
@-webkit-keyframes gaugeRainbow { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
@keyframes gaugeRainbow { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }

/* 끝점 빛 맥동 */
@-webkit-keyframes gaugePulse { 0%,100% { opacity: 0.3; -webkit-transform: scale(0.8); } 50% { opacity: 0.8; -webkit-transform: scale(1.2); } }
@keyframes gaugePulse { 0%,100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 0.8; transform: scale(1.2); } }

/* 게이지 증가 시 폭발 반짝 */
@-webkit-keyframes gaugeFlash { 0% { opacity: 1; -webkit-transform: scale(1); } 100% { opacity: 0; -webkit-transform: scale(2.5); } }
@keyframes gaugeFlash { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(2.5); } }

/* 레벨 점 맥동 (느린 호흡 — 피로도 최소) */
@-webkit-keyframes lvDotPulse { 0%,100% { box-shadow: 0 0 3px rgba(76,175,80,0.4); -webkit-transform: scale(1); } 50% { box-shadow: 0 0 6px rgba(76,175,80,0.7); -webkit-transform: scale(1.15); } }
@keyframes lvDotPulse { 0%,100% { box-shadow: 0 0 3px rgba(76,175,80,0.4); transform: scale(1); } 50% { box-shadow: 0 0 6px rgba(76,175,80,0.7); transform: scale(1.15); } }
.lv-dot-active {
  -webkit-animation: lvDotPulse 3s ease-in-out infinite !important;
  animation: lvDotPulse 3s ease-in-out infinite !important;
}

/* ═══ 한그리 다마고치 캐릭터 ═══ */
.hangri-pet {
  display: inline-block; position: relative; cursor: pointer;
  -webkit-transition: -webkit-transform 0.3s; transition: transform 0.3s;
}
.hangri-pet:hover { -webkit-transform: scale(1.1); transform: scale(1.1); }
.hangri-pet:active { -webkit-transform: scale(0.95); transform: scale(0.95); }

/* 몸통 */
.hangri-body {
  border-radius: 50%; position: relative;
  background: linear-gradient(135deg, #42A5F5, #1E88E5);
  box-shadow: 0 2px 8px rgba(30,136,229,0.3);
  display: flex; align-items: center; justify-content: center;
}
/* 눈 */
.hangri-eyes { display: flex; gap: 6px; position: relative; z-index: 1; }
.hangri-eye {
  background: #fff; border-radius: 50%; position: relative; overflow: hidden;
}
.hangri-pupil {
  background: #1A237E; border-radius: 50%; position: absolute;
  -webkit-animation: hangriLook 4s ease-in-out infinite; animation: hangriLook 4s ease-in-out infinite;
}
.hangri-highlight { background: #fff; border-radius: 50%; position: absolute; z-index: 2; }
/* 입 */
.hangri-mouth {
  position: absolute; border-radius: 0 0 50% 50%; border: 2px solid #0D47A1;
  border-top: none; background: none;
}
/* 볼 터치 */
.hangri-cheek {
  position: absolute; border-radius: 50%; background: rgba(255,138,128,0.4);
}
/* 왕관 (레벨5) */
.hangri-crown {
  position: absolute; top: -8px; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%);
  font-size: 12px; z-index: 3; opacity: 0; -webkit-transition: opacity 0.5s; transition: opacity 0.5s;
}
.hangri-pet.lv5 .hangri-crown { opacity: 1; }
/* 후광 (레벨4+) */
.hangri-glow {
  position: absolute; top: -4px; left: -4px; right: -4px; bottom: -4px;
  border-radius: 50%; opacity: 0;
  -webkit-transition: opacity 0.5s; transition: opacity 0.5s;
}
.hangri-pet.lv4 .hangri-glow, .hangri-pet.lv5 .hangri-glow {
  opacity: 1; box-shadow: 0 0 12px rgba(30,136,229,0.4), 0 0 24px rgba(30,136,229,0.15);
}

/* 레벨별 색상 (6단계) */
.hangri-pet.lv1 .hangri-body { background: linear-gradient(135deg, #B0BEC5, #90A4AE); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.hangri-pet.lv2 .hangri-body { background: linear-gradient(135deg, #81D4FA, #42A5F5); }
.hangri-pet.lv3 .hangri-body { background: linear-gradient(135deg, #42A5F5, #1E88E5); }
.hangri-pet.lv4 .hangri-body { background: linear-gradient(135deg, #1E88E5, #1565C0); }
.hangri-pet.lv5 .hangri-body { background: linear-gradient(135deg, #1565C0, #0D47A1); box-shadow: 0 2px 10px rgba(13,71,161,0.35); }
.hangri-pet.lv6 .hangri-body { background: linear-gradient(135deg, #FFD54F, #FF9800, #F57C00); box-shadow: 0 2px 12px rgba(255,152,0,0.4); }
.hangri-pet.lv5 .hangri-glow, .hangri-pet.lv6 .hangri-glow {
  opacity: 1; box-shadow: 0 0 12px rgba(30,136,229,0.4), 0 0 24px rgba(30,136,229,0.15);
}
.hangri-pet.lv6 .hangri-crown { opacity: 1; }

/* 아이들 활동 (떠다니기 + 좌우 흔들기 + 숨쉬기) */
@-webkit-keyframes hangriIdle {
  0% { -webkit-transform: translateY(0) rotate(0deg) scaleY(1); }
  15% { -webkit-transform: translateY(-4px) rotate(-3deg) scaleY(1.02); }
  30% { -webkit-transform: translateY(-2px) rotate(2deg) scaleY(1); }
  45% { -webkit-transform: translateY(-5px) rotate(-1deg) scaleY(1.03); }
  60% { -webkit-transform: translateY(-1px) rotate(3deg) scaleY(0.98); }
  75% { -webkit-transform: translateY(-4px) rotate(-2deg) scaleY(1.02); }
  100% { -webkit-transform: translateY(0) rotate(0deg) scaleY(1); }
}
@keyframes hangriIdle {
  0% { transform: translateY(0) rotate(0deg) scaleY(1); }
  15% { transform: translateY(-4px) rotate(-3deg) scaleY(1.02); }
  30% { transform: translateY(-2px) rotate(2deg) scaleY(1); }
  45% { transform: translateY(-5px) rotate(-1deg) scaleY(1.03); }
  60% { transform: translateY(-1px) rotate(3deg) scaleY(0.98); }
  75% { transform: translateY(-4px) rotate(-2deg) scaleY(1.02); }
  100% { transform: translateY(0) rotate(0deg) scaleY(1); }
}
.hangri-body { -webkit-animation: hangriIdle 4s ease-in-out infinite; animation: hangriIdle 4s ease-in-out infinite; }

/* 그림자도 움직임 */
.hangri-body::after {
  content: ''; position: absolute; bottom: -4px; left: 50%;
  -webkit-transform: translateX(-50%); transform: translateX(-50%);
  width: 60%; height: 4px; background: rgba(0,0,0,0.1); border-radius: 50%;
  -webkit-animation: hangriShadow 4s ease-in-out infinite; animation: hangriShadow 4s ease-in-out infinite;
}
@-webkit-keyframes hangriShadow { 0%,100% { width: 60%; opacity: 0.15; } 45% { width: 50%; opacity: 0.08; } }
@keyframes hangriShadow { 0%,100% { width: 60%; opacity: 0.15; } 45% { width: 50%; opacity: 0.08; } }

/* 눈동자 움직임 */
@-webkit-keyframes hangriLook { 0%,40%,100% { left: 30%; top: 25%; } 45%,55% { left: 50%; top: 20%; } 60%,80% { left: 20%; top: 30%; } }
@keyframes hangriLook { 0%,40%,100% { left: 30%; top: 25%; } 45%,55% { left: 50%; top: 20%; } 60%,80% { left: 20%; top: 30%; } }

/* 깜빡임 */
@-webkit-keyframes hangriBlink { 0%,42%,46%,100% { -webkit-transform: scaleY(1); } 44% { -webkit-transform: scaleY(0.1); } }
@keyframes hangriBlink { 0%,42%,46%,100% { transform: scaleY(1); } 44% { transform: scaleY(0.1); } }
.hangri-eye { -webkit-animation: hangriBlink 5s ease-in-out infinite; animation: hangriBlink 5s ease-in-out infinite; }
.hangri-eye:nth-child(2) { -webkit-animation-delay: 0.1s; animation-delay: 0.1s; }

/* 성장 팝 애니메이션 */
@-webkit-keyframes hangriGrow { 0% { -webkit-transform: scale(1); } 30% { -webkit-transform: scale(1.3); } 50% { -webkit-transform: scale(0.9); } 70% { -webkit-transform: scale(1.1); } 100% { -webkit-transform: scale(1); } }
@keyframes hangriGrow { 0% { transform: scale(1); } 30% { transform: scale(1.3); } 50% { transform: scale(0.9); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
.hangri-pet.growing { -webkit-animation: hangriGrow 0.6s ease-out; animation: hangriGrow 0.6s ease-out; }

/* 먹기 (소스 업로드 시) */
@-webkit-keyframes hangriEat { 0%,100% { border-radius: 0 0 50% 50%; } 50% { border-radius: 0 0 40% 40%; height: 5px; } }
@keyframes hangriEat { 0%,100% { border-radius: 0 0 50% 50%; } 50% { border-radius: 0 0 40% 40%; height: 5px; } }
.hangri-pet.eating .hangri-mouth { -webkit-animation: hangriEat 0.3s ease 3; animation: hangriEat 0.3s ease 3; }

/* 통통 튀기 (터치 시) */
@-webkit-keyframes hangriBounce { 0%,100% { -webkit-transform: translateY(0); } 30% { -webkit-transform: translateY(-8px); } 50% { -webkit-transform: translateY(0); } 70% { -webkit-transform: translateY(-4px); } }
@keyframes hangriBounce { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-8px); } 50% { transform: translateY(0); } 70% { transform: translateY(-4px); } }
.hangri-pet.bounce { -webkit-animation: hangriBounce 0.5s ease; animation: hangriBounce 0.5s ease; }

/* 성장 팝업 (호버) */
.hangri-popup {
  position: fixed; background: #fff; border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25); border: 1px solid var(--border);
  min-width: 200px; z-index: 2147483647; font-size: 11px; color: var(--text); pointer-events: none;
  -webkit-animation: fadeIn 0.15s ease-out; animation: fadeIn 0.15s ease-out;
}
.hangri-popup-arrow {
  position: absolute; top: 14px; left: -6px; -webkit-transform: rotate(-45deg); transform: rotate(-45deg);
  width: 10px; height: 10px; background: #fff; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.hangri-popup-stage { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.hangri-popup-stage.current { background: #F5F9FF; border-radius: 6px; padding: 4px 6px; margin: 0 -6px; font-weight: 700; }
.hangri-popup-stage .stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hangri-popup-stage .stage-dot.done { background: var(--green); }
.hangri-popup-stage .stage-dot.active { background: var(--primary); -webkit-animation: gaugePulse 1s ease-in-out infinite; animation: gaugePulse 1s ease-in-out infinite; }
.hangri-popup-stage .stage-dot.locked { background: #E0E0E0; }

/* 레벨 라벨 */
.hangri-level {
  font-size: 9px; font-weight: 700; text-align: center; margin-top: 3px;
  color: var(--sub); white-space: nowrap;
}

/* ═══ 파이프라인 퀵 버튼 (AI 채팅 상단) ═══ */
.pipe-quick-btn {
  padding: 4px 8px; border-radius: 6px; font-size: 10px; font-weight: 700;
  border: 1px solid var(--border); background: #fff; color: var(--sub);
  cursor: pointer; -webkit-transition: all 0.15s; transition: all 0.15s; white-space: nowrap;
}
.pipe-quick-btn:hover { border-color: var(--primary); color: var(--primary); background: #F5F9FF; }
.pipe-quick-btn:active { -webkit-transform: scale(0.95); transform: scale(0.95); }

/* ═══ 페르소나 프리셋 버튼 ═══ */
.pm-preset {
  font-size: 10px; padding: 4px 8px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  cursor: pointer; -webkit-transition: all 0.15s; transition: all 0.15s; white-space: nowrap;
}
.pm-preset:hover { border-color: var(--primary); background: #F5F9FF; color: var(--primary); }

/* ═══ 소스 퀵 추가 버튼 ═══ */
.kb-quick-btn {
  display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  gap: 3px; padding: 5px 8px; border: 1.5px solid var(--border); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 11px; font-weight: 600;
  -webkit-transition: all 0.15s; transition: all 0.15s; white-space: nowrap;
}
.kb-quick-btn:active { -webkit-transform: scale(0.97); transform: scale(0.97); }

/* ═══ 반응형 그리드 유틸 ═══ */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.grid-auto-280 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.grid-2col-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }

/* 그리드 유틸 반응형은 메인 미디어쿼리 블록으로 통합됨 */

/* ═══ 탭 UI (마이페이지/어드민) ═══ */
.page-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: 20px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border-radius: 12px 12px 0 0; padding: 0;
}
.page-tab {
  padding: 12px 20px; font-size: 13px; font-weight: 600; color: var(--sub);
  cursor: pointer; border: none; background: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.2s; flex-shrink: 0;
}
.page-tab:hover { color: var(--text); background: #F5F9FF; }
.page-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; -webkit-transition: color 0.15s, border-color 0.15s; transition: color 0.15s, border-color 0.15s; }
.page-tab.admin-tab.active { color: #E65100; border-bottom-color: #FF9800; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ═══ 상담봇 가이드 버튼 ═══ */
.guide-buttons {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.guide-btn {
  padding: 7px 14px; border-radius: 18px; font-size: 12px; font-weight: 700;
  border: 1.5px solid var(--primary); color: var(--primary) !important; background: #fff;
  cursor: pointer; -webkit-transition: all 0.15s ease; transition: all 0.15s ease; white-space: nowrap;
  -webkit-animation: fadeIn 0.2s ease-out both; animation: fadeIn 0.2s ease-out both;
}
.guide-btn:nth-child(2) { -webkit-animation-delay: 0.03s; animation-delay: 0.03s; }
.guide-btn:nth-child(3) { -webkit-animation-delay: 0.06s; animation-delay: 0.06s; }
.guide-btn:nth-child(4) { -webkit-animation-delay: 0.09s; animation-delay: 0.09s; }
.guide-btn:hover { background: var(--primary); color: #fff; -webkit-transform: translateY(-1px); transform: translateY(-1px); }
.guide-btn:active { -webkit-transform: translateY(0); transform: translateY(0); }
.guide-btn.back-btn { border-color: var(--sub); color: var(--sub); }
.guide-btn.back-btn:hover { background: var(--sub); color: #fff; }
.guide-btn.free-input-btn { border-color: var(--green); color: var(--green); }
.guide-btn.free-input-btn:hover { background: var(--green); color: #fff; }

/* 탭/가이드버튼/터치/Safe Area 반응형은 메인 미디어쿼리 블록으로 통합됨 */

/* ═══ 검색결과 테이블 수평 스크롤 래퍼 ═══ */
.result-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 8px; }

/* ═══ 스크롤바 미관 ═══ */
.page-tabs::-webkit-scrollbar, .result-table-wrap::-webkit-scrollbar { height: 4px; }
.page-tabs::-webkit-scrollbar-thumb, .result-table-wrap::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 2px; }
.page-tabs::-webkit-scrollbar-track, .result-table-wrap::-webkit-scrollbar-track { background: transparent; }

/* ═══ 탭 스크롤 스냅 ═══ */
.page-tabs { scroll-snap-type: x mandatory; -webkit-scroll-snap-type: mandatory; }
.page-tab { scroll-snap-align: start; }

/* ═══ 가로모드 모바일 대응 ═══ */
@media (max-height: 500px) and (orientation: landscape) {
  .ai-panel:not(.collapsed) { max-height: 30vh; }
  .ai-panel-messages { max-height: 15vh; }
  #chatbot-window { height: 50vh; max-height: 50dvh; }
}
