/* ============================================================
   通用组件：卡片 / 列表 / 表单 / 标签 / 按钮 / 弹层
   ============================================================ */

.pad { padding: 12px; }
.pad-x { padding-left: 12px; padding-right: 12px; }
.gap-8 { height: 8px; }
.gap-12 { height: 12px; }
.gap-24 { height: 24px; }
.safe-b { height: 18px; }

.row { display: flex; align-items: center; }
.row-b { display: flex; align-items: center; justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-500); }
.dim { color: var(--ink-400); }
.strong { font-weight: 600; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t11 { font-size: var(--fs-11); }
.t12 { font-size: var(--fs-12); }
.t13 { font-size: var(--fs-13); }
.t14 { font-size: var(--fs-14); }
.t16 { font-size: var(--fs-16); }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.card + .card { margin-top: 12px; }

.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 11px;
}

.card-hd + .card-bd { padding-top: 0; }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-15);
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: 0.2px;
}

/* 参考图的标题色条，做得更精细 */
.card-title::before {
  content: "";
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--brand-600);
}
.card-title.safety::before { background: var(--safety-600); }

.card-more {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-12);
  color: var(--ink-500);
  cursor: pointer;
  padding: 2px 0 2px 8px;
}
.card-more svg { width: 14px; height: 14px; }

.card-bd { padding: 0 14px 14px; }
.card-ft {
  padding: 11px 14px;
  border-top: 1px solid var(--line-soft);
  background: #FCFDFE;
}

/* ---------------- 分节标题（无卡片） ---------------- */
.sec-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 14px 8px;
}
.sec-hd h3 {
  margin: 0;
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--ink-700);
  letter-spacing: 0.3px;
}
.sec-hd .more { font-size: var(--fs-12); color: var(--ink-500); }

/* ---------------- 列表单元 ---------------- */
.cells { background: var(--surface); }
.cell {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  font-family: inherit;
  font-size: var(--fs-14);
  color: var(--ink-900);
  text-align: left;
  cursor: pointer;
}
.cell:last-child { border-bottom: 0; }
.cell:active { background: var(--line-soft); }
.cell .cell-ico {
  width: 32px; height: 32px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--brand-050);
  color: var(--brand-600);
}
.cell .cell-ico svg { width: 18px; height: 18px; }
.cell .cell-main { flex: 1; min-width: 0; }
.cell .cell-sub { font-size: var(--fs-12); color: var(--ink-500); margin-top: 2px; }
.cell .cell-val { font-size: var(--fs-13); color: var(--ink-500); }
.cell .chev { color: var(--ink-300); flex: none; display: grid; place-items: center; }
.cell .chev svg { width: 16px; height: 16px; }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-xs);
  font-size: var(--fs-11);
  font-weight: 500;
  line-height: 1;
  background: var(--brand-100);
  color: var(--brand-700);
  white-space: nowrap;
}
.tag.ok { background: var(--ok-100); color: var(--ok-700); }
.tag.warn { background: var(--warn-100); color: var(--warn-600); }
.tag.risk { background: var(--risk-100); color: var(--risk-700); }
.tag.safety { background: var(--safety-100); color: var(--safety-700); }
.tag.info { background: var(--info-100); color: var(--info-600); }
.tag.gray { background: var(--bg-sunken); color: var(--ink-600); }
.tag.dot::before {
  content: "";
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.tag.lg { height: 24px; padding: 0 9px; font-size: var(--fs-12); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: var(--fs-15);
  font-weight: 500;
  cursor: pointer;
  background: var(--brand-600);
  color: #fff;
  transition: transform 120ms var(--ease), background 150ms var(--ease);
}
.btn:active { transform: scale(0.985); background: var(--brand-700); }
.btn svg { width: 17px; height: 17px; }
.btn.ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink-700); }
.btn.ghost:active { background: var(--line-soft); }
.btn.tint { background: var(--brand-050); color: var(--brand-700); border-color: var(--brand-100); }
.btn.safety { background: var(--safety-600); }
.btn.danger { background: var(--surface); border-color: var(--risk-100); color: var(--risk-600); }
.btn.block { display: flex; width: 100%; }
.btn.sm { height: 32px; font-size: var(--fs-13); padding: 0 12px; border-radius: var(--r-xs); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn-bar {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 10px 14px 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.btn-bar .btn { flex: 1; }

/* ---------------- 表单 ---------------- */
.form { background: var(--surface); }
.field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 48px;
}
.field:last-child { border-bottom: 0; }
.field > label {
  flex: none;
  width: 78px;
  font-size: var(--fs-14);
  color: var(--ink-700);
  padding-top: 7px;
}
.field > label .req { color: var(--risk-600); margin-left: 2px; }
.field .fc { flex: 1; min-width: 0; }

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-14);
  color: var(--ink-900);
  padding: 7px 0;
  resize: none;
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-300); }
.field select { appearance: none; cursor: pointer; }

.picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-14);
  color: var(--ink-900);
  padding: 7px 0;
  cursor: pointer;
  text-align: left;
}
.picker.empty { color: var(--ink-300); }
.picker svg { width: 16px; height: 16px; color: var(--ink-300); flex: none; }

.field-note {
  padding: 8px 14px 12px;
  font-size: var(--fs-12);
  color: var(--ink-500);
  background: var(--surface);
  line-height: 1.6;
}

.uploader { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 2px; }
.up-item, .up-add {
  width: 72px; height: 72px;
  border-radius: var(--r-sm);
  flex: none;
  position: relative;
  overflow: hidden;
}
.up-item { background: linear-gradient(150deg, #C9D6E6, #A9BCD3); }
.up-item .del {
  position: absolute; right: 3px; top: 3px;
  width: 17px; height: 17px; border-radius: 50%;
  background: rgba(16,24,40,.55); color: #fff;
  border: 0; cursor: pointer; display: grid; place-items: center;
  font-size: 11px; line-height: 1; padding: 0;
}
.up-add {
  border: 1px dashed var(--line-strong);
  background: var(--bg);
  color: var(--ink-400);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  cursor: pointer;
  font-size: var(--fs-11);
}
.up-add svg { width: 20px; height: 20px; }

/* 开关 */
.switch {
  width: 44px; height: 25px; border-radius: var(--r-pill);
  background: var(--line-strong); border: 0; padding: 0;
  position: relative; cursor: pointer; flex: none;
  transition: background 180ms var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(16,24,40,.25);
  transition: transform 180ms var(--ease);
}
.switch.on { background: var(--brand-600); }
.switch.on::after { transform: translateX(19px); }

/* 分段控制 */
.seg {
  display: flex;
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}
.seg button {
  flex: 1; border: 0; background: transparent;
  font-family: inherit; font-size: var(--fs-13);
  color: var(--ink-600); padding: 6px 0;
  border-radius: 4px; cursor: pointer;
}
.seg button.on {
  background: var(--surface); color: var(--ink-900);
  font-weight: 500; box-shadow: var(--sh-card);
}

/* 筛选条 */
.filters {
  display: flex; gap: 8px; padding: 10px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.filters::-webkit-scrollbar { height: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 11px; flex: none;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: inherit; font-size: var(--fs-13);
  color: var(--ink-600); cursor: pointer;
}
.chip.on { background: var(--brand-050); border-color: var(--brand-200); color: var(--brand-700); font-weight: 500; }
.chip svg { width: 13px; height: 13px; }

/* 搜索框 */
.searchbar { padding: 9px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.search {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 11px;
  background: var(--bg-sunken); border-radius: var(--r-pill);
  color: var(--ink-400);
}
.search input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-family: inherit; font-size: var(--fs-13); color: var(--ink-900);
}
.search svg { width: 15px; height: 15px; flex: none; }

/* ---------------- 数据表现 ---------------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px 12px 11px 14px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  box-shadow: var(--sh-card);
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; border-radius: 0 2px 2px 0; background: var(--brand-500);
}
.kpi.ok::before { background: var(--ok-600); }
.kpi.warn::before { background: var(--warn-600); }
.kpi.risk::before { background: var(--risk-600); }
.kpi.safety::before { background: var(--safety-500); }
.kpi .v { font-size: var(--fs-26); font-weight: 600; color: var(--ink-900); line-height: 1.15; }
.kpi .v small { font-size: var(--fs-12); font-weight: 500; color: var(--ink-500); margin-left: 3px; }
.kpi .k { font-size: var(--fs-12); color: var(--ink-500); margin-top: 3px; }

.stat-row { display: flex; }
.stat {
  flex: 1;
  text-align: center;
  position: relative;
}
.stat + .stat::before {
  content: ""; position: absolute; left: 0; top: 20%; height: 60%;
  width: 1px; background: var(--line);
}
.stat .v { font-size: var(--fs-18); font-weight: 600; }
.stat .v small { font-size: var(--fs-11); font-weight: 400; color: var(--ink-500); margin-left: 2px; }
.stat .k { font-size: var(--fs-12); color: var(--ink-500); margin-top: 3px; }

/* 金额条（合同类） */
.money-list { display: grid; gap: 11px; }
.money-item .row-b { margin-bottom: 6px; }
.money-item .lbl { font-size: var(--fs-13); color: var(--ink-600); }
.money-item .amt { font-size: var(--fs-15); font-weight: 600; }
.money-item .bar { height: 5px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.money-item .bar i { display: block; height: 100%; border-radius: 3px; background: var(--brand-500); }
.money-item.out .bar i { background: var(--safety-500); }
.money-item.done .bar i { background: var(--ok-600); }

/* 进度条 */
.progress {
  height: 6px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden;
}
.progress i { display: block; height: 100%; border-radius: 3px; background: var(--brand-500); transition: width 400ms var(--ease); }
.progress.thin { height: 4px; }
.progress i.risk { background: var(--risk-600); }
.progress i.warn { background: var(--safety-500); }
.progress i.ok { background: var(--ok-600); }

/* 里程碑步进 */
.milestones {
  display: flex; gap: 0; overflow-x: auto; padding: 6px 2px 4px;
}
.milestones::-webkit-scrollbar { height: 0; }
.ms {
  flex: none; width: 74px; text-align: center; position: relative;
}
.ms::before {
  content: ""; position: absolute; left: -37px; top: 20px; width: 74px; height: 2px;
  background: var(--line-strong);
}
.ms:first-child::before { display: none; }
.ms.done::before { background: var(--ok-600); }
.ms .dot {
  position: relative; z-index: 1;
  width: 40px; height: 40px; margin: 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--fs-12); font-weight: 600;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  color: var(--ink-400);
}
.ms.done .dot { background: var(--ok-100); border-color: var(--ok-600); color: var(--ok-700); }
.ms.doing .dot { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.ms .nm { font-size: var(--fs-11); color: var(--ink-600); margin-top: 6px; line-height: 1.3; }
.ms.doing .nm { color: var(--brand-700); font-weight: 500; }

/* 排名列表 */
.rank-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
  width: 100%; background: transparent; border-left: 0; border-right: 0; border-top: 0;
  font-family: inherit; text-align: left; cursor: pointer;
}
.rank-item:last-child { border-bottom: 0; }
.rank-no {
  width: 20px; height: 20px; flex: none; border-radius: var(--r-xs);
  display: grid; place-items: center;
  font-size: var(--fs-11); font-weight: 700;
  background: var(--bg-sunken); color: var(--ink-500);
}
.rank-no.t1 { background: var(--safety-600); color: #fff; }
.rank-no.t2 { background: #8FA3BC; color: #fff; }
.rank-no.t3 { background: #C2A17B; color: #fff; }

.stars { display: inline-flex; gap: 2px; }
.stars svg { width: 12px; height: 12px; color: var(--line-strong); }
.stars svg.f { color: var(--safety-500); }

/* 斜纹警示条 */
.stripe {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  font-size: var(--fs-12);
  color: var(--safety-700);
  background:
    repeating-linear-gradient(-45deg, rgba(217,96,10,.09) 0 8px, rgba(217,96,10,.02) 8px 16px),
    var(--safety-050);
  border-left: 3px solid var(--safety-600);
}
.stripe svg { width: 15px; height: 15px; flex: none; }
.stripe.risk {
  color: var(--risk-700); border-left-color: var(--risk-600);
  background:
    repeating-linear-gradient(-45deg, rgba(201,60,49,.09) 0 8px, rgba(201,60,49,.02) 8px 16px),
    var(--risk-100);
}

/* 时间轴 */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 1px; background: var(--line);
}
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -19px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong);
}
.tl-item.on::before { border-color: var(--brand-600); background: var(--brand-600); }
.tl-item.ok::before { border-color: var(--ok-600); background: var(--ok-600); }
.tl-t { font-size: var(--fs-13); font-weight: 500; }
.tl-s { font-size: var(--fs-12); color: var(--ink-500); margin-top: 2px; }

/* 空状态 */
.empty {
  padding: 64px 24px; text-align: center; color: var(--ink-400);
}
.empty svg { width: 46px; height: 46px; color: var(--ink-300); margin-bottom: 10px; }
.empty p { margin: 0; font-size: var(--fs-13); }

/* 头像 */
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-100); color: var(--brand-700);
  font-size: var(--fs-14); font-weight: 600;
}
.avatar.sm { width: 32px; height: 32px; font-size: var(--fs-12); }
.avatar.lg { width: 54px; height: 54px; font-size: var(--fs-18); }
.avatar.safety { background: var(--safety-100); color: var(--safety-700); }
.avatar.ok { background: var(--ok-100); color: var(--ok-700); }

/* ---------------- 弹层 ---------------- */
.mask {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(16, 24, 40, 0.42);
  animation: fadeMask 200ms var(--ease);
}
@keyframes fadeMask { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 51;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  max-height: 74%;
  display: flex; flex-direction: column;
  animation: sheetUp 280ms var(--ease);
  padding-bottom: 16px;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line-soft);
}
.sheet-hd h4 { margin: 0; font-size: var(--fs-15); font-weight: 600; }
.sheet-hd .x { border: 0; background: transparent; color: var(--ink-400); cursor: pointer; padding: 4px; }
.sheet-bd { overflow-y: auto; }
.sheet-bd::-webkit-scrollbar { width: 0; }
.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line-soft);
  background: transparent; font-family: inherit; font-size: var(--fs-14);
  color: var(--ink-900); cursor: pointer; text-align: left;
}
.opt:active { background: var(--line-soft); }
.opt.on { color: var(--brand-600); font-weight: 500; }
.opt .ck { color: var(--brand-600); display: none; }
.opt.on .ck { display: block; }
.opt .ck svg { width: 17px; height: 17px; }

.dialog {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  z-index: 52; width: 280px;
  background: var(--surface); border-radius: var(--r-lg);
  overflow: hidden; animation: dlgIn 220ms var(--ease);
  box-shadow: var(--sh-float);
}
@keyframes dlgIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.dialog .d-bd { padding: 22px 20px 18px; text-align: center; }
.dialog h4 { margin: 0 0 7px; font-size: var(--fs-16); font-weight: 600; }
.dialog p { margin: 0; font-size: var(--fs-13); color: var(--ink-600); line-height: 1.6; }
.dialog .d-ft { display: flex; border-top: 1px solid var(--line-soft); }
.dialog .d-ft button {
  flex: 1; border: 0; background: transparent; padding: 13px 0;
  font-family: inherit; font-size: var(--fs-15); cursor: pointer; color: var(--ink-600);
}
.dialog .d-ft button + button { border-left: 1px solid var(--line-soft); color: var(--brand-600); font-weight: 500; }

.toast {
  position: absolute; left: 50%; top: 46%; transform: translateX(-50%);
  z-index: 60; max-width: 76%;
  background: rgba(16, 24, 40, 0.86);
  color: #fff; padding: 11px 16px; border-radius: var(--r-md);
  font-size: var(--fs-13); text-align: center; line-height: 1.5;
  animation: toastIn 200ms var(--ease);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; gap: 7px;
}
.toast svg { width: 16px; height: 16px; flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(6px); } to { opacity: 1; } }

/* 悬浮新增按钮 */
.fab-add {
  position: absolute; right: 16px; bottom: calc(70px + var(--sbb)); z-index: 15;
  width: 50px; height: 50px; border-radius: 16px; border: 0;
  background: linear-gradient(155deg, var(--brand-500), var(--brand-700));
  color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 8px 18px rgba(19, 71, 149, 0.34);
}
.fab-add svg { width: 24px; height: 24px; }
.fab-add:active { transform: scale(0.94); }
