/* Double Production — urgent pre-invoice dim-sum form (no prices) */
:root {
  --u-red: #c2410c;
  --u-red-deep: #9a3412;
  --u-orange: #ea580c;
  --u-amber: #f59e0b;
  --u-bg: #fff7ed;
  --u-card: #ffffff;
  --u-text: #1c1917;
  --u-muted: #78716c;
  --u-border: #fed7aa;
  --u-ok: #15803d;
  --u-shadow: 0 4px 16px rgba(194, 65, 12, 0.14);
  --u-safe-bottom: env(safe-area-inset-bottom, 0px);
  --u-font: "Segoe UI", "PingFang HK", "Noto Sans SC", system-ui, sans-serif;
  --u-header-approx: 0px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: var(--u-font);
  color: var(--u-text);
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(160deg, #c2410c 0%, #ea580c 50%, #f59e0b 100%);
}
body {
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}
.hidden { display: none !important; }

.u-app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  min-height: 100dvh;
  background: var(--u-bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 48px rgba(194, 65, 12, 0.35);
}

.u-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sticky header form */
.u-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, #c2410c 0%, #ea580c 70%, #f97316 100%);
  color: #fff;
  padding: 8px 10px 10px;
  box-shadow: 0 4px 14px rgba(154, 52, 18, 0.35);
}
.u-header-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.u-back {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.92;
  padding: 4px 0;
  white-space: nowrap;
}
.u-title-wrap { flex: 1; min-width: 0; }
.u-title {
  font-size: 17px;
  font-weight: 900;
  line-height: 1.2;
}
.u-badge {
  display: inline-block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  padding: 2px 8px;
}
.u-dnid {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 4px 7px;
  white-space: nowrap;
}

.u-header-form {
  background: rgba(255, 255, 255, 0.97);
  color: var(--u-text);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.u-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.u-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--u-muted);
}
.u-field em { color: var(--u-red); font-style: normal; }
.u-field input[type="text"],
.u-field input[type="tel"],
.u-field input[type="number"],
.u-other input {
  width: 100%;
  border: 1.5px solid var(--u-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--u-text);
  background: #fff;
}
.u-field input:focus,
.u-other input:focus {
  outline: none;
  border-color: var(--u-orange);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.18);
}

.u-seg {
  display: flex;
  gap: 6px;
}
.u-seg label {
  flex: 1;
  text-align: center;
  border: 1.5px solid var(--u-border);
  border-radius: 999px;
  padding: 7px 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  background: #fff;
}
.u-seg input { display: none; }
.u-seg label:has(input:checked) {
  background: linear-gradient(135deg, #c2410c, #ea580c);
  border-color: transparent;
  color: #fff;
}

.u-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.u-chips button {
  border: 1.5px solid var(--u-border);
  background: #fff;
  color: var(--u-red-deep);
  border-radius: 999px;
  padding: 7px 10px;
  min-height: 36px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.u-chips button.active {
  background: linear-gradient(135deg, #c2410c, #ea580c);
  border-color: transparent;
  color: #fff;
}

.u-boxes {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.u-field .u-boxes input[type="number"] {
  width: 72px;
  flex: 0 0 72px;
  max-width: 72px;
}
.u-boxes .u-more-toggle {
  flex-shrink: 0;
  align-self: center;
}
.u-unit {
  display: flex;
  flex: 1 1 auto;
  min-width: 110px;
  border: 1.5px solid var(--u-border);
  border-radius: 10px;
  overflow: hidden;
}
.u-unit-btn {
  flex: 1 1 50%;
  border: 0;
  background: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  color: var(--u-muted);
  padding: 8px 12px;
  min-width: 44px;
}
.u-unit-btn.active {
  background: linear-gradient(135deg, #c2410c, #ea580c);
  color: #fff;
}

.u-meta {
  align-items: end;
}
.u-datetime {
  font-size: 14px;
  font-weight: 800;
  color: var(--u-text);
  padding: 6px 0 2px;
}
.u-more-toggle {
  border: 0;
  background: transparent;
  color: var(--u-orange);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  text-align: right;
  padding: 8px 4px;
}
.u-more {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.u-more .u-field:last-child {
  grid-column: 1 / -1;
}

/* Tabs */
.u-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #fff;
  border-bottom: 1px solid var(--u-border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.u-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.u-tabs::-webkit-scrollbar { display: none; }
.u-tab {
  flex-shrink: 0;
  border: 1.5px solid var(--u-border);
  background: #fff7ed;
  color: var(--u-red-deep);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.u-tab.active {
  background: linear-gradient(135deg, #c2410c, #ea580c);
  border-color: transparent;
  color: #fff;
}
.u-picked-only {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--u-muted);
  white-space: nowrap;
}

/* Product dim-sum grid */
.u-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 8px 88px;
}
.u-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.u-card {
  background: var(--u-card);
  border: 1.5px solid var(--u-border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--u-shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.u-card.has-qty {
  border-color: var(--u-orange);
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.25), var(--u-shadow);
}
.u-card-img {
  aspect-ratio: 1 / 0.85;
  background: #ffedd5;
  position: relative;
  overflow: hidden;
}
.u-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.u-card-sku {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(194, 65, 12, 0.92);
  color: #fff;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 7px;
  border-radius: 999px;
  max-width: calc(100% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.u-card-body {
  padding: 7px 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.u-card-name {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  min-height: 2.5em;
}
.u-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--u-border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: auto;
}
.u-stepper button {
  width: 40px;
  height: 36px;
  border: 0;
  background: #fff7ed;
  color: var(--u-red-deep);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
}
.u-stepper button:active { background: #ffedd5; }
.u-stepper .u-qty {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.u-card.has-qty .u-stepper {
  border-color: var(--u-orange);
  background: #fff7ed;
}
.u-card.has-qty .u-qty { color: var(--u-red-deep); }
.u-empty {
  text-align: center;
  color: var(--u-muted);
  font-size: 13px;
  padding: 24px 12px;
}

/* Sticky bottom */
.u-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px calc(10px + var(--u-safe-bottom));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--u-border);
  box-shadow: 0 -6px 20px rgba(194, 65, 12, 0.12);
  backdrop-filter: blur(8px);
}
.u-summary {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--u-text);
}
.u-submit {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #c2410c 0%, #ea580c 100%);
  box-shadow: 0 4px 14px rgba(194, 65, 12, 0.35);
  cursor: pointer;
  white-space: nowrap;
}
.u-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.u-submit:active:not(:disabled) { transform: scale(0.98); }

/* Success */
.u-success {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px calc(24px + var(--u-safe-bottom));
  background: var(--u-bg);
}
.u-success-head {
  text-align: center;
  margin-bottom: 12px;
}
.u-success-head .u-badge {
  background: var(--u-red);
  border: 0;
  color: #fff;
}
.u-success-head h2 {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 900;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.u-success-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--u-muted);
  font-weight: 700;
}
.u-preview-wrap {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--u-border);
  padding: 8px;
  box-shadow: var(--u-shadow);
  margin-bottom: 14px;
}
.u-preview-wrap img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}
.u-success-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.u-save-big {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  border-radius: 14px;
}
.u-btn-sec {
  width: 100%;
  border: 1.5px solid var(--u-border);
  background: #fff;
  color: var(--u-red-deep);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.u-link {
  text-align: center;
  color: var(--u-orange);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  padding: 8px;
}

.u-header-form .u-datetime {
  font-size: 15px;
  font-weight: 800;
  color: var(--u-text);
  padding: 8px 10px;
  border: 1.5px solid var(--u-border);
  border-radius: 10px;
  background: #fff;
}

.u-boxes-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.u-field-grow { flex: 1; min-width: 0; }
.u-boxes-row .u-more-toggle {
  flex-shrink: 0;
  padding-bottom: 10px;
}
