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

:root {
  --primary: #1E88E5;
  --primary-dark: #1565C0;
  --bg: #F8F9FA;
  --card: #FFFFFF;
  --text: #1A237E;
  --sub: #78909C;
  --border: #EAEDF0;
  --green: #4CAF50;
  --red: #EF5350;
  --blue: #42A5F5;
  --purple: #AB47BC;
  --orange: #FFA726;
  --input-bg: #F5F9FF;
}
* { -webkit-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); -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: 50px; 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-menu { display: flex; gap: 4px; margin-left: 32px; }
.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); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-user { color: rgba(255,255,255,0.8); font-size: 12px; }
.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; }
.nav-btn:hover { background: rgba(255,255,255,0.15); }

/* ═══ 레이아웃: 사이드바 + 콘텐츠 ═══ */
.app-layout { display: -webkit-box; display: -ms-flexbox; display: flex; height: calc(100vh - 50px); overflow: hidden; }
.sidebar { width: 180px; background: #1B2A4A; padding: 16px 0; flex-shrink: 0; position: sticky; top: 50px; height: calc(100vh - 50px); 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: 12px; padding: 10px 14px; font-size: 13px; color: rgba(255,255,255,0.8); cursor: pointer; 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; }
.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: 1200px; margin: 0 auto; padding: 24px; }
/* page-dashboard는 pages-panel 내부에서 일반 main 처럼 표시 */

/* ═══ KPI 카드 ═══ */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 20px; }
.kpi-card { background: var(--card); border-radius: 12px; padding: 28px 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border-top: 3px solid var(--primary); position: relative; overflow: hidden; }
.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(--sub); margin-bottom: 6px; }
.kpi-value { font-size: 40px; font-weight: 800; color: var(--text); line-height: 1.2; }
.kpi-sub { font-size: 11px; color: var(--sub); margin-top: 6px; }

/* ═══ 섹션 카드 ═══ */
.section { background: var(--card); border-radius: 12px; padding: 20px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.section-title { font-size: 13px; font-weight: 600; color: #666; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title .icon { font-size: 18px; }

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

/* ═══ 테이블 ═══ */
.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: 180px; 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-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: 14px; }
.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: 220px; 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: 20px; margin-top: 20px; }

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

/* 파이 차트 (conic-gradient) */
.pie-container { display: flex; align-items: center; gap: 24px; justify-content: center; }
.pie-circle { width: 140px; height: 140px; border-radius: 50%; position: relative; flex-shrink: 0; }
.pie-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 70px; height: 70px; background: var(--card); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--text); }
.pie-legend { display: flex; flex-direction: column; gap: 6px; }
.pie-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.pie-legend-pct { font-weight: 700; margin-left: auto; min-width: 36px; text-align: right; }

/* 수평 막대 (지역별 TOP 5) */
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-item { display: flex; align-items: center; gap: 10px; }
.rank-num { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; 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: 12px; font-weight: 600; color: var(--text); min-width: 80px; }
.rank-bar-track { flex: 1; background: var(--bg); border-radius: 6px; height: 20px; overflow: hidden; }
.rank-bar-fill { height: 100%; border-radius: 6px; background: var(--primary); transition: width 0.6s ease; display: flex; align-items: center; padding-left: 8px; }
.rank-bar-fill span { font-size: 11px; font-weight: 700; color: #fff; }

/* 주간 트렌드 (막대 그래프) */
.trend-chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 10px; }
.trend-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.trend-bar { width: 100%; border-radius: 6px 6px 0 0; background: var(--primary); transition: height 0.5s ease; min-height: 4px; position: relative; }
.trend-bar-val { font-size: 11px; font-weight: 700; color: var(--primary); }
.trend-bar-day { font-size: 10px; color: var(--sub); 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%; }
.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 - 50px); overflow: hidden;
}
.ai-panel {
  width: 340px; min-width: 340px; max-width: 340px; background: #fff;
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  height: 100%; flex-shrink: 0;
}
.ai-panel.collapsed { width: 0; min-width: 0; overflow: hidden; border: none; }
.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 { 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;
  border-bottom: 1px solid var(--border); background: #F5F9FF; flex-shrink: 0;
}
.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: 400px; height: 500px; 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;
}
#chatbot-window.open { display: flex; }

/* 매크로 버튼 영역 */
#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: 80%; padding: 10px 14px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.55; word-break: break-word; }
.chat-msg.ai { align-self: flex-start; background: #E8EAF0; color: #1A237E; border-bottom-left-radius: 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: #E8EAF0; 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; }

/* ═══════════════════════════════════════════════════════
   반응형 — 태블릿 (≤1024px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .sidebar { width: 160px; min-width: 160px; }
  .ai-panel { width: 280px; min-width: 280px; max-width: 280px; }
  .nav-item { padding: 6px 12px; font-size: 13px; }
}

/* ═══════════════════════════════════════════════════════
   반응형 — 모바일 (≤768px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* 네비게이션 */
  .nav { padding: 0 12px; height: 44px; }
  .nav-logo { font-size: 14px; }
  .nav-menu { gap: 2px; margin-left: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-item { padding: 6px 8px; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
  .nav-right { font-size: 11px; gap: 6px; }
  .nav-right span { display: none; }
  .nav-right #userEmail { display: inline; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }

  /* 레이아웃 — 사이드바 오버레이 */
  .app-layout { height: calc(100vh - 44px); }
  .sidebar { position: fixed; top: 44px; left: 0; z-index: 300; width: 200px; height: calc(100vh - 44px);
    transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar:not(.collapsed) { transform: translateX(0); box-shadow: 4px 0 16px rgba(0,0,0,0.3); }
  .sidebar.collapsed { transform: translateX(-100%); }
  .sidebar-expand-btn { top: 50px; z-index: 301; display: block !important; }

  /* AI 패널 — 하단 시트 */
  .agentic-layout { flex-direction: column; height: 100%; }
  .ai-panel { width: 100% !important; min-width: 100% !important; max-width: 100% !important;
    height: 0; min-height: 0; border-right: none; border-top: 1px solid var(--border);
    order: 2; transition: height 0.3s ease; overflow: hidden; }
  .ai-panel:not(.collapsed) { height: 45vh; }
  .ai-panel.collapsed { height: 0; }
  .ai-panel-reopen { display: none !important; }
  .pages-panel { order: 1; flex: 1; }

  /* 모바일 AI 토글 버튼 */
  .mobile-ai-toggle { display: flex !important; }

  /* 콘텐츠 */
  .main { padding: 16px 12px; }
  #page-dashboard { height: auto; overflow: visible; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 10px; }
  .grid-2, .chart-grid { grid-template-columns: 1fr; }
  .search-form { grid-template-columns: 1fr; }
  .search-stats { grid-template-columns: repeat(2, 1fr); }
  .shortcut-grid { grid-template-columns: repeat(2, 1fr); }
  .result-table { font-size: 11px; overflow-x: auto; }
  #anl-scenarios { grid-template-columns: 1fr !important; }
  .pie-container { flex-direction: column; }
  .ch-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .ch-grid { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 14px; margin-bottom: 12px; }
  .section-title { font-size: 13px; }

  /* 파이프라인 */
  .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: 48px; height: 48px; font-size: 22px; bottom: 16px; right: 16px; }
  #chatbot-window { width: calc(100vw - 16px); right: 8px; bottom: 72px; height: 65vh; border-radius: 12px; }

  /* 테이블 스크롤 */
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ═══════════════════════════════════════════════════════
   반응형 — 소형 모바일 / 갤럭시 폴드 (≤480px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .nav { height: 40px; padding: 0 8px; }
  .nav-logo { font-size: 12px; }
  .nav-menu { margin-left: 4px; }
  .nav-item { padding: 4px 6px; font-size: 10px; }

  .kpi-row { grid-template-columns: 1fr 1fr; gap: 6px; }
  .kpi-card { padding: 10px 8px; }
  .kpi-value { font-size: 18px; }

  .main { padding: 10px 8px; }
  .section { padding: 10px; }

  .ai-panel:not(.collapsed) { height: 50vh; }
  .ai-panel-macros { gap: 4px; padding: 6px 8px; }
  .macro-btn { font-size: 10px; padding: 4px 8px; }
  .ai-panel-messages { padding: 10px; }
  .ai-panel-input { padding: 8px; gap: 6px; }
  .ai-panel-input input { padding: 7px 12px; font-size: 12px; }

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

  #chatbot-window { width: calc(100vw - 8px); right: 4px; height: 70vh; }
}

/* ═══════════════════════════════════════════════════════
   반응형 — 갤럭시 폴드 접힌 상태 (≤320px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 320px) {
  .nav-logo { font-size: 11px; }
  .nav-menu { display: none; }
  .nav-right #userEmail { display: none; }

  .kpi-row { grid-template-columns: 1fr; }
  .main { padding: 8px 6px; }
  .section { padding: 8px; }
  .kpi-value { font-size: 16px; }

  .ai-panel:not(.collapsed) { height: 55vh; }
  .macro-btn { font-size: 9px; padding: 3px 6px; }
}

/* ═══ 어드민 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;
}
