*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1a202c;
  --color-text-muted: #718096;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-badge-bg: #eef2ff;
  --color-badge-text: #4338ca;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

/* Header */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: -0.3px;
}

/* Main */
.main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Page header */
.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.3px;
}

.page-subtitle {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* Card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body {
  padding: 20px 24px;
}

/* Project list */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.project-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.project-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.project-card-domain {
  font-size: 12px;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.project-card-meta {
  display: flex;
  gap: 16px;
}

.meta-item {
  font-size: 12px;
  color: var(--color-text-muted);
}

.meta-item span {
  font-weight: 600;
  color: var(--color-text);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--color-text-muted);
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

/* Project detail */
.detail-header {
  margin-bottom: 28px;
}

.detail-domain {
  font-size: 13px;
  color: var(--color-primary);
  margin-top: 2px;
}

.detail-description {
  margin-top: 8px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.section {
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* Table */
.table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
}

td {
  padding: 11px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #fafbff;
}

.td-muted {
  color: var(--color-text-muted);
}

/* Inline add row */
.add-row td {
  background: var(--color-bg);
  padding: 8px 16px;
}

.add-row:hover td {
  background: var(--color-bg);
}

.inline-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  font-family: inherit;
}

.inline-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
}

.badge-active {
  background: #d1fae5;
  color: #065f46;
}

.badge-inactive {
  background: #fee2e2;
  color: #991b1b;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.btn-danger:hover {
  background: #fecaca;
}

.row-actions {
  white-space: nowrap;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Page header row */
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

/* Form */
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  max-width: 520px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-optional {
  font-weight: 400;
  color: var(--color-text-muted);
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

textarea.form-input {
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.form-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 20px;
}

.back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: 8px;
}

.back-link:hover {
  color: var(--color-primary);
}

/* Debug box */
.debug-box {
  background: #f8faff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.debug-row {
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

.debug-row span {
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.debug-row strong {
  font-size: 13px;
  color: var(--color-text);
}

/* SERP layout */
.serp-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.serp-main {}
.serp-side {}

.paa-item {
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.paa-item:last-child {
  border-bottom: none;
}

.related-item {
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-primary);
}

.related-item:last-child {
  border-bottom: none;
}

@media (max-width: 900px) {
  .serp-layout {
    grid-template-columns: 1fr;
  }
}

/* Page Analysis */
.analysis-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.analysis-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.analysis-rank {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  width: 28px;
  flex-shrink: 0;
}

.analysis-domain {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.heading-tree {
  padding: 10px 16px;
}

.heading-item {
  font-size: 13px;
  color: var(--color-text);
  padding: 3px 0;
  line-height: 1.5;
  border-left: 3px solid transparent;
  padding-left: 8px;
}

.heading-h1 {
  font-weight: 700;
  color: var(--color-text);
  border-left-color: var(--color-primary);
  margin-top: 4px;
}

.heading-h2 {
  font-weight: 500;
  color: var(--color-text);
  padding-left: 20px;
  border-left-color: #93c5fd;
}

.heading-h3 {
  font-weight: 400;
  color: var(--color-text-muted);
  padding-left: 36px;
  border-left-color: #dbeafe;
}

.analysis-error {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--color-danger);
}

/* LLM / AI Visibility */
.badge-google {
  background: #e8f0fe;
  color: #1a73e8;
}

.badge-chatgpt {
  background: #d1f5ea;
  color: #0a7c59;
}

.llm-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.llm-metric-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
}

.llm-metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.llm-metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.5px;
}

/* 월별 검색량 추이 스파크라인 */
.sparkline {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 26px;
}

.sparkline span {
  display: block;
  width: 6px;
  min-height: 2px;
  border-radius: 1px;
  background: var(--color-primary);
  opacity: 0.3;
}

.sparkline span.is-last {
  opacity: 1;
}
/* ── 프로젝트 카드 상태 요약 (2026-09-20) ── */
/* 카드 전체를 클릭하면 상세로 가도록 name 링크의 ::after 로 카드 면을
   덮는다(Bootstrap stretched-link 방식). 칩 안의 '설정' 링크만
   z-index 로 그 위에 올려 클릭되게 한다. a 안에 a 중첩 없음. */
.project-card {
  position: relative;
}
a.project-card-name {
  display: block;
  text-decoration: none;
  color: var(--color-text);
}
a.project-card-name::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--radius);
}
.card-status {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}
.chip {
  font-size: 11px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-bg);
  white-space: nowrap;
  text-decoration: none;
}
.chip-ok {
  color: #15803d;
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.chip-off {
  color: #9ca3af;
  background: transparent;
  border-style: dashed;
}
.chip-stale {
  color: #b45309;
  background: #fffbeb;
  border-color: #fde68a;
}
/* 설정 링크는 stretched-link ::after 위에 올려 클릭 가능하게 한다. */
a.chip-set {
  position: relative;
  z-index: 2;
  color: var(--color-primary);
  background: #eff6ff;
  border-color: #bfdbfe;
  cursor: pointer;
}
a.chip-set:hover {
  background: #dbeafe;
}

/* ── 메뉴바 서브메뉴 (2026-09-21) ───────────────────────────────── */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.nav-item {
  position: relative;
}
.nav-item > .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: none;
  white-space: nowrap;
}
.nav-item > .nav-link:hover {
  background: var(--color-bg);
}
.nav-item.nav-item-admin > .nav-link {
  color: #9a3412;
}
.nav-caret {
  font-size: 9px;
  opacity: .55;
  transform: translateY(1px);
}
.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0;   /* 0 이어야 마우스가 링크→드롭다운 사이에서 hover 를 안 잃는다 (dead zone 없앰) */
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 240px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 6px;
  z-index: 200;
}
.nav-item:hover > .nav-dropdown,
.nav-item:focus-within > .nav-dropdown {
  display: block;
}
.nav-dropdown a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text);
  text-decoration: none;
}
.nav-dropdown a:hover {
  background: var(--color-bg);
  color: var(--color-primary);
}
.nav-dropdown a small {
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}
.nav-dropdown-label {
  display: block;
  padding: 6px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .4px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}
.nav-dropdown-sep {
  height: 1px;
  background: var(--color-border);
  margin: 5px 2px;
}
.nav-dropdown-empty {
  padding: 7px 10px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ── 프로젝트처럼 항목이 많은 메뉴는 메가 메뉴로 넓게 편다 (2026-09-21) ── */
.nav-dropdown-mega {
  width: min(920px, calc(100vw - 48px));
}
.nav-mega-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 6px;
}
.nav-mega-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.nav-mega-actions a {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
}
.nav-mega-actions a:hover {
  background: var(--color-bg);
}
.nav-mega-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2px;
  padding: 2px;
}
.nav-mega-item {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--color-text);
  min-width: 0;
}
.nav-mega-item:hover {
  background: var(--color-bg);
}
.nav-mega-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-mega-item:hover .nav-mega-name {
  color: var(--color-primary);
}
.nav-mega-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  min-width: 0;
}
.nav-mega-domain {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.nav-mega-badge {
  flex-shrink: 0;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  white-space: nowrap;
}

/* ── 메뉴바 재구성 (2026-10-03): 고객 메뉴 | 관리자 메뉴 | 계정 ─────────── */
.nav-link-active,
.nav-item > .nav-link.nav-link-active {
  background: #eff6ff;
  color: var(--color-primary);
  font-weight: 600;
}
.nav-item.nav-item-admin > .nav-link.nav-link-active {
  background: #fff7ed;
  color: #9a3412;
}
.nav-admin-divider {
  width: 1px;
  height: 22px;
  background: var(--color-border);
  margin: 0 10px 0 12px;
  flex-shrink: 0;
}
.nav-admin-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 2px 8px;
  margin-right: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
/* 설명(small)이 붙은 항목이 두 줄로 꺾이지 않게 폭을 넉넉히 */
.nav-dropdown { min-width: 300px; }
.nav-item-admin > .nav-dropdown { min-width: 330px; }
.nav-dropdown-right {
  left: auto;
  right: 0;
}
/* 3단 메뉴(기획·문서): 버튼 기준 가운데로 펼쳐 화면 밖으로 넘치지 않게 */
.nav-dropdown-cols {
  width: min(680px, calc(100vw - 48px));
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.nav-item:hover > .nav-dropdown-cols,
.nav-item:focus-within > .nav-dropdown-cols {
  display: grid;
}
.nav-account {
  flex-shrink: 0;
}
.nav-dropdown-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-danger);
  cursor: pointer;
}
.nav-dropdown-btn:hover {
  background: var(--color-bg);
}
@media (max-width: 1100px) {
  .nav { gap: 16px; }
  .nav-admin-tag { display: none; }
}

/* 성과 보고서 단독 메뉴 (2026-10-03) */
.nav-link.nav-link-report { font-weight: 700; color: #1d4ed8; }
.nav-link.nav-link-report:hover, .nav-link.nav-link-report.nav-link-active { background: #eff6ff; color: #1d4ed8; }

/* 리스닝마인드 구현 메뉴: 준비 중 항목(링크 아님) (2026-10-03) */
.nav-dropdown .nav-dropdown-todo { display:block; padding:7px 14px; font-size:13px; color:#94a3b8; cursor:default; white-space:nowrap; }
.nav-dropdown .nav-dropdown-todo small { color:#cbd5e1; margin-left:4px; }
