/* ======================================================================
 * style.css — Modern v2 (F1 확정)
 * Pretendard CDN 로딩 + 단일 area transform + 11-state UI + 키캡 버튼
 * ====================================================================== */

:root {
  /* F1 색상 팔레트 */
  --primary:        #2563eb;
  --accent:         #3b82f6;
  --primary-hover:  #1e40af;
  --success:        #10b981;
  --success-bar:    #16a34a;
  --warning:        #f59e0b;
  --error:          #dc2626;

  --bg:             #fafbff;
  --panel:          #ffffff;
  --border:         #e0e7ff;
  --border-strong:  #cbd5e1;

  --text:           #1e293b;
  --text-muted:     #64748b;
  --text-faint:     #94a3b8;

  --warning-bg:     #fffbeb;
  --error-bg:       #fef2f2;
  --error-bg-light: #fef9f9;

  --radius:         16px;
  --radius-sm:      8px;
  --shadow-card:    0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-hover:   0 8px 24px rgba(15, 23, 42, 0.10);

  --duration:       200ms;
  --font-stack:     "Pretendard Variable", "Pretendard", -apple-system,
                    BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
                    "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-stack);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ── 헤더 ─────────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--success) 100%);
  color: #fff;
  padding: 32px 24px 28px;
}
.site-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}
.site-logo {
  flex: 0 0 auto;
  background: #fff;
  border-radius: 8px;
  padding: 4px 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.site-header__text { min-width: 0; }
.site-title {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.site-tagline {
  margin: 0;
  font-size: 14px;
  opacity: 0.92;
  font-weight: 400;
}

/* ── 컨테이너 ─────────────────────────────────────────────────── */
.container {
  max-width: 1080px;
  margin: 32px auto 80px;
  padding: 0 24px;
}

/* ── ★ 설명 4 섹션 ────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
}
.info-card__title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}
.info-card__list {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}
.info-card__list li + li { margin-top: 4px; }
/* 구버전 marketing tile 잔여 클래스 (호환용) */
.info-card__icon { font-size: 24px; margin-bottom: 6px; }
.info-card__desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ── Upload area (단일 area transform) ────────────────────────── */
.upload-area {
  background: var(--panel);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 56px 32px;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color var(--duration), background var(--duration);
}

/* state-dependent style — data-state 속성 기반 */
.upload-area[data-state="awaiting"],
.upload-area[data-state="queued"],
.upload-area[data-state="retry"],
.upload-area[data-state="processing"],
.upload-area[data-state="complete"] {
  border-style: solid;
  border-color: var(--border);
}
.upload-area[data-state="drag_valid"] {
  border-style: solid;
  border-color: var(--success-bar);
  background: #ecfdf5;
}
.upload-area[data-state="drag_invalid"],
.upload-area[data-state="pre_confirm_error"] {
  border-style: dashed;
  border-color: var(--error);
  background: linear-gradient(180deg, var(--error-bg) 0%, var(--error-bg-light) 100%);
}

/* pre-confirm-error 영역 내 메시지 — H.1 (planning doc line 525) */
.state--pre-confirm-error .state__title { color: var(--error); font-weight: 700; }
.state--pre-confirm-error .state__sub   { color: #991b1b; font-weight: 500; }
.state--pre-confirm-error .primary-btn  { background: #fff; color: var(--error); border: 1.5px solid var(--error); margin-top: 8px; }
.state--pre-confirm-error .primary-btn:hover { background: var(--error); color: #fff; }
.upload-area[data-state="error"],
.upload-area[data-state="queue_full"] {
  border-style: solid;
  border-color: var(--error);
  background: var(--error-bg-light);
}
.upload-area[data-state="already_running"],
.upload-area[data-state="not_your_download"] {
  border-style: solid;
  border-color: var(--warning);
  background: var(--warning-bg);
}

/* ── State 공통 (fade transition E1) ─────────────────────────── */
.state {
  text-align: center;
  width: 100%;
  animation: fadeIn var(--duration) ease-out;
}
.state[hidden] { display: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.upload-area[data-state="pre_confirm_error"] .state {
  animation: shake 300ms ease-in-out;
}

.state__icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
}
.state__icon--success { color: var(--success); }
.state__icon--error   { color: var(--error); }
.state__icon--warning { color: var(--warning); }

.state__title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.state__sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.state__hint {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 12px;
}

/* ── 버튼 ─────────────────────────────────────────────────────── */
.link-btn {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 600;
  font-size: 14px;
}
.link-btn:hover { color: var(--primary-hover); }

.primary-btn {
  background: var(--primary);
  color: #fff;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--duration);
}
.primary-btn:hover { background: var(--primary-hover); }

/* ── Progress 5단계 (C3 색상 + C4 고정 정렬) ─────────────────── */
.progress-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  text-align: left;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
}
.progress-row {
  display: grid;
  grid-template-columns: 24px 110px 50px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
}
.progress-icon {
  text-align: center;
  color: var(--text-faint);
  font-size: 16px;
}
.progress-icon::before { content: "○"; }
.progress-row[data-status="current"] .progress-icon::before { content: "⏳"; color: var(--accent); }
.progress-row[data-status="done"]    .progress-icon::before { content: "✓"; color: var(--success-bar); }

.progress-label {
  color: var(--text-muted);
  font-weight: 500;
}
.progress-row[data-status="current"] .progress-label { color: var(--accent); font-weight: 600; }
.progress-row[data-status="done"]    .progress-label { color: var(--success-bar); font-weight: 600; }

.progress-pct {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text-faint);
  text-align: right;
}
.progress-row[data-status="current"] .progress-pct { color: var(--accent); }
.progress-row[data-status="done"]    .progress-pct { color: var(--success-bar); }

.progress-bar {
  background: #f1f5f9;
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  position: relative;
}
.progress-bar__fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--border-strong);
  border-radius: 999px;
  transition: width var(--duration);
}
.progress-row[data-status="current"] .progress-bar__fill {
  background: var(--accent);
  width: 100%;
  animation: barIndeterminate 1.2s ease-in-out infinite;
}
.progress-row[data-status="done"] .progress-bar__fill {
  background: var(--success-bar);
  width: 100%;
}
@keyframes barIndeterminate {
  0%   { opacity: 0.55; }
  50%  { opacity: 1; }
  100% { opacity: 0.55; }
}

/* ── 결과 카드 (D1 + D2) ─────────────────────────────────────── */
.complete__grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: center;
  text-align: left;
}
.complete__main {
  min-width: 0;
}
.complete__main .state__icon,
.complete__main .state__title {
  text-align: center;
}
.complete__main .state__title { margin-bottom: 14px; }

.company-name {
  text-align: center;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.kpi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}
/* 기본: Verify/Refer 숫자 컬럼은 가운데 정렬, 첫 컬럼(시트명)만 좌측 정렬 */
.kpi-table th,
.kpi-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.kpi-table th { background: #f1f5f9; font-weight: 600; }
.kpi-table thead th:first-child,
.kpi-table tbody td:first-child,
.kpi-table tfoot th:first-child {
  text-align: left;
}
/* 에러 시 — 배경색 없이 오류 셀 글자만 빨강 강조 */
.kpi-table tbody tr.has-err td:nth-child(3) {
  font-weight: 700;
  color: var(--error);
}
.kpi-table tfoot th { background: #f1f5f9; font-weight: 700; }

/* verify / refer 컬럼 — 색상 없이 헤더 라벨만 시각 구분 */
.kpi-table thead tr:first-child .kpi-col-verify,
.kpi-table thead tr:first-child .kpi-col-refer {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi-table thead tr:first-child .kpi-col-refer {
  border-left: 1px solid var(--border);
}
.kpi-table thead tr:nth-child(2) th:nth-child(3) {
  border-right: 1px solid var(--border);
}
.kpi-table tbody td:nth-child(3) { border-right: 1px solid var(--border); }
.kpi-table tfoot th:nth-child(3) { border-right: 1px solid var(--border); }
/* 에러는 글자 색만 (배경색 없음) — 이미 .has-err td:nth-child(3) 빨강 글자 처리됨.
   추가로 refer 오류 (col 5) 도 동일 처리. */
.kpi-table tbody tr.has-err td:nth-child(5) {
  font-weight: 700;
  color: var(--error);
}

/* verify/refer 분리 요약 카드 */
.kpi-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.kpi-summary__row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.kpi-summary__row.total {
  border-left: 2px solid var(--border-strong);
  padding-left: 8px;
}
.kpi-summary__label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-summary__val {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text);
}
.kpi-summary__val b { font-weight: 700; }
.kpi-summary__val b.err {
  color: var(--text);
}
.kpi-summary__row.total .kpi-summary__val b { font-size: 14px; }
.err-positive { color: var(--error) !important; font-weight: 700; }

.refresh-note {
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
}

/* ── 키캡 다운로드 버튼 (D3) ─────────────────────────────────── */
.keycap-btn {
  display: inline-block;
  width: 160px;
  padding: 18px 14px;
  text-align: center;
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.45;
  border-radius: 10px;
  background: linear-gradient(180deg, #60a5fa 0%, var(--accent) 55%, var(--primary) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 rgba(0, 0, 0, 0.22),
    0 5px 0 #1e40af,
    0 8px 18px rgba(59, 130, 246, 0.35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  transition: transform 90ms ease-out, box-shadow 90ms ease-out, background 90ms ease-out;
  align-self: center;
  user-select: none;
}
.keycap-btn:hover {
  background: linear-gradient(180deg, #93c5fd 0%, #60a5fa 55%, var(--accent) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(0, 0, 0, 0.22),
    0 6px 0 #1e40af,
    0 10px 22px rgba(59, 130, 246, 0.45);
}
.keycap-btn:active {
  transform: translateY(5px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 0 rgba(0, 0, 0, 0.22),
    0 0 0 #1e40af,
    0 4px 10px rgba(59, 130, 246, 0.30);
}
.keycap-btn__icon {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}
.keycap-btn__line {
  display: block;
}
.keycap-btn__line--muted {
  opacity: 0.85;
  font-size: 12px;
  margin-top: 4px;
}

/* awaiting 확인 버튼 — 다운로드 버튼과 동일 키캡 스타일, 파일명 위 배치 */
.keycap-btn--confirm {
  margin: 4px 0 16px;
}

/* ── Toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  min-width: 280px;
  max-width: 360px;
  background: #fff;
  border-left: 4px solid var(--error);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-hover);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastSlideIn 200ms ease-out;
  z-index: 1000;
}
.toast[hidden] { display: none; }
.toast__icon { font-size: 20px; color: var(--error); }
.toast__title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.toast__msg   { font-size: 13px; color: var(--text-muted); }

@keyframes toastSlideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Footer ───────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ── G3 비활성화 (사용자 요청, 28차 후속 5) ─────────────────────
 * mobile fallback 메시지 ("PC 에서 .dsd 검증 가능") 영구 비활성화.
 * 모든 화면 너비에서 dropzone (".dsd 파일을 여기에 드래그") 표시 유지.
 * DOM 의 .state--mobile-fallback 자체는 보존 (CSS 만으로 비활성, 향후 재활성 용이).
 */
.state--mobile-fallback { display: none !important; }

/* 좁은 너비 (≤1023px) — info-grid + summary 카드만 1열 stack, dropzone 정상 작동 */
@media (max-width: 1023px) {
  .info-grid { grid-template-columns: 1fr 1fr; }
  .upload-area { padding: 40px 20px; }
  .complete__grid { grid-template-columns: 1fr; }
  .keycap-btn { width: auto; margin: 16px auto 0; }
  .kpi-table { font-size: 12.5px; }
  .kpi-summary { grid-template-columns: 1fr; gap: 4px; }
  .kpi-summary__row.total { border-left: none; border-top: 1px solid var(--border-strong); padding: 6px 0 0; }
}

@media (max-width: 599px) {
  .info-grid { grid-template-columns: 1fr; }
  .site-header { padding: 24px 16px; }
  .container { padding: 0 16px; margin: 24px auto 60px; }
  .site-title { font-size: 22px; }
  .kpi-table { font-size: 11.5px; }
  .kpi-table th, .kpi-table td { padding: 4px 6px; }
}
