:root {
  --ink: #23202b;
  --ink-2: #3a3547;
  --paper: #f5f3ef;
  --card: #ffffff;
  --line: #e6e1d8;
  --gold: #c9a227;
  --gold-soft: #f4ead0;
  --red: #c0392b;
  --green: #2e7d5b;
  --blue: #2f6fb0;
  --muted: #8a8577;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(35, 32, 43, 0.08), 0 4px 14px rgba(35, 32, 43, 0.05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--ink); min-width: 0; }

#root { max-width: 560px; margin: 0 auto; min-height: 100vh; background: var(--paper); }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), #e3c25a);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--ink); font-size: 15px;
}
.topbar .brand .t1 { font-weight: 700; font-size: 16px; }
.topbar .brand .t2 { font-size: 11px; opacity: .7; margin-top: -2px; }
.topbar .who { text-align: right; }
.topbar .who .name { font-size: 13px; font-weight: 600; }
.topbar .who .role { font-size: 11px; opacity: .75; }
.topbar .switch {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; padding: 5px 12px; font-size: 12px;
}

/* 内容区 */
.view { padding: 14px 14px 96px; }
.section-title { font-size: 13px; color: var(--muted); margin: 18px 2px 8px; letter-spacing: .5px; }
.section-title:first-child { margin-top: 4px; }

/* 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.card h4 { margin: 12px 0 6px; font-size: 14px; color: var(--ink-2); }

/* 表单 */
.field { margin-bottom: 10px; min-width: 0; }
.field label:not(.switch) { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%; max-width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; background: #fbfaf7; outline: none;
}
input[type="date"], input[type="month"], input[type="time"], input[type="datetime-local"] {
  min-width: 0; width: 100%; -webkit-appearance: none; appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); background: #fff; }
.row { display: flex; gap: 10px; }
.row .field { flex: 1; min-width: 0; }
textarea { min-height: 60px; resize: vertical; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { display: none; }
.switch .track { flex: 0 0 auto; width: 44px; height: 24px; border-radius: 999px; background: #d8d3c8; position: relative; transition: .2s; }
.switch > span:last-child { line-height: 1.4; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { left: 23px; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 9px; padding: 10px 16px; font-size: 14px; font-weight: 600; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-outline { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
.btn-danger { background: #fbeae8; color: var(--red); border: 1px solid #f0c9c4; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 0; }

/* 徽章 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.badge-S { background: #f4ead0; color: #8a6d1a; }
.badge-A { background: #e3f0ea; color: var(--green); }
.badge-B { background: #e3ecf7; color: var(--blue); }
.badge-C { background: #fdf0d8; color: #b0761a; }
.badge-D { background: #fbeae8; color: var(--red); }
.badge-pending { background: #fdf0d8; color: #b0761a; }
.badge-approved { background: #e3f0ea; color: var(--green); }
.badge-rejected { background: #fbeae8; color: var(--red); }
.badge-plain { background: #eeece6; color: var(--ink-2); }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13px; }
th, td { padding: 8px 9px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f3f0ea; color: var(--ink-2); font-weight: 600; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
td.left { text-align: left; }
.num { font-variant-numeric: tabular-nums; }
.td-total { font-weight: 700; }
.td-input { width: 76px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 13px; text-align: center; }

/* 照片 */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.photo-cell { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f0ede7; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: none; font-size: 13px; line-height: 1;
}
.photo-add { aspect-ratio: 1; border: 1.5px dashed var(--line); border-radius: 8px; background: #fbfaf7; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 12px; text-align: center; }

/* 列表 */
.item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item .body { flex: 1; min-width: 0; }
.item .body .t { font-weight: 600; font-size: 14px; }
.item .body .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item .right { text-align: right; }

/* 空态 */
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13px; }

/* 登录页 */
.login { padding: 20px 16px; }
.login .hero { text-align: center; padding: 26px 0 18px; }
.login .hero .seal {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, var(--ink), #4a4459); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; box-shadow: var(--shadow);
}
.login .hero h1 { margin: 0; font-size: 22px; }
.login .hero p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.login .pick { margin-bottom: 8px; }
.login .pick-head { font-size: 13px; color: var(--muted); margin: 14px 2px 8px; }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tabbar .tab {
  flex: 1 0 auto; min-width: 62px; border: none; background: none; padding: 9px 2px 8px; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar .tab .ic { font-size: 19px; line-height: 1; }
.tabbar .tab.active { color: var(--gold); font-weight: 700; }

/* 多选 DM 芯片 */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fbfaf7; font-size: 13px; cursor: pointer; }
.chip input { display: none; }
.chip:has(input:checked) { background: var(--gold-soft); border-color: var(--gold); font-weight: 600; color: var(--ink); }

/* 照片放大查看 */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.86); z-index: 120; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 8px; }
.lightbox .lb-close { position: absolute; top: 18px; right: 18px; width: 36px; height: 36px; border-radius: 50%; border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 22px; line-height: 1; }

/* 结算摘要卡 */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; text-align: center; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.hl { background: linear-gradient(135deg, var(--ink), #4a4459); color: #fff; border: none; }
.kpi.hl .k { color: rgba(255,255,255,.7); }

/* 提示条 */
.note { background: var(--gold-soft); border: 1px solid #eadfbe; color: #7a5f16; border-radius: 9px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.note.red { background: #fbeae8; border-color: #f0c9c4; color: #9a2e22; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(35,32,43,.92); color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 99; max-width: 82vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 弹层 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal .m-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal .m-head h2 { margin: 0; font-size: 17px; }
.modal .m-close { border: none; background: #f0ede7; width: 30px; height: 30px; border-radius: 50%; font-size: 16px; color: var(--ink-2); }
