:root {
  --bg: #efe6d6;
  --ink: #1c241f;
  --muted: #5e675f;
  --card: #fffaf3;
  --line: #e3d5c0;
  --green: #1f6b4a;
  --green-dark: #144833;
  --seal: #b64024;
  --warn: #8a5a12;
  --warn-bg: #fff4df;
  --bad: #8d2d2d;
  --bad-bg: #fdeceb;
  --ok-bg: #e7f5ee;
  --shadow: 0 10px 28px rgba(70, 48, 18, 0.06);
  --tab: 64px;
  --safe: env(safe-area-inset-bottom);
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 28%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--green-dark); }
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(var(--tab) + var(--safe) + 28px); }
body.admin-view .wrap { max-width: 1100px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: rgba(239, 230, 214, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; font-weight: 700; min-width: 0; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark {
  width: 44px; height: 44px; display: block; object-fit: contain; flex: 0 0 auto;
  background: #fff5f7; border-radius: 12px;
}
.text-btn, .btn, .btn.secondary, .btn.ghost, .btn.danger {
  min-height: 44px; border-radius: 12px; padding: 10px 14px; border: 1px solid transparent; cursor: pointer;
}
.text-btn { background: transparent; border-color: var(--line); }
.btn { background: var(--green); color: white; border-color: var(--green-dark); font-weight: 700; }
.btn.secondary { background: var(--seal); border-color: #8c2f18; color: white; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); font-weight: 600; }
.btn.danger { background: transparent; border-color: #e4b4b4; color: var(--bad); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.full, .stack .btn { width: 100%; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fffaf3; border-top: 1px solid var(--line);
  padding-bottom: var(--safe);
}
.tabbar a {
  text-align: center; text-decoration: none; padding: 12px 4px 10px; color: var(--muted); font-weight: 700;
}
.tabbar a.active { color: var(--green-dark); box-shadow: inset 0 3px 0 var(--green); }

.card, .banner {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 16px;
}
.card + .card, .stack > * + * { margin-top: 12px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.ok { background: var(--ok-bg); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: 0.92rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.hero a, .hero button { min-height: 64px; font-size: 1.05rem; }
label { display: block; font-weight: 650; margin-bottom: 6px; }
.field { margin-bottom: 12px; }
input, textarea, select {
  width: 100%; background: white; border: 1px solid #d9ccb8; border-radius: 12px; padding: 12px; min-height: 44px;
}
textarea { min-height: 180px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(31, 107, 74, 0.25); border-color: var(--green); }
.nums, .mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  word-break: break-all; white-space: pre-wrap; margin: 0;
}
.badge {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 0.78rem;
  background: #f3eadc; color: var(--ink); border: 1px solid var(--line);
}
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--green-dark); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.total { margin: 8px 0 0; font-size: 1.2rem; font-weight: 700; }
.split { display: grid; grid-template-columns: 1fr 88px; gap: 8px; }
.submit-dock {
  position: fixed; left: 0; right: 0; z-index: 5;
  bottom: calc(var(--tab) + var(--safe));
  padding: 8px 16px;
  background: rgba(239, 230, 214, 0.96);
  border-top: 1px solid var(--line);
}
.submit-dock .btn { width: min(760px, 100%); display: block; margin: 0 auto; }
body.reporting .wrap { padding-bottom: calc(var(--tab) + var(--safe) + 88px); }
body.reporting #toast { bottom: calc(var(--tab) + var(--safe) + 72px); }
.address-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chips button { min-height: 40px; border-radius: 999px; padding: 8px 12px; border: 1px solid var(--line); background: white; cursor: pointer; }
.chips button.on { background: var(--green); color: white; border-color: var(--green-dark); }
.mode-row { display: flex; gap: 8px; }
.mode-row button {
  flex: 1; min-height: 44px; border-radius: 999px; padding: 8px 12px;
  border: 1px solid var(--line); background: white; cursor: pointer;
}
.mode-row button.on { background: var(--green); color: white; border-color: var(--green-dark); }
.addr-btn {
  min-height: 40px; border-radius: 999px; padding: 8px 14px;
  border: 1px solid var(--line); background: white; cursor: pointer;
}
.addr-btn.empty { color: var(--warn); border-color: #e2c48a; background: var(--warn-bg); }
.card.need-address { outline: 2px solid #e2c48a; }
body.addr-open { overflow: hidden; }
.addr-sheet {
  position: fixed; inset: 0; z-index: 40; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(28, 36, 31, 0.45);
  touch-action: none;
}
.addr-panel {
  width: min(520px, 100%); background: var(--card);
  border-radius: 16px 16px 0 0; padding: 12px 12px calc(12px + var(--safe));
  display: flex; flex-direction: column; gap: 8px;
  overflow: hidden; touch-action: none;
}
.addr-title { margin: 0; font-weight: 700; }
.addr-list {
  height: 240px; flex: none;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  border: 1px solid var(--line); border-radius: 12px;
  background: white;
}
.addr-list button {
  display: block; width: 100%; text-align: left; min-height: 48px;
  padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: white; cursor: pointer;
  touch-action: pan-y;
}
.addr-list button.on { background: var(--ok-bg); font-weight: 700; }
.addr-list button:last-child { border-bottom: 0; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: auto; min-height: 0; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab) + var(--safe) + 16px); transform: translateX(-50%);
  background: #1c241f; color: white; padding: 10px 14px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#toast.show { opacity: 1; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 4px; }
.tabs button { white-space: nowrap; }
.tabs button.active { background: var(--green); color: white; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid #f0e6d6; }
.line .k { color: var(--muted); flex: 0 0 76px; }
.sheet-head { display: none; }
.order-card { margin-top: 12px; }
@media (min-width: 900px) {
  .sheet-head, .order-card.grid {
    display: grid; grid-template-columns: 128px 88px 72px minmax(140px, 1.1fr) minmax(160px, 1.3fr) 88px 72px 80px;
    gap: 8px; align-items: start;
  }
  .sheet-head { color: var(--muted); font-size: 0.85rem; font-weight: 700; padding: 0 16px; }
  .order-card.grid .line { display: block; border: 0; padding: 0; }
  .order-card.grid .k { display: none; }
  .order-card.grid > .row { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.new-order-alert { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 5px; border-radius: 50%; background: #ad351f; color: white; font-weight: 800; }
