:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text-1: #0F172A;
  --text-2: #334155;
  --text-3: #64748B;
  --muted: #94A3B8;
  --primary: #0B3D91;
  --primary-2: #1E40AF;
  --accent: #B58A2B;
  --good: #15803D;
  --warn: #B45309;
  --bad: #B91C1C;
  --chip: #EEF2F7;
  --ai: #7C3AED;
}

* { font-family: 'Pretendard Variable', Pretendard, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
body { background: var(--bg); color: var(--text-1); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}

.section-title { font-size: 14px; font-weight: 600; color: var(--text-2); letter-spacing: -0.01em; }
.section-sub { font-size: 12px; color: var(--text-3); }

.kpi-label { font-size: 12px; color: var(--text-3); }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text-1); letter-spacing: -0.02em; }
.kpi-delta-up   { color: var(--good); }
.kpi-delta-down { color: var(--bad); }
.kpi-delta-flat { color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 999px;
  background: var(--chip); color: var(--text-2);
  font-size: 11px; font-weight: 500;
}
.chip-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); }
.chip-dot.good { background: var(--good); }
.chip-dot.warn { background: var(--warn); }
.chip-dot.bad  { background: var(--bad); }
.chip-dot.info { background: var(--primary-2); }

.status-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.status-pre      { background: #F1F5F9; color: #475569; border-color: #E2E8F0; }
.status-done     { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.status-changed  { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.status-rerun    { background: #FFEDD5; color: #9A3412; border-color: #FED7AA; }
.status-fail     { background: #FEE2E2; color: #991B1B; border-color: #FECACA; }
.status-dot {
  width: 8px; height: 8px; border-radius: 999px; background: currentColor;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.6);
}

/* Severity colorbar (P2-4: 이상 징후 우선순위) */
.sev-bar { width: 4px; border-radius: 2px; align-self: stretch; }
.sev-bar.red { background: #B91C1C; }
.sev-bar.amber { background: #D97706; }
.sev-bar.gray { background: #CBD5E1; }
.sev-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
}
.sev-pill.red   { background: #FEE2E2; color: #991B1B; }
.sev-pill.amber { background: #FEF3C7; color: #92400E; }
.sev-pill.gray  { background: #F1F5F9; color: #475569; }

.btn-primary {
  background: var(--primary); color: #fff; font-weight: 600; font-size: 13px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--primary);
}
.btn-primary:hover { background: #0A347B; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  background: transparent; color: var(--text-2); font-weight: 500; font-size: 12px;
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
}
.btn-ghost:hover { background: #F8FAFC; }
.btn-ghost:disabled { opacity: .55; cursor: not-allowed; }

.btn-warn   { background: #B45309; color: #fff; font-weight: 600; font-size: 13px; padding: 10px 16px; border-radius: 10px; border: 1px solid #B45309; }
.btn-danger { background: #B91C1C; color: #fff; font-weight: 600; font-size: 13px; padding: 10px 16px; border-radius: 10px; border: 1px solid #B91C1C; }

.tab {
  font-size: 13px; font-weight: 500; color: var(--text-3);
  padding: 8px 0; margin-right: 24px; border-bottom: 2px solid transparent; cursor: pointer;
}
.tab.active { color: var(--text-1); border-bottom-color: var(--primary); }

.toggle-btn {
  font-size: 12px; font-weight: 500; padding: 6px 12px;
  border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text-2); cursor: pointer;
}
.toggle-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Campaign segment (P3-7: 전체/NU/RT 토글) */
.segment {
  display: inline-flex; padding: 3px; background: #F1F5F9; border-radius: 10px; gap: 2px;
}
.segment .seg {
  padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--text-3);
  border-radius: 8px; cursor: pointer;
}
.segment .seg.active { background: #fff; color: var(--text-1); box-shadow: 0 1px 2px rgba(15,23,42,.08); }

.divider { height: 1px; background: var(--border); }

.alert-warn { background: #FFF7ED; border: 1px solid #FED7AA; color: #9A3412; border-radius: 10px; }
.alert-info { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E3A8A; border-radius: 10px; }

.table th {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); background: #FAFAFB;
}
.table td {
  font-size: 13px; color: var(--text-1);
  padding: 12px; border-bottom: 1px solid var(--border);
}
.table tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

.placeholder { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.gold-accent { color: var(--accent); }

.progress-track { background: #EEF2F7; height: 8px; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 999px; }
.progress-fill.amber { background: linear-gradient(90deg, #D97706, #F59E0B); }
.progress-fill.red   { background: linear-gradient(90deg, #B91C1C, #DC2626); }

[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; left: 0; top: 100%; margin-top: 6px;
  background: #0F172A; color: #fff; font-size: 11px; line-height: 1.4;
  padding: 6px 8px; border-radius: 6px; white-space: nowrap; z-index: 50;
}

.badge-status { font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 600; }
.badge-success { background: #DCFCE7; color: #166534; }
.badge-warn    { background: #FEF3C7; color: #92400E; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-mute    { background: #E5E7EB; color: #475569; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-v2      { background: #1F2937; color: #FCD34D; border: 1px solid #374151; }
.badge-agency  { background: #E2E8F0; color: #334155; }
.badge-ai      { background: #EDE9FE; color: #6D28D9; }

.scroll-x { overflow-x: auto; }
.scroll-x::-webkit-scrollbar { height: 8px; }
.scroll-x::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 999px; }

.commentary { font-size: 13px; line-height: 1.7; color: var(--text-2); white-space: pre-wrap; }
.commentary .ph { color: var(--muted); }

/* v5 메타 스트립 — 5칸 2·2·2·2·4 */
.basis-strip {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}
.basis-strip .col-span-2 { grid-column: span 2; }
.basis-strip .col-span-4 { grid-column: span 4; }

.basis-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  box-shadow: none;
  overflow: hidden;
}
.basis-card .label {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
  line-height: 1.2;
}
.basis-card .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

/* v5 헤더 기준일 일치 칩 */
.basis-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.basis-chip .chip-dot { width: 6px; height: 6px; border-radius: 999px; }
.basis-chip.match    { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.basis-chip.match    .chip-dot { background: #166534; }
.basis-chip.mismatch { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.basis-chip.mismatch .chip-dot { background: #92400E; }

/* v5 델타 칩 (▲▼) — KPI/예산 공통 */
.delta-chip {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.delta-chip.up   { background: #DCFCE7; color: #166534; }
.delta-chip.down { background: #FEE2E2; color: #991B1B; }
.delta-chip.flat { background: #F1F5F9; color: #475569; }

/* v5 예산 카드 */
.budget-card {
  min-height: 128px;
  padding: 16px 18px;
  gap: 10px;
}
.budget-today {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.budget-today-left {
  display: flex; flex-direction: column; gap: 4px;
}
.budget-today-label {
  font-size: 13px; color: var(--text-3); font-weight: 500;
}
.budget-today-amount {
  font-size: 24px; font-weight: 700; color: var(--text-1);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  white-space: nowrap; line-height: 1.15;
}
.budget-cum {
  display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.budget-cum-label {
  font-size: 13px; color: var(--text-3); margin-right: 4px; font-weight: 500;
}
.budget-cum-spent {
  font-size: 17px; font-weight: 700; color: var(--text-1); white-space: nowrap;
}
.budget-cum-total {
  font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.budget-cum-rate {
  font-size: 13px; color: var(--text-3); margin-left: 4px; font-weight: 600;
}
.budget-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-3);
  padding-right: 2px;
}
.status-chip {
  margin-left: auto;
  padding: 3px 10px; border-radius: 999px;
  background: #F1F5F9; color: #475569;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}

/* v5 KPI 값/금액 nowrap 강제 */
.kpi-value { white-space: nowrap; }

/* Executive Summary card (P1-1) */
.exec-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFB 100%);
  border: 1px solid #DBE3F1; border-radius: 14px;
}
.exec-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--primary); text-transform: uppercase; }
.exec-headline { font-size: 18px; font-weight: 700; color: var(--text-1); line-height: 1.5; letter-spacing: -0.01em; }
.exec-stat { display: flex; flex-direction: column; align-items: flex-start; }
.exec-stat .k { font-size: 11px; color: var(--text-3); }
.exec-stat .v { font-size: 16px; font-weight: 700; color: var(--text-1); font-variant-numeric: tabular-nums; }
.exec-stat .d { font-size: 11px; font-weight: 600; }
.exec-stat .d.up   { color: var(--good); }
.exec-stat .d.down { color: var(--bad); }
.exec-stat .d.flat { color: var(--muted); }

/* Bullet daily comment (P1-2) */
.bullet-card { border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.bullet-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.bullet-body { padding: 12px 14px; }
.camp-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
}
.camp-tag.nu { background: #DBEAFE; color: #1E40AF; }
.camp-tag.rt { background: #FCE7F3; color: #9D174D; }
.kv-row { display: grid; grid-template-columns: 88px 1fr; gap: 6px; font-size: 12px; padding: 4px 0; }
.kv-row .k { color: var(--text-3); }
.kv-row .v { color: var(--text-1); font-weight: 500; font-variant-numeric: tabular-nums; }

.raw-toggle { font-size: 11px; color: var(--primary-2); cursor: pointer; }

/* AI card distinct (P2-3) */
.ai-card {
  background: linear-gradient(180deg, #FBFAFF 0%, #F4F0FF 100%);
  border: 1px solid #DDD6FE; border-left: 4px solid var(--ai); border-radius: 12px;
}
.ai-evidence {
  font-size: 10.5px; color: var(--ai); font-weight: 600;
  cursor: pointer;
}

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 14px; width: 480px; max-width: 92vw; box-shadow: 0 20px 40px rgba(15,23,42,0.18); overflow: hidden; }
.modal-head { padding: 18px 20px 8px; }
.modal-icon { width: 36px; height: 36px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.modal-icon.info  { background: #DBEAFE; color: #1E40AF; }
.modal-icon.good  { background: #DCFCE7; color: #166534; }
.modal-icon.warn  { background: #FEF3C7; color: #92400E; }
.modal-icon.rerun { background: #FFEDD5; color: #9A3412; }
.modal-icon.fail  { background: #FEE2E2; color: #991B1B; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--text-1); }
.modal-body  { padding: 4px 20px 16px; color: var(--text-2); font-size: 13px; line-height: 1.7; }
.modal-meta  { margin-top: 10px; padding: 10px 12px; background: #F8FAFC; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; }
.modal-meta .row { display: flex; justify-content: space-between; padding: 3px 0; }
.modal-meta .row .k { color: var(--text-3); }
.modal-meta .row .v { color: var(--text-1); font-weight: 600; font-variant-numeric: tabular-nums; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }

.modal-preview { position: static; background: transparent; padding: 0; }
.modal-preview .modal { width: 100%; box-shadow: 0 4px 12px rgba(15,23,42,0.08); border: 1px solid var(--border); }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .card { box-shadow: none; border-color: #E5E7EB; break-inside: avoid; }
}

/* ============ v6: 전체 성과 추이 듀얼 모드 ============ */

/* 기간 pill */
.pill-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.pill-btn:hover { border-color: var(--border-strong); color: var(--text-2); }
.pill-btn.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

/* segmented control (모드 토글) */
.segmented {
  display: inline-flex;
  background: #F1F5F9;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  padding: 7px 18px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text-2); }
.seg-btn.active {
  background: #FFFFFF;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(15,23,42,0.08);
}

/* 안내 배지 (우상단) */
.info-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: #EEF2FF;
  color: #3730A3;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #C7D2FE;
  white-space: nowrap;
}

/* 지표/묶음 선택 row */
.metric-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.metric-row.hidden { display: none; }
.metric-row-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  margin-right: 4px;
}
.metric-pill {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.metric-pill:hover { border-color: var(--border-strong); }
.metric-pill.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}
.metric-pill .pill-sub {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.75;
  margin-left: 2px;
}

/* 안내 문구 */
.trend-hint {
  font-size: 11.5px;
  color: var(--text-3);
  background: #F8FAFC;
  border: 1px dashed #E2E8F0;
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.5;
}

/* 요약 카드 (우측 3칸) */
.summary-card {
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px;
  height: 320px;
  display: flex;
  flex-direction: column;
}
.summary-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 8px;
}
.summary-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: nowrap;
}
.summary-delta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.summary-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0 12px;
}
.summary-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.summary-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.summary-meta-label { color: var(--text-3); }
.summary-meta-val {
  color: var(--text-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 보조 차트 카드 */
.sub-chart-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.sub-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.sub-chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
}
.sub-chart-unit {
  font-size: 11px;
  color: var(--text-3);
}
