:root {
  --bg: #f1f2f4;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #e2e6ed;
  --line-strong: #cfd7e3;
  --text: #15171c;
  --muted: #6d7480;
  --blue: #1273ea;
  --blue-strong: #075fd0;
  --blue-soft: #edf4ff;
  --green: #0f9f6e;
  --amber: #b7791f;
  --red: #d92d20;
  --shadow: 0 1px 2px rgba(20, 28, 40, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 44px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.topnav a:hover,
.topnav a.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.balance-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--blue);
  background: var(--surface-soft);
  font-weight: 800;
  white-space: nowrap;
}

.avatar-link {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.avatar-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-menu-button {
  display: none;
}

.icon-button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
}

.icon-button span {
  display: block;
  width: 21px;
  height: 2px;
  margin: 5px auto;
  background: currentColor;
  border-radius: 99px;
}

.page-shell {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 34px);
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 34px) 40px;
  color: var(--muted);
  font-size: 14px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.flash.success {
  color: var(--green);
  border-color: #b9ead7;
  background: #effaf5;
}

.flash.warning {
  color: var(--amber);
  border-color: #f1d49a;
  background: #fff8e8;
}

.flash.danger {
  color: var(--red);
  border-color: #fac5c0;
  background: #fff1f0;
}

.section-stack {
  display: grid;
  gap: 22px;
}

.panel {
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-header h1,
.section-header h2,
.section-header h3 {
  margin: 0;
  color: var(--text);
  line-height: 1.2;
}

.section-header h1 {
  font-size: clamp(26px, 3vw, 38px);
}

.section-header h2 {
  font-size: clamp(22px, 2.2vw, 30px);
}

.section-header h3 {
  font-size: 20px;
}

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

.text-tight {
  margin: 4px 0 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.button.primary {
  color: #ffffff;
  background: var(--blue);
}

.button.primary:hover {
  background: var(--blue-strong);
}

.button.ghost {
  color: var(--blue);
  border-color: #b9d6ff;
  background: #ffffff;
}

.button.ghost:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.button.danger {
  color: #ffffff;
  background: var(--red);
}

.button.small {
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
}

.button.full {
  width: 100%;
}

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

.ad-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  min-height: 230px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ad-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: clamp(22px, 4vw, 42px);
}

.ad-content h1 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.1;
}

.ad-content p {
  margin: 0;
  max-width: 660px;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 700;
}

.ad-media {
  min-height: 230px;
  background: var(--blue-soft);
}

.ad-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.search-form {
  display: flex;
  gap: 8px;
  width: min(100%, 520px);
}

.search-form input {
  min-width: 0;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.product-card {
  display: grid;
  grid-template-rows: 150px 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.product-card:hover {
  border-color: #b7cdf0;
}

.product-media {
  background: var(--surface-soft);
}

.product-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.product-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.price {
  color: var(--blue);
  font-weight: 900;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 800;
}

.chip.success {
  color: var(--green);
  background: #effaf5;
}

.chip.warning {
  color: var(--amber);
  background: #fff8e8;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 22px;
  align-items: start;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 460px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.detail-image {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  aspect-ratio: 4 / 3;
}

.detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.balance-band {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 86px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.balance-amount {
  color: var(--blue);
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 900;
  text-align: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.stat-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.stat-box strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.25;
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.list-row.compact {
  grid-template-columns: minmax(0, 1fr) auto;
}

.thumb {
  width: 74px;
  height: 74px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.row-meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: #303642;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(18, 115, 234, 0.12);
}

.form-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-hint.success {
  color: var(--green);
}

.form-hint.danger {
  color: var(--red);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--surface);
}

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

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 900;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs a {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  font-weight: 800;
}

.tabs a.active {
  color: var(--blue);
  border-color: #b9d6ff;
  background: var(--blue-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.notice {
  padding: 14px;
  border: 1px solid #b9d6ff;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: #134982;
  font-weight: 800;
}

.code-box {
  display: block;
  overflow: auto;
  min-height: 220px;
  font-family: Consolas, Monaco, monospace;
  font-size: 14px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: auto auto;
  }

  .brand {
    font-size: 21px;
  }

  .mobile-menu-button {
    display: inline-grid;
    place-items: center;
    justify-self: end;
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .topnav {
    display: none;
    grid-column: 1 / -1;
    justify-content: stretch;
    flex-direction: column;
    align-items: stretch;
  }

  .topnav.open {
    display: flex;
  }

  .top-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .ad-strip,
  .split-layout,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .ad-media {
    min-height: 190px;
  }
}

@media (max-width: 680px) {
  body {
    font-size: 15px;
  }

  .page-shell {
    padding: 14px;
  }

  .panel {
    padding: 16px;
  }

  .section-header,
  .market-toolbar,
  .footer {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form,
  .button-row {
    width: 100%;
  }

  .search-form {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .list-row {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .list-row .button,
  .list-row form {
    grid-column: 1 / -1;
  }

  .thumb {
    width: 58px;
    height: 58px;
  }

  .balance-band {
    grid-template-columns: 1fr;
  }
}
