:root {
  --bg: #eef1f7;
  --panel: #ffffff;
  --line: #e3e7ef;
  --text: #1c2331;
  --muted: #6b7488;
  --blue: #2f6fed;
  --blue-dark: #2459c6;
  --amber: #e08a00;
  --green: #199a63;
  --red: #d93a3a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 6px 20px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

button, input, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, .14);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.lan {
  font-size: 12.5px;
  color: var(--muted);
  background: #f3f5fa;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: all;
  cursor: copy;
}

/* ---------------------------------------------------------------- 按钮 */

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 15px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .06s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(47, 111, 237, .28);
}
.btn.primary:hover { background: var(--blue-dark); }

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.btn.ghost:hover { background: #f4f6fa; color: var(--text); }

.btn.danger {
  background: transparent;
  color: var(--red);
  border-color: #f0c9c9;
}
.btn.danger:hover { background: #fdf1f1; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #f0f2f7; color: var(--text); }

/* ---------------------------------------------------------------- 看板 */

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  padding: 20px 22px 40px;
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}

/* 中等屏幕放不下五列时，横向滑动看板 */
@media (max-width: 1250px) and (min-width: 861px) {
  .board {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .col {
    flex: 0 0 280px;
  }
}

.col {
  background: #e7ebf3;
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
}

.col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 10px;
}

.col-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.col-head h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.col[data-status="todo"] .col-head h2::before { background: var(--amber); }
.col[data-status="doing"] .col-head h2::before { background: var(--blue); }
.col[data-status="pending"] .col-head h2::before { background: #7c5cd6; }
.col[data-status="done"] .col-head h2::before { background: var(--green); }
.col[data-status="expired"] .col-head h2::before { background: #c2410c; }

.count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .8);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.col-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.col-add {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid #d5e2fb;
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.col-add:hover {
  border-color: var(--blue);
  background: #f2f7ff;
}

.card {
  background: var(--panel);
  border-radius: 12px;
  padding: 13px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  border: 1px solid rgba(255, 255, 255, .7);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(20, 30, 60, .08), 0 12px 28px rgba(20, 30, 60, .10);
}

.card-order {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 7px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eef3fd;
  color: #2b4a86;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.card-title {
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.45;
  word-break: break-word;
  margin-bottom: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #9aa2b4;
  background: #f4f6fa;
  border: 1px solid #eef1f6;
  border-radius: 7px;
  padding: 2px 7px;
}
.chip.on { color: #3c4a63; background: #eef3fd; border-color: #dbe6fb; }
.chip b { font-weight: 700; color: var(--blue); }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 11.5px;
  color: #9aa2b4;
}

.empty {
  text-align: center;
  color: #98a1b3;
  font-size: 12.5px;
  padding: 22px 8px;
  border: 1px dashed #cfd6e3;
  border-radius: 10px;
}

/* ---------------------------------------------------------------- 详情 */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 26, 43, .42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 18px;
  overflow-y: auto;
  backdrop-filter: blur(2px);
  animation: fade .15s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.detail {
  width: 100%;
  max-width: 1000px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(10, 20, 40, .25);
  animation: pop .18s ease;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.995); }
  to { opacity: 1; transform: none; }
}

.detail-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 12px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
}

.title-input {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 8px;
  outline: none;
  text-overflow: ellipsis;
}
.detail-title {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: text;
}

.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); }

.badge {
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.badge.todo { background: #fff3df; color: #a26000; }
.badge.doing { background: #e5efff; color: #1d4ed8; }
.badge.pending { background: #f1ecfe; color: #6d3bd1; }
.badge.done { background: #e2f6ec; color: #0d7a4c; }
.badge.expired { background: #fdecea; color: #b3261e; }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px 4px;
}

.detail-actions .btn.danger {
  margin-left: auto;
}

.detail-meta {
  padding: 10px 20px 0;
  font-size: 12px;
  color: #9aa2b4;
}

.blocks {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 18px 22px;
}

/* 详情底部：进入下一步 */
.detail-footer {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  border-radius: 0 0 16px 16px;
  box-shadow: 0 -8px 24px rgba(20, 30, 60, .06);
}

/* 详情打开时，提示条上移，避免压住底部按钮 */
body.modal-open .toast {
  bottom: calc(100px + env(safe-area-inset-bottom));
}

.detail-footer[hidden] { display: none !important; }

.detail-footer .btn {
  flex: 1;
  min-height: 46px;
  font-size: 15px;
  border-radius: 11px;
}

.detail-footer .btn.ghost {
  flex: 0 0 auto;
  padding: 0 16px;
  font-size: 14px;
}

/* ---------------------------------------------------------------- 模块（业务信息 / 生产计划） */

.modules {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 18px 22px;
}

.module {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.module-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: #f7f9fd;
  border-bottom: 1px solid var(--line);
}

.module-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
}

.module-sub {
  font-size: 12px;
  color: #9aa2b4;
}

.module-head .btn {
  margin-left: auto;
  flex: none;
}

.module-head.collapsible {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.module-head.collapsible:hover { background: #eef3fb; }
.module-head.collapsible:active { background: #e7eefa; }
.module-head.collapsible:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.module-arrow {
  margin-left: auto;
  color: #8b95a8;
  font-size: 13px;
  line-height: 1;
  width: 16px;
  text-align: center;
}

.module-body .blocks {
  padding: 14px;
}

.module-body[hidden] {
  display: none;
}

.block {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px;
  background: #fbfcfe;
}

.business-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.business-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcfe;
}

.business-field.wide {
  grid-column: 1 / -1;
}

.business-field label {
  font-size: 13px;
  font-weight: 600;
  color: #43506a;
  white-space: nowrap;
}

.biz-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #dfe4ee;
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.biz-input::placeholder { color: #b3bac9; }
.biz-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}
.biz-input.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(217, 58, 58, .12);
}

.biz-input.readonly {
  background: #f5f7fb;
  color: #43506a;
  cursor: default;
}
.biz-input.readonly:focus {
  border-color: #dfe4ee;
  box-shadow: none;
}

.cost-table input.cell[readonly],
.cost-table input.col-title[readonly] {
  background: #f8fafd;
  color: #43506a;
  cursor: default;
}
.cost-table input.cell[readonly]:focus,
.cost-table input.col-title[readonly]:focus {
  background: #f8fafd;
  box-shadow: none;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.block-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.block-head h3::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--blue);
}

.save-state {
  font-size: 11.5px;
  color: #9aa2b4;
  min-height: 16px;
  transition: color .15s;
}
.save-state.saved { color: var(--green); }
.save-state.error { color: var(--red); }

.block-text {
  width: 100%;
  min-height: 108px;
  resize: vertical;
  border: 1px solid #dfe4ee;
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.65;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.block-text::placeholder { color: #b3bac9; }
.block-text:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}

/* 只读（非当前阶段的内容不可编辑） */
.block-text.readonly {
  background: #f5f7fb;
  color: #43506a;
  cursor: default;
  resize: none;
}
.block-text.readonly:focus {
  border-color: #dfe4ee;
  box-shadow: none;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 10px 0;
}
.file-list:empty { display: none; }

.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #eef1f7;
  min-width: 0;
}
.file-row:hover { border-color: #dde3ef; }

.file-name {
  flex: 1;
  min-width: 0;
  color: #2b4a86;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-name:hover { text-decoration: underline; }
.file-name::before { content: "📎 "; }

.file-size {
  font-size: 11.5px;
  color: #9aa2b4;
  white-space: nowrap;
}

.file-empty {
  font-size: 12px;
  color: #a8b0c0;
  padding: 2px 2px 6px;
}

.dropzone {
  display: block;
  border: 1.5px dashed #cfd7e6;
  border-radius: 11px;
  padding: 14px 12px;
  text-align: center;
  color: #7b859a;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--blue);
  background: #f4f8ff;
  color: var(--blue);
}
.dropzone.busy { cursor: progress; }

.progress {
  height: 5px;
  background: #e8edf6;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.progress .bar {
  height: 100%;
  width: 0;
  background: var(--blue);
  border-radius: 999px;
  transition: width .15s ease;
}

/* ---------------------------------------------------------------- 成本表格 */

.cost-table-wrap {
  margin-bottom: 2px;
}

.cost-table-scroll {
  border: 1px solid #e3e8f1;
  border-radius: 10px;
  background: #fff;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cost-table {
  width: 100%;
  min-width: 320px;
  border-collapse: collapse;
  table-layout: fixed;
}

.cost-table th {
  background: #f3f6fc;
  border-bottom: 1px solid #e3e8f1;
  padding: 0;
  text-align: left;
  position: relative;
}

.cost-table th.idx-col {
  width: 52px;
  padding: 9px 4px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: #6b7588;
}

.cost-table th.ops-col,
.cost-table td.ops-col { width: 40px; }

.cost-table .col-title {
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 22px 9px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: #43506a;
  outline: none;
}
.cost-table .col-title::placeholder { color: #b3bac9; font-weight: 400; }

.cost-table .col-title-static {
  display: block;
  padding: 9px 22px 9px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: #43506a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 成本与报价：总价栏 */
.cost-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  margin: 10px 2px 2px;
  padding: 10px 14px;
  border: 1px solid #e3e8f1;
  border-radius: 10px;
  background: #f7f9fd;
  font-size: 13px;
  color: #43506a;
}

.cost-summary .summary-item b {
  margin-left: 6px;
  color: var(--blue-dark);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.cost-table input.cell.calc {
  background: #f5f8ff;
  color: var(--blue-dark);
  font-weight: 600;
  cursor: default;
}
.cost-table .col-title:focus {
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(47, 111, 237, .35);
}

.cost-table .col-del {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #b6bdcb;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: none;
  padding: 0;
}
.cost-table th:hover .col-del { display: block; }
.cost-table .col-del:hover { background: #fdeaea; color: var(--red); }

.cost-table td {
  border-bottom: 1px solid #eef1f7;
  padding: 0;
  background: #fff;
}
.cost-table tbody tr:last-child td { border-bottom: none; }

.cost-table td.idx {
  text-align: center;
  font-size: 12.5px;
  color: #8b95a8;
  background: #fafbfe;
  padding: 9px 4px;
}

.cost-table input.cell {
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 10px;
  font-size: 13.5px;
  outline: none;
}
.cost-table input.cell:focus {
  background: #f7faff;
  box-shadow: inset 0 0 0 2px rgba(47, 111, 237, .35);
}

.cost-table .del-row { opacity: 0; }
.cost-table tr:hover .del-row { opacity: 1; }
.cost-table .del-row:hover { color: var(--red); background: #fdeaea; }

.cost-table tr.cost-empty-row td {
  text-align: center;
  color: #a8b0c0;
  font-size: 12.5px;
  padding: 18px 10px;
  border-bottom: none;
}

/* 有无库存勾选框 */
.cost-table td.stock-cell {
  text-align: center;
  padding: 0;
}

.cost-table td.stock-cell input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--blue);
  cursor: pointer;
  vertical-align: middle;
}

.cost-table td.stock-cell input[type="checkbox"]:disabled {
  cursor: default;
  opacity: .65;
}

/* 价格列：数值输入（去掉上下微调箭头） */
.cost-table input.cell.num {
  font-variant-numeric: tabular-nums;
}
.cost-table input.cell[type="number"]::-webkit-outer-spin-button,
.cost-table input.cell[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.cost-table input.cell[type="number"] {
  -moz-appearance: textfield;
}

/* 总计行 */
.cost-table tfoot td {
  background: #f7f9fd;
  border-top: 1px solid #e3e8f1;
  padding: 9px 10px;
  font-size: 13px;
}
.cost-table tfoot td.idx {
  background: #f2f5fa;
  color: #8b95a8;
  font-size: 12px;
  text-align: center;
  padding: 9px 4px;
}
.cost-table td.total-label {
  color: #6b7588;
  font-weight: 600;
  font-size: 12.5px;
}
.cost-table td.total-cell {
  color: var(--blue-dark);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 2px;
}

.btn.small {
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  background: #fff;
  border-color: #dfe4ee;
  color: #3f4c63;
}
.btn.small:hover { border-color: var(--blue); color: var(--blue); background: #f6f9ff; }

.table-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: #a8b0c0;
}

/* 触屏设备没有 hover，删除按钮常驻 */
@media (hover: none) {
  .cost-table .col-del { display: block; }
  .cost-table .del-row { opacity: 1; }
}

/* ---------------------------------------------------------------- 弹窗 / 提示 */

.modal {
  width: 100%;
  max-width: 420px;
  margin: 12vh auto 0;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(10, 20, 40, .28);
  animation: pop .18s ease;
}

.modal h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.modal input {
  width: 100%;
  border: 1px solid #dfe4ee;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
}
.modal input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.alert-text {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-line;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 100;
  background: #1f2937;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  max-width: 80vw;
  text-align: center;
  animation: pop .15s ease;
}
.toast.error { background: #b62828; }

/* ---------------------------------------------------------------- 手机端 */

/* ---------------------------------------------------------------- 任务统计 */

.stats-modal {
  max-width: 760px;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 86vh;
  overflow: hidden;
}

.stats-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  padding: 12px 16px 4px;
}

.stats-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.stats-filters select,
.stats-filters input[type="date"] {
  border: 1px solid #dfe4ee;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
  outline: none;
}

.stats-filters select:focus,
.stats-filters input[type="date"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}

.stats-filters .btn { margin-left: auto; }

.stats-steps { flex: 1 1 100%; }

.stats-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.stats-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.stats-filters .stats-check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #43506a;
  cursor: pointer;
}

.stats-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

.stats-filters .stats-toggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-bottom: 9px;
  font-size: 13px;
  color: #43506a;
  white-space: nowrap;
  cursor: pointer;
}

.stats-filters .stats-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

.stats-meta {
  min-height: 18px;
  padding: 8px 16px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.stats-table-wrap {
  flex: 1;
  min-height: 100px;
  margin: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table th,
.stats-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef1f7;
  text-align: left;
  vertical-align: top;
}

.stats-table th {
  position: sticky;
  top: 0;
  background: #f5f8fd;
  color: #43506a;
  font-size: 12.5px;
  font-weight: 600;
}

.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table td { word-break: break-word; }

.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.stats-table tfoot td {
  background: #f8fafd;
  font-weight: 600;
}
.stats-table tfoot .total-label { color: #43506a; }

.stats-empty {
  padding: 26px 12px;
  text-align: center;
  color: #98a1b3;
  font-size: 13px;
}

.stats-modal .modal-actions {
  margin: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------------- 图片预览 */

body.preview-open { overflow: hidden; }

.file-name.file-preview { cursor: zoom-in; }

.preview {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: rgba(10, 14, 22, .9);
  backdrop-filter: blur(3px);
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  color: #fff;
}

.preview-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: #e8edf7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-bar .btn.small {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .3);
  color: #fff;
  text-decoration: none;
}
.preview-bar .btn.small:hover {
  background: rgba(255, 255, 255, .26);
  color: #fff;
}

.preview-close { color: #fff; }
.preview-close:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  overflow: auto;
}

.preview-stage > img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  margin: auto;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .45);
}

.preview-hint {
  flex: 0 0 auto;
  padding: 6px 0 12px;
  color: #dfe7f5;
  font-size: 12.5px;
  text-align: center;
}

.preview-pages {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.preview-pages img {
  width: 100%;
  max-width: 100%;
  max-height: none;
  height: auto;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .4);
}

.preview-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 6px;
  background: #fff;
}

.preview-text {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto 30px;
  padding: 16px 18px;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  font: 13px/1.65 ui-monospace, Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

/* ---------------------------------------------------------------- 搜索 */

.searchbar {
  display: flex;
  gap: 10px;
  padding: 14px 22px 0;
  max-width: 1500px;
  margin: 0 auto;
}

.searchbar .btn {
  background: #fff;
  border-color: var(--line);
  color: #3f4c63;
}
.searchbar .btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: #f6f9ff;
}

.search-modal {
  max-width: 560px;
  margin-top: 9vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 76vh;
  overflow: hidden;
}

.search-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.search-head h2 {
  margin: 0;
  flex: 1;
  font-size: 16px;
}

.search-modal #searchInput {
  flex: none;
  width: calc(100% - 32px);
  margin: 14px 16px 6px;
}

.search-results {
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  padding: 6px 8px 14px;
}

.search-item {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.search-item:hover {
  background: #f4f7fc;
  border-color: #e6ecf7;
}

.search-item-title {
  font-size: 14px;
  font-weight: 650;
  word-break: break-word;
}

.search-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.search-item .badge {
  font-size: 11px;
  padding: 2px 8px;
}

.search-empty {
  padding: 24px 10px;
  text-align: center;
  color: #98a1b3;
  font-size: 13px;
}

/* ---------------------------------------------------------------- 登录 / 注册 */

.auth {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: linear-gradient(160deg, #eef3fd 0%, #f6f8fc 55%, #eef1f7 100%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 18px;
  padding: 26px 24px;
  box-shadow: 0 20px 60px rgba(20, 30, 60, .16);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 20px;
  font-size: 19px;
  font-weight: 700;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: #eef1f7;
  border-radius: 10px;
}

.auth-tab {
  flex: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.auth-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 30, 60, .1);
}

.auth-field { display: block; margin-bottom: 12px; }
.auth-field span {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--muted);
}
.auth-field input {
  width: 100%;
  border: 1px solid #dfe4ee;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
}
.auth-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}
/* 后台密码框：文本输入 + 圆点遮罩，浏览器不识别为密码框，不会提示保存密码 */
.auth-field input.masked {
  -webkit-text-security: disc;
  font-family: inherit;
}

.auth-error {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fdecea;
  color: #b3261e;
  font-size: 12.5px;
}

.auth-error.success {
  background: #e2f6ec;
  color: #0d7a4c;
}

.auth-submit {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
}

.auth-hint {
  margin-top: 14px;
  color: #9aa2b4;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

body.auth-locked .topbar,
body.auth-locked .searchbar,
body.auth-locked .mtabs,
body.auth-locked .board {
  display: none !important;
}

/* ---------------------------------------------------------------- 当前账号 / 用户管理 */

.userbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.who {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.col.status-hidden { display: none !important; }

/* 中等宽度下隐藏账号名，避免顶部拥挤 */
@media (max-width: 1100px) and (min-width: 861px) {
  .who { display: none; }
}

.admin-panel { max-width: 760px; }

.admin-body { padding: 14px 18px 22px; }

.admin-hint {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #e6ecf7;
  border-radius: 10px;
  background: #f5f8fd;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}

.admin-user { flex: 1; min-width: 0; }

.admin-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 650;
}

.admin-name .me-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: #eef3fd;
  color: #2b4a86;
  font-size: 11px;
  font-weight: 600;
}

.admin-meta {
  margin-top: 2px;
  color: #9aa2b4;
  font-size: 11.5px;
}

.admin-level {
  border: 1px solid #dfe4ee;
  border-radius: 8px;
  background: #fff;
  padding: 7px 8px;
  font-size: 12.5px;
  outline: none;
}

.admin-actions { display: flex; gap: 6px; }

/* 独立管理后台页面 */
.admin-page { background: var(--bg); }

.admin-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 22px 40px;
}

.admin-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.admin-head h2 { margin: 0; font-size: 17px; }
.admin-head .badge { margin-left: auto; font-weight: 600; }

.admin-head .admin-download {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.admin-login-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
  text-align: center;
}

.auth-hint a { color: var(--blue); text-decoration: none; }

.admin-role-label {
  padding: 6px 10px;
  border-radius: 8px;
  background: #fff3df;
  color: #a26000;
  font-size: 12.5px;
  white-space: nowrap;
}

.role-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff3df;
  color: #a26000;
  font-size: 11px;
  font-weight: 600;
}

.role-tag.pending-tag {
  background: #fdecea;
  color: #b3261e;
}

.admin-actions .btn.primary.small {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.admin-actions .btn.primary.small:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #fff;
}

.admin-page .topbar-right .btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

/* 后台 · 操作记录弹窗 */
.logs-modal {
  max-width: 760px;
  max-height: 86vh;
  margin-top: 6vh;
  display: flex;
  flex-direction: column;
}

.logs-modal .search-head { margin-bottom: 6px; }

.logs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.logs-meta {
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 12.5px;
}

.logs-toolbar > .logs-days:first-of-type { margin-left: auto; }

.logs-days {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.logs-days select,
.logs-days input[type="date"] {
  border: 1px solid #dfe4ee;
  border-radius: 8px;
  background: #fff;
  padding: 5px 6px;
  color: var(--text, #1f2937);
  font-size: 12.5px;
  outline: none;
}

.logs-days input[type="date"] { width: 132px; }
.logs-days select:focus,
.logs-days input[type="date"]:focus { border-color: var(--blue); }

.logs-list {
  flex: 1 1 auto;
  min-height: 180px;
  overflow: auto;
  margin-top: 2px;
  padding-right: 2px;
}

.logs-day {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  padding: 10px 0 6px;
  color: #5b6478;
  font-size: 12px;
  font-weight: 650;
}

.log-row {
  display: flex;
  gap: 10px;
  padding: 7px 0 8px;
  border-bottom: 1px dashed #eef1f6;
}

.log-time {
  flex: 0 0 42px;
  padding-top: 1px;
  color: #9aa2b4;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.log-main { flex: 1; min-width: 0; }

.log-line {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #1f2937;
  font-size: 13.5px;
  font-weight: 600;
}

.log-count {
  padding: 0 6px;
  border-radius: 999px;
  background: #eef3fd;
  color: #2b4a86;
  font-size: 11px;
  font-weight: 600;
}

.log-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  margin-top: 3px;
  color: #5b6478;
  font-size: 12px;
}

.log-detail { overflow-wrap: anywhere; }

.log-preview {
  padding: 2px 9px;
  border: 0;
  border-radius: 999px;
  background: #eef3fd;
  color: #2b4a86;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.log-preview:hover { background: #dfe9fb; }

.log-ip {
  margin-top: 2px;
  color: #b3bac8;
  font-size: 11px;
}

.logs-empty {
  padding: 30px 0;
  color: #9aa2b4;
  font-size: 13px;
  text-align: center;
}
.logs-empty.error { color: #b3261e; }

/* 手机端状态切换条：桌面隐藏 */
.mtabs { display: none; }

@media (max-width: 860px) {
  .topbar {
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  .lan { display: none; }
  .who { display: none; }
  .userbox { gap: 6px; }

  .auth { padding: 16px 14px; }
  .auth-card { padding: 22px 18px; border-radius: 16px; }
  .auth-field input { font-size: 16px; }

  .admin-row { flex-wrap: wrap; }
  .admin-user { flex: 1 1 100%; }
  .admin-level { flex: 1; }
  .admin-role-label { flex: 1; text-align: center; }
  .admin-actions { flex: 1 1 auto; justify-content: flex-end; }

  .admin-main { padding: 12px 14px 30px; }
  .admin-card { padding: 14px; }
  .admin-page .topbar-right { gap: 6px; }

  .searchbar { padding: 10px 14px 0; }
  .searchbar .btn { flex: 1; }

  .stats-modal { max-width: none; margin: 6vh 12px 0; max-height: 86vh; }
  .stats-filters { padding: 10px 12px 2px; }
  .stats-filters .btn { margin-left: 0; width: 100%; min-height: 40px; }
  .stats-meta { padding: 8px 12px 0; }
  .stats-table-wrap { margin: 8px 12px; }
  .search-modal {
    max-width: none;
    margin: 8vh 12px 0;
    max-height: 78vh;
  }

  /* 手机版：顶部三个状态按钮 + 单列任务列表，不再横向滑动 */
  .mtabs {
    display: flex;
    gap: 8px;
    padding: 10px 14px 2px;
    position: sticky;
    top: var(--topbar-h, 57px);
    z-index: 15;
    background: var(--bg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mtabs::-webkit-scrollbar { display: none; }
  .mtab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .mtab .count {
    height: 18px;
    min-width: 18px;
    padding: 0 5px;
    font-size: 11px;
    background: #eef1f7;
    color: #6b7488;
  }
  .mtab.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    box-shadow: 0 3px 10px rgba(47, 111, 237, .28);
  }
  .mtab.active .count {
    background: rgba(255, 255, 255, .24);
    color: #fff;
  }

  .board {
    display: block;
    padding: 10px 14px calc(30px + env(safe-area-inset-bottom));
  }
  .col {
    display: none;
    min-height: 0;
    padding: 12px;
  }
  .col.active { display: block; }

  .overlay { padding: 0; align-items: stretch; }
  .detail {
    max-width: none;
    border-radius: 0;
    min-height: 100%;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .detail-head { border-radius: 0; padding: 12px 12px 10px; }
  .title-input { font-size: 16px; }
  .detail-title { font-size: 16px; padding: 6px 4px; }
  .detail-actions { padding: 12px 14px 2px; }
  .detail-meta { padding: 8px 14px 0; }
  .blocks { padding: 12px 14px 30px; }
  .modules { padding: 12px 14px 30px; gap: 12px; }
  .module-body .blocks { padding: 12px; }
  .module-head { padding: 10px 12px; }
  .module-sub { display: none; }
  .module-head .btn { margin-left: auto; }
  .detail-actions .btn { flex: 1; }
  .detail-actions .btn.danger { flex: 0 0 auto; }
  .detail-footer {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    border-radius: 0;
  }

  /* 触屏更好点按 */
  .btn { min-height: 42px; padding: 10px 16px; }
  .icon-btn { width: 38px; height: 38px; }
  .file-row { padding: 10px 6px; }
  .dropzone { padding: 18px 12px; }
  .cost-table td { height: 44px; }
  .table-hint { display: none; }
  .table-actions { gap: 10px; }

  /* 字号不小于 16px，避免 iPhone 聚焦输入框时自动放大整页 */
  .block-text,
  .cost-table input.cell,
  .cost-table .col-title,
  .modal input,
  .biz-input,
  .title-input {
    font-size: 16px;
  }

  .business-fields { grid-template-columns: 1fr; }
  .business-field.wide { grid-column: auto; }
}
