/* ============================================================
   GHG Analysis System — Global Styles
   ============================================================ */
:root {
  --green:    #16a34a;
  --green-l:  #dcfce7;
  --green-d:  #14532d;
  --blue:     #0ea5e9;
  --blue-l:   #e0f2fe;
  --red:      #ef4444;
  --red-l:    #fee2e2;
  --amber:    #f59e0b;
  --amber-l:  #fef3c7;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --nav-h:    60px;
  --sidebar-w:240px;
  --radius:   10px;
  --shadow:   0 1px 4px rgba(0,0,0,.10);
  --shadow-lg:0 4px 16px rgba(0,0,0,.12);
}
*{box-sizing:border-box;margin:0;padding:0;}
body{font-family:"Pretendard","Noto Sans KR","Apple SD Gothic Neo",sans-serif;
     background:var(--gray-50);color:var(--gray-900);font-size:14px;line-height:1.6;}
a{color:inherit;text-decoration:none;}
button{cursor:pointer;}

/* ── 네비게이션 ─────────────────────── */
.topnav{
  position:fixed;top:0;left:0;right:0;height:var(--nav-h);
  background:#0f172a;color:#fff;display:flex;align-items:center;
  padding:0 24px;z-index:200;gap:8px;box-shadow:0 2px 8px rgba(0,0,0,.3);
}
.topnav .logo{
  display:flex;align-items:center;gap:8px;font-size:1rem;font-weight:700;
  color:#4ade80;margin-right:24px;white-space:nowrap;
}
.topnav .logo span{color:#fff;}
.topnav nav{display:flex;gap:2px;flex:1;}
.topnav nav a{
  padding:8px 14px;border-radius:6px;font-size:.85rem;color:#94a3b8;
  transition:all .2s;
}
.topnav nav a:hover,.topnav nav a.active{background:#1e293b;color:#fff;}
.topnav .badge{
  background:#ef4444;color:#fff;border-radius:99px;
  padding:2px 7px;font-size:.7rem;margin-left:4px;font-weight:700;
}

/* ── 레이아웃 ────────────────────────── */
.page{padding-top:calc(var(--nav-h) + 24px);min-height:100vh;}
.container{max-width:1300px;margin:0 auto;padding:0 20px 40px;}
.page-title{font-size:1.4rem;font-weight:700;margin-bottom:4px;}
.page-sub  {color:var(--gray-500);font-size:.85rem;margin-bottom:24px;}

/* ── 카드 ─────────────────────────────── */
.card{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);padding:20px;}
.card-header{font-size:.95rem;font-weight:700;color:var(--gray-700);
             margin-bottom:14px;padding-bottom:10px;border-bottom:1px solid var(--gray-200);}
.card-sm{padding:16px;}

/* ── KPI 그리드 ──────────────────────── */
.kpi-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:14px;margin-bottom:24px;}
.kpi-card{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);
          padding:18px 16px;border-left:4px solid var(--green);}
.kpi-card.red  {border-color:var(--red);}
.kpi-card.blue {border-color:var(--blue);}
.kpi-card.amber{border-color:var(--amber);}
.kpi-label{font-size:.75rem;color:var(--gray-500);margin-bottom:4px;}
.kpi-value{font-size:1.5rem;font-weight:800;color:var(--gray-900);}
.kpi-sub  {font-size:.72rem;color:var(--gray-500);margin-top:2px;}
.kpi-trend{font-size:.78rem;font-weight:600;margin-top:4px;}
.kpi-trend.up  {color:var(--red);}
.kpi-trend.down{color:var(--green);}

/* ── 2열 / 3열 그리드 ───────────────── */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:16px;}
.grid-3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:16px;}
.grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;}
@media(max-width:900px){.grid-2,.grid-3,.grid-4{grid-template-columns:1fr;}}

/* ── 차트 컨테이너 ───────────────────── */
.chart-wrap{position:relative;width:100%;}
.chart-wrap canvas{max-height:300px;}

/* ── 테이블 ──────────────────────────── */
.tbl-wrap{overflow-x:auto;}
table{width:100%;border-collapse:collapse;font-size:.83rem;}
th{background:var(--gray-100);padding:10px 12px;text-align:left;
   font-weight:600;color:var(--gray-700);border-bottom:2px solid var(--gray-200);}
td{padding:9px 12px;border-bottom:1px solid var(--gray-100);vertical-align:middle;}
tr:hover td{background:var(--gray-50);}
td.num{text-align:right;font-variant-numeric:tabular-nums;}

/* ── 뱃지 ────────────────────────────── */
.badge{display:inline-flex;align-items:center;border-radius:99px;
       padding:2px 10px;font-size:.72rem;font-weight:600;white-space:nowrap;}
.badge-green {background:var(--green-l); color:var(--green-d);}
.badge-red   {background:var(--red-l);   color:#991b1b;}
.badge-amber {background:var(--amber-l); color:#92400e;}
.badge-blue  {background:var(--blue-l);  color:#0c4a6e;}
.badge-gray  {background:var(--gray-100);color:var(--gray-700);}

/* ── 뉴스 카드 ───────────────────────── */
.news-item{border:1px solid var(--gray-200);border-radius:8px;padding:14px 16px;
           margin-bottom:10px;transition:box-shadow .2s;}
.news-item:hover{box-shadow:var(--shadow-lg);}
.news-item .ni-head{display:flex;align-items:center;gap:8px;margin-bottom:6px;}
.news-item .ni-date{font-size:.72rem;color:var(--gray-500);}
.news-item .ni-title{font-size:.9rem;font-weight:700;color:var(--gray-900);margin-bottom:4px;}
.news-item .ni-summary{font-size:.8rem;color:var(--gray-700);line-height:1.5;}
.news-item .ni-tags{display:flex;gap:4px;flex-wrap:wrap;margin-top:8px;}
.news-item .ni-tag{background:var(--gray-100);color:var(--gray-700);
                   border-radius:4px;padding:2px 8px;font-size:.7rem;}

/* ── 리스크 히트맵 ──────────────────── */
.risk-cell{text-align:center;border-radius:6px;padding:6px 4px;font-weight:700;font-size:.8rem;}
.risk-1{background:#dcfce7;color:#14532d;}
.risk-2{background:#bbf7d0;color:#14532d;}
.risk-3{background:#fef9c3;color:#713f12;}
.risk-4{background:#fed7aa;color:#7c2d12;}
.risk-5{background:#fecaca;color:#7f1d1d;}

/* ── 전략 카드 ───────────────────────── */
.strategy-card{border:1px solid var(--gray-200);border-radius:8px;padding:14px 16px;margin-bottom:10px;}
.sc-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;}
.sc-title{font-size:.88rem;font-weight:700;color:var(--gray-900);}
.sc-badges{display:flex;gap:4px;flex-shrink:0;}
.sc-desc{font-size:.8rem;color:var(--gray-600);margin-top:6px;}
.sc-horizon{font-size:.72rem;color:var(--gray-500);margin-top:4px;}
.priority-chip{border-radius:4px;padding:2px 8px;font-size:.7rem;font-weight:700;}
.p-core{background:#fee2e2;color:#991b1b;}
.p-important{background:#fef3c7;color:#92400e;}
.p-normal{background:#e0f2fe;color:#0c4a6e;}

/* ── 게이지 바 ───────────────────────── */
.progress-bar{background:var(--gray-200);border-radius:99px;height:8px;overflow:hidden;}
.progress-fill{height:100%;border-radius:99px;transition:width .6s ease;}

/* ── 탭 ──────────────────────────────── */
.tab-bar{display:flex;gap:4px;border-bottom:2px solid var(--gray-200);margin-bottom:18px;}
.tab-btn{padding:8px 16px;border:none;background:none;font-size:.85rem;
         color:var(--gray-500);border-bottom:2px solid transparent;margin-bottom:-2px;
         font-family:inherit;transition:all .2s;border-radius:6px 6px 0 0;}
.tab-btn:hover{color:var(--gray-900);}
.tab-btn.active{color:var(--green);border-bottom-color:var(--green);font-weight:700;}
.tab-content{display:none;} .tab-content.active{display:block;}

/* ── 셀렉터 / 인풋 ──────────────────── */
select,input{padding:8px 12px;border:1px solid var(--gray-300);border-radius:6px;
             font-size:.85rem;font-family:inherit;outline:none;background:#fff;}
select:focus,input:focus{border-color:var(--green);box-shadow:0 0 0 3px rgba(22,163,74,.15);}

/* ── 섹션 헤더 ───────────────────────── */
.section-title{font-size:1rem;font-weight:700;margin-bottom:12px;
               display:flex;align-items:center;gap:8px;}
.section-title::before{content:'';display:block;width:4px;height:18px;
                        background:var(--green);border-radius:2px;}

/* ── 알림 박스 ───────────────────────── */
.alert{border-radius:8px;padding:12px 16px;font-size:.83rem;margin-bottom:12px;}
.alert-red   {background:var(--red-l);border-left:4px solid var(--red);color:#7f1d1d;}
.alert-green {background:var(--green-l);border-left:4px solid var(--green);color:var(--green-d);}
.alert-amber {background:var(--amber-l);border-left:4px solid var(--amber);color:#78350f;}
.alert-blue  {background:var(--blue-l);border-left:4px solid var(--blue);color:#0c4a6e;}

/* ── 로딩 ────────────────────────────── */
.spinner{display:inline-block;width:20px;height:20px;border:3px solid var(--gray-200);
         border-top-color:var(--green);border-radius:50%;animation:spin .7s linear infinite;}
@keyframes spin{to{transform:rotate(360deg);}}

/* ── 반응형 ──────────────────────────── */
@media(max-width:700px){
  .topnav nav a span{display:none;}
  .kpi-grid{grid-template-columns:1fr 1fr;}
}

/* ============================================================
   챗봇 컴포넌트
   ============================================================ */

/* FAB 플로팅 버튼 */
.chatbot-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 1000;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); color: #fff;
  border: none; font-size: 1.5rem; cursor: pointer;
  box-shadow: 0 4px 16px rgba(22,163,74,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
.chatbot-fab:hover  { transform: scale(1.1); box-shadow: 0 6px 20px rgba(22,163,74,.55); }
.chatbot-fab.active { background: #dc2626; }

/* 패널 */
.chatbot-panel {
  position: fixed; top: 0; right: -380px; width: 360px; height: 100vh;
  background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.12);
  z-index: 999; display: flex; flex-direction: column;
  transition: right .3s cubic-bezier(.4,0,.2,1);
  border-left: 1px solid var(--gray-200);
}
.chatbot-panel.open { right: 0; }

/* 헤더 */
.chatbot-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--green); color: #fff;
  flex-shrink: 0;
}
.chatbot-header-left { display: flex; align-items: center; gap: 10px; }
.chatbot-icon        { font-size: 1.4rem; }
.chatbot-title       { font-size: .95rem; font-weight: 700; }
.chatbot-ctx         { font-size: .72rem; opacity: .85; margin-top: 1px; }
.chatbot-close {
  background: none; border: none; color: #fff;
  font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: 4px;
  line-height: 1;
}
.chatbot-close:hover { background: rgba(255,255,255,.2); }

/* 메시지 영역 */
.chatbot-msgs {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}

/* 메시지 버블 */
.chatbot-msg         { display: flex; }
.chatbot-msg-user    { justify-content: flex-end; }
.chatbot-msg-assistant { justify-content: flex-start; }

.chatbot-bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 14px;
  font-size: .83rem; line-height: 1.55; word-break: break-word;
}
.chatbot-msg-user .chatbot-bubble {
  background: var(--green); color: #fff;
  border-bottom-right-radius: 4px;
}
.chatbot-msg-assistant .chatbot-bubble {
  background: var(--gray-100); color: var(--gray-900);
  border-bottom-left-radius: 4px;
}

/* 타이핑 인디케이터 */
.chatbot-typing { display: flex; gap: 5px; align-items: center; padding: 12px 16px; }
.chatbot-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gray-400); display: inline-block;
  animation: bounce .9s infinite ease-in-out;
}
.chatbot-typing span:nth-child(2) { animation-delay: .15s; }
.chatbot-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes bounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-6px); }
}

/* 빠른 질문 칩 */
.chatbot-chips {
  padding: 8px 12px 4px; display: flex; flex-wrap: wrap; gap: 6px;
  border-top: 1px solid var(--gray-200); flex-shrink: 0;
}
.chatbot-chip {
  padding: 5px 10px; border-radius: 20px;
  background: var(--green-l); color: var(--green-d);
  border: 1px solid #bbf7d0; font-size: .75rem;
  cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.chatbot-chip:hover { background: #bbf7d0; }

/* 입력 영역 */
.chatbot-input-row {
  display: flex; gap: 8px; padding: 10px 12px 14px;
  border-top: 1px solid var(--gray-200); flex-shrink: 0;
  align-items: flex-end;
}
.chatbot-textarea {
  flex: 1; padding: 9px 12px; border: 1px solid var(--gray-300);
  border-radius: 10px; font-family: inherit; font-size: .83rem;
  resize: none; outline: none; max-height: 120px;
  line-height: 1.4;
}
.chatbot-textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.chatbot-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--green); color: #fff; border: none;
  font-size: 1rem; cursor: pointer; flex-shrink: 0;
  transition: background .15s;
}
.chatbot-send:hover    { background: var(--green-d); }
.chatbot-send:disabled { background: var(--gray-300); cursor: default; }

/* 모바일 패널 전체 너비 */
@media(max-width:480px) {
  .chatbot-panel { width: 100%; right: -100%; }
  .chatbot-fab   { bottom: 18px; right: 18px; }
}
