/* naver-ad-monitor 디자인 시스템 이식 */
:root {
  --green: #03c75a;       /* 네이버 그린 */
  --green-dark: #02a64c;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1c1e21;
  --muted: #8b95a1;
  --pc: #2f6fed;
  --topbar-h: 56px;
  /* 채널 색 (차트/도트) */
  --smartstore: #2a78d6;
  --coupang: #eb6834;
  --cafe24: #1baf7a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Pretendard", -apple-system, "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── 레이아웃: 탑바 + 좌측 사이드바 ─────────────────── */
#layout { display: flex; flex-direction: column; min-height: 100vh; }
#content-row { display: flex; flex: 1; min-height: 0; }
#main-col { flex: 1; min-width: 0; }

#topbar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; justify-content: space-between;
  height: var(--topbar-h); padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--border); }
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-left #page-title { font-size: 15px; margin: 0; font-weight: 700; white-space: nowrap; }
.topbar-divider { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; margin: 0 2px; }
.header-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.header-right button { font-size: 13px; }
#hamburger { border: none; background: none; font-size: 18px; padding: 4px 4px; line-height: 1; color: var(--text); flex-shrink: 0; }
#hamburger:hover { background: var(--bg); border-radius: 6px; }
.side-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; white-space: nowrap; }
.brand-logo { width: 24px; height: 24px; flex-shrink: 0; }
.brand-text { color: #1d3f8f; }
.user-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.user-chip { font-size: 13px; color: #445; font-weight: 600; }

#sidebar {
  width: 232px; flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
  overflow-y: auto; transition: width .15s ease; padding-top: 8px;
}

/* 브랜드 선택 블록 (naver의 광고주 블록) */
.side-adv { margin: 4px 12px 12px; padding: 12px; border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--green-dark)); display: flex; flex-direction: column; gap: 8px; }
.side-adv select { width: 100%; border: none; border-radius: 6px; padding: 8px 10px; font-size: 13px; background: #fff; color: var(--text); }
.side-adv #btn-add-brand { width: 100%; background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.55); font-weight: 600; }
.side-adv #btn-add-brand:hover { background: rgba(255,255,255,.3); }

/* 네비게이션 */
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px; }
.nav-parent { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: none; background: none;
  border-radius: 8px; color: var(--text); font-size: 14px; font-weight: 600; text-align: left; }
.nav-parent:hover { background: var(--bg); }
.nav-ico { width: 22px; text-align: center; flex-shrink: 0; font-size: 16px; }
.nav-label { flex: 1; white-space: nowrap; }
.nav-caret { font-size: 11px; color: var(--muted); transition: transform .15s ease; }
.nav-group.open > .nav-parent .nav-caret { transform: rotate(180deg); }
.nav-children { display: none; flex-direction: column; gap: 1px; padding: 2px 0 6px; }
.nav-group.open > .nav-children { display: flex; }
.nav-children button { width: 100%; text-align: left; border: none; background: none; border-left: 3px solid transparent;
  padding: 8px 12px 8px 44px; color: var(--muted); font-size: 13px; border-radius: 0 6px 6px 0; }
.nav-children button:hover { background: var(--bg); color: var(--text); }
.nav-children button.active { color: var(--green-dark); background: #eef9f1; border-left-color: var(--green); font-weight: 600; }

#sidebar.collapsed { width: 60px; }
#sidebar.collapsed .side-adv,
#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-caret,
#sidebar.collapsed .nav-children { display: none; }
#sidebar.collapsed .nav-parent { justify-content: center; padding: 12px 0; }

.badge { background: #eef2f7; color: #445; border-radius: 12px; padding: 3px 10px; font-size: 13px; }
.badge.mock { background: #fff4e5; color: #b06a00; }
.muted { color: var(--muted); font-size: 13px; }

button { cursor: pointer; border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 7px 12px; font-size: 13px; font-family: inherit; }
button.primary { background: var(--green); color: #fff; border-color: var(--green); }
button.primary:hover { background: var(--green-dark); }
button.danger { background: #fdecec; color: #b00020; border-color: #f0c0c0; }
select, input, textarea { font-family: inherit; }
select, input { border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-size: 13px; background: #fff; color: var(--text); }

main { padding: 18px 22px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* 카드 */
.cards { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 6px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; flex: 0 0 auto; min-width: 210px; }
.card .label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 6px; white-space: nowrap; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.mom { font-weight: 600; }
.mom.up { color: var(--green-dark); }
.mom.down { color: #b00020; }

/* 블록/표 (kw-block 스타일) */
.kw-block { background: var(--card); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.kw-block h3 { margin: 0; padding: 12px 16px; background: #fafbfc; border-bottom: 1px solid var(--border); font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.kw-block h3 .ts { font-size: 12px; color: var(--muted); font-weight: 400; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
th { background: #fafbfc; color: #556; font-weight: 600; }
tr:hover td { background: #fafdff; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }

.section-title { margin: 28px 0 10px; font-size: 16px; border-top: 1px solid var(--border); padding-top: 20px; }
.cov-controls { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.cov-controls label { font-size: 13px; color: var(--muted); }
.cov-controls select, .cov-controls input { margin-left: 4px; }
.ctl-label { font-size: 13px; color: var(--muted); }

/* 차트 */
.chart-box { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 12px 0; position: relative; }
.legend { display: flex; gap: 16px; font-size: 12px; color: #556; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
#tooltip { position: absolute; pointer-events: none; display: none; z-index: 5;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); min-width: 150px; }
#tooltip .t { font-weight: 700; margin-bottom: 4px; }
#tooltip .row { display: flex; justify-content: space-between; gap: 12px; color: #556; }
#tooltip .row b { color: var(--text); font-variant-numeric: tabular-nums; }

/* 상태 뱃지 */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status .ic { font-size: 11px; }
.status.good { color: var(--green-dark); }
.status.warn { color: #b06a00; }
.status.crit { color: #b00020; }
.chip { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 12px; background: #eef2f7; color: #445; margin-right: 6px; }
.chip.warn { background: #fff4e5; color: #b06a00; }
.chip.crit { background: #fdecec; color: #b00020; }

/* 로그인 */
.login-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 4px 24px rgba(0,0,0,.06); }
.login-card h2 { margin: 0 0 6px; font-size: 20px; }
.login-card label { display: block; font-size: 13px; color: #445; margin: 14px 0 0; }
.login-card input { width: 100%; margin-top: 5px; padding: 9px 10px; }
.login-card button { margin-top: 20px; width: 100%; padding: 11px; }
.login-error { color: #b00020; font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* 모달 */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 1100; }
.modal-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 22px; width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.modal-card h3 { margin: 0 0 12px; font-size: 16px; }
.modal-card label { display: block; font-size: 13px; color: #445; margin: 10px 0 0; }
.modal-card input, .modal-card select { width: 100%; margin-top: 5px; padding: 9px 10px; }
.modal-card .chk { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: #445; }
.modal-card .chk input { width: auto; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-error { color: #b00020; font-size: 13px; min-height: 16px; margin: 8px 0 0; }

/* 온보딩(브랜드 없을 때) */
.onboarding { display: flex; justify-content: center; padding: 60px 20px; }
.onboarding-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 100%; max-width: 520px; box-shadow: 0 4px 24px rgba(0,0,0,.06); }
.onboarding-card h2 { margin: 0 0 6px; }
.onboarding-card label { display: block; font-size: 13px; color: #445; margin: 12px 0 0; }
.onboarding-card input { width: 100%; margin-top: 5px; }
.onboarding-card button { margin-top: 20px; width: 100%; padding: 11px; }

/* 사용자 관리 행 (naver 스타일) */
.manage-section { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.manage-section > h3 { margin: 0 0 4px; font-size: 15px; }
.manage-section > .muted { margin-bottom: 12px; }
.row-toolbar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.user-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 13px 4px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row .who { flex: 1; min-width: 200px; }
.user-row .who b { font-size: 14px; }
.user-row .who .meta { color: var(--muted); font-size: 12.5px; }
.user-row button { font-size: 12px; padding: 5px 10px; }

/* 채널 태그 */
.ch-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
