* {
  box-sizing: border-box;
}

:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  font-weight: 400;
  color-scheme: light;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  --primary-color: #6366f1;
  --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --button-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --line-color: #e2e8f0;
  --input-bg: #f8fafc;
  --success-color: #10b981;
  --success-bg: #ecfdf5;
  --warning-color: #f59e0b;
  --warning-bg: #fffbeb;
  --error-color: #ef4444;
  --error-bg: #fef2f2;
  --shadow-soft: 0 16px 40px rgba(15, 23, 42, 0.05), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-button: 0 10px 24px rgba(99, 102, 241, 0.24);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(99, 102, 241, 0.08), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, var(--bg-color) 42%, #f4f7fb 100%);
  color: var(--text-main);
}

.charge-system,
.query-page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.page-header {
  text-align: center;
  margin-bottom: 26px;
}

.page-header-content {
  position: relative;
}

.page-title {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-main);
}

.page-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.inline-helper-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  margin-left: 6px;
}

.header-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  gap: 10px;
}

.header-btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line-color);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.header-btn:hover,
.primary-button:hover,
.secondary-button:hover,
.link-button:hover,
.secondary-link:hover,
.mini-button:hover,
.back-button:hover {
  transform: translateY(-1px);
}

.content-card,
.query-card {
  background: var(--card-bg);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.embedded-progress {
  padding: 32px 30px 28px;
  border-bottom: 1px solid var(--line-color);
}

.progress-timeline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0;
}

.timeline-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  text-align: center;
}

.timeline-marker {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.marker-circle {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--input-bg);
  border: 1px solid var(--line-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 600;
  position: relative;
  z-index: 2;
  transition: all 0.25s ease;
}

.connector-line {
  position: absolute;
  top: 50%;
  left: calc(50% + 23px);
  width: calc(100% - 46px);
  height: 2px;
  transform: translateY(-50%);
  background: var(--line-color);
  z-index: 1;
}

.timeline-item:last-child .connector-line {
  display: none;
}

.label-text {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.timeline-item.active .marker-circle {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}

.timeline-item.active .label-text {
  color: var(--primary-color);
  font-weight: 600;
}

.timeline-item.completed .marker-circle {
  background: linear-gradient(135deg, #34d399, #10b981);
  border-color: transparent;
  color: #ffffff;
}

.timeline-item.completed .label-text {
  color: var(--success-color);
  font-weight: 600;
}

.timeline-item.completed .connector-line {
  background: rgba(16, 185, 129, 0.45);
}

.step-content,
.query-card {
  padding: 28px;
}

.feedback-banner {
  border-radius: 16px;
  border: 1px solid var(--line-color);
  background: #f8fafc;
  padding: 16px 18px;
  margin-bottom: 24px;
}

.feedback-banner.warning {
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.24);
}

.feedback-banner.success {
  background: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.22);
}

.feedback-banner.error {
  background: var(--error-bg);
  border-color: rgba(239, 68, 68, 0.22);
}

.feedback-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.feedback-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.masked-code {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
}

.feedback-text {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.step-panel {
  display: none;
  animation: fade-in 0.3s ease;
}

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

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.back-button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line-color);
  background: #ffffff;
  color: var(--text-main);
  font-size: 18px;
  cursor: pointer;
}

.header-text {
  flex: 1;
}

.header-text h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.form-section,
.query-input-panel,
.query-result-panel {
  display: flex;
  flex-direction: column;
}

.input-wrapper {
  margin-bottom: 22px;
}

.input-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.required-mark {
  color: var(--error-color);
}

.modern-input,
.modern-textarea {
  width: 100%;
  border: 1px solid var(--line-color);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
  -webkit-appearance: none;
}

.modern-input {
  min-height: 54px;
  padding: 0 16px;
}

.modern-textarea {
  min-height: 180px;
  padding: 16px;
  resize: vertical;
}

.query-textarea {
  min-height: 168px;
}

.modern-input::placeholder,
.modern-textarea::placeholder {
  color: #94a3b8;
}

.modern-input:focus,
.modern-textarea:focus {
  border-color: var(--primary-color);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
}

.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(135deg, #eef2ff, #eff6ff);
  border: 1px solid rgba(99, 102, 241, 0.14);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 700;
}

.banner-text {
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.7;
}

.link-row,
.button-row,
.query-actions,
.copy-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.link-row {
  margin-bottom: 18px;
}

.link-button,
.secondary-link,
.primary-button,
.secondary-button,
.mini-button {
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.link-button,
.secondary-link {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.link-button,
.primary-button {
  background: var(--button-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-button);
}

.secondary-link,
.secondary-button,
.mini-button {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--line-color);
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}

.primary-button:disabled,
.secondary-button:disabled,
.mini-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.success-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border-radius: 14px;
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.22);
  margin-bottom: 18px;
}

.success-label {
  font-size: 12px;
  font-weight: 600;
  color: #047857;
}

.success-value {
  font-size: 15px;
  font-weight: 700;
  color: #065f46;
  word-break: break-word;
}

.status-card {
  padding: 22px 20px;
  border-radius: 16px;
  margin-bottom: 18px;
  text-align: center;
  border: 1px solid var(--line-color);
  background: #f8fafc;
}

.ready-card {
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  border-color: rgba(99, 102, 241, 0.18);
}

.processing-card {
  background: linear-gradient(135deg, #fff7ed, #fffbeb);
  border-color: rgba(245, 158, 11, 0.2);
}

.success-card-state {
  background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
  border-color: rgba(16, 185, 129, 0.2);
}

.status-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-main);
  font-size: 24px;
  font-weight: 700;
}

.pulse {
  animation: pulse-icon 2s ease-in-out infinite;
}

.bounce {
  animation: bounce-icon 0.8s ease-out;
}

.rotating {
  animation: rotate-icon 1s linear infinite;
}

@keyframes pulse-icon {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes bounce-icon {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes rotate-icon {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}

.status-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
}

.status-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.success-text {
  color: #059669;
}

.account-card {
  padding: 16px;
  border: 1px solid var(--line-color);
  border-radius: 14px;
  background: #f8fafc;
  margin-bottom: 18px;
}

.account-card span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.account-card strong {
  display: block;
  font-size: 15px;
  color: var(--text-main);
  word-break: break-word;
}

.charge-action {
  width: 100%;
}

.query-card {
  display: grid;
  gap: 24px;
}

.query-actions {
  margin-top: 18px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.result-stat {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line-color);
  background: #f8fafc;
}

.result-stat span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.result-stat strong {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
}

.mini-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

.mini-button.is-active {
  background: var(--button-gradient);
  color: #ffffff;
  border-color: transparent;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.table-shell {
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line-color);
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-color);
  font-size: 13px;
  color: var(--text-main);
}

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.used {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

.status-pill.not_used {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}

.status-pill.invalid {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.94);
  color: #ffffff;
  line-height: 1.6;
  font-size: 13px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toast.success {
  background: rgba(5, 150, 105, 0.96);
}

.toast.error {
  background: rgba(220, 38, 38, 0.96);
}

.loader {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.34);
  border-top-color: rgba(255, 255, 255, 1);
  animation: spin 0.8s linear infinite;
}

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

@media (max-width: 720px) {
  .charge-system,
  .query-page {
    padding: 18px 14px 36px;
  }

  .page-title {
    font-size: 26px;
  }

  .header-actions {
    position: static;
    transform: none;
    justify-content: center;
    margin-top: 16px;
  }

  .content-card,
  .query-card {
    border-radius: 18px;
  }

  .embedded-progress {
    padding: 24px 18px 22px;
  }

  .step-content,
  .query-card {
    padding: 20px 18px;
  }

  .marker-circle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 14px;
  }

  .connector-line {
    left: calc(50% + 20px);
    width: calc(100% - 40px);
  }

  .label-text {
    font-size: 12px;
  }

  .result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .page-title {
    font-size: 24px;
  }

  .page-subtitle {
    line-height: 1.8;
  }

  .header-actions {
    width: 100%;
  }

  .header-btn {
    width: 100%;
  }

  .feedback-head,
  .link-row,
  .button-row,
  .query-actions,
  .copy-row {
    flex-direction: column;
    align-items: stretch;
  }

  .link-button,
  .secondary-link,
  .mini-button {
    width: 100%;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }
}
