:root {
  --ink: #0a4f68;
  --ink-strong: #073f54;
  --aqua: #4fbfe8;
  --aqua-soft: #e3f7ff;
  --orange: #ff8a3d;
  --line: #cfe9f3;
  --card: #ffffff;
  --muted: #5f8a9b;
  --danger: #d9534f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #f2fbff;
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}

.wrap { max-width: 620px; margin: 0 auto; }

header { margin: 8px 0 20px; }
h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: .5px; }
h2 { margin: 0 0 10px; font-size: 18px; }
p.lead { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(10, 79, 104, .06);
}

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
input[type="text"], input[type="password"], input[type="tel"], textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--ink);
  background: #f7fdff;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(79, 191, 232, .18); }

.slots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
.slot-wrap { display: flex; flex-direction: column; gap: 6px; }
.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 132px;
  padding: 10px;
  text-align: center;
  background: #f7fdff;
  border: 1px dashed #a9dcee;
  border-radius: 14px;
  cursor: pointer;
  overflow: hidden;
}
.slot.has-file { border-style: solid; border-color: var(--aqua); background: #fff; }
.slot-title { font-size: 14px; font-weight: 700; }
.slot-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }
.slot-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 74px;
  font-size: 12px;
  color: #8ab8c8;
}
.slot-preview img { max-width: 100%; max-height: 74px; object-fit: contain; }
.slot-warn {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 3px 6px;
  font-size: 10px;
  color: #8a5a00;
  background: #fff4d6;
  border-radius: 8px;
}

.ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  padding: 3px 9px 3px 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}
.ref-chip:active { background: var(--aqua-soft); }
.ref-chip img {
  display: block;
  width: 18px;
  height: 30px;
  object-fit: cover;
  border-radius: 4px;
}
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}
.field-block { margin-bottom: 14px; }
.field-block input { display: block; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(7, 63, 84, .9);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.lightbox-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  width: 42px;
  height: 42px;
  font-size: 26px;
  line-height: 1;
  color: var(--ink-strong);
  background: rgba(255, 255, 255, .94);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--orange);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(255, 138, 61, .28);
}
.btn:disabled { opacity: .55; box-shadow: none; }
.btn.ghost { color: var(--ink); background: #fff; border: 1px solid var(--line); box-shadow: none; }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 10px; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f0c4c3; box-shadow: none; }

.msg { min-height: 20px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.msg.error { color: var(--danger); }
.msg.ok { color: #1a8f5a; }

.link-box {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.link-box input { flex: 1; font-size: 13px; padding: 10px 12px; background: #f7fdff; border: 1px solid var(--line); border-radius: 10px; }

.new-code {
  margin: 16px 0 8px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  text-align: center;
  color: var(--ink-strong);
}
.sub-title { margin: 16px 0 6px; font-size: 14px; color: var(--muted); }
.code-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.code-row:first-child { border-top: 0; }
.code-text {
  flex: 1;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.admin-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.admin-toolbar .btn { flex: 1; }

.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.order-name { font-size: 17px; font-weight: 700; }
.order-time { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.pending { color: #8a5a00; background: #fff4d6; }
.badge.approved { color: #116b43; background: #dff7ea; }

.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--muted); }
.thumbs img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #f2fbff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.order-texts { font-size: 12px; color: var(--muted); line-height: 1.7; word-break: break-all; }
.order-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.order-hint {
  margin: 0 0 2px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #8a5a00;
  background: #fff9e8;
  border-radius: 9px;
}
.order-hint.ok { color: #116b43; background: #eaf9f1; }

.center-card { max-width: 460px; margin: 12vh auto 0; text-align: center; }
.center-card .btn { margin-top: 8px; }
.big-emoji { font-size: 42px; line-height: 1; margin-bottom: 8px; }
.hidden { display: none !important; }

@media (min-width: 520px) {
  .slots { grid-template-columns: repeat(3, 1fr); }
}
