:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-raised: #fbfcfe;
  --text: #141a22;
  --muted: #687384;
  --line: #dbe2ea;
  --line-strong: #c9d3df;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #e7f3f1;
  --ink: #213547;
  --accent: #c2410c;
  --accent-soft: #fff2ea;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --focus: rgba(15, 118, 110, 0.18);
  --shadow-sm: 0 8px 22px rgba(20, 26, 34, 0.07);
  --shadow-md: 0 22px 60px rgba(20, 26, 34, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(244, 246, 248, 0.72), rgba(244, 246, 248, 1) 42%),
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 0 1px, transparent 1px 96px),
    linear-gradient(180deg, rgba(194, 65, 12, 0.06) 0 1px, transparent 1px 96px),
    #f4f6f8;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 54px;
}

.pickup-shell {
  width: min(1040px, calc(100% - 40px));
}

.admin-shell {
  width: min(1220px, calc(100% - 40px));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  margin-bottom: 24px;
  border: 1px solid rgba(219, 226, 234, 0.86);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}

.brand,
.nav-button,
.ghost-button,
.secondary-button,
.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 850;
  letter-spacing: 0;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background-color 0.16s ease,
    box-shadow 0.16s ease;
}

.brand {
  min-width: 0;
  color: var(--ink);
  font-size: 16px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.2);
}

.nav-button,
.ghost-button,
.secondary-button {
  min-height: 40px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
}

.nav-button:hover,
.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.primary-button {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--primary-strong);
  padding: 0 18px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 14px 30px rgba(15, 118, 110, 0.22);
  font-size: 17px;
}

.secondary-button {
  border-color: rgba(15, 118, 110, 0.3);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.danger {
  border-color: rgba(180, 35, 24, 0.28);
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  padding: 0;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.pickup-hero,
.admin-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 2px 30px;
}

.pickup-hero {
  min-height: 182px;
}

.admin-hero {
  min-height: 126px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(38px, 7vw, 72px);
  font-weight: 900;
}

h2 {
  font-size: 20px;
  font-weight: 900;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid rgba(194, 65, 12, 0.24);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--accent-soft);
  color: #8a2c0b;
  font-weight: 900;
}

.pickup-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 22px;
  align-items: stretch;
}

.panel,
.result-panel,
.empty-result {
  border: 1px solid rgba(219, 226, 234, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
}

.panel-title {
  display: grid;
  gap: 2px;
}

.pickup-panel {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 22px;
}

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

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(20, 26, 34, 0.02);
}

input,
select {
  min-height: 48px;
  padding: 0 13px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 21px,
    calc(100% - 13px) 21px;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

textarea {
  min-height: 160px;
  padding: 13px;
  resize: vertical;
  line-height: 1.65;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

.product-meta {
  display: flex;
  min-height: 72px;
  align-items: center;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  padding: 14px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 850;
  line-height: 1.45;
}

.result-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 430px;
  overflow: hidden;
}

.result-panel[hidden] {
  display: none;
}

.result-head,
.toolbar,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.result-head {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-raised);
}

pre {
  margin: 0;
  min-height: 320px;
  max-height: 58vh;
  overflow: auto;
  padding: 24px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #17202a;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.04) 0 1px, transparent 1px 32px),
    #fff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 15px;
  line-height: 1.75;
}

.empty-result {
  display: grid;
  min-height: 430px;
  align-content: space-between;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(251, 252, 254, 0.94)),
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(194, 65, 12, 0.06));
}

.result-panel:not([hidden]) + .empty-result {
  display: none;
}

.empty-lines {
  display: grid;
  gap: 12px;
}

.empty-lines span {
  display: block;
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, #e5ebf2, #f6f8fa);
}

.empty-lines span:nth-child(1) {
  width: 92%;
}

.empty-lines span:nth-child(2) {
  width: 74%;
}

.empty-lines span:nth-child(3) {
  width: 54%;
}

.admin-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.product-list-panel,
.editor-panel,
.issued-panel {
  padding: 20px;
}

.product-list-panel {
  position: sticky;
  top: 92px;
}

.token-field {
  margin-top: 18px;
}

.product-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.product-item {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.product-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.product-item.active {
  border-color: rgba(15, 118, 110, 0.38);
  background: var(--primary-soft);
  box-shadow: inset 4px 0 0 var(--primary);
}

.product-item span {
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-item small {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.35;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.editor-panel form {
  display: grid;
  gap: 18px;
}

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

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

.issued-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.issued-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-raised);
}

.issued-item div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.issued-item strong {
  color: var(--text);
  font-size: 14px;
}

.issued-item code {
  display: block;
  overflow-wrap: anywhere;
  color: #243447;
  line-height: 1.55;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: var(--surface-raised);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100% - 48px));
  min-height: 0;
  margin: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  font-weight: 850;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    padding 0.2s ease;
}

.toast:not(:empty) {
  padding: 13px 16px;
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 920px) {
  .shell,
  .pickup-shell,
  .admin-shell {
    width: min(100% - 24px, 720px);
    padding-top: 12px;
  }

  .topbar {
    min-height: 60px;
    margin-bottom: 14px;
  }

  .pickup-hero,
  .admin-hero {
    align-items: flex-start;
    flex-direction: column;
    min-height: auto;
    padding: 22px 0;
  }

  h1 {
    font-size: clamp(34px, 12vw, 48px);
  }

  .pickup-grid,
  .admin-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .product-list-panel {
    position: static;
  }

  .empty-result,
  .result-panel {
    min-height: 340px;
  }

  .result-head,
  .button-row,
  .issued-item div {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-button,
  .ghost-button,
  .secondary-button,
  .primary-button {
    width: 100%;
  }

  .topbar .nav-button {
    width: auto;
  }
}

@media (max-width: 520px) {
  .brand span:last-child {
    display: none;
  }

  .panel,
  .result-panel,
  .empty-result {
    box-shadow: var(--shadow-sm);
  }

  .pickup-panel,
  .product-list-panel,
  .editor-panel,
  .issued-panel,
  .result-head,
  pre {
    padding: 16px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-end;
  }
}
