:root {
  --bg: #f3f7f8;
  --surface: #ffffff;
  --surface-2: #f7fafb;
  --ink: #12212e;
  --muted: #66788a;
  --line: #dce6ec;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --soft: #e8f7f4;
  --soft-amber: #fff5e8;
  --soft-red: #fef3f2;
  --amber: #a15c08;
  --red: #b42318;
  --on-brand: #ffffff;
  --shadow: 0 8px 24px rgba(18, 33, 46, 0.06);
  --radius: 18px;
  --topbar-bg: rgba(243, 247, 248, 0.92);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b141b;
    --surface: #111d26;
    --surface-2: #0e1921;
    --ink: #e5eef4;
    --muted: #9db0be;
    --line: #243541;
    --brand: #5eead4;
    --brand-dark: #99f6e4;
    --soft: #102a28;
    --soft-amber: #2a2113;
    --soft-red: #2a1615;
    --amber: #fbbf24;
    --red: #fca5a5;
    --on-brand: #06231f;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    --topbar-bg: rgba(11, 20, 27, 0.92);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

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

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--brand), var(--brand-dark));
  color: var(--on-brand);
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 5px 12px rgba(15, 118, 110, 0.22);
}

.brand-text {
  min-width: 0;
}

.brand-text strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.mode-badge {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--brand);
  background: var(--soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.page {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 14px calc(118px + env(safe-area-inset-bottom));
}

.dev-notice {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--amber) 22%, transparent);
  border-radius: 10px;
  background: var(--soft-amber);
  color: var(--amber);
  font-size: 11px;
  line-height: 1.55;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
}

.banner.error {
  border: 1px solid color-mix(in srgb, var(--red) 24%, transparent);
  background: var(--soft-red);
  color: var(--red);
}

.text-btn {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 4px 2px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.text-btn:hover {
  text-decoration: underline;
}

.card {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.customer-card {
  background:
    radial-gradient(240px 160px at 96% 0%, var(--soft), transparent 72%),
    var(--surface);
}

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

.section-head.compact {
  margin-top: 16px;
  margin-bottom: 8px;
}

.eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 20px;
  line-height: 1.35;
}

h2 {
  font-size: 17px;
  line-height: 1.4;
}

.pill {
  flex: none;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--soft);
  color: var(--brand);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.customer-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.customer-meta > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.customer-meta span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.customer-meta strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.address-list {
  display: grid;
  gap: 8px;
}

.address-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
}

.address-item.selected {
  border-color: var(--brand);
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.address-main {
  min-width: 0;
}

.address-label {
  display: inline-block;
  margin-bottom: 3px;
  border-radius: 999px;
  padding: 1px 7px;
  background: var(--surface);
  color: var(--brand);
  font-size: 10px;
  font-weight: 600;
}

.address-full {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.address-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.radio {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
}

.address-item.selected .radio {
  border-color: var(--brand);
}

.address-item.selected .radio::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
}

.last-order-card {
  border-color: color-mix(in srgb, var(--amber) 22%, var(--line));
  background:
    linear-gradient(180deg, var(--soft-amber), transparent 52%),
    var(--surface);
}

.mini-list {
  display: grid;
  gap: 6px;
}

.mini-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.mini-item span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-item span:last-child {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.product-list {
  display: grid;
  gap: 9px;
}

.product {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.product-main {
  min-width: 0;
}

.product-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.product-spec {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.product-price {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 5px;
}

.product-price strong {
  color: var(--brand);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.product-price span {
  color: var(--muted);
  font-size: 10px;
}

.product-stock {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.stepper {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 6px;
}

.step-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--brand);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.step-btn:disabled {
  color: var(--muted);
  opacity: 0.45;
  cursor: default;
}

.qty {
  width: 28px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  gap: 10px;
}

.field {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.field > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.field select,
.field input[type="text"],
.field input[type="tel"],
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 16px;
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.55;
}

.field select:focus,
.field input:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}

.switch-field {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.switch-field > span:first-child {
  font-size: 11px;
  font-weight: 600;
}

.switch-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: var(--line);
  transition: background 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 160ms ease;
}

.switch-field input:checked + .switch {
  background: var(--brand);
}

.switch-field input:checked + .switch::after {
  transform: translateX(16px);
}

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

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.chip.selected {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
}

.summary-card {
  background:
    linear-gradient(145deg, var(--soft), transparent 64%),
    var(--surface);
}

.summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 13px;
}

.summary-row > span {
  color: var(--muted);
}

.summary-row > strong {
  text-align: right;
  overflow-wrap: anywhere;
}

.summary-row .total {
  color: var(--brand);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.order-card {
  border-color: color-mix(in srgb, var(--brand) 32%, var(--line));
  background:
    linear-gradient(160deg, var(--soft), transparent 56%),
    var(--surface);
}

.order-success {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.success-mark {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 18px;
  font-weight: 700;
}

.actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--brand) 22%, transparent);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

.notification-status {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--brand) 20%, var(--line));
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.notification-status strong {
  color: var(--brand);
}

.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: 100%;
  max-width: 640px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
}

.bottom-total {
  min-width: 0;
}

.bottom-total span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.bottom-total strong {
  display: block;
  color: var(--brand);
  font-size: 22px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.bottom-bar .btn {
  flex: none;
  min-width: 138px;
}

.debug {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
}

.debug summary {
  cursor: pointer;
  padding: 6px 0;
}

.debug pre {
  max-height: 260px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 10px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
  margin-top: 18px;
  padding: 14px 4px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(88vw, 520px);
  transform: translateX(-50%);
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

.skeleton {
  display: grid;
  gap: 10px;
  padding: 4px 0;
}

.skeleton-line,
.skeleton-block {
  border-radius: 12px;
  background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-line {
  height: 18px;
  width: 62%;
}

.skeleton-line.wide {
  width: 88%;
}

.skeleton-block {
  height: 132px;
}

.skeleton-block.short {
  height: 72px;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@media (max-width: 420px) {
  .customer-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .product {
    grid-template-columns: minmax(0, 1fr);
  }

  .stepper {
    justify-content: flex-end;
  }

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

  .bottom-bar .btn {
    min-width: 126px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .skeleton-line,
  .skeleton-block {
    animation: none;
  }

  .switch,
  .switch::after {
    transition: none;
  }
}
