*, *::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;
}
