:root {
  --bg: #f4f1ea;
  --ink: #1c1f1d;
  --muted: #5c6570;
  --line: #ddd6c8;
  --card: #fff;
  --teal: #1f5c4d;
  --danger: #9b1c1c;
  --ship: #1d4e89;
  --arch: #5c6570;
  --late: #9b1c1c;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--teal);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 12px;
  padding: 24px 20px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 20px; color: var(--teal); }
.auth-card .lead { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.auth label { display: block; font-size: 13px; margin-bottom: 10px; }
.auth input { width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; min-height: 44px; }
.auth .primary { width: 100%; min-height: 44px; background: var(--teal); color: #fff; border: 0; border-radius: 8px; font-weight: 600; }
.error { color: var(--danger); font-size: 13px; min-height: 1.2em; }

.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 8px 12px;
  padding: 10px 16px; background: var(--teal); color: #f4f1ea;
}
.brand { font-weight: 700; font-size: 16px; }
.who { font-size: 12px; margin-left: auto; opacity: .9; }
.topbar .ghost {
  background: transparent; color: #f4f1ea; border: 1px solid #cde;
  border-radius: 8px; padding: 8px 12px; min-height: 40px;
}

main { flex: 1; padding: 16px 16px 28px; max-width: 1100px; width: 100%; margin: 0 auto; }
h2 { margin: 0; font-size: 20px; color: var(--teal); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pills button {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 8px 12px; min-height: 40px; font-size: 13px;
}
.pills button b { font-variant-numeric: tabular-nums; margin-left: 2px; }
.pills button.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.pills button[data-status="overdue"].on { background: var(--late); border-color: var(--late); }

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.filters label, .flab { display: block; font-size: 12px; color: var(--muted); }
.filters input, .filters select {
  width: 100%; min-height: 42px; padding: 8px 10px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.filters .span2 { grid-column: 1 / -1; }

.toolbar { display: flex; gap: 8px; }
.btn {
  min-height: 42px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; font-weight: 600;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn.ship { background: var(--ship); color: #fff; border-color: var(--ship); }
.btn.ghost { background: transparent; }

.list { display: flex; flex-direction: column; gap: 10px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.sheet-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.sheet-table th {
  text-align: left; padding: 10px 8px; background: #eef6f3; color: var(--teal);
  font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--line);
}
.sheet-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sheet-table tr:last-child td { border-bottom: 0; }
.sheet-table tr.late { background: #fdf2f2; }
.sheet-table .party { font-weight: 700; }
.sheet-table .ops { display: flex; gap: 6px; white-space: nowrap; }
.sheet-table .ops .btn { min-height: 36px; padding: 0 10px; font-size: 13px; }
.late-banner {
  background: var(--late); color: #fff; padding: 10px 12px; border-radius: 10px;
  margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 14px;
}
.late-banner.hidden { display: none !important; }
.late-banner .btn { background: #fff; color: var(--late); border-color: #fff; min-height: 36px; font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 1px 0 rgb(28 31 29 / .04);
}
.card.late {
  background: #fdf2f2; border-color: #e0a0a0;
  box-shadow: inset 4px 0 0 var(--late);
}
.card .row1 { display: flex; align-items: center; gap: 8px; }
.card .party { font-size: 17px; font-weight: 700; line-height: 1.3; flex: 1; min-width: 0; }
.card .kv {
  display: grid; grid-template-columns: 64px 1fr; gap: 4px 8px;
  margin-top: 8px; font-size: 13px;
}
.card .kv dt { color: var(--muted); }
.card .kv dd { margin: 0; word-break: break-all; }
.card .actions { display: flex; gap: 8px; margin-top: 10px; }
.card .actions .btn { flex: 1; }
.st {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); flex: 0 0 auto;
}
.st.late-tag { background: var(--late); color: #fff; border-color: var(--late); }
.st.draft { background: #f6f4ef; }
.st.shipped { background: #e8f0fa; color: var(--ship); border-color: #c5d6ee; }
.st.archived { background: #eee; color: var(--arch); }
.st.mode { background: #eef6f3; color: var(--teal); border-color: #cfe0d9; }

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

.form { display: grid; gap: 12px; }
.form label { display: block; font-size: 13px; }
.form input, .form select, .form textarea {
  width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; min-height: 44px; background: #fff;
}
.req { color: var(--danger); font-weight: 700; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }
.form-actions .btn { flex: 1; }

.choice { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 6px; }
.choice.four { grid-template-columns: 1fr 1fr; }
@media (min-width: 520px) {
  .choice.four { grid-template-columns: 1fr 1fr 1fr 1fr; }
}
.choice button {
  min-height: 44px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-weight: 600;
}
.choice button.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.choice button:disabled { opacity: .4; cursor: not-allowed; }
.logis {
  display: grid; gap: 12px; padding: 12px; background: #eef6f3;
  border: 1px solid #cfe0d9; border-radius: 10px;
}

.combo { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 8;
  margin: 4px 0 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  max-height: 220px; overflow: auto; box-shadow: 0 8px 24px rgb(28 31 29 / .12);
}
.suggest li { padding: 10px 12px; border-radius: 6px; min-height: 40px; }
.suggest li:hover, .suggest li.on { background: #eef6f3; }

.detail dl { margin: 0; display: grid; grid-template-columns: 108px 1fr; gap: 8px 10px; font-size: 14px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.log { margin-top: 16px; font-size: 13px; padding-left: 18px; }
.log li { margin: 6px 0; color: var(--muted); }

.modal {
  position: fixed; inset: 0; background: rgb(0 0 0 / .4);
  display: grid; place-items: end center;
}
.modal .sheet {
  width: min(520px, 100%); background: #fff; border-radius: 12px 12px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 720px) {
  .modal { place-items: center; }
  .modal .sheet { border-radius: 12px; }
}
.modal h3 { margin: 0 0 10px; font-size: 16px; }
.modal textarea, .modal input {
  width: 100%; padding: 10px; border: 1px solid var(--line);
  border-radius: 8px; min-height: 44px;
}
.modal textarea { min-height: 72px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; z-index: 20; max-width: 90%;
}
