:root {
  --bg-color: #0f061a;
  --accent-color: #a855f7;
  --accent-secondary: #f97316;
  --text-color: #f5f3ff;
  --muted-color: rgba(245, 243, 255, 0.75);
  --border-color: rgba(168, 85, 247, 0.35);
  --card-bg: rgba(32, 16, 52, 0.75);
  --error-color: #f87171;
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(168, 85, 247, 0.35), transparent 55%),
    radial-gradient(circle at bottom, rgba(249, 115, 22, 0.25), transparent 50%),
    var(--bg-color);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

main {
  width: min(640px, 100%);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: clamp(1.75rem, 4vw, 2.75rem);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 55px rgba(15, 6, 26, 0.6);
}

.card::before {
  content: "";
  position: absolute;
  inset: -120px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.22), transparent 65%);
  transform: rotate(12deg);
  pointer-events: none;
}

h1, h2 {
  font-family: "Playfair Display", "Noto Serif KR", serif;
  margin: 0 0 1.25rem;
  letter-spacing: 1px;
}

p {
  line-height: 1.6;
  color: var(--muted-color);
  margin: 0 0 1rem;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

input[type="number"], input[type="text"], textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(245, 243, 255, 0.1);
  background: rgba(12, 6, 22, 0.85);
  color: var(--text-color);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: rgba(168, 85, 247, 0.6);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 14px;
  padding: 0.85rem 1.75rem;
  font-weight: 600;
  font-size: 1.05rem;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.92), rgba(236, 72, 153, 0.92));
  color: var(--text-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(168, 85, 247, 0.32);
}

.notice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.notice svg {
  flex-shrink: 0;
  margin-top: 0.25rem;
}

.error-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--error-color);
}

.success-message {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: var(--text-color);
}

.consent-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted-color);
}

.consent-list li {
  margin-bottom: 0.6rem;
}

.checkbox {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-top: 1.25rem;
}

.checkbox input[type="checkbox"] {
  margin-top: 0.3rem;
  width: 1.1rem;
  height: 1.1rem;
}

.progress-text {
  margin-top: 1.5rem;
  font-style: italic;
  color: rgba(245, 243, 255, 0.7);
}

footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(245, 243, 255, 0.45);
}

.magic-sigil {
  position: absolute;
  inset: auto -120px -120px auto;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.35), transparent 60%);
  filter: blur(12px);
  pointer-events: none;
  transform: rotate(-18deg);
}

.back-link {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  color: rgba(245, 243, 255, 0.8);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 1rem;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: var(--text-color);
}

@media (max-width: 600px) {
  body {
    padding: 1.5rem 1rem;
  }

  .card {
    padding: 1.5rem;
  }
}

.spin {
  animation: spin 1s linear infinite;
}

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

/* 관리자 페이지 스타일 */
.admin-layout {
  min-height: 100vh;
  padding: clamp(1.5rem, 2vw + 1rem, 3rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 2vw + 1rem, 2.5rem);
  background: radial-gradient(circle at top, rgba(147, 112, 219, 0.15), transparent 60%),
    radial-gradient(circle at bottom, rgba(0, 0, 0, 0.55), transparent 70%),
    #0f0b19;
}

.admin-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}

.admin-header h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(2rem, 1rem + 2vw, 2.75rem);
}

.admin-header p {
  color: rgba(255, 255, 255, 0.75);
  max-width: 32rem;
}

.fallback-banner {
  width: min(100%, 72rem);
  margin: -0.5rem auto 0;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 198, 109, 0.4);
  background: rgba(255, 198, 109, 0.12);
  color: #ffdd9c;
  font-size: 0.95rem;
  line-height: 1.5;
}

.fallback-detail {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: rgba(255, 221, 156, 0.9);
}

.admin-card {
  width: min(100%, 72rem);
  margin: 0 auto;
}

.admin-form {
  display: grid;
  gap: 1rem;
}

.field-group {
  display: grid;
  gap: 0.5rem;
}

.field-group input[type="text"] {
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 11, 25, 0.65);
  color: #fff;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.field-group input[type="text"]:focus {
  border-color: rgba(147, 112, 219, 0.7);
  box-shadow: 0 0 0 4px rgba(147, 112, 219, 0.2);
  outline: none;
}

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

#codes-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

#codes-table th,
#codes-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#codes-table th {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.03);
}

#codes-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 11, 25, 0.6);
  color: #fff;
}

.table-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 11, 25, 0.6);
  color: #fff;
}

.table-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.8);
}

.table-checkbox input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

.table-actions button {
  padding: 0.4rem 0.9rem;
  border-radius: 0.6rem;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.table-actions button:disabled {
  opacity: 0.6;
  cursor: wait;
}

button.secondary {
  background: rgba(147, 112, 219, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

button.secondary:hover:not(:disabled) {
  background: rgba(147, 112, 219, 0.35);
  transform: translateY(-1px);
}

button.danger {
  background: rgba(220, 20, 60, 0.35);
  color: rgba(255, 255, 255, 0.92);
}

button.danger:hover:not(:disabled) {
  background: rgba(220, 20, 60, 0.5);
  transform: translateY(-1px);
}

.empty-state {
  text-align: center;
  padding: 1.5rem;
  color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 768px) {
  .admin-layout {
    padding: 1.5rem 1rem 2.5rem;
  }

  .admin-card {
    width: 100%;
  }

  .table-actions {
    flex-direction: column;
  }

  .table-actions button {
    width: 100%;
  }
}
