/* ============================================================
   Portal — shared component styles (admin SPA와 디자인 일치)
   디자인 토큰은 guardus-marketing.css 의 :root 사용
   ============================================================ */

/* ── 페이지 헤더 ───────────────────────────────────────── */
.page-head {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 28px;
}
.page-head h1 {
  font-size: 28px; font-weight: 800; letter-spacing: -0.02em;
  margin: 0; color: var(--ink);
}
.page-head .greeting {
  font-size: 14px; color: var(--ink-dim); margin-top: 4px;
}
.page-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Range pill (기간 토글) ───────────────────────────── */
.range-pill {
  display: inline-flex; gap: 4px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-pill); padding: 4px;
}
.range-pill button {
  border: none; background: transparent;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: var(--radius-pill);
  color: var(--ink-2); cursor: pointer;
}
.range-pill button.active {
  background: var(--ink); color: #fff; font-weight: 600;
}

/* 기간 pill "직접 지정" 팝오버 달력 — 시작→종료 두 번 클릭으로 구간 선택 */
.range-wrap { position: relative; }
.range-cal {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  width: 252px; padding: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
  font-family: var(--sans);
}
.range-cal .cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--ink);
}
.range-cal .cal-head button {
  border: none; background: transparent; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px 8px; border-radius: 6px; color: var(--ink-2);
}
.range-cal .cal-head button:hover { background: var(--bg-soft); }
.range-cal .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.range-cal .dow { text-align: center; font-size: 11px; color: var(--ink-mute); padding: 2px 0; }
.range-cal .day {
  border: none; background: transparent; cursor: pointer;
  font-family: var(--sans); font-size: 12px; color: var(--ink-2);
  padding: 5px 0; border-radius: 6px; text-align: center;
}
.range-cal .day:hover:not(:disabled) { background: var(--bg-soft); }
.range-cal .day:disabled { color: var(--line); cursor: default; }
.range-cal .day.in { background: var(--pastel-blue); border-radius: 0; }
.range-cal .day.edge { background: var(--ink); color: #fff; font-weight: 600; }
.range-cal .cal-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.range-cal .sel { font-size: 12px; color: var(--ink-2); }
.range-cal .apply {
  border: none; background: var(--ink); color: #fff; cursor: pointer;
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: var(--radius-pill);
}
.range-cal .apply:disabled { background: var(--line); cursor: default; }

/* ── 카테고리 pill (purpose 등) ────────────────────────── */
.purpose-pill {
  border: none; border-radius: 20px; padding: 4px 12px;
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  cursor: pointer; background: var(--bg-soft); color: var(--ink-2);
  transition: background 120ms, color 120ms;
}
.purpose-pill.active { color: #fff; }

/* ── CSV 다운로드 버튼 ───────────────────────────────── */
.csv-btn {
  margin-left: auto; padding: 4px 10px; font-size: 11px; font-weight: 700;
  color: var(--ink-dim); background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer; letter-spacing: 0.02em;
  transition: background 150ms, color 150ms; flex-shrink: 0;
  font-family: var(--sans);
}
.csv-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── 일반 버튼 ────────────────────────────────────────── */
.btn {
  font-family: var(--sans);
  font-weight: 600; font-size: 13.5px;
  padding: 9px 18px; border-radius: 10px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  cursor: pointer; transition: filter 120ms;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost {
  background: #fff; color: var(--ink-2); border-color: var(--line);
}
.btn.ghost:hover { background: var(--bg-soft); border-color: var(--ink-mute); }
.btn.danger {
  background: var(--bad); border-color: var(--bad);
}
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

/* ── KPI 카드 ─────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px; position: relative; overflow: hidden;
}
.kpi.accent { background: var(--brand); color: #fff; border-color: var(--brand); }
.kpi.accent .l, .kpi.accent .s { color: rgba(255,255,255,0.85); }
.kpi .l { font-size: 12.5px; color: var(--ink-dim); font-weight: 500; margin-bottom: 8px; }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; color: inherit; }
.kpi .s { font-size: 12px; color: var(--ink-dim); margin-top: 6px; }
.kpi .s.up { color: var(--ok); }
.kpi .s.down { color: var(--bad); }
.kpi.accent .s.up { color: #c8ffd9; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .kpis { grid-template-columns: 1fr 1fr; } }

/* ── 패널 ────────────────────────────────────────────── */
.panel {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.panel-head h3 { font-size: 16px; font-weight: 700; margin: 0; color: var(--ink); }
.panel-head .sub { font-size: 13px; color: var(--ink-dim); }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel-head .right a { font-size: 13px; color: var(--brand); font-weight: 600; text-decoration: none; }
.panel-head .right a:hover { text-decoration: underline; }

/* ── 테이블 ──────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  padding: 11px 14px; text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-mute); background: var(--bg-soft); border-bottom: 1px solid var(--line);
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-soft); }

/* ── 폼 입력 ─────────────────────────────────────────── */
.inp {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13.5px; font-family: var(--sans); outline: none; background: #fff;
  width: 100%;
}
.inp:focus { border-color: var(--brand); }
.inp.mono { font-family: var(--mono); font-size: 12.5px; }
.lbl { font-size: 12px; color: var(--ink-dim); font-weight: 600; margin-bottom: 4px; display: block; }

/* ── 상태 배지 ───────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge.ok    { background: var(--pastel-mint); color: var(--ok); }
.badge.bad   { background: var(--pastel-rose); color: var(--bad); }
.badge.warn  { background: var(--pastel-lemon); color: var(--warn); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.sdot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.sdot::before { content:''; display:inline-block; width:7px; height:7px; border-radius:50%; }
.sdot-on::before  { background: var(--ok); }
.sdot-off::before { background: var(--ink-mute); }

/* ── 헬퍼 ────────────────────────────────────────────── */
.mono { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.muted { color: var(--ink-mute); }
.bar { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 400ms; }

/* ── 모달 (botgate.html 디자인 포팅 — 가격규칙 등 공용) ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: #fff; border-radius: 20px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto;
  box-shadow: 0 30px 70px -20px rgba(15,23,42,0.4);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 14px;
}
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.modal-x {
  border: none; background: var(--bg-soft); width: 32px; height: 32px;
  border-radius: 50%; cursor: pointer; font-size: 14px; color: var(--ink-dim);
}
.modal-x:hover { background: #e8ebf1; color: var(--ink); }
.modal-body { padding: 6px 24px 8px; font-size: 14px; color: var(--ink-2); line-height: 1.6; word-break: keep-all; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px 22px;
}

/* ── "준비중" 플레이스홀더 패널 (가격규칙 등 공용) ── */
.soon-panel { opacity: 0.7; }
.soon-note { font-size: 13px; color: var(--ink-mute); padding: 10px 4px 2px; }

/* ── 포털 공용 — 분석 리포트/대시보드 (botgate.html 포팅) ── */
/* 채널 셀렉터 */
.chan-select { position: relative; display: inline-flex; align-items: center; }
.chan-select select {
  appearance: none; -webkit-appearance: none;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  color: var(--ink);
  padding: 9px 38px 9px 16px;
  border: 1px solid var(--line-2); border-radius: var(--radius-pill);
  background: #fff; cursor: pointer;
  transition: border-color 140ms, box-shadow 140ms;
}
.chan-select select:hover { border-color: var(--ink); }
.chan-select select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 18%, transparent);
}
.chan-select select:disabled { color: var(--ink-dim); cursor: not-allowed; }
.chan-select svg {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-dim); pointer-events: none;
}

/* 2단 패널 그리드 (botgate.html .row) */
.row { display: grid; gap: 16px; margin-bottom: 16px; }
.row.r-7-5 { grid-template-columns: 7fr 5fr; }
.row.r-6-6 { grid-template-columns: 1fr 1fr; }
.row.r-8-4 { grid-template-columns: 8fr 4fr; }
.row .panel { margin-bottom: 0; }
@media (max-width: 1100px) { .row.r-7-5, .row.r-6-6, .row.r-8-4 { grid-template-columns: 1fr; } }

/* KPI 4컬럼 변형 (kpis 기본 5컬럼 오버라이드) */
.kpis.k4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .kpis.k4 { grid-template-columns: repeat(2, 1fr); } }

/* KPI 3컬럼 변형 */
.kpis.k3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .kpis.k3 { grid-template-columns: repeat(2, 1fr); } }

/* pastel 패널 (botgate.html) */
.panel.pastel-blue  { background: var(--pastel-blue);  border-color: transparent; }
.panel.pastel-mint  { background: var(--pastel-mint);  border-color: transparent; }
.panel.pastel-lemon { background: var(--pastel-lemon); border-color: transparent; }
.panel.pastel-lilac { background: var(--pastel-lilac); border-color: transparent; }

/* 정산·세금계산서 내역 리스트 (proto 글로벌 primitives) */
.payout-banner {
  background: linear-gradient(120deg, var(--pastel-lemon) 0%, var(--pastel-peach) 100%);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 16px;
}
.payout-banner .ico {
  width: 48px; height: 48px; border-radius: 14px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.payout-banner .body { flex: 1; }
.payout-banner .body .h { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 3px; }
.payout-banner .body .p { font-size: 13.5px; color: var(--ink-2); }
.payout-banner .v { font-size: 24px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }

.rules { display: flex; flex-direction: column; gap: 8px; }
.rule {
  display: grid; grid-template-columns: 80px 1fr auto auto; gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: 12px;
  font-size: 14px;
}
.rule .path { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.rule .price { font-weight: 700; color: var(--ink); font-size: 13px; }
.rule .ax { color: var(--ink-mute); cursor: pointer; padding: 4px; }
.rule .ax:hover { color: var(--ink); }
.badge.free  { background: var(--pastel-mint); color: var(--ok); }
.badge.paid  { background: var(--brand-soft); color: var(--brand); }
.badge.block { background: #ffd9d3; color: var(--bad); }

/* 데이터 영역 "준비중" 박스 (흰/pastel 패널 공용) */
.soon-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; border-radius: 12px;
  background: rgba(15, 23, 42, 0.035);
  border: 1px dashed rgba(15, 23, 42, 0.18);
}
.soon-box .t { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.soon-box .d { font-size: 12.5px; color: var(--ink-dim); text-align: center; padding: 0 16px; word-break: keep-all; }

/* KPI 값 자리 준비중 */
.kpi .v.soon-v { font-size: 18px; color: var(--ink-mute); }

/* 빈 데이터 / 로딩 안내 (분석·트래픽·대시보드 공용) */
.empty-note { padding: 36px 0; text-align: center; font-size: 13.5px; color: var(--ink-dim); }

/* ── 일별 추이 스택 바 차트 (분석 Bots 탭·대시보드 공유) — 색은 inline ── */
.chart { height: 220px; display: flex; align-items: flex-end; gap: 6px; padding: 12px 0; }
.chart .col {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  gap: 2px; position: relative; cursor: pointer;
}
.chart .col .bar { border-radius: 4px 4px 0 0; transition: opacity 160ms; }
.chart .col:hover .bar { opacity: 0.7; }
/* 호버 툴팁 — 봇별 수치 + 합계 (CSS hover 만으로 표시) */
.chart .col .chart-tip {
  display: none;
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  z-index: 20; min-width: 170px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 30px -10px rgba(15, 23, 42, 0.25);
  padding: 10px 12px; pointer-events: none;
  font-size: 12.5px; white-space: nowrap;
}
.chart .col:hover .chart-tip { display: block; }
.chart .col .chart-tip.tip-start { left: 0; transform: none; }
.chart .col .chart-tip.tip-end { left: auto; right: 0; transform: none; }
.chart-tip .tip-date { font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 7px; padding: 2px 0; color: var(--ink-2); }
.chart-tip .tip-row .dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.chart-tip .n { margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.chart-tip .tip-total {
  display: flex; margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--line); font-weight: 700; color: var(--ink);
}
.chart-x { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.chart-x .l { flex: 1; text-align: center; font-size: 11px; color: var(--ink-mute); }
.legend { display: flex; gap: 18px; margin-top: 14px; flex-wrap: wrap; font-size: 13px; }
.legend .it { display: inline-flex; align-items: center; gap: 7px; }
.legend .it .dot { width: 10px; height: 10px; border-radius: 3px; }

/* ── 순위/회사 리스트 (분석 Overview·대시보드 공유) — botgate.html .bot-list ── */
.bot-list { display: flex; flex-direction: column; gap: 12px; }
.bot-row {
  display: grid; grid-template-columns: 36px 1fr auto auto; gap: 14px;
  align-items: center;
}
.bot-avatar {
  width: 36px; height: 36px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff;
}
.bot-row .meta .name {
  font-size: 16px; font-weight: 800; color: var(--ink); letter-spacing: -0.01em;
}
.bot-row .meta .ua {
  font-family: var(--mono); font-size: 11px; color: var(--ink-mute);
  margin-top: 1px;
}
.bot-row .meta .ua-list {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px;
}
.ua-chip {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 6px;
  background: var(--bg-soft); color: var(--ink-dim);
  border: 1px solid var(--line);
}
.bot-row .req { text-align: right; }
.bot-row .req .n { font-weight: 700; font-size: 14px; }
.bot-row .req .s { font-size: 11.5px; color: var(--ink-dim); }
.bot-row .rev {
  background: var(--brand-soft); color: var(--brand);
  padding: 6px 11px; border-radius: 999px;
  font-weight: 700; font-size: 13px;
  min-width: 90px; text-align: right;
}
.bot-row .rev.soon { background: var(--bg-soft); color: var(--ink-mute); font-weight: 500; }

/* ── 이벤트 피드 (실시간 트래픽·대시보드 공유) — botgate.html .events ── */
.events { display: flex; flex-direction: column; gap: 10px; }
.event {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 12px;
  align-items: center;
  padding: 11px 14px;
  background: var(--bg-soft);
  border-radius: 12px;
  font-size: 13.5px;
}
.event .pin {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
}
.event.ev-ok .pin   { background: var(--ok); }
.event.ev-bad .pin  { background: var(--bad); }
.event.ev-warn .pin { background: var(--warn); }
.event .msg { color: var(--ink); }
.event .msg b { color: var(--ink); font-weight: 700; }
.event .msg .ua { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.event time { font-size: 12px; color: var(--ink-mute); white-space: nowrap; }

/* 카테고리 필터 pill (분석 Platforms 탭·봇 카탈로그 공유) */
.cat-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.cat-filter button {
  border: none; background: var(--bg-soft);
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  padding: 7px 14px; border-radius: var(--radius-pill);
  color: var(--ink-2); cursor: pointer; transition: all 120ms;
}
.cat-filter button:hover { background: #e8ebf1; }
.cat-filter button.active { background: var(--brand); color: #fff; }
.cat-filter button:disabled { cursor: not-allowed; }

/* 도넛 차트 + 범례 (분석 Platforms 탭·대시보드 봇 구성 공유) — botgate.html .ring/.seg-legend */
.ring { position: relative; width: 160px; height: 160px; margin: 0 auto; }
.ring svg { transform: rotate(-90deg); }
.ring .center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.ring .center .v { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.ring .center .l { font-size: 12px; color: var(--ink-dim); }
.seg-legend { margin-top: 18px; display: flex; flex-direction: column; gap: 9px; }
.seg-legend .row-l {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 10px;
  align-items: center; font-size: 13px;
}
.seg-legend .dot { width: 10px; height: 10px; border-radius: 3px; }
.seg-legend .name { color: var(--ink); }
.seg-legend .pct { font-weight: 700; color: var(--ink); }

/* 채널명 배지 — botgate.html .ch-chip */
.ch-chip {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; margin-right: 8px;
  background: var(--brand-soft); color: var(--brand);
  vertical-align: middle;
}

/* 실시간 트래픽 용도 라벨 (색은 인라인 — 용도별 동적) */
.purpose-tag { font-size: 11px; font-weight: 700; margin-right: 6px; vertical-align: middle; }
