:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --ink: #1e2528;
  --muted: #6d746d;
  --line: #d8d2c5;
  --panel: #fffdf8;
  --accent: #006d5b;
  --accent-strong: #004b3f;
  --danger: #a33424;
  --warn: #9b5c00;
  --shadow: 0 18px 44px rgba(30, 37, 40, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(0, 109, 91, 0.10), transparent 34%),
    linear-gradient(315deg, rgba(155, 92, 0, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(22px + env(safe-area-inset-bottom));
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 29px;
  line-height: 1.08;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.db-pill {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.74);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.db-pill.ok {
  border-color: rgba(0, 109, 91, 0.34);
  color: var(--accent);
}

.db-pill.bad {
  border-color: rgba(163, 52, 36, 0.35);
  color: var(--danger);
}

.scan-panel,
.orders-panel {
  border: 1px solid rgba(30, 37, 40, 0.10);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.scan-panel {
  padding: 14px;
}

.orders-panel {
  margin-top: 14px;
  overflow: hidden;
}

.scan-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#statusText {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#statusText.error {
  color: var(--danger);
}

#statusText.success {
  color: var(--accent);
}

.camera-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: #121817;
}

.camera-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.26);
}

.scan-frame::before,
.scan-frame::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  background: #55e0b7;
}

.scan-frame::before {
  top: 18px;
}

.scan-frame::after {
  bottom: 18px;
}

.primary-btn,
.ghost-btn,
.text-btn,
.manual-row button {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 14px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
}

.primary-btn:active,
.manual-row button:active {
  background: var(--accent-strong);
}

.ghost-btn {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fffaf0;
  color: var(--ink);
}

.text-btn {
  min-height: 36px;
  padding: 0 10px;
  background: transparent;
  color: var(--accent);
}

.scan-mark {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 5px;
  box-shadow:
    8px 0 0 -5px currentColor,
    0 8px 0 -5px currentColor,
    8px 8px 0 -5px currentColor;
}

.manual-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.manual-form label,
.qty-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.manual-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 8px;
}

.manual-row input,
#quantityInput {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.manual-row input:focus,
#quantityInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 109, 91, 0.15);
}

.manual-row button {
  background: #24302f;
  color: #fff;
}

.section-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.order-list {
  display: grid;
}

.order-item {
  display: grid;
  gap: 7px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(216, 210, 197, 0.78);
  background: rgba(255, 255, 255, 0.45);
}

.order-item:last-child {
  border-bottom: 0;
}

.order-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.order-main strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.order-main span {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 900;
}

.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 18px 14px;
  color: var(--muted);
  text-align: center;
}

.site-footer {
  display: grid;
  gap: 6px;
  padding: 18px 4px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.site-footer a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.site-footer span {
  display: inline-block;
  margin-left: 8px;
}

.order-dialog {
  width: min(calc(100% - 28px), 460px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.34);
}

.order-dialog::backdrop {
  background: rgba(15, 19, 20, 0.48);
}

.order-dialog form {
  padding: 18px;
}

.dialog-head {
  margin-bottom: 16px;
}

.sticker-detail {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}

.sticker-detail div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.sticker-detail dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sticker-detail dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 360px) {
  .manual-row,
  .dialog-actions {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }
}
