/* ── 리셋 & 변수 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --page-w: 1560px;   /* 화면 내용 최대 폭 (2026-10-17 1100 → 1560: 넓은 모니터에서 표·달력을 크게) */
  --bg:       #f5f6fa;
  --surface:  #ffffff;
  --border:   #e2e4ea;
  --text:     #1a1d2e;
  --muted:    #6b7280;
  --accent:   #4f46e5;
  --accent-h: #4338ca;
  --green:    #16a34a;
  --red:      #dc2626;
  --amber:    #d97706;
  --radius:   10px;
  --shadow:   0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
}

/* ── 헤더 ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: var(--page-w); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
}
.logo {
  font-weight: 700; font-size: 17px;
  color: var(--accent); text-decoration: none; letter-spacing: -.3px;
}
nav { display: flex; gap: 4px; }
nav a {
  padding: 6px 14px; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-size: 14px;
  transition: background .15s, color .15s;
}
nav a:hover { background: var(--bg); color: var(--text); }

/* ── 레이아웃 ── */
main { max-width: var(--page-w); margin: 0 auto; padding: 32px 24px; }
.page-title {
  font-size: 22px; font-weight: 700; margin-bottom: 6px;
}
.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }

/* ── 카드 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

/* ── 폼 ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=number], input[type=password],
select, textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
textarea { resize: vertical; min-height: 80px; }
.optional-label { color: var(--muted); font-weight: 400; }

.file-input-wrap {
  border: 2px dashed var(--border);
  border-radius: 7px;
  padding: 24px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
  user-select: none;
}
.file-input-wrap:hover,
.file-input-wrap.drag-over {
  border-color: var(--accent);
  background: #f5f3ff;
}
.file-input-wrap.drag-over { border-style: solid; }
.file-input-wrap input[type=file] { display: none; }

.file-drop-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.file-drop-icon { font-size: 28px; line-height: 1; }
.file-label { color: var(--muted); font-size: 14px; cursor: pointer; }
.file-label u { color: var(--accent); text-decoration-color: var(--accent); }
.file-sub { font-size: 12px; color: #9ca3af; }

.file-selected {
  display: flex; align-items: center; gap: 10px;
  justify-content: center;
}
.file-icon { font-size: 18px; color: var(--green); }
#file-name-display { font-size: 14px; color: var(--text); font-weight: 500; word-break: break-all; }
.file-clear {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
  transition: color .15s, background .15s;
}
.file-clear:hover { color: var(--red); background: #fee2e2; }

/* ── 참고자료 드롭존 ── */
.ref-drop-zone {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .82rem;
  background: #f3f4f6;
  border: 1px dashed #9ca3af;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.ref-drop-zone:hover { border-color: var(--accent); background: #f5f3ff; }
.ref-drop-zone.drag-over {
  border-color: var(--accent);
  border-style: solid;
  background: #f5f3ff;
}

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 7px;
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-skip { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.btn-skip:hover { background: #f3f4f6; color: var(--text); }
.btn-lg { padding: 13px 28px; font-size: 16px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ── 로그인 ── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 360px; padding: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.login-logo { font-size: 22px; font-weight: 700; color: var(--accent); margin-bottom: 24px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; }

/* ── 인덱스 페이지 2컬럼 ── */
.index-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.tips-card { padding: 22px; }
.tips-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--accent); }
.tips-card ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.tips-card li { font-size: 13px; color: var(--muted); line-height: 1.5; padding-left: 16px; position: relative; }
.tips-card li::before { content: "•"; position: absolute; left: 0; color: var(--accent); }

/* ── 진행 페이지 ── */
.run-header { margin-bottom: 20px; }
.run-project { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* 전체 진행 헤더 */
.progress-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  margin-bottom: 16px;
}

/* 스텝 원형 행 */
.progress-steps-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.ps-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.ps-dot {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--muted);
  transition: all .25s;
  position: relative;
}
.ps-label {
  font-size: 10px; color: var(--muted); font-weight: 500;
  white-space: nowrap; transition: color .2s;
  max-width: 48px; text-align: center; overflow: hidden;
  text-overflow: ellipsis;
}
.ps-line {
  flex: 1; height: 2px;
  background: var(--border);
  min-width: 12px; max-width: 32px;
  margin: 0 2px;
  margin-bottom: 18px;
  transition: background .25s;
  flex-shrink: 0;
}
.ps-item.active .ps-dot {
  border-color: var(--accent);
  background: #ede9fe;
  color: var(--accent);
  box-shadow: 0 0 0 4px rgba(79,70,229,.15);
  animation: ps-pulse 1.5s ease-in-out infinite;
}
.ps-item.active .ps-label { color: var(--accent); font-weight: 700; }
.ps-item.done .ps-dot {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-size: 12px;
}
.ps-item.done .ps-label { color: var(--green); }
.ps-item.done + .ps-line { background: var(--green); }
.ps-item.error .ps-dot {
  border-color: var(--red);
  background: #fee2e2;
  color: var(--red);
}
.ps-item.skip .ps-dot { opacity: .5; }

@keyframes ps-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(79,70,229,.15); }
  50%       { box-shadow: 0 0 0 8px rgba(79,70,229,.08); }
}

/* 진행 바 */
.progress-bar-wrap {
  height: 6px; background: var(--bg);
  border-radius: 99px; overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 99px;
  transition: width .5s ease;
  width: 0%;
}
.progress-bar-fill.done { background: var(--green); }

/* 상태 + 시간 힌트 */
.progress-meta {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 6px;
}
.step-status-text {
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.step-status-text.active {
  color: var(--accent);
  display: flex; align-items: center; gap: 6px;
}
.step-status-text.active::before {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.step-status-text.done { color: var(--green); }
.step-status-text.retrying {
  color: var(--amber);
  display: flex; align-items: center; gap: 6px;
}
.step-status-text.retrying::before {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--amber);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .9s linear infinite;
  flex-shrink: 0;
}
.time-estimate { font-size: 12px; color: var(--muted); }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 스텝 필 */
.steps-bar {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.step-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--border);
  transition: all .2s;
}
.step-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
}
.step-pill.active { background: #ede9fe; color: var(--accent); border-color: #c4b5fd; }
.step-pill.active .dot {
  background: transparent;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  animation: spin .7s linear infinite;
  width: 10px; height: 10px;
}
.step-pill.done { background: #dcfce7; color: var(--green); border-color: #bbf7d0; }
.step-pill.done .dot { background: var(--green); }
.step-pill.error { background: #fee2e2; color: var(--red); border-color: #fecaca; }
.step-pill.error .dot { background: var(--red); }
.step-pill.skip { background: var(--bg); color: var(--muted); opacity: .6; }
.step-pill.skipped { background: #f3f4f6; color: var(--muted); border-color: #d1d5db; }
.step-pill.skipped .dot { background: #9ca3af; }
.step-pill.retrying { background: #fffbeb; color: var(--amber); border-color: #fde68a; }
.step-pill.retrying .dot {
  background: transparent;
  border: 2px solid var(--amber);
  border-top-color: transparent;
  animation: spin .9s linear infinite;
  width: 10px; height: 10px;
}

/* 재시도 구분선 */
.retry-divider {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--amber); font-weight: 600;
  padding: 4px 0;
}
.retry-divider::before,
.retry-divider::after {
  content: ''; flex: 1; height: 1px; background: #fde68a;
}


/* 결과 피드 */
.results-feed { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* overflow: hidden 제거 — 내용이 잘리는 원인 */
}
.result-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  user-select: none;
}
.result-card-header h4 { font-size: 14px; font-weight: 700; }
.result-card-header .elapsed { font-size: 12px; color: var(--muted); font-weight: 400; }
.result-card-body {
  padding: 18px 20px;
  font-size: 14px;
  line-height: 1.7;
}
.result-card-body .summary-val {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}
.result-card-body .summary-list li {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  padding: 4px 0 4px 14px;
}

.summary-row {
  display: flex; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--bg);
}
.summary-row:last-child { border-bottom: none; }
.summary-key {
  min-width: 110px; font-size: 12px; font-weight: 700;
  color: var(--muted); padding-top: 3px; flex-shrink: 0;
}
.summary-val { font-size: 14px; color: var(--text); flex: 1; line-height: 1.7; }
.summary-list { font-size: 14px; flex: 1; list-style: none; }
.summary-list li { padding: 4px 0 4px 14px; position: relative; line-height: 1.7; }
.summary-list li::before { content: "•"; position: absolute; left: 0; color: var(--accent); }

.step-error-card {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 13px; color: var(--red);
}

/* 처리 중 카드 */
.processing-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid #c4b5fd;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px; color: var(--accent); font-weight: 600;
}
.processing-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* 토스트 */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  background: #1a1d2e; color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  opacity: 0; transform: translateX(16px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
  max-width: 300px;
}
.toast.toast-show    { opacity: 1; transform: translateX(0); }
.toast.toast-success { background: var(--green); }
.toast.toast-error   { background: var(--red); }
.toast.toast-info    { background: #2563eb; }

/* 컨펌 패널 */
.confirm-panel {
  position: sticky; bottom: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -4px 24px rgba(0,0,0,.1);
  padding: 20px 24px;
  display: none;
}
.confirm-panel.visible { display: block; }
.confirm-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; color: var(--accent); }
.slogans-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.slogan-btn {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  text-align: left; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.slogan-btn:hover { border-color: var(--accent); background: #ede9fe; }
.slogan-btn strong { font-size: 14px; color: var(--text); }
.slogan-btn small { font-size: 12px; color: var(--muted); }
.confirm-row { display: flex; gap: 10px; align-items: center; }
.confirm-row input { flex: 1; }
.confirm-hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* 완료 배너 */
.done-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  display: none;
}
.done-banner.visible { display: block; }
.done-banner h3 { font-size: 20px; font-weight: 700; color: var(--green); margin-bottom: 8px; }
.done-banner p { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

/* 오류 배너 */
.error-banner {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 24px; text-align: center;
  display: none;
}
.error-banner.visible { display: block; }
.error-banner h3 { color: var(--red); margin-bottom: 8px; }

/* ── 이력 페이지 ── */
.search-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.search-bar input { flex: 1; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; font-weight: 700;
  color: var(--muted); padding: 10px 14px;
  border-bottom: 2px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--bg); font-size: 14px; }
tr:hover td { background: var(--bg); }
.history-row:hover td { background: #f5f3ff; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
}
.badge-blue  { background: #ede9fe; color: var(--accent); }
.badge-gray  { background: var(--bg); color: var(--muted); }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }

/* ── 큐 대기 배너 ── */
.queue-banner {
  display: flex; align-items: center; gap: 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.queue-icon { font-size: 28px; }
.queue-banner strong { font-size: 15px; color: #92400e; }

/* ── 헤더 사용자명 ── */
.nav-user {
  font-size: 13px; color: var(--muted);
  padding: 6px 8px;
}
.nav-admin { color: #d97706 !important; font-weight: 600; }

/* ── 반응형 ── */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .index-layout { grid-template-columns: 1fr; }
  .steps-bar { gap: 4px; }
  .step-pill { font-size: 11px; padding: 4px 8px; }
  main { padding: 20px 16px; }
}

/* ── 한글 이름·낱말이 글자 단위로 끊겨 세로로 떨어지지 않게 (모든 화면 공통) ──
   표 칸은 띄어쓰기에서만 줄을 바꾸고, 사람 이름 칸은 한 줄로 두되 너무 길면 '…'으로 줄임 */
td, th { word-break: keep-all; }
.who, td.who, .c-who, .assignee, .list-assignee {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em;
}
td.who { max-width: 8em; }
/* 메뉴·표시 배지도 글자 단위로 꺾이지 않게 — 화면이 좁으면 메뉴 줄을 통째로 내림 */
nav a, .division-tab, .sub-nav a, .nav-user, .logo,
.badge, .pill, .arc-badge, .og-card-meta span, .badge-src, .det-badge { white-space: nowrap; }
.sub-nav-inner { overflow-x: auto; }
@media (max-width: 1120px) { nav a { padding: 6px 9px; } .division-tab { padding: 6px 10px; } }
@media (max-width: 920px) {
  .header-inner { height: auto; min-height: 56px; flex-wrap: wrap; row-gap: 4px; padding: 6px 12px; }
  nav, .division-menu { flex-wrap: wrap; }
}
