/* ============================================================
   Social Radar — 리뉴얼 와이어프레임 공용 파운데이션 (renew.css)
   ------------------------------------------------------------
   리뉴얼 원칙:
   - 토큰 이름 단일화 (별칭 이중 체계 제거 — 이 파일이 유일한 정본)
   - 비컬러 토큰 신설: radius / spacing / font ramp / shadow
   - 라이트 스킨, Pretendard Variable, 인디고 1색 절제
   - 그림자 없는 border-only 카드 (팝업류만 --shadow-pop)
   - 차트: 마크만 컬러, 텍스트는 잉크 토큰 (dataviz 규칙)
   ============================================================ */

:root {
  /* ---- Surface (5단) ---- */
  --bg:            #f7f8fa;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --surface-hover: #f3f5f8;

  /* ---- Line (3단) ---- */
  --border:        #e6e9ef;
  --border-soft:   #eef0f4;
  --border-strong: #d1d5db;

  /* ---- Ink (4단) ---- */
  --ink:   #0b1220;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --ink-4: #cbd5e1;

  /* ---- Brand (인디고 1색) ---- */
  --brand:      #4f46e5;
  --brand-soft: #eef0ff;
  --brand-deep: #3730a3;

  /* ---- Semantic (softened 쌍) ---- */
  --good:      #1f9d55;
  --good-soft: #e3f6ea;
  --good-text: #15803d;
  --bad:       #dd4444;
  --bad-soft:  #fcebeb;
  --bad-text:  #b91c1c;
  --warn:      #d97e1a;
  --warn-soft: #fdf1d7;
  --warn-text: #92500a;

  /* ---- Viz (차트 전용 — 신호색과 분리) ----
     감성 = diverging (양극 + 중립 회색). 중립 회색은 대비 3:1 미만이라
     범례 + 직접 % 라벨을 반드시 동반한다 (relief 의무). */
  --viz-bar:  #4f46e5;   /* 단일 시리즈 막대 = 브랜드 인디고 (4.9:1) */
  --viz-bar-soft: #c7ccf4;
  --viz-pos:  #1f9d55;
  --viz-neu:  #9ca3af;
  --viz-neg:  #dd4444;

  /* ---- Radius scale ---- */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-pill: 999px;

  /* ---- Shadow (팝업류 전용 — 카드는 그림자 금지) ---- */
  --shadow-pop: 0 8px 28px rgba(11, 18, 32, .10), 0 2px 8px rgba(11, 18, 32, .06);

  /* ---- Font ramp (가독성 확대판 — 본문 14 / 강조 16 / 카드 타이틀 17) ---- */
  --fs-xs:    12px;
  --fs-sm:    13px;
  --fs-base:  14px;
  --fs-md:    16px;
  --fs-lg:    17px;
  --fs-xl:    20px;
  --fs-title: 26px;
  --fs-hero:  38px;

  /* ---- Layout ---- */
  --sidebar-w: 244px;
  --topbar-h:  56px;
  --content-max: 1180px;
}

/* ============ Reset / Base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-base);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
button { font: inherit; letter-spacing: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
input, textarea, select { font: inherit; letter-spacing: inherit; color: var(--ink); }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
svg { flex-shrink: 0; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.ink-2 { color: var(--ink-2); }
.ink-3 { color: var(--ink-3); }

/* ============ App shell ============ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: baseline; gap: 1px;
  font-size: 19px; font-weight: 800; letter-spacing: -0.02em;
  padding: 2px 12px 18px;
}
.sidebar-brand .b1 { color: var(--ink-3); font-weight: 600; }
.sidebar-brand .b2 { color: var(--ink); }
.sidebar-brand .b3 { color: var(--brand); }

.ws-switch {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; transition: border-color .15s;
}
.ws-switch:hover { border-color: var(--border-strong); }
.ws-avatar {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 700;
}
.ws-name { font-size: var(--fs-base); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-caret { color: var(--ink-3); }

/* v5 — 워크스페이스 스위처 드롭다운 (프로젝트 전환, 4개 앱 화면 공통) */
.ws-wrap { position: relative; }
.ws-menu {
  position: absolute; top: calc(100% - 8px); left: 0; right: 0; z-index: 80;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 6px;
}
.ws-menu-label {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .08em; padding: 6px 10px 4px;
}
.ws-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: var(--fs-base); font-weight: 600; color: var(--ink-2);
  cursor: pointer; transition: background .12s, color .12s;
}
.ws-item:hover { background: var(--surface-hover); color: var(--ink); }
.ws-item.is-cur { background: var(--brand-soft); color: var(--brand); }
.ws-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ws-item .dot.ok { background: var(--good); }
.ws-item .dot.warn { background: var(--warn); }
.ws-item .dot.crit { background: var(--bad); }
.ws-item .dot.off { background: var(--ink-4); }
.ws-item .mini { margin-left: auto; font-size: var(--fs-xs); font-weight: 500; color: var(--ink-3); white-space: nowrap; }
.ws-item.is-cur .mini { color: var(--brand); opacity: .75; }
.ws-menu-div { height: 1px; background: var(--border-soft); margin: 6px 4px; }

.nav-group-label {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 15px; font-weight: 500;   /* 본문(14)과 구메뉴(16) 사이 — 페이지별 토큰 차이와 무관하게 고정 */
  cursor: pointer; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-hover); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; opacity: .85; }
.nav-badge {
  margin-left: auto; font-size: var(--fs-xs); font-weight: 600;
  padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--surface-hover); color: var(--ink-2);
}
.nav-item.active .nav-badge { background: rgba(79, 70, 229, .12); color: var(--brand); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-soft); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: var(--fs-lg); font-weight: 700; display: flex; align-items: center; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* v5 — topbar 가 유일한 페이지 제목: "워크스페이스 / 페이지" 크럼 (본문 h1 중복 제거) */
.topbar-title .ws { color: var(--ink-3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title .sep { color: var(--ink-4); font-weight: 400; padding: 0 7px; }
.topbar-note { font-size: var(--fs-sm); color: var(--ink-3); white-space: nowrap; }
@media (max-width: 640px) { .topbar-note { display: none; } }

/* v5 — 로그인 사용자: 모든 화면 우측 상단 통일 */
.topbar-user { display: inline-flex; align-items: center; gap: 9px; }
.topbar-user .nm { font-size: var(--fs-sm); font-weight: 600; }
.topbar-user .ws-avatar { border-radius: 50%; }

.content {
  width: 100%; max-width: var(--content-max);
  margin: 0 auto; padding: 28px;
  display: flex; flex-direction: column; gap: 28px;
}

/* 페이지 헤더 */
.page-head { display: flex; align-items: flex-start; gap: 14px; }
.page-title { font-size: var(--fs-title); font-weight: 800; letter-spacing: -0.02em; }
.page-desc { font-size: var(--fs-base); color: var(--ink-3); margin-top: 3px; }
.page-head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* 섹션 넘버링 리듬 — "01 · 오늘의 핵심" */
.sec-label {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .09em;
  margin-bottom: 12px;
}
.sec-label .sec-num { color: var(--brand); }
.sec-label::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }

/* ============ Card ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color .15s;
}
.card:hover { border-color: var(--border-strong); }
.card-pad { padding: 22px; }
.card-title { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.015em; }
.card-sub { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; }

/* ============ KPI ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--fs-sm); font-weight: 500; color: var(--ink-3);
}
.kpi-value { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-delta { display: flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 600; }
.kpi-delta.up   { color: var(--bad-text); }   /* 언급·부정 증가 = 주의 */
.kpi-delta.down { color: var(--good-text); }
.kpi-delta.flat { color: var(--ink-3); }
.kpi-delta .vs { color: var(--ink-3); font-weight: 400; }

/* 지표 정의 툴팁 (ⓘ) */
.metric-hint { position: relative; display: inline-flex; color: var(--ink-4); cursor: help; }
.metric-hint svg { width: 13px; height: 13px; }
.metric-hint .hint-pop {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: 230px; padding: 10px 12px;
  background: var(--ink); color: #fff;
  font-size: var(--fs-sm); font-weight: 400; line-height: 1.5; letter-spacing: -0.005em;
  border-radius: var(--r-sm); box-shadow: var(--shadow-pop); z-index: 60;
  white-space: normal; text-transform: none;
}
.metric-hint:hover .hint-pop { display: block; }

/* ============ Chip ============ */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-sm); font-weight: 500;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--surface-hover); color: var(--ink-2);
}
.chip-good  { background: var(--good-soft);  color: var(--good-text); }
.chip-bad   { background: var(--bad-soft);   color: var(--bad-text); }
.chip-warn  { background: var(--warn-soft);  color: var(--warn-text); }
.chip-brand { background: var(--brand-soft); color: var(--brand); }
.chip-sm { font-size: var(--fs-xs); padding: 2px 7px; }

/* ============ Button ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: var(--fs-base); font-weight: 600;
  padding: 8px 14px; border-radius: var(--r-sm);
  transition: all .15s; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #1e293b; }
.btn-primary:disabled { background: var(--ink-4); cursor: not-allowed; }
.btn-outline { background: var(--surface); color: var(--ink-2); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--ink); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink); }
.btn-lg { font-size: var(--fs-md); padding: 11px 22px; border-radius: 10px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2);
}
.btn-icon:hover { background: var(--surface-hover); color: var(--ink); }
.btn-icon svg { width: 16px; height: 16px; }

/* ============ Input ============ */
.input {
  width: 100%; padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: var(--fs-base); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); }
.input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.field-label { display: block; font-size: var(--fs-base); font-weight: 600; margin-bottom: 6px; }
.field-help { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 6px; line-height: 1.5; }
.field-help b { color: var(--ink-2); font-weight: 600; }

/* 검색 인풋 (아이콘 내장) */
.search-box { position: relative; }
.search-box svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--ink-3); pointer-events: none;
}
.search-box .input { padding-left: 34px; }

/* 토글 스위치 */
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--r-pill);
  background: var(--ink-4); transition: background .15s;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.switch input:checked ~ .track { background: var(--brand); }
.switch input:checked ~ .thumb { transform: translateX(16px); }

/* 태그 입력 (키워드) */
.tag-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 10px; min-height: 46px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: text; transition: border-color .15s, box-shadow .15s;
}
.tag-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.tag-input input {
  flex: 1; min-width: 120px; border: 0; outline: none;
  font-size: var(--fs-base); padding: 3px 2px; background: transparent;
}
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-sm); font-weight: 600;
  padding: 4px 6px 4px 10px; border-radius: var(--r-sm);
  background: var(--brand-soft); color: var(--brand);
}
.tag.tag-muted { background: var(--surface-hover); color: var(--ink-2); }
.tag .tag-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 4px; color: inherit; opacity: .55;
}
.tag .tag-x:hover { opacity: 1; background: rgba(79, 70, 229, .14); }
.tag .tag-x svg { width: 11px; height: 11px; }

/* ============ Filter (피드) ============ */
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-base); font-weight: 500; color: var(--ink-2);
  padding: 7px 12px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: all .13s; white-space: nowrap;
}
.filter-pill:hover { border-color: var(--border-strong); color: var(--ink); }
.filter-pill.on { background: var(--brand-soft); border-color: rgba(79, 70, 229, .35); color: var(--brand); font-weight: 600; }
.filter-pill svg { width: 14px; height: 14px; opacity: .75; }
.filter-pill .cnt {
  font-size: var(--fs-xs); font-weight: 700;
  padding: 0 6px; border-radius: var(--r-pill);
  background: var(--brand); color: #fff;
}

.filter-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 50;
  min-width: 230px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
}
.filter-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: var(--fs-base); color: var(--ink-2); cursor: pointer;
}
.filter-opt:hover { background: var(--surface-hover); color: var(--ink); }
.filter-opt.sel { color: var(--brand); font-weight: 600; background: var(--brand-soft); }
.filter-opt .opt-n { margin-left: auto; font-size: var(--fs-sm); color: var(--ink-3); font-weight: 400; }
.filter-divider { height: 1px; background: var(--border-soft); margin: 6px 4px; }

/* 활성 필터 chip 행 */
.active-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.active-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: 600;
  padding: 4px 7px 4px 11px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand);
}
.active-chip .k { font-weight: 400; opacity: .75; }
.active-chip button { display: inline-flex; opacity: .6; }
.active-chip button:hover { opacity: 1; }
.active-chip button svg { width: 12px; height: 12px; }

/* ============ 감성/위험 표시 ============ */
.sent-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sent-dot.pos { background: var(--viz-pos); }
.sent-dot.neu { background: var(--viz-neu); }
.sent-dot.neg { background: var(--viz-neg); }

.risk-num {
  width: 48px; height: 48px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; font-weight: 800; font-size: var(--fs-lg); line-height: 1;
  gap: 2px;
}
.risk-num .rl { font-size: 10px; font-weight: 600; letter-spacing: .05em; opacity: .75; }
.risk-num.high { background: var(--bad-soft);  color: var(--bad-text); }
.risk-num.mid  { background: var(--warn-soft); color: var(--warn-text); }
.risk-num.low  { background: var(--surface-hover); color: var(--ink-3); }

/* ============ 모달 ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(11, 18, 32, .42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 20px;
  overflow-y: auto;
}
.modal {
  width: 100%; max-width: 760px;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px; border-bottom: 1px solid var(--border-soft);
}
.modal-body { padding: 22px; }
.hidden { display: none !important; }

/* ============ 차트 공통 (dataviz 규칙) ============ */
.viz-legend { display: flex; align-items: center; gap: 14px; font-size: var(--fs-sm); color: var(--ink-2); }
.viz-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend .sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.viz-tooltip {
  position: fixed; z-index: 120; pointer-events: none;
  background: var(--ink); color: #fff;
  font-size: var(--fs-sm); line-height: 1.45; letter-spacing: -0.005em;
  padding: 8px 11px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop);
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
}
.viz-tooltip .tt-label { color: rgba(255, 255, 255, .65); font-size: var(--fs-xs); }
.viz-tooltip .tt-val { font-weight: 700; }

/* ============ 반응형 ============ */
.mobile-menu-btn { display: none; }

@media (max-width: 1024px) {
  .sidebar { display: none; }
  .mobile-menu-btn { display: inline-flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px 16px; gap: 22px; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .page-head-actions { margin-left: 0; }
}

/* ============================================================
   renew_v2 확장 — "위험과 기회는 대칭이다"
   ------------------------------------------------------------
   v2 컨셉: 리스크 감지 → 4질문(건강/맥락/변화/행동) 범용 확장.
   기회(opportunity) 시그널 전용 teal 1쌍 신설 — 위험(red)과 대칭,
   감성 긍정(green)·브랜드(indigo)와 구분되는 독립 축.
   (#0d9488 — 팔레트 검증기 4개 항목 통과, 대비 4.2:1)
   ============================================================ */
:root {
  --opp:      #0d9488;
  --opp-soft: #daf1ee;
  --opp-text: #0f766e;
}

/* 기회 chip — chip-bad 와 대칭 */
.chip-opp { background: var(--opp-soft); color: var(--opp-text); }

/* 기회도 점수 넘버 — .risk-num 과 동일 형태의 대칭 변형 */
.risk-num.opp { background: var(--opp-soft); color: var(--opp-text); }

/* 시그널 유형 마커 (피드·대시보드·브리핑 공용) */
.sig-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 700;
  padding: 2px 8px; border-radius: var(--r-pill);
}
.sig-tag svg { width: 11px; height: 11px; }
.sig-tag.opp  { background: var(--opp-soft);  color: var(--opp-text); }
.sig-tag.risk { background: var(--bad-soft);  color: var(--bad-text); }
.sig-tag.ctx  { background: var(--brand-soft); color: var(--brand); }
