/* ==========================================================================
   Design v2 — "카드 캔버스" 레이어  (2026-10-31)
   --------------------------------------------------------------------------
   styles.css 위에 얹는 디자인 레이어입니다. 모든 페이지가 styles.css 다음에
   이 파일을 불러옵니다. 이 줄 하나(<link ... design-v2.css>)를 빼면 예전
   디자인으로 그대로 돌아갑니다.

   왜 바꿨나 — 예전 화면은 바탕(#f6f6f4)과 패널(#fff)의 명도 차가 거의 없고
   1px 헤어라인 + 6px 모서리만으로 패널을 나눠, 패널이 12개 이어지는
   대시보드에서 "어디서 어디까지가 한 섹션인지"가 보이지 않았습니다.

   원칙 (레퍼런스: 소셜 분석 대시보드 캡처 2장)
   1. 회색 캔버스 + 흰 카드. 구분은 선이 아니라 "면"으로 합니다.
      카드는 테두리 없이 16px 모서리, 카드 사이 20px.
   2. 카드 안의 하위 상자는 한 톤 낮은 면(--bg-inset)으로만 나눕니다.
   3. 제목은 굵게(700), 보조 설명은 회색 12px. 숫자는 Pretendard 700.
   4. 선택 상태는 인디고 채움(알약). 비선택은 흰 알약 + 회색 글자.
   5. 차트 색은 채도를 낮춘 파스텔 계열(보라·초록·핑크·블루).
   6. 좌측 색띠 없음 (hygiene 테스트의 규칙을 이 파일도 지킵니다).
   ========================================================================== */

/* ---------- 공통 토큰 ---------- */
:root {
  --radius-control: 8px;
  --radius-card: 16px;
  --radius-inner: 12px;    /* 카드 안 하위 상자 */
  --radius-pill: 999px;

  /* 한글 UI 라 본문·숫자 모두 Pretendard 로 통일합니다(tnum 으로 숫자 폭 고정).
     코드 조각만 Geist Mono 를 유지합니다. */
  --font-body: 'Pretendard Variable', 'Pretendard', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-display: var(--font-body);
  --font-mono: 'Pretendard Variable', 'Pretendard', -apple-system, 'Apple SD Gothic Neo', sans-serif;
  --font-code: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --sidebar-width: 232px;
  --page-max-width: 1440px;
  --section-gap: 20px;
  --topbar-h: 112px;       /* 앵커 이동 시 스티키 헤더만큼 띄우기 */
}

/* ---------- 라이트 (기본) ---------- */
:root,
:root[data-theme="light"] {
  color-scheme: light;

  --bg-base: #f2f3f6;          /* 캔버스 */
  --bg-surface: #ffffff;       /* 카드 */
  --bg-surface-alt: #f6f7f9;   /* 호버·합계 행 */
  --bg-inset: #f6f7f9;         /* 카드 안 하위 상자 */

  --hairline: #eceef2;
  --border-strong: #dfe2e8;

  --text-primary: #16181d;
  --text-secondary: #4a4f5c;
  --text-muted: #6b7280;       /* 흰 바탕 4.8:1 — 11px 라벨도 통과 */
  --text-on-accent: #ffffff;
  --text-on-signal: #ffffff;

  --signal: #4b3df5;
  --signal-solid: #4b3df5;
  --signal-solid-hover: #3b2ee0;
  --signal-tint: #efedff;

  --positive: #138a4c;
  --positive-tint: #e6f6ed;
  --negative: #d1343b;
  --negative-tint: #fdecec;
  --warning: #a8620b;
  --warning-tint: #fdf3e2;

  --surface-2: #f6f7f9;
  --bg-elevated: #ffffff;
  --border: #dfe2e8;
  --accent: #4b3df5;

  --platform-google: #4f86e8;
  --platform-meta: #8b7cf6;
  --platform-naver: #5bb85d;
  --platform-kakao: #e9a23b;

  --chart-bar: #8b7cf6;
  --chart-line: #5bb85d;
  --chart-alt: #e48fcf;
  --chart-axis: #eceef2;
  --chart-guide: rgba(22, 24, 29, 0.28);
  --chart-dot-stroke: #ffffff;
  --chart-area-opacity: 0.14;

  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-card-hover: 0 4px 16px rgba(16, 24, 40, 0.07);
  --shadow-ring: 0 1px 2px rgba(16, 24, 40, 0.08), 0 0 0 1px rgba(16, 24, 40, 0.04);
  --shadow-popover: 0 12px 32px -8px rgba(16, 24, 40, 0.18), 0 0 0 1px rgba(16, 24, 40, 0.06);
  --shadow-btn-inset: none;
  --focus-ring: rgba(75, 61, 245, 0.22);

  --glass-bg: #ffffff;
  --glass-border: #e4e6eb;
  --glass-highlight: transparent;
  --overlay-bg: rgba(16, 18, 24, 0.40);

  --btn-primary-hover: #3b2ee0;
}

/* ---------- 다크 ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-base: #0d0e11;
  --bg-surface: #17181c;
  --bg-surface-alt: #1f2025;
  --bg-inset: #1d1e23;

  --hairline: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);

  --text-primary: #f2f3f5;
  --text-secondary: #b3b6be;
  --text-muted: #8b8f99;
  --text-on-accent: #ffffff;
  --text-on-signal: #ffffff;

  --signal: #9d94ff;
  --signal-solid: #5b4ef7;
  --signal-solid-hover: #6c60ff;
  --signal-tint: rgba(125, 113, 255, 0.16);

  --positive: #4fd18b;
  --positive-tint: rgba(79, 209, 139, 0.14);
  --negative: #ff7a7a;
  --negative-tint: rgba(255, 122, 122, 0.14);
  --warning: #f2b84b;
  --warning-tint: rgba(242, 184, 75, 0.14);

  --surface-2: #1f2025;
  --bg-elevated: #24252b;
  --border: rgba(255, 255, 255, 0.13);
  --accent: #5b4ef7;

  --platform-google: #6e9ff0;
  --platform-meta: #a99ff8;
  --platform-naver: #6fcf73;
  --platform-kakao: #f2b84b;

  --chart-bar: #8f84f6;
  --chart-line: #6fcf73;
  --chart-alt: #e89ad6;
  --chart-axis: rgba(255, 255, 255, 0.08);
  --chart-guide: rgba(255, 255, 255, 0.35);
  --chart-dot-stroke: #17181c;
  --chart-area-opacity: 0.20;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-card-hover: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-ring: 0 0 0 1px rgba(255, 255, 255, 0.10);
  --shadow-popover: 0 14px 32px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.10);
  --focus-ring: rgba(157, 148, 255, 0.30);

  --glass-bg: #1d1e23;
  --glass-border: rgba(255, 255, 255, 0.14);
  --overlay-bg: rgba(4, 4, 6, 0.62);

  --btn-primary-hover: #6c60ff;
}
/* ==========================================================================
   기본
   ========================================================================== */
body { letter-spacing: -0.01em; font-feature-settings: 'tnum' 1; background: var(--bg-base); }
code, pre, kbd, samp { font-family: var(--font-code); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ==========================================================================
   셸 — 사이드바
   ========================================================================== */
.sidebar {
  background: var(--bg-surface);
  border-right: none;
  box-shadow: 1px 0 0 var(--hairline);
  padding: 18px 12px;
}
.sidebar-brand { margin-bottom: 18px; padding: 0 6px; }
.sidebar-brand .brand-mark { border-radius: 8px; }
.sidebar-brand-text strong { font-size: 15px; font-weight: 800; letter-spacing: -0.02em; }
.sidebar-nav { gap: 2px; }
/* 메뉴 묶음 제목 — 분석 / 운영 / 관리 */
.nav-group {
  margin: 14px 12px 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--text-muted);
}
.nav-group:first-child { margin-top: 0; }
.nav-group[hidden] { display: none; }   /* 안의 링크가 모두 숨겨진 카테고리 제목 — app.js gateNavGroups */
.sidebar-nav a {
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}
.sidebar-nav a:hover { background: var(--bg-surface-alt); color: var(--text-primary); }
.sidebar-nav a.is-active { background: var(--signal-tint); color: var(--signal); font-weight: 700; }
.sidebar.is-collapsed .nav-group { display: none; }
.sidebar-footer { border-top-color: var(--hairline); }
.sidebar-footer button { border-radius: 10px; font-size: 14px; }

/* ==========================================================================
   셸 — 상단바 (한 줄: 경로 · 동작)
   ========================================================================== */
.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--hairline);
  padding: 0 32px;
  min-height: 56px;
  justify-content: center;
  gap: 0;
}
.topbar-row { min-height: 56px; }
.topbar-left { gap: 8px; }
.topbar-crumb { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.topbar-sep { font-size: 13px; color: var(--border-strong); }
.topbar-label { font-size: 13px; font-weight: 700; color: var(--text-primary); margin: 0; }
.icon-btn { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn:hover { background: var(--bg-surface-alt); }
.user-chip { background: var(--bg-surface); border: 1px solid var(--hairline); padding: 3px 12px 3px 3px; }
.user-avatar { width: 26px; height: 26px; background: var(--signal-solid); }
.user-chip span { font-weight: 600; }

/* ==========================================================================
   본문
   ========================================================================== */
.content {
  max-width: var(--page-max-width);
  padding: 24px 32px 96px;
  gap: 16px;
}

/* 페이지 머리 — 제목 옆에 한 줄 설명, 오른쪽 끝에 기간 */
.content-heading {
  display: flex; align-items: baseline; justify-content: flex-start; flex-wrap: wrap;
  gap: 6px 12px;
  padding: 4px 2px 0;
}
.content-heading h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.25; }
.content-heading > p { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.content-heading #periodLabel:not(:empty) {
  margin-left: auto;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  box-shadow: var(--shadow-ring);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}

/* 출처 배너 — 페이지 머리 바로 아래, 얇은 정보 줄 */
.source-banner {
  border: none; border-radius: 12px; padding: 10px 16px;
  background: var(--bg-surface); box-shadow: var(--shadow-card);
}

/* ---------- 조회 조건 카드 (기간 + 거래처·매체·계정·캠페인·광고세트) ---------- */
.filter-card {
  background: var(--bg-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.filter-card__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-card__label { font-size: 12px; font-weight: 700; color: var(--text-secondary); min-width: 40px; }
.filter-period { display: flex; align-items: center; gap: 8px; }
.filter-card .scope-panel {
  background: transparent; box-shadow: none; border-radius: 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--hairline);
}
.scope-field { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

/* 알약 세그먼트 — 선택은 인디고 채움 */
.toggle-group {
  background: var(--bg-surface-alt);
  border: none;
  border-radius: var(--radius-pill);
  padding: 3px; gap: 2px;
}
.toggle-btn {
  height: 30px; padding: 0 14px;
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
}
.toggle-btn:hover { color: var(--text-primary); }
.toggle-btn.is-active,
.toggle-btn.is-active:hover {
  background: var(--signal-solid); color: var(--text-on-signal); font-weight: 700;
  box-shadow: 0 1px 2px rgba(75, 61, 245, 0.30);
}

/* ---------- 섹션 바로가기 — 밑줄 탭 ---------- */
.section-tabs {
  position: sticky; top: 56px; z-index: 15;
  display: flex; gap: 24px;
  margin: 4px -32px 0; padding: 0 34px;
  background: var(--bg-base);
  box-shadow: inset 0 -1px 0 var(--hairline);
  overflow-x: auto; scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs a {
  flex: none; display: inline-flex; align-items: center;
  height: 44px;
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  box-shadow: inset 0 -2px 0 transparent;
  transition: color .16s ease, box-shadow .16s ease;
}
.section-tabs a:hover { color: var(--text-primary); }
.section-tabs a.is-active { color: var(--text-primary); font-weight: 800; box-shadow: inset 0 -2px 0 var(--signal); }

/* ---------- 섹션 머리 ---------- */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 20px 2px 0;
  scroll-margin-top: 120px;
}
.section-head__text { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.section-head__num {
  align-self: center;
  display: inline-flex; align-items: center; justify-content: center;
  height: 22px; padding: 0 8px; border-radius: var(--radius-pill);
  background: var(--signal-tint); color: var(--signal);
  font-size: 11px; font-weight: 800; letter-spacing: 0.04em;
}
.section-head__title { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.section-head__desc { font-size: 13px; color: var(--text-muted); }

/* 표시 지표 — 요약 섹션 머리 오른쪽 */
.metric-picker-bar__inner { display: flex; align-items: center; gap: 10px; }
.metric-picker-bar__label { font-size: 12px; font-weight: 600; color: var(--text-muted); }

/* ==========================================================================
   카드(패널)
   ========================================================================== */
.panel {
  --panel-pad: 24px;
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.panel-head {
  align-items: flex-start;
  margin: calc(var(--panel-pad) * -1) calc(var(--panel-pad) * -1) 20px;
  padding: 20px var(--panel-pad) 16px;
  border-bottom: 1px solid var(--hairline);
}
.panel-head h2 { font-size: 16px; font-weight: 800; letter-spacing: -0.025em; }
.panel-head > span { font-size: 12px; color: var(--text-muted); align-self: center; }
.panel-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.panel-title__row { display: flex; align-items: center; gap: 6px; }
.panel-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.chart-metric-controls, .campaign-toolbar { align-self: center; }
.scope-panel { --panel-pad: 20px; }

/* ? 설명 말풍선 */
.help-tip {
  position: relative;
  flex: none;
  width: 18px; height: 18px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 11px; font-weight: 700; line-height: 1;
}
.help-tip::before { content: ''; position: absolute; inset: -10px; }  /* 누르기 쉬운 영역 */
.help-tip:hover, .help-tip.is-open { color: var(--signal); border-color: var(--signal); }
.help-tip::after {
  content: attr(data-help);
  position: absolute; top: calc(100% + 8px); left: -8px; z-index: 40;
  width: 280px; padding: 10px 12px;
  border-radius: 10px;
  background: var(--text-primary); color: var(--bg-surface);
  font-size: 12px; font-weight: 500; line-height: 1.55; letter-spacing: -0.01em; text-align: left;
  white-space: normal;
  box-shadow: var(--shadow-popover);
  opacity: 0; visibility: hidden; transform: translateY(-2px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
  pointer-events: none;
}
.help-tip:hover::after, .help-tip:focus-visible::after, .help-tip.is-open::after {
  opacity: 1; visibility: visible; transform: none;
}

/* ---------- KPI — 따로 떨어진 카드 + 한 줄 풀이 ---------- */
.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  background: transparent; border: none; border-radius: 0; box-shadow: none; overflow: visible;
}
.kpi-card,
.kpi-card:first-child {
  display: flex; flex-direction: column; align-items: flex-start;
  border-left: none;
  background: var(--bg-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  transition: box-shadow .18s ease;
}
.kpi-card:hover { background: var(--bg-surface); box-shadow: var(--shadow-card-hover); }
.kpi-card__label { font-size: 13px; font-weight: 700; color: var(--text-secondary); cursor: help; }
.kpi-card__label::before { width: 8px; height: 8px; border-radius: 50%; }
.kpi-card__value {
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: clamp(18px, 1.45vw, 26px); font-weight: 800; letter-spacing: -0.035em;
  white-space: nowrap;
}
.kpi-card__hint { margin-top: 4px; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.kpi-card__delta { margin-top: 12px; padding: 3px 8px; }

/* ---------- 매체 구성 — 매체마다 한 장의 알약 카드 ---------- */
.panel--mix .platform-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px;
}
.panel--mix .platform-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 12px;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--bg-inset);
}
.panel--mix .platform-bar-track { grid-column: 1 / -1; order: 3; height: 8px; background: var(--bg-surface); }
.panel--mix .platform-roas { grid-column: 1 / -1; order: 4; text-align: left; font-size: 12px; }
.panel--mix .platform-spend { font-size: 18px; letter-spacing: -0.02em; }
.panel--mix .platform-notice { margin-top: 14px; font-size: 12px; }

/* ---------- 카드 안 하위 상자: 선 대신 면 ---------- */
.best-block, .winner-card, .report-item, .report-insight, .report-conf, .creative-card,
.diff-row, .credential-guide, .credential-hint, .utm-option-manager, .utm-preview, .utm-result,
.cb-flex-group, .cb-ad-mock, .split-table-block {
  border: none;
  border-radius: var(--radius-inner);
  background: var(--bg-inset);
}
.combo-panel { border: none; border-radius: var(--radius-inner); background: transparent; box-shadow: inset 0 0 0 1px var(--hairline); padding: 16px 20px 18px; }
.combo-panel__head h3 { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.best-block { padding: 16px; }
.report-frame { border: none; border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.empty-state { border: none; border-radius: var(--radius-inner); background: var(--bg-inset); color: var(--text-muted); padding: 32px 24px; }

/* ==========================================================================
   표
   ========================================================================== */
.table-scroll { border: none; border-radius: var(--radius-inner); box-shadow: inset 0 0 0 1px var(--hairline); }
.data-table thead th {
  background: var(--bg-inset);
  color: var(--text-muted);
  font-size: 12px; font-weight: 700;
  border-bottom: 1px solid var(--hairline);
}
.data-table thead th[data-term="1"] { cursor: help; }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--signal-tint) 45%, transparent); }
.data-table tr.total-row td { background: var(--bg-surface-alt); font-weight: 800; }
.sig-legend { margin-top: 12px; font-size: 12px; color: var(--text-muted); }

/* ==========================================================================
   컨트롤
   ========================================================================== */
select, .metric-select, .scope-popover-btn, .listbox-search,
.client-create input[type="text"], .picker-toolbar input[type="search"] {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  transition: border-color .15s ease, box-shadow .15s ease;
}
select:hover, .metric-select:hover, .scope-popover-btn:hover {
  border-color: color-mix(in srgb, var(--signal) 45%, var(--border-strong)); background-color: var(--bg-surface);
}
select:focus, .metric-select:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--focus-ring); }
.field label { font-size: 12px; font-weight: 600; }
.field input, .field textarea, .field select { border: 1px solid var(--border-strong); background: var(--bg-surface); }
.field input:focus, .field textarea:focus { border-color: var(--signal); box-shadow: 0 0 0 3px var(--focus-ring); }

.btn-primary {
  background: var(--signal-solid); color: var(--text-on-signal);
  border-radius: 10px; font-weight: 700; padding: 0 16px;
}
.btn-primary:hover { background: var(--signal-solid-hover); }
.btn-primary:disabled:hover { background: var(--signal-solid); }
.btn-ghost {
  height: 34px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface); color: var(--text-secondary); font-weight: 600;
}
.btn-ghost:hover { background: var(--bg-surface-alt); color: var(--text-primary); }
.btn-ghost.is-active { background: var(--signal-tint); color: var(--signal); border-color: transparent; }
.btn-sm { height: 30px; border-radius: 8px; }

.chip { border: none; background: var(--bg-inset); border-radius: var(--radius-pill); }
.status-badge { font-weight: 700; }
.best-tabs { border: none; background: var(--bg-surface-alt); }

.calendar-popover, .listbox-popover, .member-brand-menu { border: none; border-radius: 14px; box-shadow: var(--shadow-popover); }
.modal-card { border: none; border-radius: 20px; }
.chart-tooltip { border: none; border-radius: 10px; box-shadow: var(--shadow-popover); }
.cal-day { border-radius: 8px; }

.platform-bar-track { height: 8px; border-radius: 999px; background: var(--bg-surface-alt); }
.platform-bar-fill { border-radius: 999px; }
.platform-spend { font-weight: 800; }
.heatmap-cell { border-radius: 4px; }

/* ==========================================================================
   페이지별
   ========================================================================== */
.integration-card__head h2 { font-size: 16px; font-weight: 800; }

.objective-card { border-radius: 12px; }

/* 로그인 · 회원가입 — 캔버스 위 흰 카드. 로그인은 왼쪽 7 소개 / 오른쪽 3 카드 */
.login-card { border: none; box-shadow: var(--shadow-card); }
.login-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.login-card .btn-primary, .login-card .btn-ghost.login-signup-btn, .btn-social { height: 44px; border-radius: 10px; font-size: 14px; }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pw-toggle-btn { font-size: 12px; text-decoration: none; }
.login-forgot { display: block; margin: 18px auto 0; font-size: 13px; text-decoration: none; }
.btn-social { font-weight: 600; }
.btn-social + .btn-social { margin-top: 8px; }
.btn-social--naver { background: #03c75a; border-color: #03c75a; color: #ffffff; }
.btn-social--naver:hover { background: #02b351; }
/* 재설정 폼을 연 동안에는 로그인 쪽 버튼을 감춥니다 — 폼이 소셜 버튼 아래에 붙어 보이지 않게 */
#loginForm[hidden] ~ :not(#resetForm) { display: none !important; }

.login-shell { background: var(--bg-base); }
.login-hero { flex: 7 1 0; background: transparent; border-right: none; padding: 64px clamp(40px, 6vw, 112px); }
.login-hero-inner { max-width: 560px; }
.login-hero-eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.login-hero-eyebrow img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.login-hero-title { font-size: clamp(28px, 2.6vw, 40px); font-weight: 800; letter-spacing: -0.04em; line-height: 1.3; color: var(--text-primary); }
.login-hero-desc { margin-top: 14px; font-size: 15px; line-height: 1.6; color: var(--text-muted); }
.login-hero-channels { display: flex; flex-wrap: wrap; gap: 8px; margin: 28px 0 0; padding: 0; list-style: none; }
.login-hero-channels li {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 14px; border-radius: var(--radius-pill);
  background: var(--bg-surface); box-shadow: var(--shadow-card);
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
}
.login-hero-channels i { width: 8px; height: 8px; border-radius: 50%; }
.login-hero-channels .is-meta i { background: var(--platform-meta); }
.login-hero-channels .is-google i { background: var(--platform-google); }
.login-hero-channels .is-naver i { background: var(--platform-naver); }
.login-panel { flex: 3 1 0; min-width: 440px; background: transparent; padding: 32px 40px; }
@media (max-width: 1024px) {
  .login-hero { display: none; }
  .login-panel { min-width: 0; padding: 24px 16px; }
}

.settings-toggle-row { padding: 14px 4px; }
#settingsForm { display: flex; flex-direction: column; gap: 16px; }
.utm-campaign-rule { border-radius: var(--radius-inner); border-color: var(--border-strong); }

/* ==========================================================================
   반응형 · 인쇄
   ========================================================================== */
@media (max-width: 900px) {
  .content { padding: 20px 16px 72px; }
  .topbar { padding: 0 16px; }
  .section-tabs { margin: 4px -16px 0; padding: 0 16px; gap: 18px; }
  .panel { --panel-pad: 18px; }
  .help-tip::after { width: 220px; }
}
/* 태블릿(721~1024px) — 64px 아이콘 레일. 글자는 링크마다 있는 title 로 보입니다. */
@media (min-width: 721px) and (max-width: 1024px) {
  .sidebar, .sidebar.is-collapsed { width: 64px; padding: 16px 8px; }
  .sidebar-brand { flex-direction: column; justify-content: center; padding: 0; gap: 8px; margin-bottom: 18px; }
  .sidebar-brand-text, .sidebar-collapse-btn, .nav-group, .sidebar .nav-label { display: none; }
  .sidebar-nav { gap: 4px; }
  .sidebar-nav a, .sidebar-footer button { justify-content: center; padding: 10px; }
}

/* 모바일(720px 이하) — 아래 탭 바(아이콘 위·글자 아래). 메뉴가 넘치면 옆으로 밀어 봅니다.
   예전엔 사이드바가 위쪽 가로줄이 되면서 묶음 제목(분석·운영·관리)이 세로로 깨졌습니다. */
@media (max-width: 720px) {
  .sidebar, .sidebar.is-collapsed {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 50;
    width: 100%; height: auto;
    flex-direction: row; align-items: stretch; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg-surface); border: none; box-shadow: 0 -1px 0 var(--hairline);
  }
  .sidebar-brand, .nav-group { display: none; }
  /* 가로 스크롤 상자는 자동 최소 높이가 0 이라 글자 줄이 잘립니다 — 높이를 못박습니다 */
  .sidebar-nav { flex-direction: row; flex: 1 1 auto; min-width: 0; height: 54px; align-items: stretch; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; gap: 0; }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .sidebar-nav a, .sidebar-footer button {
    flex: 1 0 64px; max-width: 88px;
    flex-direction: column; justify-content: center; gap: 4px;
    padding: 6px 4px; border-radius: 10px;
    font-size: 11px; font-weight: 600;
  }
  .sidebar .sidebar-nav .nav-label { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-nav a.is-active, .sidebar-nav a.is-active:hover { background: transparent; color: var(--signal); }
  .sidebar-footer { margin: 0; padding: 0; border: none; display: flex; }
  .sidebar-footer button { flex: 0 0 48px; }
  .sidebar .sidebar-footer button .nav-label { display: none; }
  .content { padding-bottom: 104px; }
  .topbar-crumb, .topbar-sep { display: none; }
  .section-tabs { top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .kpi-card, .section-tabs a, .help-tip::after { transition: none; }
}
@media print {
  .section-tabs, .help-tip, .kpi-card__hint { display: none !important; }
}

/* ==========================================================================
   옵션 박스 — 디자인 시스템 OptionBox 와 같은 모양(전 페이지 공용)
   라벨은 위에 작게, 칸은 40px 흰 상자에 굵은 글자, 열리면 인디고 테두리 + 포커스 링.
   목록은 그림자 상자 안에 체크 상자 줄, 고른 줄은 인디고 옅은 바탕. 동작 · id 는 그대로입니다.
   ========================================================================== */
.scope-field { gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--text-muted); }
.scope-field--check { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.scope-field select, .scope-popover-btn {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-control);
  background-color: var(--bg-surface);
  font: inherit; font-size: 13px; font-weight: 700; color: var(--text-primary);
}
.scope-field select {
  appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%238a8f98' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
.scope-popover-btn { min-width: 140px; max-width: 240px; }
.scope-popover-btn:hover, .scope-field select:hover { background-color: var(--bg-surface); border-color: color-mix(in srgb, var(--signal) 45%, var(--border-strong)); }
.scope-popover-btn[aria-expanded="true"], .scope-popover-btn:focus-visible, .scope-field select:focus-visible {
  outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--focus-ring);
}
.listbox-popover, .calendar-popover {
  border: none; border-radius: var(--radius-inner);
  background: var(--bg-elevated); box-shadow: var(--shadow-popover);
}
.listbox-row {
  gap: 10px; min-height: 36px; padding: 8px 10px;
  border-radius: var(--radius-control);
  font-size: 13px; font-weight: 600; color: var(--text-primary); cursor: pointer;
}
.listbox-row:hover { background: var(--bg-surface-alt); color: var(--text-primary); }
.listbox-row:has(input:checked) { background: var(--signal-tint); }
.listbox-row input[type="checkbox"], .listbox-row input[type="radio"] {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 18px; height: 18px; margin: 0;
  border: 1.5px solid var(--border-strong); border-radius: 5px;
  background: var(--bg-surface) center / 12px no-repeat; cursor: pointer;
}
.listbox-row input:checked {
  border-color: var(--signal-solid); background-color: var(--signal-solid);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.listbox-row input:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.listbox-row--empty { cursor: default; font-weight: 500; color: var(--text-muted); }
.listbox-row--empty:hover { background: transparent; }
.listbox-row__sub { font-weight: 600; }
.listbox-toolbar { gap: 8px; padding: 6px 4px 10px; margin-bottom: 4px; background: var(--bg-elevated); }
.listbox-search { height: 36px; padding: 0 12px; font-size: 13px; background: var(--bg-surface); }
.listbox-search:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--focus-ring); }
.listbox-clear { height: 36px; padding: 0 10px; border: 0; font-size: 12px; font-weight: 700; color: var(--signal); }
.listbox-clear:hover { color: var(--signal); background: var(--signal-tint); }
.calendar-nav { font-size: 13px; font-weight: 800; }

/* ==========================================================================
   자동 보고서 — 전체 → 매체별 섹션. 매체마다 제목 · 숫자 · 분석 · AI 글을 한 묶음으로 보여 줍니다.
   ========================================================================== */
.report-media { margin: 28px 0 0; padding-top: 4px; scroll-margin-top: 72px; }
.report-media__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 12px; padding: 0 0 10px; border-bottom: 2px solid var(--signal); }
.report-media__head h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.report-media__head span { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.report-media__head--all { margin-top: 4px; border-bottom-color: var(--border-strong); }
.report-media--all .report-media__head { border-bottom-color: var(--border-strong); }
.report-media-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
.report-media-nav__chip { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: var(--radius-pill); background: var(--bg-surface); box-shadow: var(--shadow-card); font-size: 13px; font-weight: 700; color: var(--text-secondary); text-decoration: none; }
.report-media-nav__chip:hover { color: var(--signal); }
.report-media-nav__chip:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.report-aibar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-inner); background: var(--bg-inset); font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.report-aibar__msg { display: inline-flex; align-items: center; gap: 8px; }
/* 이 매체 숫자 한눈에 */
.rm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin: 0 0 14px; }
.rm-kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 12px; border-radius: var(--radius-inner); background: var(--bg-surface); box-shadow: var(--shadow-card); }
.rm-kpi__l { font-size: 11.5px; font-weight: 700; color: var(--text-muted); }
.rm-kpi b { font-size: 15px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text-primary); overflow-wrap: anywhere; }
.rm-delta { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.rm-delta.is-good { color: var(--positive); }
.rm-delta.is-bad { color: var(--negative); }

/* ==========================================================================
   글자가 도형 속에서 깨지지 않게 (전 페이지 · 특히 핸드폰)
   1) 한글은 기본값이면 글자 단위로 줄이 바뀌어 단어가 중간에서 꺾입니다("통합관/리자"). 공백에서만 줄을 바꾸고(keep-all),
      한 단어가 칸보다 길 때(이름 · 주소 · 긴 소재명)만 어디서든 꺾습니다(anywhere).
   2) 짧은 이름표 도형(버튼 · 칩 · 배지 · 탭 · 상태)은 줄을 바꾸지 않습니다. 자리가 모자라면 글자가 아니라 도형 줄이 아래로 내려가야 하므로,
      도형을 담는 줄에는 flex-wrap 을 줍니다.
   ========================================================================== */
html, body { word-break: keep-all; overflow-wrap: anywhere; }
.btn-primary, .btn-ghost, .btn-sm, .toggle-btn, .chip, .status-badge, .rank-badge, .platform-chip, .comment-badge, .source-banner__tag,
.cl-chip, .cl-rank, .cl-save, .cs-chip, .cx-badge, .cx-state, .cxb-badge, .cxb-chip, .cxb-fchip, .cb-signal__badge, .cb-asset-card__status,
.utm-option-chip, .bs-chip, .bs-badge, .bs-tag, .bs-mchip, .bs-warn__badge, .report-media-nav__chip, .rm-delta, .user-chip, .sync-stamp,
.cxd-mode, .cxd-job__state, .cxd-obox__field > em, .legend-line-combo, .section-tabs a, .metric-tab { white-space: nowrap; }
.user-chip { max-width: 100%; }
.user-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bs-chips, .cs-chips, .cxb-fchips, .cb-flex-group__chips, .report-media-nav, .cl-card__row { flex-wrap: wrap; }

/* 짝으로 놓인 칸(캠페인 · 광고세트)의 목록 상자가 오른쪽으로 쏠리지 않게 — .listbox-wrap 의 margin-left:auto 는 지표 선택 드롭다운용입니다 */
.scope-field--popover .scope-popover-wrap { margin-left: 0; width: 100%; }

@media (max-width: 720px) {
  /* 윗줄: 글자가 꺾이지 않게 줄 자체가 아래로 내려가고, 사용자 칩은 이름이 길면 줄임표 */
  .topbar { padding: 10px 16px; }
  .topbar-row { flex-wrap: wrap; gap: 8px 12px; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; gap: 8px 10px; min-width: 0; margin-left: auto; }
  .user-chip span { max-width: 7.5em; }
  /* 아래 탭 바: 이름을 줄임표로 자르지 않고 전부 보이게 두고, 넘치면 옆으로 밉니다 */
  .sidebar-nav a, .sidebar-footer button { flex: 0 0 auto; min-width: 64px; max-width: none; padding: 6px 10px; white-space: nowrap; }
  .sidebar .sidebar-nav .nav-label { max-width: none; overflow: visible; text-overflow: clip; }
  /* 기간 버튼 다섯 개가 카드 폭을 넘어 "직접 지정"이 카드 밖으로 잘리던 것 — 칸을 좁히고, 그래도 넘치면(320px 폰) 옆으로 밉니다 */
  .filter-period { min-width: 0; max-width: 100%; }
  .filter-period .toggle-btn { padding: 0 10px; }
  /* 열 때 보이는 곳까지 굴리는 달력 · 상자가 아래 탭 바 뒤에서 멈추지 않게(적용 · 저장 버튼이 가려졌습니다) */
  .calendar-popover, .bs-pop, .cxd-pop { scroll-margin-bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* ==========================================================================
   수집 중 팝업 — 화면 전체를 덮고(.modal-overlay), 끝날 때까지 다른 작업을 막습니다 (app.js busyOverlay)
   ========================================================================== */
.busy-overlay { z-index: 200; cursor: progress; }
.busy-card { align-items: center; max-width: 380px; gap: 6px; padding: 30px 28px 24px; text-align: center; }
.busy-card h2 { font-size: 17px; font-weight: 700; }
.busy-spin { width: 30px; height: 30px; margin-bottom: 10px; border: 3px solid var(--hairline); border-top-color: var(--signal); border-radius: 50%; animation: busy-spin .9s linear infinite; }
.busy-line { margin: 4px 0 0; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.busy-note { margin: 0; min-height: 1.4em; font-size: 12.5px; font-weight: 600; color: var(--warning, var(--text-muted)); }
.busy-hint { margin: 6px 0 0; font-size: 12px; font-weight: 500; line-height: 1.5; color: var(--text-muted); }
.busy-leave { margin-top: 12px; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .busy-spin { animation-duration: 3s; } }
