/* ─── Reset & Variables ───────────────────────────────── */

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

:root {
  --color-bg: #f8f9fb;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-secondary: #6b7280;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-border: #e5e7eb;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-accent: #8b5cf6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
  --transition: 200ms ease;
  --max-width: 1200px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Skip Link ───────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 100;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 8px;
}

/* ─── Screen Reader Only ──────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Header ──────────────────────────────────────────── */

.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 24px;
}

.header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.header__badge {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* ─── Main ────────────────────────────────────────────── */

.main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
}

/* ─── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition);
  line-height: 1.4;
}

.btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

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

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

.btn--outline {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

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

/* ─── Section Title ───────────────────────────────────── */

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--color-text);
}

/* ─── Onboarding ──────────────────────────────────────── */

.onboarding__card {
  background: var(--color-surface);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  max-width: 560px;
  margin: 64px auto;
}

.onboarding__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.onboarding__desc {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
  line-height: 1.7;
}

.onboarding__steps {
  text-align: left;
  max-width: 360px;
  margin: 0 auto 32px;
  padding-left: 24px;
  color: var(--color-text-secondary);
}

.onboarding__steps li {
  margin-bottom: 8px;
}

.onboarding__cta {
  font-size: 1rem;
  padding: 14px 32px;
}

/* ─── Summary Cards ───────────────────────────────────── */

.summary {
  margin-bottom: 32px;
}

.summary__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card__value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
}

.card__label {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

/* Skeleton loading */
.card__skeleton {
  display: none;
}

.card--loading .card__content {
  visibility: hidden;
}

.card--loading .card__skeleton {
  display: block;
  position: absolute;
  inset: 24px;
}

.card--loading .card__skeleton::before,
.card--loading .card__skeleton::after {
  content: "";
  display: block;
  background: linear-gradient(90deg, var(--color-bg) 25%, #e2e8f0 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.card--loading .card__skeleton::before {
  width: 60%;
  height: 28px;
  margin-bottom: 12px;
}

.card--loading .card__skeleton::after {
  width: 80%;
  height: 14px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Pending state (null analytics) */
.card--pending .card__value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

/* ─── Actions ─────────────────────────────────────────── */

.actions {
  margin-bottom: 32px;
}

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

/* ─── Timeline ────────────────────────────────────────── */

.timeline-section {
  margin-bottom: 32px;
}

.timeline {
  list-style: none;
  border-left: 2px solid var(--color-border);
  padding-left: 24px;
  margin-left: 8px;
}

.timeline__item {
  position: relative;
  padding-bottom: 20px;
}

.timeline__item::before {
  content: "";
  position: absolute;
  left: -31px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-surface);
}

.timeline__item--content_published::before {
  background: var(--color-success);
}

.timeline__item--pipeline_run::before {
  background: var(--color-accent);
}

.timeline__item--escalation::before {
  background: var(--color-warning);
}

.timeline__time {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-bottom: 2px;
}

.timeline__title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 2px;
}

.timeline__badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 6px;
  text-transform: uppercase;
}

.timeline__badge--content_published {
  background: #d1fae5;
  color: #065f46;
}

.timeline__badge--pipeline_run {
  background: #ede9fe;
  color: #5b21b6;
}

.timeline__badge--escalation {
  background: #fef3c7;
  color: #92400e;
}

.timeline__detail {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.timeline__product {
  font-size: 0.75rem;
  color: var(--color-primary);
  font-weight: 500;
}

/* Skeleton timeline items */
.timeline__item--skeleton {
  height: 60px;
  position: relative;
}

.timeline__item--skeleton::after {
  content: "";
  display: block;
  width: 80%;
  height: 14px;
  background: linear-gradient(90deg, var(--color-bg) 25%, #e2e8f0 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  margin-top: 8px;
}

.timeline__empty {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  padding: 24px 0;
}

/* ─── Error State ─────────────────────────────────────── */

.error-state {
  text-align: center;
  padding: 64px 24px;
}

.error-state__message {
  color: var(--color-text-secondary);
  margin-bottom: 16px;
  font-size: 1rem;
}

/* ─── Modal ───────────────────────────────────────────── */

.modal {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  max-width: 420px;
  width: 90%;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.modal__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal__field {
  margin-bottom: 16px;
}

.modal__field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text-secondary);
}

.modal__field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--color-surface);
  color: var(--color-text);
  appearance: auto;
}

.modal__field select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.modal__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ─── Footer ──────────────────────────────────────────── */

.footer {
  text-align: center;
  padding: 16px 24px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border);
}

/* ─── Responsive ──────────────────────────────────────── */

@media (max-width: 1024px) {
  .summary__grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 640px) {
  .summary__grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 20px 16px;
  }

  .header {
    padding: 12px 16px;
  }

  .onboarding__card {
    padding: 32px 20px;
    margin: 32px auto;
  }

  .card {
    padding: 20px;
  }

  .card__value {
    font-size: 1.5rem;
  }
}

/* ─── Reduced Motion ──────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .card--loading .card__skeleton::before,
  .card--loading .card__skeleton::after,
  .timeline__item--skeleton::after {
    animation: none;
  }
}
