/* ============ EZED® 광고 대시보드 — 프리랜서 IA 그대로 ============ */

:root {
  --bg: #F4F5F8;
  --surface: #FFFFFF;
  --line: #ECECF0;
  --line-soft: #F2F2F4;
  --text: #1A1A1A;
  --text-muted: #6E6E78;
  --text-soft: #A0A0A8;
  --primary: #5C5CE0;
  --primary-soft: #EFEEFB;
  --primary-strong: #4A4ACB;
  --orange: #F39A28;
  --orange-soft: #FFF1DD;
  --green: #1F9E5C;
  --green-soft: #E8F5EE;
  --red: #DC5D6F;
  --red-soft: #FCE8EB;
  --blue: #2683F0;
  --blue-soft: #E5F0FE;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ============ Top Nav ============ */
.topnav {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topnav-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topnav-logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #5C5CE0, #7E60E5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topnav-logo-text {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

.topnav-logo-text strong { font-weight: 800; letter-spacing: -0.2px; }
.topnav-logo-text sup { font-size: 9px; vertical-align: super; margin-left: 1px; }

.topnav-center {
  display: inline-flex;
  align-items: center;
  gap: 28px;
  margin-left: 24px;
}

.tnav-item {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 18px 4px;
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
}

.tnav-item:hover { color: var(--text); }

.tnav-item.is-active {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--text);
}

.topnav-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}

.profile-btn:hover { background: var(--bg); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.profile-btn .caret { color: var(--text-muted); display: inline-flex; }

/* ============ App Layout ============ */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 56px);
}

/* ============ Client Aside (Left list) ============ */
.client-aside {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
}

.client-search {
  position: relative;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.client-search .search-icon {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  display: inline-flex;
}

.client-search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
}

.client-search input::placeholder { color: var(--text-soft); }

.client-search input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.client-list {
  list-style: none;
  margin: 0;
  padding: 6px 8px;
  overflow-y: auto;
  flex: 1;
}

.cl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}

.cl-item:hover { background: var(--bg); }

.cl-item.is-active {
  background: var(--primary-soft);
}

.cl-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.cl-status.is-warn { background: var(--orange); }
.cl-status.is-off  { background: var(--text-soft); }

.cl-info { flex: 1; min-width: 0; }

.cl-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.cl-item.is-active .cl-name { color: var(--primary); }

.cl-meta {
  font-size: 11.5px;
  color: var(--text-soft);
  margin-top: 1px;
}

/* ============ Content (Main) ============ */
.content {
  padding: 26px 32px 56px;
  min-width: 0;
}

.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.brand-title {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin: 0;
}

.brand-title-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5C5CE0, #7E60E5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 10px;
}

.action-link:hover { color: var(--text); }

.action-ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background .12s, border-color .12s;
}

.action-ghost:hover { background: var(--bg); border-color: var(--text-soft); }

.action-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.action-date:hover { background: var(--bg); border-color: var(--text-soft); }

.action-date.inline-date {
  margin-left: auto;
  padding: 6px 10px;
  font-size: 12.5px;
}

.date-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(20,20,30,0.10);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 280px;
}

.date-popover input[type="date"] {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  flex: 1;
}

.date-popover input[type="date"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.date-popover-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-popover-row span { color: var(--text-soft); font-size: 13px; }

.date-popover button.apply {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.date-popover button.apply:hover { background: var(--primary-strong); }

/* ============ ctabs (전체요약 / 공헌이익) ============ */
.ctabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
  margin-bottom: 18px;
}

.ctab {
  background: transparent;
  border: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: 7px;
  transition: color .12s, background .12s;
}

.ctab:hover { color: var(--text); }

.ctab.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

/* ============ Section / Cards ============ */
.section { margin-bottom: 22px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin: 0;
  color: var(--text);
}

.bar {
  display: inline-block;
  width: 4px;
  height: 18px;
  border-radius: 2px;
}

.bar-blue { background: var(--primary); }

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px 20px;
}

.metric-card.no-pad { padding: 0; }

.metric-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  margin-bottom: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ============ Donut Cards ============ */
.donut-wrap {
  position: relative;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0 4px;
}

.donut-wrap canvas {
  max-height: 100%;
}

.donut-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -56%);
  text-align: center;
  pointer-events: none;
}

.dc-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.dc-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px;
}

.donut-bottom-pct {
  position: absolute;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-soft);
  pointer-events: none;
}

.media-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
}

.legend-item.is-google   { background: var(--orange-soft); }
.legend-item.is-meta     { background: #E8F0FE; }
.legend-item.is-naver_sa { background: #E8F8EF; }
.legend-item.is-naver_gfa{ background: #E8F8EF; }
.legend-item.is-tiktok   { background: #F2F2F2; }

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-name {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.4px;
}

.legend-pct {
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.legend-val {
  color: var(--orange);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.legend-item.is-meta     .legend-val { color: #1A6CC9; }
.legend-item.is-naver_sa .legend-val { color: #1F9E5C; }
.legend-item.is-naver_gfa.legend-val { color: #1F9E5C; }
.legend-item.is-tiktok   .legend-val { color: #1A1A1A; }

/* ============ 수집 로그 ============ */
.collect-log { margin-bottom: 14px; }

.cl-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  width: 100%;
  text-align: left;
}

.cl-toggle:hover { background: var(--bg); }

.cl-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.cl-caret {
  color: var(--text-muted);
  display: inline-flex;
  transition: transform .15s;
}

.collect-log.is-open .cl-caret { transform: rotate(180deg); }

.cl-dot-red {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.cl-count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
}

.cl-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 12px 12px;
  margin-top: -4px;
  padding: 14px 18px;
}

.cl-row {
  display: grid;
  grid-template-columns: 90px 1fr 80px;
  gap: 14px;
  font-size: 12.5px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line-soft);
  align-items: center;
}

.cl-row:last-child { border-bottom: none; }

.cl-row .cl-row-time { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.cl-row .cl-row-msg  { color: var(--text); }
.cl-row .cl-row-status { text-align: right; font-size: 11px; font-weight: 700; }
.cl-row .cl-row-status.success { color: var(--green); }
.cl-row .cl-row-status.fail    { color: var(--red); }

/* ============ 데이터 테이블 ============ */
.data-table-wrap {
  overflow-x: auto;
  border-radius: 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  color: var(--text);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover td { background: #FAFAFC; }

/* 컬럼 의미 색상 */
.data-table th.col-cost  { background: var(--red-soft); color: var(--red); font-weight: 700; }
.data-table td.col-cost  { background: rgba(220,93,111,0.04); color: var(--red); font-weight: 700; }
.data-table th.col-rev   { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.data-table td.col-rev   { background: rgba(38,131,240,0.04); color: var(--blue); font-weight: 700; }
.data-table th.col-roas  { background: var(--green-soft); color: var(--green); font-weight: 700; }
.data-table td.col-roas  { background: rgba(31,158,92,0.05); color: var(--green); font-weight: 700; }

/* ============ 공헌이익 placeholder ============ */
.contrib-empty {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 16px 48px;
  text-align: center;
  gap: 6px;
}

.contrib-empty-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 8px 0 4px;
}

.contrib-empty-desc {
  font-size: 12.5px;
  color: var(--text-soft);
  max-width: 460px;
  line-height: 1.55;
  margin: 0;
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .client-aside { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .client-list { max-height: 240px; }
  .topnav-center { display: none; }
}
