/* ===== 기본 리셋 & 변수 ===== */
:root {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-border: #d1d5db;
  --color-error: #dc2626;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

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

/* hidden 속성은 항상 우선 (display 지정 요소도 숨김) */
[hidden] {
  display: none !important;
}

body {
  font-family: "Segoe UI", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

.view {
  min-height: 100vh;
}

/* ===== 로그인 화면 ===== */
#loginView {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
}

.card__title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

.card__subtitle {
  margin-top: 8px;
  margin-bottom: 28px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ===== 폼 ===== */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.field__input {
  padding: 11px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: border-color 0.15s ease;
}

.field__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ===== 버튼 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

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

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

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  padding: 8px 14px;
  font-size: 0.85rem;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 스피너 */
.btn__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ===== 에러 메시지 ===== */
.error {
  color: var(--color-error);
  font-size: 0.85rem;
  background: rgba(220, 38, 38, 0.08);
  border-radius: var(--radius);
  padding: 10px 12px;
}

/* ===== 메인 화면 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--color-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.topbar__title {
  font-size: 1.2rem;
  font-weight: 700;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar__user {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.content {
  padding: 32px 24px 60px;
}

/* ===== 단계 표시기 ===== */
.steps {
  display: flex;
  justify-content: center;
  gap: 0;
  list-style: none;
  max-width: 640px;
  margin: 0 auto 32px;
}

.steps__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  position: relative;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* 단계 사이 연결선 */
.steps__item::before {
  content: "";
  position: absolute;
  top: 16px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}

.steps__item:first-child::before {
  display: none;
}

.steps__num {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: all 0.2s ease;
}

.steps__item.is-active {
  color: var(--color-primary);
  font-weight: 700;
}

.steps__item.is-active .steps__num {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.steps__item.is-done .steps__num {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.steps__item.is-done::before,
.steps__item.is-active::before {
  background: var(--color-primary);
}

/* ===== 슬라이드(단계) ===== */
.wizard {
  overflow: hidden;
}

.step {
  display: none;
}

.step.is-active {
  display: block;
}

.step.slide-next {
  animation: slideInRight 0.28s ease;
}

.step.slide-prev {
  animation: slideInLeft 0.28s ease;
}

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-48px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== 단계 이동 버튼 ===== */
.wizard__nav {
  display: flex;
  justify-content: space-between;
  max-width: 1200px;
  margin: 28px auto 0;
}

.wizard__nav .btn {
  min-width: 110px;
}

/* prev 버튼이 숨겨졌을 때 next 버튼을 오른쪽으로 밀기 */
.wizard__nav #prevBtn[hidden] + #nextBtn {
  margin-left: auto;
}

.content__placeholder {
  text-align: center;
  color: var(--color-text-muted);
  line-height: 1.7;
}

/* ===== 패널 ===== */
.panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  max-width: 560px;
  margin: 0 auto;
}

.panel__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.field__row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.field__row .field__input {
  flex: 1;
}

/* select도 field__input 스타일을 공유하되 화살표 여백 확보 */
select.field__input {
  background: var(--color-surface);
  cursor: pointer;
}

select.field__input:disabled {
  background: var(--color-bg);
  cursor: not-allowed;
  color: var(--color-text-muted);
}

.field__row .btn--ghost {
  white-space: nowrap;
}

/* ===== 선택 정보 ===== */
.selected {
  margin-top: 18px;
  padding: 12px 14px;
  background: rgba(37, 99, 235, 0.08);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.selected__code {
  color: var(--color-text-muted);
}

/* ===== 패널 (검색/결과는 더 넓게) ===== */
.result-panel,
.content .panel:nth-of-type(2) {
  max-width: 1200px;
}

.panel + .panel {
  margin-top: 20px;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel__count {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

/* ===== 엑셀 다운로드 버튼 ===== */
.btn--excel {
  background: #1d6f42;
  color: #fff;
  padding: 9px 16px;
  font-size: 0.85rem;
  box-shadow: 0 1px 3px rgba(29, 111, 66, 0.3);
}

.btn--excel:hover:not(:disabled) {
  background: #175935;
}

.btn--excel__icon {
  font-size: 0.95rem;
  line-height: 1;
}

.btn--excel:disabled {
  background: var(--color-border);
  color: var(--color-text-muted);
  box-shadow: none;
}

/* 날짜 입력 2열 그리드 */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

/* ===== 수수료 단가 설정 ===== */
.fee-config {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.fee-config__group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
}

.fee-config__title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.fee-config__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.fee-config__row:last-child {
  margin-bottom: 0;
}

.fee-config__input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.fee-config__input input {
  width: 90px;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  text-align: right;
}

.fee-config__input input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.fee-config__input em {
  font-style: normal;
  color: var(--color-text-muted);
}

.formula {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--color-bg);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.formula strong {
  color: var(--color-text);
}

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

/* ===== 상태 메시지 ===== */
.status {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--color-primary);
}

/* ===== 결과 표 ===== */
.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
}

.table th,
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.table thead th {
  background: var(--color-bg);
  font-weight: 700;
  position: sticky;
  top: 0;
}

.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}

.table .empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 24px;
}

.cell-error {
  color: var(--color-error) !important;
}

/* 수수료 컬럼 강조 */
.table th.fee,
.table td.fee {
  background: rgba(37, 99, 235, 0.05);
}

.table td.fee {
  font-weight: 600;
}

.foot-total td {
  font-weight: 700;
  border-top: 2px solid var(--color-border);
  background: var(--color-bg);
}
