:root {
  --navy: #14213d;
  --navy-dark: #0b1526;
  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --err-bg: #fee2e2;
  --err-text: #991b1b;
  --warn-bg: #fef9c3;
  --warn-text: #854d0e;
  --muted-bg: #f1f5f9;
  --muted-text: #475569;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: inherit; }

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.badge-connected {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-connect {
  background: var(--muted-bg);
  color: var(--muted-text);
  border: 1px solid var(--border);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
}

.container-narrow {
  max-width: 600px;
  margin: 60px auto;
  padding: 0 24px;
}

/* ---- Home hero ---- */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  padding: 80px 0;
  align-items: center;
}

.eyebrow {
  color: var(--teal);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 13px;
  margin-bottom: 16px;
}

.hero h1 {
  font-size: 44px;
  line-height: 1.25;
  margin: 0 0 20px;
  font-weight: 800;
}

.hero p {
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 32px;
}

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }

.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-soft); }

.btn-teal { background: var(--teal); color: #fff; }

.btn-block { width: 100%; }

.fine-print { margin-top: 16px; color: var(--muted); font-size: 13px; }

.preview-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.preview-box-bar {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.preview-box-dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; }

.preview-box-body {
  min-height: 360px;
  background: repeating-linear-gradient(45deg, var(--teal-light), var(--teal-light) 10px, #ffffff 10px, #ffffff 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  font-weight: 700;
  overflow: hidden;
}

.preview-box-img {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
  object-position: top;
  display: block;
}

.steps {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 60px;
  padding: 48px 0 90px;
  border-top: 1px solid var(--border);
}

.step { display: flex; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: none; }
.step-num { font-size: 26px; font-weight: 800; color: var(--teal); width: 40px; }
.step-title { font-weight: 700; margin-bottom: 4px; }
.step-desc { color: var(--muted); font-size: 14px; }

.trust-title { font-weight: 700; margin-bottom: 12px; }
.trust-desc { color: var(--muted); font-size: 14px; }

/* ---- Connect cards (2a) ---- */
.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
}

.provider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.provider-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
}

.provider-icon.google { background: #eef2ff; color: #3b57e0; }
.provider-icon.naver { background: var(--navy); }

.card h2 { font-size: 24px; margin: 0 0 8px; }
.card .desc { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.info-box {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 24px;
  line-height: 1.7;
}

.info-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.info-badge-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: info-badge-blink 1.4s ease-in-out infinite;
}

@keyframes info-badge-blink {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.45); }
  50% { opacity: 0.5; box-shadow: 0 0 0 6px rgba(29, 78, 216, 0); }
}

.info-tooltip {
  display: none;
  position: absolute;
  top: 28px;
  left: 0;
  z-index: 20;
  width: 640px;
  max-width: 90vw;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 16px;
}

.info-badge:hover .info-tooltip,
.info-badge:focus .info-tooltip,
.info-badge:focus-within .info-tooltip {
  display: block;
}

.info-tooltip-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--text);
}

.info-tooltip img {
  display: block;
  width: 100%;
  border-radius: 6px;
  margin-bottom: 10px;
}

.info-tooltip img:last-child { margin-bottom: 0; }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.field input:focus { outline: 2px solid var(--teal); border-color: var(--teal); }

.card-actions { display: flex; gap: 12px; margin-top: 28px; }
.card-actions .btn { flex: 1; }

.alert-error {
  background: var(--err-bg);
  color: var(--err-text);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}

/* ---- Dashboard (3) ---- */
.dash-header {
  padding: 40px 0 12px;
}

.dash-title { font-size: 26px; font-weight: 800; margin: 0 0 6px; }
.dash-sub { color: var(--muted); font-size: 14px; margin-bottom: 32px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  border-radius: 12px;
  padding: 22px 24px;
  border: 1px solid var(--border);
}

.stat-card .label { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.stat-card .value { font-size: 30px; font-weight: 800; }

.stat-card.total { background: var(--bg-soft); border-color: var(--border); }
.stat-card.on { background: var(--teal-light); border-color: transparent; }
.stat-card.on .value { color: var(--teal); }
.stat-card.on .label { color: var(--teal); }
.stat-card.ok { background: var(--ok-bg); border-color: transparent; }
.stat-card.ok .value { color: var(--ok-text); }
.stat-card.ok .label { color: var(--ok-text); }
.stat-card.err { background: var(--err-bg); border-color: transparent; }
.stat-card.err .value { color: var(--err-text); }
.stat-card.err .label { color: var(--err-text); }
.stat-card.warn { background: var(--warn-bg); border-color: transparent; }
.stat-card.warn .value { color: var(--warn-text); }
.stat-card.warn .label { color: var(--warn-text); }

.stat-card[data-filter] {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.stat-card[data-filter]:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); }
.stat-card[data-filter].is-selected { outline: 2px solid var(--navy); outline-offset: 2px; }

table.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 40px;
}

.report-table th {
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  padding: 12px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.report-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.report-table th.sortable::after {
  content: "\21C5";
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.35;
  display: inline-block;
}

.report-table th.sortable[data-dir="asc"]::after {
  content: "\25B2";
  opacity: 1;
}

.report-table th.sortable[data-dir="desc"]::after {
  content: "\25BC";
  opacity: 1;
}

.report-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

.report-table td.url-cell {
  max-width: 320px;
}

.url-cell-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.url-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-shortcut {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  line-height: 1;
}

.url-shortcut:hover { background: var(--teal-light); }

.status-pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.status-pill.err { background: var(--err-bg); color: var(--err-text); }
.status-pill.muted { background: var(--muted-bg); color: var(--muted-text); }
.status-pill.on { background: var(--ok-bg); color: var(--ok-text); }
.status-pill.off { background: var(--muted-bg); color: var(--muted-text); }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
}

.connect-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 40px;
}

.connect-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
}

.connect-panel h3 { margin: 0 0 6px; font-size: 16px; }
.connect-panel p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.account-list { list-style: none; margin: 0; padding: 0; }
.account-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.account-list li:last-child { border-bottom: none; }
.account-list .tag { color: var(--muted); font-size: 12px; }

/* ---- Loading spinner (연동/리포트 생성 버튼) ---- */
@keyframes lg-spin { to { transform: rotate(360deg); } }

.btn.is-loading,
.badge.is-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}

.btn.is-loading::after,
.badge.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: lg-spin 0.6s linear infinite;
}

.btn-outline.is-loading::after,
.badge.is-loading::after {
  border-color: rgba(15, 23, 42, 0.2);
  border-top-color: var(--navy);
}

/* ---- 캠페인 선택 (구글) ---- */
.campaign-select-actions { display: flex; gap: 12px; margin-bottom: 12px; }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.campaign-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 2px;
  margin-bottom: 24px;
}

.campaign-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.campaign-item:hover { border-color: #cbd5e1; }
.campaign-item:has(input:checked) { border-color: var(--teal); background: var(--teal-light); }
.campaign-item input { flex-shrink: 0; margin-top: 3px; width: 16px; height: 16px; accent-color: var(--teal); }

.campaign-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.campaign-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.campaign-meta { color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  .hero, .steps, .stat-grid, .connect-panels { grid-template-columns: 1fr; }
  .container { padding: 0 20px; }
}

.save-check { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 18px; font-size: 14px; font-weight: 700; cursor: pointer; }
.save-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--teal); flex-shrink: 0; }
.save-check small { display: block; font-weight: 400; color: #6b7280; margin-top: 2px; line-height: 1.4; }
.save-notice { background: #e6f6f3; color: #0f6b5c; border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; font-size: 14px; font-weight: 600; }
