:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --surface-3: #f2f3f5;
  --ink: #1a1d21;
  --ink-2: #3a3f47;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --line: #e7e9ed;
  --line-strong: #d6d9df;
  --accent: #1c7a66;
  --accent-hover: #15644f;
  --accent-tint: #eaf4f0;
  --warn: #a15c00;
  --warn-bg: #fff8e8;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.05);
  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1180px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", Arial, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.brand-logo {
  display: block;
  width: 112px;
  height: 45px;
  object-fit: contain;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.status-pill--read::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.assistant-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 5px 14px rgba(28, 122, 102, 0.2);
}

.assistant-toggle:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.assistant-toggle svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.assistant-live-dot,
.assistant-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #36b399;
  box-shadow: 0 0 0 3px rgba(54, 179, 153, 0.18);
}

.assistant-scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(17, 24, 39, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.assistant-scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.assistant-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 31;
  display: flex;
  flex-direction: column;
  width: 460px;
  max-width: calc(100vw - 28px);
  height: 100vh;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: -18px 0 48px rgba(15, 23, 42, 0.2);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.assistant-panel.open {
  transform: translateX(0);
}

.assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.assistant-title {
  display: grid;
  gap: 7px;
}

.assistant-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.assistant-subtitle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.assistant-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
}

.assistant-body {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  background: linear-gradient(180deg, #fbfcfd 0%, #f4f7fa 100%);
}

.assistant-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.assistant-message {
  display: flex;
  margin-bottom: 12px;
}

.assistant-message.user {
  justify-content: flex-end;
}

.assistant-bubble {
  max-width: 86%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  line-height: 1.58;
  white-space: pre-line;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
}

.assistant-message.user .assistant-bubble {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.assistant-message.typing .assistant-bubble {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.assistant-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #7b8798;
  animation: assistantPulse 1s infinite ease-in-out;
}

.assistant-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.assistant-typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes assistantPulse {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.assistant-composer {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 8px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.assistant-composer input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.assistant-composer input:focus-visible,
.assistant-send:focus-visible,
.assistant-toggle:focus-visible,
.assistant-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.assistant-send {
  min-width: 70px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.assistant-send:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px 26px 32px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin: 0 0 5px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  max-width: 660px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 12.5px;
}

button, select {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

button {
  padding: 0 12px;
  font-weight: 600;
}

button:hover {
  background: var(--surface-3);
}

select {
  min-width: 150px;
  padding: 0 10px;
}

.warning-box {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #f0d28a;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn);
  line-height: 1.5;
}

.panel {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 8px;
  min-height: 52px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--accent-hover);
  background: var(--accent);
  color: #ffffff;
}

.panel-head > span {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: #ffffff;
}

.panel-head select {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.panel-head select option {
  color: var(--ink-2);
  background: var(--surface);
}

.panel-head-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Left-side header group: title + 계정 드롭다운. Lives in the panel-head
   1fr column, sitting against the title so it visually belongs to "what
   we're looking at" rather than the right-side date filter. */
/* 계정 드롭다운 공용 스타일 (panel-head 외부에서 사용). 긴 source label
   ('Meta Collaborative Ads_29cm_Piscess (1319641269343127)' 등)이 헤더를
   부풀리지 않도록 너비 캡. 펼치면 전체 라벨 노출됨. */
.account-select {
  height: 24px;
  padding: 0 6px;
  font-size: 11.5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  max-width: 260px;
  text-overflow: ellipsis;
}

/* 박스 4 (chart-title 안에 위치): 미니 날짜 필터 옆에 자연스럽게 정렬. */
.chart-title .account-select.account-select--in-chart {
  margin-left: auto;
  margin-right: 6px;
}

/* 박스 5 / 6 (테이블 상단 toolbar): 테이블 좌측 정렬에 맞춰 왼쪽 정렬. */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 8px 0;
}

/* Summary rows (sum/average): tinted background + bold. */
.data-table tr.sum-row td {
  background: var(--accent-tint);
  font-weight: 700;
  color: var(--ink);
  border-top: 1px solid var(--accent);
}

/* Header link button (e.g. CRM '캠페인별 세부 설정'), white on green header. */
.btn-head-link {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.btn-head-link:hover {
  background: rgba(255, 255, 255, 0.26);
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px 0;
}

.section-actions .btn-head-link {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--accent);
}

.section-actions .btn-head-link:hover {
  background: var(--accent-tint);
}

.inventory-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 0 10px 0;
}

.inventory-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.inventory-search select {
  min-width: 136px;
}

.inventory-search input[type="search"] {
  width: min(360px, 42vw);
  height: 34px;
  min-width: 180px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.inventory-search input[type="search"]:focus-visible,
.inventory-search select:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid rgba(28, 122, 102, 0.35);
  outline-offset: 2px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 720px) {
  .inventory-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .inventory-search {
    width: 100%;
  }

  .inventory-search input[type="search"] {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .inventory-toolbar .section-actions {
    justify-content: flex-start;
  }
}

.chart-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-filter select,
.chart-filter input[type="date"] {
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font: inherit;
}

.chart-filter input[type="date"] {
  color-scheme: dark; /* makes the native date picker icon legible on green */
}

.chart-filter select option {
  color: var(--ink-2);
  background: var(--surface);
}

.chart-filter .date-sep {
  color: #ffffff;
  opacity: 0.85;
}

/* Per-chart mini filter sits on the white chart-title bar (not the green
 * panel-head), so it uses light-background styling. */
.chart-title {
  gap: 10px;
}

.chart-filter--mini {
  flex: 0 0 auto;
}

.chart-filter--mini select,
.chart-filter--mini input[type="date"] {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11.5px;
}

.chart-filter--mini input[type="date"] {
  color-scheme: light;
}

.chart-filter--mini select option {
  color: var(--ink-2);
  background: var(--surface);
}

.chart-filter--mini .date-sep {
  color: var(--muted);
  opacity: 1;
}

.panel-body {
  padding: 14px;
}

.chart-stack {
  display: grid;
  gap: 12px;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
}

.chart-source {
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
}

.chart-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 6px;
  padding: 10px 12px 12px;
}

.chart-canvas {
  position: relative;
  height: 320px;
  min-width: 0;
}

.chart-breakdown-scroll {
  max-width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  isolation: isolate;
}

.chart-breakdown-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.chart-breakdown-table thead tr,
.chart-breakdown-table tbody tr + tr {
  border-top: 1px solid var(--line);
}

.chart-breakdown-table th,
.chart-breakdown-table td {
  padding: 8px 6px;
  white-space: nowrap;
  min-width: 86px;
}

.chart-breakdown-table th[scope="row"],
.chart-breakdown-table thead th:first-child {
  position: sticky;
  left: 0;
  min-width: 152px;
  width: 152px;
  background: var(--surface);
  background-clip: padding-box;
}

.chart-breakdown-table th {
  color: var(--muted);
  font-weight: 600;
  text-align: right;
}

.chart-breakdown-table th[scope="row"] {
  z-index: 3;
  text-align: left;
  box-shadow: 8px 0 12px rgba(255, 255, 255, 0.94), 1px 0 0 var(--line);
}

.chart-breakdown-table thead th:first-child {
  z-index: 4;
  box-shadow: 8px 0 12px rgba(255, 255, 255, 0.94), 1px 0 0 var(--line);
}

.chart-breakdown-table td {
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart-guide {
  position: absolute;
  top: 8px;
  bottom: 28px;
  width: 1px;
  background: var(--line-strong);
  pointer-events: none;
  z-index: 3;
}

.chart-tooltip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  min-width: 150px;
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-md);
  font-size: 11.5px;
}

.chart-tooltip .ct-label {
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 700;
}

.chart-tooltip .ct-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}

.chart-tooltip .ct-row:last-child {
  margin-bottom: 0;
}

.chart-tooltip .ct-row i {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.chart-tooltip .ct-name {
  margin-right: auto;
  color: var(--muted);
  word-break: keep-all;
}

.chart-tooltip .ct-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.chart-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis-label, .tick {
  fill: var(--muted);
  font-size: 10px;
}

.grid-line {
  stroke: #e8eaee;
  stroke-width: 1;
}

.line-series {
  fill: none;
  stroke-width: 2.2;
}

.bar {
  shape-rendering: crispEdges;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 4px 2px 6px;
  color: var(--ink-2);
  font-size: 10.5px;
  border-bottom: 1px solid var(--line);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.legend-item > span {
  word-break: keep-all;
}

.legend i {
  flex: 0 0 auto;
}

.swatch-line {
  width: 14px;
  height: 2px;
  border-radius: 2px;
}

.swatch-bar {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.axis-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.platform-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.platform-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.platform-head h3 {
  margin: 0;
  font-size: 13px;
}

.sim-label {
  display: inline-flex;
  align-items: center;
  height: 18px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: middle;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.data-table td {
  color: var(--ink-2);
  font-size: 12px;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.numeric {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

/* Background + text color come from inline style="..." computed from the
 * product's hue (golden-angle stepping). Same product → same color across
 * platforms / repurchase columns / re-renders. Unlimited distinct hues. */
.product-tag {
  font-weight: 600;
  box-shadow: inset 0 0 0 1px #ffffff;
}

.section-expand {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.expand-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.18s ease, border-color 0.12s ease;
}

.expand-toggle:hover {
  background: var(--accent-tint);
  border-color: rgba(28, 122, 102, 0.3);
}

.expand-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}

.expand-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Cohort table: center every header and cell (overrides .numeric right-align). */
#cohort-table .data-table th,
#cohort-table .data-table td {
  text-align: center;
}

#cohort-table .data-table td.numeric {
  text-align: center !important;
}

/* Real horizontal gap between cohort columns so adjacent data bars are clearly
 * separated (a white border was invisible against the white cell background). */
#cohort-table .data-table {
  border-collapse: separate;
  border-spacing: 6px 0;
  width: 100%;
}

/* 유입 cohort 컬럼은 텍스트 길이에 딱 맞게(줄바꿈 없이) 축소하고, 남는 폭은
 * 나머지 지표 컬럼들이 균등하게 나눠 갖도록 한다. */
#cohort-table .data-table th:first-child,
#cohort-table .data-table td:first-child {
  width: 1%;
  white-space: nowrap;
}

#cohort-table .data-table th,
#cohort-table .data-table td {
  border-bottom: 0;
  box-shadow: inset 0 -1px 0 var(--line);
}

.ig-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.ig-link:hover {
  text-decoration: underline;
}

.ig-caption {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.period-note {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

/* ===== Next Best Actions ===== */

.panel-head--plain {
  background: var(--surface);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  grid-template-columns: 1fr auto;
  padding-left: 14px;
}

.panel-head--plain h2 {
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.badge-dev {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0;
}

.nba-list {
  margin: 0;
  padding-left: 16px;
  list-style: disc;
  color: var(--ink-2);
  line-height: 1.6;
}

.nba-list li {
  margin-bottom: 8px;
  font-size: 13px;
}

.nba-list li::marker {
  color: var(--accent);
}

.nba-list li:last-child {
  margin-bottom: 0;
}

/* ===== Daily KPIs ===== */

.period-tabs {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.period-tab {
  height: 26px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.period-tab:hover {
  background: rgba(255, 255, 255, 0.18);
}

.period-tab.active {
  background: #ffffff;
  color: var(--accent);
}

/* Toolbar above the KPI cards: comparison dropdown on the left, date range
 * (with weekday suffix) pushed to the right. */
.kpi-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

#kpi-comparison {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
}

.kpi-range {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.kpi-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.kpi-name {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.kpi-change {
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kpi-change--up   { color: #15644f; }
.kpi-change--down { color: #b3324c; }
.kpi-change--neutral { color: var(--muted); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.table-wrap--wide {
  max-width: 100%;
}

.table-unit-note {
  margin: 0 0 6px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.product-channel-mix-table {
  min-width: 1420px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.product-click-cart-churn-table th:first-child,
.product-click-cart-churn-table td:first-child {
  min-width: 260px;
}

.product-click-cart-churn-table th:nth-child(2),
.product-click-cart-churn-table td:nth-child(2) {
  min-width: 120px;
}

.table-footnote {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.product-channel-mix-table col.pcm-product-col {
  width: 240px;
}

.product-channel-mix-table col.pcm-metric-col {
  width: 78px;
}

.product-channel-mix-table col.pcm-quantity-col {
  width: 78px;
}

.product-channel-mix-table th,
.product-channel-mix-table td {
  overflow-wrap: anywhere;
}

.product-channel-mix-table .pcm-metric-cell,
.product-channel-mix-table .pcm-quantity-cell {
  white-space: nowrap;
}

.product-channel-mix-table th:first-child,
.product-channel-mix-table td:first-child {
  min-width: 0;
}

.product-channel-mix-table .pcm-channel-head {
  text-align: center !important;
  background: var(--surface-3);
  color: var(--ink-2);
}

.product-channel-mix-table .pcm-channel-start {
  border-left: 8px solid var(--surface);
  box-shadow: inset 1px 0 0 var(--line-strong);
}

.product-channel-mix-table tbody .pcm-channel-start {
  background: linear-gradient(90deg, var(--surface-2), var(--surface) 72%);
}

.product-channel-mix-table .pcm-delta-up {
  color: #b3324c;
  font-weight: 700;
}

.product-channel-mix-table .pcm-delta-down {
  color: #2563b8;
  font-weight: 700;
}

.influencer-effect-wrap {
  overflow-x: auto;
  position: relative;
}

.influencer-effect-table {
  min-width: 3710px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.influencer-effect-table th,
.influencer-effect-table td {
  white-space: nowrap;
}

.influencer-effect-table .seeding-sticky {
  position: sticky;
  background: var(--surface);
  z-index: 2;
  box-shadow: 1px 0 0 var(--line);
}

.influencer-effect-table thead .seeding-sticky {
  background: var(--surface-3);
  z-index: 5;
}

.influencer-effect-table .seeding-sticky-1 { left: 0; width: 150px; min-width: 150px; max-width: 150px; }
.influencer-effect-table .seeding-sticky-2 { left: 150px; width: 90px; min-width: 90px; max-width: 90px; }
.influencer-effect-table .seeding-sticky-3 { left: 240px; width: 280px; min-width: 280px; max-width: 280px; }
.influencer-effect-table .seeding-sticky-4 { left: 520px; width: 120px; min-width: 120px; max-width: 120px; }
.influencer-effect-table .seeding-sticky-5 { left: 640px; width: 72px; min-width: 72px; max-width: 72px; }

.influencer-effect-table .seeding-sticky-3 {
  overflow: hidden;
  text-overflow: ellipsis;
}

.influencer-effect-table .seeding-metric,
.influencer-effect-table .seeding-metric-head {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
  text-align: center;
}

.influencer-effect-table .seeding-group-head {
  text-align: center;
  border-left: 6px solid var(--surface);
}

.influencer-effect-table .seeding-group-total { background: #e9edf2; color: #303844; }
.influencer-effect-table .seeding-group-cafe24 { background: #dceee7; color: #245b49; }
.influencer-effect-table .seeding-group-musinsa { background: #ece9e2; color: #4f4a41; }
.influencer-effect-table .seeding-group-29cm { background: #e5eaf4; color: #354f7b; }
.influencer-effect-table .seeding-group-eql { background: #f3e6e8; color: #78414b; }

.influencer-effect-table .pcm-delta-up {
  color: #b3324c;
  font-weight: 700;
}

.influencer-effect-table .pcm-delta-down {
  color: #2563b8;
  font-weight: 700;
}

.section-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* ===== Print / PDF export =====
 * Goals:
 *   - Each numbered panel stays together on a page (no mid-panel break)
 *   - Topbar prints once at the top instead of sticking on every page
 *   - Drop the 1180px min-width clamp so the layout fits A4/Letter at 100%
 *   - Hide interactive-only controls (Update button, expand chevrons)
 *   - Force-render backgrounds (accent-green headers, product cell tags) */
@media print {
  @page { size: A4; margin: 12mm; }

  body {
    min-width: 0;
    background: #ffffff;
    font-size: 11px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .topbar {
    position: static;
    border-bottom: 1px solid var(--line);
  }

  main {
    padding: 12px 0 0;
    max-width: none;
  }

  #refresh-data,
  .expand-toggle,
  .section-expand {
    display: none !important;
  }

  /* Force-show all rows that the UI was collapsing behind expand toggles. */
  .panel, .chart-card, .platform-card {
    page-break-inside: avoid;
    break-inside: avoid;
    box-shadow: none;
  }

  .panel-head {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .product-tag {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .chart-canvas { height: 240px; }

  .legend { font-size: 10px; }
}

/* 일자별 마케팅 KPI: header text right-aligned. */
#daily-marketing-table .data-table th {
  text-align: right;
}

/* Link icon(s) appended inside a cell (e.g. 집행 광고 수). */
.cell-links {
  margin-left: 6px;
  white-space: nowrap;
}

.link-icon {
  display: inline-flex;
  align-items: center;
  margin: 0 2px;
  color: var(--accent);
  vertical-align: middle;
}

.link-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.link-icon:hover {
  color: var(--accent-hover);
}

.link-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  margin-left: 4px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.link-more:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.link-popover {
  position: absolute;
  z-index: 50;
  width: min(320px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.16);
}

.link-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.link-popover-close {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.link-popover-body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.link-popover-body .link-icon {
  margin: 0;
}

/* Creative: narrow the Ads Name column and ellipsize overflow. */
#creative-table .data-table th:first-child,
#creative-table .data-table td:first-child {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 일자별 마케팅 KPI: 일자(1열) 우측정렬, 집행 광고 수(2열) 폭 축소. */
#daily-marketing-table .data-table td:first-child {
  text-align: right;
}
#daily-marketing-table .data-table th:nth-child(2),
#daily-marketing-table .data-table td:nth-child(2) {
  width: 1%;
  white-space: nowrap;
}

/* Top 제품: 단위 노트 — 셀 텍스트와 동일 크기. 첫 카드(자사몰)에만 표시. */
.unit-note {
  padding: 4px 12px 0;
  color: var(--muted);
  font-size: 12px;
}

/* Top 제품 카드 표: 헤더 글자 축소 + 제품명 컬럼이 남은 폭을 차지하도록
 * #, 판매가, 매출액 컬럼을 컨텐츠 폭으로 축소. */
.platform-card .data-table {
  width: 100%;
}
.platform-card .data-table th {
  font-size: 10.5px;
}
.platform-card .data-table th:not(:nth-child(2)),
.platform-card .data-table td:not(:nth-child(2)) {
  width: 1%;
  white-space: nowrap;
}

/* Instagram Buzz: 다른 컬럼은 nowrap으로 좁게, 내용 컬럼은 넓게. */
#ig-table .data-table th,
#ig-table .data-table td {
  white-space: nowrap;
}
#ig-table .ig-caption {
  max-width: 680px;
}

/* 재구매: 고객수/판매수량/판매금액(4~6열) 폭 축소. */
#repurchase-table .data-table th:nth-child(n + 4),
#repurchase-table .data-table td:nth-child(n + 4) {
  width: 1%;
  white-space: nowrap;
}

/* Optional CRM note area kept invisible unless a future renderer uses it. */
#crm-note {
  border: none;
  background: none;
  padding-left: 0;
}
