:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #f0f4f3;
  --ink: #162022;
  --muted: #667174;
  --line: #dce3e5;
  --accent: #0f766e;
  --accent-strong: #0b4f4a;
  --danger: #b42318;
  --warning: #a85512;
  --shadow: 0 14px 42px rgba(22, 32, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(168, 85, 18, 0.06), transparent 32%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand strong {
  font-size: 19px;
}

.brand span {
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(220, 227, 229, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: stretch;
}

.compact-hero {
  grid-template-columns: minmax(0, 1fr) 390px;
}

.panel {
  padding: 28px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 14px;
  font-size: 24px;
  letter-spacing: 0;
}

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

.lead {
  max-width: 680px;
  margin-top: 18px;
  font-size: 18px;
}

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #334144;
  font-size: 14px;
  font-weight: 700;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334144;
  font-size: 14px;
  font-weight: 750;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.input {
  height: 48px;
  padding: 0 14px;
}

.textarea {
  min-height: 190px;
  resize: vertical;
  padding: 13px 14px;
  line-height: 1.5;
}

.large-textarea {
  min-height: 360px;
}

.input:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.button.secondary {
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.danger {
  background: var(--danger);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-button,
.image-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.image-button {
  display: inline-flex;
}

.table-action {
  min-height: 34px;
  padding: 0 11px;
  font-size: 13px;
}

.link-cell {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.preview-link {
  display: block;
  max-width: 560px;
  overflow: hidden;
  color: var(--accent-strong);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.space-between {
  justify-content: space-between;
}

.submissions-panel {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.admin-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.admin-summary h1 {
  font-size: clamp(34px, 5vw, 54px);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(22, 32, 34, 0.06);
}

.tab-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #405053;
  cursor: pointer;
  font-weight: 800;
}

.tab-button.active {
  border-color: rgba(15, 118, 110, 0.22);
  background: rgba(15, 118, 110, 0.10);
  color: var(--accent-strong);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.signature-thumb {
  display: block;
  width: 160px;
  height: 70px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.signature-large {
  display: block;
  width: min(100%, 720px);
  max-height: 360px;
  object-fit: contain;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.editor-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.visual-editor {
  min-height: 320px;
  padding: 20px;
  outline: 0;
  line-height: 1.65;
}

.visual-editor:empty::before {
  content: "여기에 판매 페이지 내용을 작성하세요.";
  color: var(--muted);
}

.visual-editor h1,
.visual-editor h2,
.visual-editor p,
.visual-editor ul,
.visual-editor ol {
  margin-top: 0;
}

.signature-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.signature-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.signature-confirm {
  margin-top: 14px;
}

.signature-canvas {
  display: block;
  width: 100%;
  height: 220px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

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

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: var(--danger);
  font-weight: 700;
}

.status.ok {
  color: var(--accent-strong);
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.mini {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
}

.mini strong {
  display: block;
  margin-bottom: 8px;
}

.table-wrap {
  overflow: auto;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: #405053;
  background: var(--surface-soft);
  font-size: 13px;
}

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

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #405053;
  font-size: 12px;
  font-weight: 800;
}

.badge.unused {
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.12);
}

.badge.active {
  color: var(--warning);
  background: rgba(168, 85, 18, 0.12);
}

.badge.consumed,
.badge.expired,
.badge.blocked {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.10);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 32, 34, 0.46);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(22, 32, 34, 0.24);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  padding: 20px;
}

.modal-body h3 {
  margin: 24px 0 12px;
  font-size: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.detail-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.detail-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
}

.modal-content-preview {
  max-height: 420px;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.modal-open {
  overflow: hidden;
}

.viewer {
  position: relative;
  user-select: none;
}

.viewer-content {
  min-height: 58vh;
  padding: 32px;
}

.timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  min-height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.watermark {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0.11;
  background-image: repeating-linear-gradient(
    -24deg,
    transparent 0 120px,
    rgba(22, 32, 34, 0.22) 120px 122px,
    transparent 122px 240px
  );
}

.watermark-text {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: rgba(22, 32, 34, 0.16);
  font-size: clamp(22px, 5vw, 58px);
  font-weight: 900;
  transform: rotate(-18deg);
  text-align: center;
}

.preview-banner {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(168, 85, 18, 0.22);
  border-radius: 8px;
  background: #fffaf3;
  color: var(--warning);
  font-size: 14px;
  font-weight: 800;
}

@media (max-width: 860px) {
  .hero,
  .grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-summary,
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    overflow-x: auto;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 24px, 1080px);
    padding-top: 18px;
  }

  .panel,
  .viewer-content {
    padding: 22px;
  }
}
