/* 공통 화면은 차분한 배경과 작은 간격 차이로 정보의 위계를 만듭니다. */
/* 기능별 색상은 버튼·상태·브랜드 표시처럼 의미가 있는 곳에만 사용합니다. */
/* 반응형 규칙은 기존 입력과 표가 작은 화면에서도 읽히도록 최소한만 둡니다. */
:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --surface: #ffffff;
  --soft: #f8fafc;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --success: #047857;
  --danger: #b91c1c;
  --shadow: 0 18px 50px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f8fafc 0%, #f3f5f9 100%);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

header {
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1180px;
  min-height: 76px;
  margin: 0 auto;
  padding: 0 32px;
}

.brand-link,
.nav-links,
.nav-link,
.provider-heading,
.status-summary,
.check-label {
  display: flex;
  align-items: center;
}

.brand-link {
  gap: 10px;
  color: #111827;
  font-size: 17px;
  font-weight: 750;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  box-shadow: 0 7px 16px rgba(79, 70, 229, 0.25);
  font-size: 14px;
  font-weight: 800;
}

.nav-links {
  gap: 6px;
}

.nav-link {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--accent-dark);
  background: var(--accent-soft);
  outline: none;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 32px 72px;
}

.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.page-intro h1,
.section-heading h2,
.provider-card h2 {
  margin: 0;
  color: #111827;
  letter-spacing: -0.045em;
}

.page-intro h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
}

.page-description,
.section-heading p,
.provider-card p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.hero-badge,
.provider-tag,
.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hero-badge {
  padding: 7px 11px;
  color: #4338ca;
  background: var(--accent-soft);
}

.panel,
.provider-card,
.table-card {
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 28px;
}

.section-heading {
  margin-bottom: 22px;
}

.section-heading h2,
.provider-card h2 {
  font-size: 20px;
}

.settings-form,
.provider-form {
  margin: 0;
}

.settings-grid,
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

.settings-group {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
}

.provider-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.provider-heading strong {
  font-size: 15px;
}

.provider-tag {
  padding: 4px 8px;
  color: #4b5563;
  background: #e5e7eb;
  letter-spacing: 0;
}

.field {
  min-width: 0;
}

.field label,
.check-label {
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
}

.field label {
  display: block;
  margin-bottom: 7px;
}

input:not([type="checkbox"]),
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #d7dce5;
  border-radius: 10px;
  color: var(--ink);
  background: white;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:not([type="checkbox"]):hover,
select:hover {
  border-color: #a5b4fc;
}

input:not([type="checkbox"]):focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}

.check-field {
  display: flex;
  align-items: flex-end;
  min-height: 66px;
}

.check-label {
  gap: 9px;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

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

button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.18);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

button:hover,
button:focus-visible {
  background: var(--accent-dark);
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.24);
  outline: none;
  transform: translateY(-1px);
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.provider-card {
  padding: 24px;
}

.provider-card h2 {
  display: flex;
  align-items: center;
  gap: 9px;
}

.provider-card h2::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.provider-card .field-grid {
  margin-top: 20px;
}

.provider-card .check-field {
  align-items: center;
  min-height: 42px;
}

.provider-card .form-actions {
  margin-top: 20px;
}

#task-progress {
  margin-top: 20px;
}

#task-progress h2 {
  margin: 0;
  font-size: 18px;
}

#task-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#task-progress-events {
  margin: 18px 0 0;
  padding-left: 20px;
  color: #4b5563;
  font-size: 13px;
}

#task-progress-events li + li {
  margin-top: 7px;
}

pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: 10px;
  color: #dbeafe;
  background: #172033;
  font: 12px/1.65 "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.table-card {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1050px;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid #eef0f4;
  text-align: left;
  vertical-align: top;
}

th {
  color: #6b7280;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafbff;
}

td pre {
  max-width: 480px;
  max-height: 132px;
  padding: 0;
  color: #4b5563;
  background: transparent;
  font: inherit;
  line-height: 1.55;
}

td code {
  color: #4f46e5;
  font-size: 11px;
}

td a {
  color: var(--accent-dark);
  font-weight: 750;
  text-decoration: none;
}

td a:hover,
td a:focus-visible {
  text-decoration: underline;
}

.status-badge {
  padding: 5px 9px;
  color: var(--success);
  background: #ecfdf5;
  letter-spacing: 0;
}

.status-badge.is-failed {
  color: var(--danger);
  background: #fef2f2;
}

/* 상태 JSON은 현재 화면의 흐름을 유지하도록 중앙 dialog 안에 표시합니다. */
/* 긴 진행 기록은 화면 높이를 넘지 않고 JSON 영역 안에서만 스크롤됩니다. */
/* 링크와 닫기 버튼은 기존 강조색을 재사용해 새 동작만 명확히 구분합니다. */
.status-json-link {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--accent-soft);
  white-space: nowrap;
}

.status-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  padding: 32px 16px;
  place-items: center;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(3px);
}

.status-dialog-backdrop[hidden] {
  display: none;
}

.status-dialog {
  width: min(720px, 100%);
  max-height: calc(100vh - 64px);
  padding: 24px;
  overflow: hidden;
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

.status-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.status-dialog-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

.status-dialog-close {
  min-height: 36px;
  padding: 0 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  box-shadow: none;
}

.status-dialog-close:hover,
.status-dialog-close:focus-visible {
  color: white;
  background: var(--accent);
  box-shadow: none;
  transform: none;
}

#status-dialog-content {
  max-height: calc(100vh - 210px);
  white-space: pre-wrap;
}

/* 결과 화면은 긴 응답을 넓은 카드 안에서 읽기 쉽게 표시합니다. */
/* 목록 링크는 기존 표 링크와 같은 강조색을 사용합니다. */
/* 응답 줄바꿈은 보존하고, 긴 단어는 화면 밖으로 넘치지 않게 합니다. */
.result-card {
  padding: 24px;
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.result-content {
  max-height: none;
  min-height: 180px;
}

.back-link,
.result-link {
  color: var(--accent-dark);
  font-weight: 750;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible,
.result-link:hover,
.result-link:focus-visible {
  text-decoration: underline;
}

.empty-state {
  margin: 0;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}

/* 로그인 화면은 카드 하나만 화면 가운데에 좁게 배치합니다. */
/* 입력·버튼 스타일은 기존 field·button 규칙을 그대로 재사용합니다. */
/* 오류 문구는 실패 배지와 같은 danger 색으로만 구분합니다. */
.page-login {
  display: flex;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.login-card .brand-link {
  margin-bottom: 20px;
}

.login-card .field {
  margin-bottom: 16px;
}

.form-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--danger);
  background: #fef2f2;
  font-size: 13px;
  font-weight: 650;
}

/* 헤더 오른쪽에 로그인 사용자명과 POST 로그아웃 버튼을 나란히 둡니다. */
/* 로그아웃 버튼은 배경 없는 nav-link 느낌으로 화면 위계를 해치지 않습니다. */
/* 사용자명은 보조 정보라 muted 색의 작은 글씨로만 보여 줍니다. */
.nav-session {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 좁은 화면에서 한글이 음절 단위로 꺾여 헤더가 무너지지 않게 고정합니다. */
.nav-link,
.nav-user,
.logout-button {
  white-space: nowrap;
}

.nav-user {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.logout-button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: 14px;
}

.logout-button:hover,
.logout-button:focus-visible {
  color: var(--accent-dark);
  background: var(--accent-soft);
  box-shadow: none;
  transform: none;
}

@media (max-width: 760px) {
  .site-nav,
  .page-shell {
    padding-right: 18px;
    padding-left: 18px;
  }

  .site-nav {
    min-height: 68px;
  }

  .nav-link {
    padding: 0 9px;
  }

  /* 좁은 화면에서는 사용자명을 숨기고 로그아웃 버튼만 촘촘하게 남깁니다. */
  .nav-user {
    display: none;
  }

  .nav-session {
    gap: 6px;
  }

  .logout-button {
    padding: 0 9px;
  }

  .page-shell {
    padding-top: 34px;
  }

  .page-intro {
    display: block;
  }

  .hero-badge {
    margin-top: 16px;
  }

  .panel,
  .provider-card {
    padding: 20px;
  }

  .settings-grid,
  .field-grid,
  .provider-grid {
    grid-template-columns: 1fr;
  }
}
