:root {
  --bg: #f7f6f4;
  --card: #ffffff;
  --ink: #1c1917;
  --ink-2: #57534e;
  --ink-3: #8c8681;
  --line: #e7e5e4;
  --line-soft: #f0eeeb;
  --brand: #c2410c;
  --brand-soft: #fdf3ee;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 4px 16px rgba(28, 25, 23, 0.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* .sheet 等元素带 display:flex，会覆盖 [hidden] 的 display:none，必须显式压回去 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.shell {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  background: rgba(247, 246, 244, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-brand { display: flex; align-items: center; gap: 8px; }

.mark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--brand);
  display: inline-block;
}

.brand-text { font-size: 15px; font-weight: 600; letter-spacing: 0.2px; }

.topbar-action {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.topbar-action:active { background: var(--line-soft); }

/* ---------- 加载 ---------- */
.loading { padding: 64px 0; text-align: center; color: var(--ink-3); font-size: 14px; }

.spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 14px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 卡片 ---------- */
.card {
  max-width: 100%;
  min-width: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 16px;
}

.card-head {
  padding: 18px 18px 0;
}

.period-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.period-title { font-size: 17px; font-weight: 600; letter-spacing: 0.2px; }

.period-sub { font-size: 12.5px; color: var(--ink-3); }

.person-line {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--ink-2);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.person-line .sep { color: var(--line); }

/* ---------- 实发金额 ---------- */
.hero {
  margin: 16px 18px 4px;
  padding: 20px 18px;
  border-radius: 12px;
  background: var(--brand-soft);
}

.hero-label {
  font-size: 12.5px;
  color: var(--brand);
  letter-spacing: 1px;
  font-weight: 500;
}

.hero-amount {
  margin-top: 4px;
  font-size: 38px;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.hero-amount .unit { font-size: 18px; font-weight: 500; margin-right: 2px; }

.hero-meta {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---------- 明细 ---------- */
.section { padding: 18px; border-top: 1px solid var(--line-soft); }
.section:first-of-type { border-top: none; }

.section-title {
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.6px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  font-size: 14.5px;
}

.item-row .label { color: var(--ink-2); }
.item-row .value { font-variant-numeric: tabular-nums; color: var(--ink); }

.item-row.subtotal {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-weight: 600;
}
.item-row.subtotal .label { color: var(--ink); }

.item-row.zero .value { color: var(--ink-3); }

.item-row.deduct .value { color: var(--warn); }

.remark {
  margin-top: 4px;
  padding: 12px 14px;
  background: #faf9f7;
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 签收 ---------- */
.sign-zone { padding: 0 18px 18px; }

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.995); opacity: 0.9; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost {
  background: var(--card);
  color: var(--ink-2);
  border: 1px solid var(--line);
  font-weight: 500;
  font-size: 14.5px;
  margin-top: 10px;
}
.btn:disabled { opacity: 0.5; cursor: default; }

.signed-box {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--ok-soft);
  border: 1px solid #dcfce7;
}

.signed-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ok);
  position: relative;
}
.signed-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}

.signed-text strong { color: var(--ok); font-size: 14.5px; display: block; }
.signed-text span { font-size: 12.5px; color: var(--ink-2); display: block; margin-top: 3px; }
.signed-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ---------- 状态标签 ---------- */
.tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  line-height: 1.6;
}
.tag-wait { background: var(--warn-soft); color: var(--warn); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-dispute { background: var(--brand-soft); color: var(--brand); }

/* ---------- 历史 ---------- */
.history-list { margin-top: 16px; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  cursor: pointer;
}
.history-item:active { background: #fcfbfa; }

.history-left { display: flex; flex-direction: column; gap: 3px; }
.history-period { font-size: 15px; font-weight: 600; }
.history-sub { font-size: 12px; color: var(--ink-3); }
.history-right { text-align: right; }
.history-amount {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.history-amount.muted { color: var(--ink-3); }

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.8;
}

/* ---------- 页面切换 ---------- */
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0 4px;
}
.back-btn {
  border: none;
  background: none;
  font-size: 14.5px;
  color: var(--brand);
  padding: 4px 0;
  cursor: pointer;
  font-family: inherit;
}
.page-title { font-size: 16px; font-weight: 600; }

/* ---------- 抽屉 ---------- */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.4);
  z-index: 40;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-width: 430px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  animation: slideUp 0.22s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
@keyframes slideUp { from { transform: translateY(100%); } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet-close {
  border: none;
  background: var(--line-soft);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
}

.sheet-body { padding: 0 20px; overflow-y: auto; }

.field-label {
  font-size: 13px;
  color: var(--ink-2);
  margin: 16px 0 8px;
  display: block;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
}
.chip.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 500;
}

textarea {
  width: 100%;
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14.5px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  color: var(--ink);
  background: #fcfbfa;
}
textarea:focus { outline: none; border-color: var(--brand); background: #fff; }

.sheet-actions { padding: 18px 0 4px; }

.hint { font-size: 12px; color: var(--ink-3); margin-top: 10px; line-height: 1.6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  background: rgba(28, 25, 23, 0.92);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 60;
  max-width: 82vw;
  text-align: center;
  animation: fade 0.16s ease;
}

/* ---------- 页脚 ---------- */
.footnote {
  margin-top: 40px;
  padding: 28px 4px 0;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.7;
  text-align: center;
}

/* ---------- 登录（模拟模式） ---------- */
.login-card { padding: 24px 20px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; font-weight: 600; }
.login-card p { font-size: 13.5px; color: var(--ink-2); margin: 0 0 20px; line-height: 1.7; }

.picker { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
}
.picker-item:active { background: var(--brand-soft); border-color: var(--brand); }
.picker-item .no {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--ink-3);
}

.dev-note {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--warn-soft);
  border-radius: 10px;
  font-size: 12px;
  color: var(--warn);
  line-height: 1.7;
}
