/* 记工系统 v2.8 SPA — 移动端 + NAS 浏览器适配 */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --surface: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --nav-h: 56px;
  --header-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-top: calc(var(--nav-h) + 8px);
  padding-bottom: 16px;
}

[x-cloak] { display: none !important; }

/* 顶栏 */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}

.app-header > div:last-child,
.app-header-actions { display: flex; gap: 6px; align-items: center; }
.app-header-actions .btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.app-title { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; }
.app-user { font-size: 12px; color: var(--muted); }
.role-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #dbeafe;
  color: #1e40af;
}

/* 主内容 */
.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.panel-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
}
.panel-head .panel-title { margin: 0; flex: 1; min-width: 0; }
.ledger-panel-head .panel-title { flex: 0 0 auto; }
.ledger-head-export {
  margin-left: auto;
  flex: 0 0 auto;
}
.wage-panel-head .panel-title,
.finance-panel-head .panel-title { flex: 0 0 auto; }
.wage-head-month,
.finance-head-month,
.ledger-head-month {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 170px;
  margin-left: 8px;
}
.wage-toolbar-actions,
.finance-toolbar-actions { margin-top: 0; margin-bottom: 10px; }
.wage-toolbar-actions .btn-generate,
.finance-toolbar-actions .btn-generate {
  min-width: 9.5em;
  padding-left: 18px;
  padding-right: 18px;
}
.panel-help-btn {
  flex: 0 0 auto;
  width: 32px;
  min-width: 32px;
  min-height: 32px !important;
  height: 32px;
  padding: 0 !important;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: #64748b;
  border: 1px solid var(--border);
  background: #f8fafc;
}
.panel-help-btn:active { background: #e2e8f0; }
.panel-desc { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.panel-desc.is-help-src { display: none !important; }
.help-modal-body {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}
.dialog-help {
  max-height: min(70dvh, 520px);
  overflow: auto;
}

/* 顶部 Tab：记工录入/记工本优先；手机其余进「更多」 */
.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.top-nav > .nav-item,
.top-nav > .nav-more-wrap {
  flex: 1 1 0;
  min-width: 0;
}

.top-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  min-width: 0;
  padding: 8px 4px;
  border: none;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  touch-action: manipulation;
  white-space: nowrap;
}

.top-nav .nav-item .icon { font-size: 18px; line-height: 1; }
.top-nav .nav-item.active {
  color: var(--primary);
  font-weight: 600;
  background: #eff6ff;
}

.nav-more-wrap {
  position: relative;
}
.nav-more-wrap > .nav-item { width: 100%; }
.nav-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 168px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
}
.nav-more-menu .nav-item {
  flex-direction: row;
  justify-content: flex-start;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  width: 100%;
}

@media (max-width: 767px) {
  .top-nav .nav-item-more { display: none !important; }
}

/* 不使用底部 Tab 栏；保留 .bottom-nav 隐藏规则以兼容旧缓存 */
.bottom-nav { display: none !important; }

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--nav-h);
  padding: 6px 4px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  touch-action: manipulation;
}

.nav-item .icon { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--primary); font-weight: 600; }

/* 兼容旧 desktop-tabs 类名 */
.desktop-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tab-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  touch-action: manipulation;
}

.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

@media (min-width: 768px) {
  .header-record-help { display: none !important; }
  body { padding-top: 8px; padding-bottom: 16px; }
  .top-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .top-nav > .nav-item,
  .top-nav .nav-item {
    flex: 1 1 auto;
    flex-direction: row;
    gap: 6px;
    min-height: 40px;
    font-size: 13px;
    padding: 8px 12px;
  }
  .top-nav .nav-item .icon { font-size: 16px; }
  .nav-more-wrap { display: none !important; }
}

@media (max-width: 767px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  .app-main, .panel {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .record-panel,
  #record-form {
    overflow-x: clip;
    max-width: 100%;
    min-width: 0;
  }
  .record-panel {
    background: transparent;
    border: none;
    padding: 0;
  }
  .record-panel-head { display: none; }
  .header-record-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px !important;
  }
  .record-block {
    margin: 0 0 12px;
    padding: 12px 12px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  }
  .record-block-qty {
    padding-top: 12px;
    padding-bottom: 4px;
    border-top: none;
  }
  .record-panel .record-submit-dock {
    background: var(--bg);
    box-shadow: 0 -12px 18px var(--bg);
  }
  #record-form .form-grid > *,
  #record-form .record-pair-row > * {
    min-width: 0;
    max-width: 100%;
  }
  #record-form .table-wrap {
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
  }
  #record-form .batch-qty-table,
  #record-form table.data-table.compact {
    min-width: 0 !important;
    width: 100%;
    table-layout: fixed;
  }
  #record-form input,
  #record-form select,
  #record-form .input-with-btn,
  #record-form .record-style-field,
  #record-form .record-style-picker {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .record-qty-actions .btn { min-width: 0; }
  .smart-chip { max-width: 100%; white-space: normal; }
  .btn-quick {
    min-height: 28px !important;
    height: 28px;
    padding: 0 10px;
    font-size: 13px;
  }
}

/* 表单 */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 480px) {
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* 记工录入：日期 | 客户 始终两列 */
#record-form .record-pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 0;
  grid-column: 1 / -1;
}
#record-form .record-pair-row > * {
  min-width: 0;
  max-width: 100%;
}
#record-form .record-date-quick {
  margin: 6px 0 0;
  justify-content: flex-start;
}
.record-date-label-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}
.record-date-label-row .field-label { margin: 0; }
.record-date-year {
  display: none;
  margin: 0;
  width: auto;
  max-width: 5.6em;
  min-height: 0 !important;
  height: auto;
  padding: 0 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.2;
  appearance: auto;
}
.record-date-md-wrap { position: relative; }
.record-date-md-text { display: none; }
@media (max-width: 767px) {
  .record-date-year {
    display: inline-block;
    min-height: 28px !important;
    height: 28px;
  }
  .record-date-md-text {
    display: flex;
    align-items: center;
    position: absolute;
    left: 1px;
    top: 1px;
    bottom: 1px;
    right: 2.4em;
    padding: 0 10px;
    background: var(--surface);
    border-radius: 8px;
    font-size: 16px;
    color: var(--text);
    pointer-events: none;
    z-index: 1;
  }
  .record-date-md-wrap input[type="date"] {
    color: transparent;
    background: var(--surface);
  }
  .record-date-md-wrap input[type="date"]::-webkit-datetime-edit,
  .record-date-md-wrap input[type="date"]::-webkit-datetime-edit-fields-wrapper,
  .record-date-md-wrap input[type="date"]::-webkit-datetime-edit-text,
  .record-date-md-wrap input[type="date"]::-webkit-datetime-edit-year-field,
  .record-date-md-wrap input[type="date"]::-webkit-datetime-edit-month-field,
  .record-date-md-wrap input[type="date"]::-webkit-datetime-edit-day-field {
    color: transparent;
  }
  .record-date-md-wrap input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 1;
    z-index: 2;
    position: relative;
  }
}
#record-form .record-style-block,
#record-form .record-note-row {
  grid-column: 1 / -1;
}
#record-form .record-note-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
#record-form .record-note-row > .field-label {
  margin: 0;
  flex: 0 0 auto;
}
#record-form .record-note-row > .input-with-btn {
  flex: 1 1 0;
  min-width: 0;
  align-items: center;
}
#record-form .record-note-row > .input-with-btn input,
#record-form .record-note-row > .input-with-btn .btn-sm {
  min-height: 34px !important;
  height: 34px;
  padding-top: 0;
  padding-bottom: 0;
}
#record-form .record-note-rework {
  flex: 1 1 100%;
}

/* 录入页视觉以手机为准。电脑：单面板 + 轻分隔；手机：两块卡片 */
.record-block {
  margin: 0 0 14px;
}
.record-block-qty {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.record-block .field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.record-filled-hint {
  font-weight: 400;
}
.record-filled-hint strong {
  color: var(--primary);
  font-weight: 800;
}

/* 移动端触控优化 */
@media (max-width: 767px) {
  .form-grid.cols-2,
  .form-grid.cols-3 { grid-template-columns: 1fr !important; }
  .btn, button, input, select, textarea { min-height: 40px; }
  .btn-row { gap: 6px; }
  .table-wrap { margin: 0 -8px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .today-summary { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .ledger-module-head { min-height: 48px; }
  .qty-hint { display: none; }
  .price-data-table { min-width: 520px; }
  .panel-desc { font-size: 12px; }
}

label.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* 防止 iOS 缩放 */
  background: var(--surface);
  min-height: 44px;
}

textarea { min-height: 80px; resize: vertical; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-ghost.is-on {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}
.worker-sort-btns {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 auto;
  margin-right: 2px;
}
.worker-sort-btn {
  min-height: 22px !important;
  height: 22px;
  width: 28px;
  padding: 0 !important;
  font-size: 10px !important;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
}
.worker-sort-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}
.td-sort {
  width: 40px;
  padding: 4px 6px !important;
  vertical-align: middle;
}
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn-xs {
  min-height: 28px !important;
  height: 28px;
  padding: 2px 8px !important;
  font-size: 12px !important;
  border-radius: 6px;
  line-height: 1.2;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.record-worker-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 0 0 8px;
}
.record-qty-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}
.record-qty-actions .btn {
  width: 100%;
  min-width: 0;
  padding-left: 4px;
  padding-right: 4px;
}
.record-qty-done { width: 100%; }

/* 表格（移动端横向滚动） */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; border: 1px solid var(--border); }
table.data-table.compact { min-width: 640px; }
th, td { padding: 8px 10px; border: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: #f8fafc; font-weight: 600; white-space: nowrap; position: sticky; top: 0; color: #1e293b; }
.td-actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
  align-items: center;
}

/* 款号价格表：分隔清晰 + 移动端横滑 */
.price-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.settle-module .price-table-wrap {
  border: none;
  border-radius: 0;
}
.price-data-table {
  min-width: 560px;
  border: none;
  margin: 0;
}
.price-data-table th,
.price-data-table td {
  border-color: #e2e8f0;
  padding: 10px 12px;
  line-height: 1.35;
}
.price-data-table thead th {
  background: #f1f5f9;
  border-bottom: 2px solid #cbd5e1;
}
.price-data-table tbody tr:nth-child(even) td {
  background: #f8fafc;
}
.price-data-table tbody tr:hover td {
  background: #eef6f5;
}
.price-data-table:not(.show-customer-price) .col-customer-price {
  display: none;
}
/* 返修价智能显隐：客户表格内任一工序设了返修价才显示该列（show-rework-price 由 hasReworkPrice() 控制） */
.price-data-table:not(.show-rework-price) .col-rework-price {
  display: none;
}
.price-toolbar { margin-bottom: 8px; }
.price-toolbar-actions { margin-top: 0; margin-bottom: 8px; }
.price-toolbar-filters { margin-bottom: 8px; }
.price-gap-chips { margin: 0 0 8px; }
.price-panel-head .panel-title { flex: 0 0 auto; }
.price-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex: 0 0 auto;
}
@media (max-width: 767px) {
  .price-head-actions .btn {
    min-height: 32px;
    padding: 4px 8px;
    font-size: 13px;
  }
  .price-toolbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .price-toolbar-actions .btn {
    width: 100%;
    min-height: 36px;
    padding: 6px 6px;
    font-size: 13px;
  }
  .price-toolbar-filters.form-grid.cols-2 {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px;
  }
  .price-toolbar-filters .field-label { display: none; }
  .price-toolbar-filters select,
  .price-toolbar-filters input {
    min-height: 40px;
    padding: 8px 10px;
  }
  .price-gap-chips {
    gap: 4px;
  }
  .price-gap-chips .smart-chip {
    min-height: 30px !important;
    padding: 4px 8px;
    font-size: 12px;
  }
}
.price-data-table td.price-missing {
  color: #b45309;
  font-weight: 700;
}
.price-data-table tbody tr.is-settle-gap td {
  background: #fff4d6;
}
.price-data-table tbody tr.is-settle-gap:nth-child(even) td {
  background: #ffecb8;
}
.price-data-table tbody tr.is-settle-gap:hover td {
  background: #ffe08a;
}
.price-data-table tbody tr.is-settle-gap td.price-missing {
  color: #9a3412;
}
.settle-gap-tag {
  font-size: 11px;
  color: #9a3412;
  background: #fdba74;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  font-weight: 700;
}
.price-settle-hint {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  color: #9a3412;
}
.smart-chip.is-settle {
  border-color: #f59e0b;
  color: #9a3412;
  background: #fff7ed;
}
.smart-chip.is-settle.is-on {
  background: #f59e0b;
  border-color: #d97706;
  color: #fff;
}
.style-code-link {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.style-code-link.has-image {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.style-code-link.is-open {
  color: #0f766e;
}
.style-code-link:active {
  opacity: 0.75;
}
.style-code-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.style-code-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
}
.merged-style-hint {
  font-size: 11px;
  line-height: 1.2;
  color: #64748b;
  font-weight: 500;
}
.hermes-cleaned-tag {
  font-size: 11px;
  color: #64748b;
  background: #f1f5f9;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}
.price-use-tag {
  font-size: 11px;
  color: #1d4ed8;
  background: #eff6ff;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  font-weight: 600;
}
.style-image-preview {
  margin-top: 8px;
  max-width: min(100%, 420px);
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 4px;
}
/* 裸 img 预览（点款号展开）：无滑块结构，需单独限尺寸，否则手机原图全尺寸渲染 */
.style-image-preview > img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(50vh, 360px);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  transition: max-height 0.2s ease-out;
}
/* 单击放大态：放开上限方便看清细节，仍不出屏 */
.style-image-preview > img.zoomed {
  max-height: min(80vh, 600px);
}

/* —— 缩略图条（款号弹窗已上传/待上传）—— */
.saved-image-strip { margin-top: 10px; }
.thumb-strip-row { margin-top: 8px; }
.thumb-strip-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.thumb-strip-row.pending .thumb-strip-label { color: #b45309; }
.thumb-strip-track {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.thumb-cell {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f8fafc;
}
.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.95);
  color: #fff;
  border: 0;
  font-size: 14px;
  line-height: 18px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.thumb-x:active { background: #dc2626; }

@media (max-width: 767px) {
  .style-image-preview {
    max-width: 100%;
  }
  /* 手机端点款号展开图：明显收小（用户反馈原图太大） */
  .style-image-preview > img {
    max-height: min(36vh, 220px);
  }
  /* 手机端放大态：比缩略图大但仍控制在屏内 */
  .style-image-preview > img.zoomed {
    max-height: min(70vh, 520px);
  }
  .thumb-cell {
    width: 64px;
    height: 64px;
  }
}

/* 款号价格：桌面表格；工人/客户等用 mobile-card-list */
.mobile-card-list { display: none; }
.m-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface);
}
/* —— 停用/在用统一视觉（工人、客户、款号价等）——
   在用：绿；停用：黑字灰底 + 行/卡片变灰 */
.status-pill {
  display: inline-block;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  white-space: nowrap;
}
.status-pill.is-off {
  background: #e5e7eb;
  color: #111827;
}
.data-table tr.row-inactive td {
  background: #f3f4f6;
  color: #6b7280;
}
.data-table tr.row-inactive td:first-child {
  text-decoration: line-through;
  text-decoration-color: #9ca3af;
}
.m-card.inactive {
  opacity: 1;
  background: #f3f4f6;
  border-color: #d1d5db;
  border-style: dashed;
}
.m-card.inactive .m-card-title {
  color: #6b7280;
  text-decoration: line-through;
  text-decoration-color: #9ca3af;
}
.m-card.inactive .m-card-meta,
.m-card.inactive .m-card-sub {
  color: #9ca3af;
}

.m-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.m-card-title { font-size: 15px; font-weight: 700; }
.m-card-sub { font-size: 13px; color: var(--muted); margin-left: 6px; }
/* 金额等非状态徽章（保持绿底，勿与停用黑混淆） */
.m-card-badge {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-weight: 600;
}
.m-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}
.m-card-meta b { font-weight: 700; color: var(--primary); }
.m-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 767px) {
  .desktop-only-table { display: none !important; }
  .mobile-card-list { display: block !important; }
  .price-table-wrap {
    margin-left: -4px;
    margin-right: -4px;
    border-radius: 8px;
  }
  .price-data-table {
    min-width: 480px;
  }
  .price-data-table th,
  .price-data-table td {
    padding: 8px 8px;
    font-size: 12px;
  }

  .process-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .process-row-head {
    display: none;
  }
  .process-row .btn {
    justify-self: start;
    min-height: 40px;
  }

  .month-input,
  .month-range-row .month-input {
    max-width: none;
    width: 100%;
    min-height: 44px;
    font-size: 16px !important;
  }

  table { min-width: 0; font-size: 12px; }
  table.data-table.compact { min-width: 0; }
  th, td {
    padding: 5px 6px;
    font-size: 12px;
  }
  .td-actions { gap: 4px; }

  /* 批量记工两列表 */
  .batch-qty-table { min-width: 0 !important; width: 100%; }
  .batch-qty-table td input {
    width: 100% !important;
    min-height: 48px;
    height: 48px;
    font-size: 16px !important;
  }
  .batch-qty-table .qty-cell input {
    width: auto !important;
    flex: 1 1 auto;
  }
  .batch-qty-table td input:disabled {
    opacity: 0.45;
    background: #f3f4f6;
  }

  /* 明细弹窗表格可换行 */
  .dialog .table-wrap table { min-width: 0; }
  .dialog .table-wrap th,
  .dialog .table-wrap td {
    padding: 4px 5px;
    font-size: 12px;
    white-space: normal;
  }

  .list-card .btn-sm,
  .list-card .btn-xs {
    min-height: 32px !important;
    padding: 4px 10px !important;
    font-size: 13px !important;
  }

  .audit-table th:first-child,
  .audit-table td:first-child {
    white-space: nowrap;
  }

  table.data-table.compact th,
  table.data-table.compact td {
    padding: 4px 6px;
    font-size: 12px;
  }
  .table-wrap .btn-sm,
  .table-wrap .btn-xs,
  .m-card .btn-sm,
  .m-card .btn-xs {
    min-height: 28px !important;
    height: 28px;
    padding: 2px 8px !important;
    font-size: 12px !important;
  }
}

/* 卡片列表 */
.list-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  background: #fafafa;
}

.list-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.list-card .meta { font-size: 13px; color: var(--muted); }
.list-card .amount { font-size: 15px; font-weight: 700; color: var(--primary); }

/* 状态：普通小字，不当功能说明框 */
.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 8px;
}
.hint-warn {
  font-size: 13px;
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

/* 款号工价：工序列表 */
.process-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.process-row {
  display: grid;
  grid-template-columns: 1fr 88px 88px auto;
  gap: 8px;
  align-items: center;
}

.process-row-head {
  font-size: 12px;
  color: var(--muted);
  padding: 0 2px;
}

.process-row input {
  width: 100%;
  min-height: 40px;
}

.month-input {
  width: 100%;
  max-width: 220px;
  min-height: 40px;
}

.month-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.month-range-row .month-input {
  flex: 1;
  min-width: 140px;
  max-width: none;
}

.msg-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.period-fallback-hint { color: #0369a1; font-size: 13px; margin-top: 6px; }
.period-lock-chips { margin: 8px 0 4px; }
.statement-file-list { margin: 12px 0 8px; display: flex; flex-direction: column; gap: 8px; }
.statement-file-heading { font-size: 14px; margin: 0 0 2px; color: #0f172a; }
.statement-file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 48px;
  cursor: pointer;
}
.statement-file-title { font-weight: 700; font-size: 14px; }
.statement-file-meta { flex: 1; font-size: 12px; color: #64748b; }
.statement-file-open { font-size: 13px; color: #1d4ed8; font-weight: 700; }
.msg-success { color: var(--success); font-size: 13px; margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; font-size: 14px; }

/* HTMX 加载条 */
.global-indicator {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  pointer-events: none;
}

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.loading-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  width: 0;
  transition: width 0.25s;
}
.htmx-request .loading-bar { width: 100%; }

/* 弹窗 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 480px) {
  .overlay { align-items: center; padding: 16px; }
}

.dialog {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}

@media (min-width: 480px) {
  .dialog { border-radius: 14px; }
}

.dialog-lg { max-width: 640px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* Toast：其它模块贴底部；记工录入用保存按钮上方 .record-status */
.toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 16px !important;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  max-width: min(92vw, 420px);
  text-align: center;
  pointer-events: none;
}

.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

/* 记工保存结果：贴在保存按钮上方，并随按钮吸底，始终在视线内 */
.record-status {
  margin: 0 0 8px;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  color: #fff;
}
.record-status.ok { background: var(--success); }
.record-status.err { background: var(--danger); }
.record-submit-dock {
  position: sticky;
  bottom: 0;
  z-index: 35;
  margin-top: 10px;
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  box-shadow: 0 -12px 18px var(--surface);
}
.record-submit-dock .btn-row { margin-top: 0; }
@media (max-width: 767px) {
  .record-submit-dock .btn-primary {
    min-height: 50px;
    font-size: 17px;
    font-weight: 700;
  }
  .record-submit-dock .btn-primary.is-ready {
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.32);
  }
}

.batch-qty-table {
  border-collapse: separate;
  border-spacing: 0 6px;
  border: none;
  min-width: 0;
}
.batch-qty-table thead th {
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
}
.batch-qty-table thead th:first-child { border-radius: 8px 0 0 8px; }
.batch-qty-table thead th:last-child { border-radius: 0 8px 8px 0; }
.batch-qty-table tbody td {
  padding: 0;
  vertical-align: middle;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-left: none;
  border-right: none;
}
.batch-qty-table tbody td:first-child {
  border-left: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 8px 0 0 8px;
}
.batch-qty-table tbody td:last-child {
  border-right: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 0 8px 8px 0;
}
.worker-name-inner,
.qty-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  height: 48px;
  padding: 0 10px;
  box-sizing: border-box;
}
.worker-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.worker-tone-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.batch-qty-table tbody tr.worker-tone-0 td { background: #dbeafe; }
.batch-qty-table tbody tr.worker-tone-0 .worker-tone-dot { background: #2563eb; }
.batch-qty-table tbody tr.worker-tone-1 td { background: #fef3c7; }
.batch-qty-table tbody tr.worker-tone-1 .worker-tone-dot { background: #d97706; }
.batch-qty-table tbody tr.worker-tone-2 td { background: #ffe4e6; }
.batch-qty-table tbody tr.worker-tone-2 .worker-tone-dot { background: #e11d48; }
.batch-qty-table tbody tr.worker-tone-3 td { background: #ede9fe; }
.batch-qty-table tbody tr.worker-tone-3 .worker-tone-dot { background: #7c3aed; }
.batch-qty-table tbody tr.worker-tone-4 td { background: #ccfbf1; }
.batch-qty-table tbody tr.worker-tone-4 .worker-tone-dot { background: #0d9488; }
.batch-qty-table tbody tr.worker-tone-5 td { background: #ffedd5; }
.batch-qty-table tbody tr.worker-tone-5 .worker-tone-dot { background: #ea580c; }
.batch-qty-table tbody tr.worker-tone-6 td { background: #ecfccb; }
.batch-qty-table tbody tr.worker-tone-6 .worker-tone-dot { background: #65a30d; }
.batch-qty-table tbody tr.worker-tone-7 td { background: #e0f2fe; }
.batch-qty-table tbody tr.worker-tone-7 .worker-tone-dot { background: #0284c7; }
.batch-qty-table tbody tr.worker-tone-8 td { background: #fce7f3; }
.batch-qty-table tbody tr.worker-tone-8 .worker-tone-dot { background: #db2777; }
.batch-qty-table tbody tr.worker-tone-9 td { background: #f1f5f9; }
.batch-qty-table tbody tr.worker-tone-9 .worker-tone-dot { background: #475569; }
.batch-qty-table tbody tr.row-selected td {
  box-shadow: inset 4px 0 0 #0f766e;
}
.batch-qty-table tbody tr.row-selected td:first-child {
  font-weight: 700;
}

.no-perm { opacity: 0.45; pointer-events: none; }

/* 登录页 */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-b));
}

.login-box {
  width: 100%;
  max-width: 400px;
}

.login-logo {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  text-align: center;
}

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 0;
}

.backup-status { font-size: 14px; line-height: 1.8; }
.backup-status .ok { color: var(--success); font-weight: 600; }
.backup-status .bad { color: var(--danger); font-weight: 600; }
.backup-page { display: flex; flex-direction: column; gap: 12px; }
.backup-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}
.backup-block .panel-title { margin-bottom: 6px; }
.backup-places {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 8px 0 10px;
}
@media (min-width: 768px) {
  .backup-places { grid-template-columns: repeat(3, 1fr); }
}
.backup-place {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}
.backup-place-name { font-weight: 700; font-size: 14px; }
.backup-place-state { margin-top: 4px; font-size: 13px; font-weight: 600; }
.backup-place-state.ok { color: var(--success); }
.backup-place-state.bad { color: var(--danger); }
.backup-advanced { margin-top: 10px; }
.backup-advanced > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

/* 概览统计卡片 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

.stat-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* 数据概览：卡片顶部色条（按 class 上色，无 class 时透明不影响今日看板） */
.stat-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
}

.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--primary); }
/* 数据概览：可点击的统计卡（点了弹明细） */
.stat-box.is-clickable { cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s, background .15s; }
.stat-box.is-clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(15, 23, 42, .10); }
.stat-box.is-clickable:active { transform: translateY(0); box-shadow: none; }
.stat-hint { font-size: 10px; color: #93c5fd; margin-top: 2px; }
.stat-hint.stat-warn { color: #dc2626; font-weight: 600; }

/* 数据概览统计卡配色：件数=蓝 工资=绿 记工=琥珀 工人=紫 客户=青 天数=靛 客户应付=玫红 */
.stat-box.stat-blue { background: linear-gradient(160deg, #eff6ff, #dbeafe); }
.stat-box.stat-blue::before { background: #3b82f6; }
.stat-box.stat-blue .stat-value { color: #1d4ed8; }
.stat-box.stat-blue .stat-hint { color: #60a5fa; }

.stat-box.stat-green { background: linear-gradient(160deg, #ecfdf5, #d1fae5); }
.stat-box.stat-green::before { background: #10b981; }
.stat-box.stat-green .stat-value { color: #047857; }
.stat-box.stat-green .stat-hint { color: #34d399; }

.stat-box.stat-amber { background: linear-gradient(160deg, #fffbeb, #fef3c7); }
.stat-box.stat-amber::before { background: #f59e0b; }
.stat-box.stat-amber .stat-value { color: #b45309; }
.stat-box.stat-amber .stat-hint { color: #fbbf24; }

.stat-box.stat-violet { background: linear-gradient(160deg, #f5f3ff, #ede9fe); }
.stat-box.stat-violet::before { background: #8b5cf6; }
.stat-box.stat-violet .stat-value { color: #6d28d9; }
.stat-box.stat-violet .stat-hint { color: #a78bfa; }

.stat-box.stat-cyan { background: linear-gradient(160deg, #ecfeff, #cffafe); }
.stat-box.stat-cyan::before { background: #06b6d4; }
.stat-box.stat-cyan .stat-value { color: #0e7490; }
.stat-box.stat-cyan .stat-hint { color: #22d3ee; }

.stat-box.stat-indigo { background: linear-gradient(160deg, #eef2ff, #e0e7ff); }
.stat-box.stat-indigo::before { background: #6366f1; }
.stat-box.stat-indigo .stat-value { color: #4338ca; }
.stat-box.stat-indigo .stat-hint { color: #818cf8; }

.stat-box.stat-rose { background: linear-gradient(160deg, #fdf2f8, #fce7f3); }
.stat-box.stat-rose::before { background: #ec4899; }
.stat-box.stat-rose .stat-value { color: #be185d; }
.stat-box.stat-rose .stat-hint { color: #f472b6; }
/* 概览明细弹窗：客户小计行 */
.ov-subtotal td { font-weight: 700; background: #f0fdf4; color: #166534; }
.today-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
/* 简洁统一风格：浅灰边框 + 白底，不用彩色分块 */
.today-summary .stat-box {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
}
.today-summary .stat-label {
  font-size: 11px;
  margin-bottom: 4px;
  color: #6b7280;
  font-weight: 500;
  letter-spacing: .02em;
}
.today-summary .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.sub-title { font-size: 14px; font-weight: 600; margin: 16px 0 8px; color: var(--muted); }

.settings-dialog { max-width: 720px; }
.settings-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }

.upload-box {
  margin-top: 6px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #f8fafc;
}
.upload-box input[type="file"] { width: 100%; font-size: 13px; }
.price-image-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.price-image-actions .camera-trigger {
  margin-top: 0;
  width: 100%;
}

.dialog-image {
  max-width: min(1100px, 98vw);
  width: 98vw;
  max-height: 96vh;
}
.image-viewer {
  margin-top: 8px;
  max-height: 85vh;
  overflow: auto;
  text-align: center;
  background: #0f172a;
  border-radius: 10px;
}
.image-viewer img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  display: inline-block;
  cursor: pointer;
}
.image-viewer.is-doc {
  background: #e2e8f0;
}
.image-viewer.is-doc img {
  cursor: default;
  background: #fff;
}
.image-share-hint {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.image-overlay {
  background: rgba(15, 23, 42, 0.88);
  align-items: stretch;
  padding: 8px;
  z-index: 320;
}
.image-overlay .dialog {
  background: #fff;
  margin: auto;
  width: 100%;
}

/* 款号图涂抹遮盖 */
.image-redact-overlay {
  z-index: 320;
  background: rgba(15, 23, 42, 0.72);
}
.dialog-image-redact {
  max-width: min(720px, 96vw);
  width: 96vw;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
}
.image-redact-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.image-redact-canvas-wrap {
  flex: 1 1 auto;
  min-height: 180px;
  max-height: min(62vh, 560px);
  overflow: auto;
  touch-action: none;
  background: #0f172a;
  border-radius: 10px;
  text-align: center;
}
#price-redact-canvas {
  display: inline-block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
}

/* 记工本列表只用卡片，不再渲染表格 */
.ledger-viewer-cards { display: block; }
/* 桌面端基础样式（≥768px 生效；手机端会被下方 @media 覆盖）*/
.ledger-worker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.ledger-worker-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 12px;
  background: #f9fafb;
  background: color-mix(in srgb, var(--worker-color, var(--primary, #2563eb)) 8%, #f9fafb);
  border: 1px solid #e5e7eb;
  border-left: 4px solid var(--worker-color, var(--primary, #2563eb));
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.ledger-worker-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  border-color: #d1d5db;
  border-left-color: var(--worker-color, var(--primary, #2563eb));
}
.ledger-worker-card.has-today {
  background: #ecfdf5;
  background: color-mix(in srgb, var(--worker-color, var(--primary, #2563eb)) 8%, #ecfdf5);
  border-color: #86efac;
  border-left-color: var(--worker-color, #86efac);
}
.ledger-worker-card-name {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  color: #111827;
}
.ledger-worker-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  flex-wrap: wrap;
}
.ledger-worker-card-badge {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.6;
  color: #6b7280;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.ledger-worker-card-badge.empty {
  color: #9ca3af;
  font-style: italic;
}
.ledger-worker-card-amt {
  margin-left: auto;
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}
/* 手机端：3列 → 2列，给名称多留宽度；字号统一略缩但允许换行不省略 */
@media (max-width: 767px) {
  .ledger-worker-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .ledger-worker-card {
    padding: 12px 12px 10px;
    gap: 8px;
    border-radius: 10px;
  }
  .ledger-worker-card-name {
    font-size: 16px;
    line-height: 1.4;
  }
  .ledger-worker-card-row {
    gap: 6px;
    padding-top: 6px;
  }
  .ledger-worker-card-badge {
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.6;
  }
  .ledger-worker-card-amt {
    font-size: 15px;
  }
}
.ledger-hits {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.ledger-hit {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}
.ledger-hit-when {
  font-variant-numeric: tabular-nums;
}
.ledger-hit-qty {
  margin-left: auto;
  font-weight: 700;
  color: #334155;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 480px) {
  .ledger-modules {
    gap: 10px;
  }
  .ledger-module-head {
    padding: 6px 0 8px;
    min-height: 0;
  }
  .ledger-module-name {
    font-size: 14px;
  }
  .ledger-module-meta {
    font-size: 11px;
  }
  .ledger-today-wage {
    font-size: 11px;
    padding: 3px 6px;
  }
}
.ledger-entry-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #1d4ed8;
  background: #eff6ff;
  border-radius: 4px;
  vertical-align: middle;
}
.ledger-badge-total {
  color: #9a3412;
  background: #ffedd5;
}
.ledger-badge-rework {
  color: #9f1239;
  background: #ffe4e6;
}

/* 个人记工本卡片 */
html.phone-ui .ledger-panel.is-viewer .today-summary,
html.phone-ui .ledger-panel.is-viewer .ledger-panel-head {
  display: none;
}
html.phone-ui .ledger-panel {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-left: 0;
  margin-right: 0;
}
html.phone-ui .col-time-split { display: none !important; }
.ledger-personal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ledger-entry-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  cursor: pointer;
}
.ledger-entry-card:active { background: #f8fafc; }
.ledger-entry-card.is-static { cursor: default; }
.ledger-entry-card.is-static:active { background: #fff; }
.ledger-entry-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.ledger-entry-cust {
  font-size: 16px;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.3;
}
.ledger-entry-meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: #94a3b8;
  font-weight: 600;
}
.ledger-cust-line { margin-top: 8px; }
.ledger-cust-line + .ledger-cust-line {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #eef1f4;
}
.ledger-entry-proc {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
  line-height: 1.45;
}
.ledger-cust-line .ledger-entry-who { margin-bottom: 2px; }
.ledger-entry-proc-lab {
  flex: 0 0 auto;
  font-size: 13px;
  color: #94a3b8;
  font-weight: 500;
}
.ledger-entry-proc-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}
.ledger-entry-proc .ledger-entry-badge { margin-left: 0; }
.ledger-entry-price {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}
.ledger-entry-amt {
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 800;
  color: #1b5e54;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 767px) {
  .ledger-panel {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-left: 0;
    margin-right: 0;
  }
  .ledger-panel-head {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 8px;
  }
  .ledger-panel-head .panel-title { display: none; }
  .ledger-panel .today-summary,
  .ledger-panel .ledger-filter,
  .ledger-panel .empty {
    margin-left: 0;
    margin-right: 0;
  }
  .ledger-panel.is-viewer .today-summary,
  .ledger-panel.is-viewer .ledger-panel-head {
    display: none;
  }
  .ledger-module {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin: 0 0 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  }
  .ledger-module.is-viewer {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    margin: 0;
  }
  .ledger-module-head {
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
  }
  .ledger-history-toggle,
  .ledger-month-tabs {
    padding-left: 12px;
    padding-right: 12px;
  }
  .ledger-module.is-viewer .ledger-history-toggle,
  .ledger-module.is-viewer .ledger-month-tabs {
    padding-left: 2px;
    padding-right: 2px;
  }
  .ledger-panel .table-wrap {
    margin-left: 0;
    margin-right: 0;
    overflow-x: hidden;
  }
  .ledger-when-full { display: none !important; }
  .ledger-when-stack { display: block; }
  .ledger-when-stack.ledger-main-date {
    display: inline;
    line-height: 1.25;
  }
  .col-time-split { display: none !important; }
  .ledger-when-md { font-weight: 800; color: var(--text); }
  .ledger-th-date { line-height: 1.2; }
  .ledger-th-year,
  .ledger-day-title .ledger-when-year {
    display: block;
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
    margin-top: 1px;
  }
  .ledger-when-time {
    display: block;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: #334155;
  }
  .ledger-day-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    line-height: 1.25;
  }
}

/* 工资/客户结算：一人（或一客户）一张表 */
.settle-modules {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
.settle-module {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.settle-module.has-settle-gap {
  border-color: #f59e0b;
}
.settle-module.has-settle-gap > .settle-module-toggle {
  background: #fff7ed;
}
.settle-module-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
button.settle-module-toggle {
  width: 100%;
  border: 0;
  border-bottom: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  min-height: 48px;
  align-items: center;
}
.settle-module:not(.is-open) > .settle-module-toggle {
  border-bottom: none;
}
.settle-module.is-open > .settle-module-toggle {
  border-bottom: 1px solid var(--border);
  background: #eff6ff;
}
.settle-module-chevron {
  flex: 0 0 auto;
  font-size: 14px;
  color: var(--muted);
  line-height: 1;
  padding-top: 2px;
}
.settle-module-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.settle-module-title strong {
  font-size: 15px;
}
.settle-module-meta {
  font-size: 12px;
  color: var(--muted);
}

/* 款号价格：客户模块卡循环配色（仅款号价格 Tab 加 price-tone-N；结算 Tab 不受影响）。
   左侧 4px 色条 + 收起态头部浅渐变 + 客户名同色；橙色缺价警示（has-settle-gap）优先保留 */
.settle-module[class*="price-tone"] {
  position: relative;
}
.settle-module[class*="price-tone"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  z-index: 1;
}
.settle-module[class*="price-tone"] > .settle-module-toggle {
  padding-left: 16px;
}
.settle-module.price-tone-0::before { background: #3b82f6; }
.settle-module.price-tone-0:not(.has-settle-gap) > .settle-module-toggle { background: linear-gradient(160deg, #eff6ff, #dbeafe); }
.settle-module.price-tone-0 .settle-module-title strong { color: #1d4ed8; }
.settle-module.price-tone-1::before { background: #10b981; }
.settle-module.price-tone-1:not(.has-settle-gap) > .settle-module-toggle { background: linear-gradient(160deg, #ecfdf5, #d1fae5); }
.settle-module.price-tone-1 .settle-module-title strong { color: #047857; }
.settle-module.price-tone-2::before { background: #f59e0b; }
.settle-module.price-tone-2:not(.has-settle-gap) > .settle-module-toggle { background: linear-gradient(160deg, #fffbeb, #fef3c7); }
.settle-module.price-tone-2 .settle-module-title strong { color: #b45309; }
.settle-module.price-tone-3::before { background: #8b5cf6; }
.settle-module.price-tone-3:not(.has-settle-gap) > .settle-module-toggle { background: linear-gradient(160deg, #f5f3ff, #ede9fe); }
.settle-module.price-tone-3 .settle-module-title strong { color: #6d28d9; }
.settle-module.price-tone-4::before { background: #06b6d4; }
.settle-module.price-tone-4:not(.has-settle-gap) > .settle-module-toggle { background: linear-gradient(160deg, #ecfeff, #cffafe); }
.settle-module.price-tone-4 .settle-module-title strong { color: #0e7490; }
.settle-module.price-tone-5::before { background: #ec4899; }
.settle-module.price-tone-5:not(.has-settle-gap) > .settle-module-toggle { background: linear-gradient(160deg, #fdf2f8, #fce7f3); }
.settle-module.price-tone-5 .settle-module-title strong { color: #be185d; }
.settle-data-table {
  min-width: 560px;
}
.settle-data-table tfoot td {
  font-weight: 700;
  background: #d1fae5;
  color: #065f46;
  border-top: 2px solid #10b981;
}
.settle-data-table tbody tr.settle-cust-start td {
  border-top: 2px solid #cbd5e1;
}
.settle-data-table tbody tr.wage-cust-sub td {
  font-weight: 700;
  background: #e0f2fe;
  color: #075985;
}

/* 款号扫码：输入框 + 相机按钮 */
.input-with-btn {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.input-with-btn select,
.input-with-btn input { flex: 1; min-width: 0; }
.input-with-btn .record-style-picker {
  flex: 1;
  min-width: 0;
  position: relative;
}
.record-style-trigger {
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
}
.record-style-trigger.is-open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px #dbeafe;
}
.record-style-trigger-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-style-trigger-text.is-placeholder { color: var(--muted); }
.record-style-search-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  color: var(--muted);
  z-index: 2;
}
.record-style-search-btn:active { color: var(--primary); }
.record-style-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 60;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  display: flex;
  flex-direction: column;
  max-height: min(72vh, 520px);
  overflow: hidden;
}
.record-style-search {
  margin: 8px 8px 0;
  width: calc(100% - 16px);
  min-height: 40px;
}
.record-style-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}
.record-style-preview {
  margin: 8px;
  padding: 8px;
  min-height: 140px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.record-style-preview img {
  max-height: 160px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.record-style-preview-cap {
  margin: 0;
  font-size: 12px;
  color: #334155;
  text-align: center;
  font-weight: 600;
}
.record-style-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 8px;
}
.record-style-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: none;
  font: inherit;
  min-height: 48px;
  cursor: pointer;
}
.record-style-opt.is-hover { background: #eff6ff; }
.record-style-opt.is-on { background: #dbeafe; font-weight: 600; }
.record-style-opt.is-on.is-hover { background: #bfdbfe; }
.record-style-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #e2e8f0;
  flex: 0 0 auto;
}
.record-style-opt-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
}
@media (max-width: 767px) {
  .record-style-field.is-picking { z-index: 80; }
  .record-style-menu {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: auto minmax(0, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    transform: none;
    box-sizing: border-box;
    padding: 0 max(10px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
    max-height: min(46vh, 280px);
    z-index: 90;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .record-style-search {
    grid-column: 2;
    grid-row: 1;
    margin: 8px 0 0 8px;
    width: auto;
    min-height: 36px;
  }
  .record-style-preview {
    grid-column: 1;
    grid-row: 1 / span 2;
    z-index: 91;
    margin: 8px 0 8px 0;
    min-height: 0;
    padding: 4px;
    background: #fff;
  }
  .record-style-preview img {
    max-height: none;
    height: 100%;
    width: 100%;
    object-fit: contain;
    object-position: left center;
  }
  .record-style-preview-cap { display: none; }
  .record-style-list {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
  }
  .record-style-thumb { display: none; }
  .record-style-opt { min-height: 40px; padding: 6px 8px; font-size: 13px; }
}
.input-with-btn .btn-sm {
  flex: 0 0 auto;
  white-space: nowrap;
  min-height: 44px;
  padding: 0 10px;
}
.btn-icon {
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 18px;
}

/* 日期快捷按钮 */
.date-quick {
  display: flex;
  gap: 6px;
  margin: 0 0 0 auto;
  flex-wrap: nowrap;
}
.btn-quick {
  flex: 0 0 auto;
  min-height: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.smart-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 10px 0 4px;
}
.smart-chip {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px !important;
  height: auto;
  text-align: left;
}
.smart-chip.is-on {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 700;
}
.record-continue-chips {
  margin-top: 10px;
  margin-bottom: 0;
}
.record-continue-chips .field-label {
  font-size: 12px !important;
  font-weight: 600;
  color: var(--muted);
}
.record-continue-chips .smart-chip {
  padding: 3px 8px;
  font-size: 11px !important;
  font-weight: 400;
  min-height: 26px !important;
  line-height: 1.25;
}
.qty-hint {
  display: inline;
  font-size: 11px;
  color: #64748b;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
}
.qty-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  height: 48px;
  padding: 0 10px;
  box-sizing: border-box;
}
.qty-cell input {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  min-height: 48px;
  box-sizing: border-box;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.qty-cell input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(15, 23, 42, 0.28);
}
.qty-fill-last {
  flex: 0 0 auto;
  border: 0;
  background: #e2e8f0;
  color: #334155;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px !important;
  height: 32px;
}
.qty-anomaly {
  margin: 4px 0 0;
  font-size: 12px;
  color: #b45309;
  line-height: 1.3;
}

/* 扫码/拍照弹窗 */
.scanner-dialog {
  max-width: 560px;
  display: flex;
  flex-direction: column;
}
.scanner-dialog .scan-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.scanner-dialog .scan-hint {
  margin: 0 0 8px;
  text-align: center;
  font-size: 14px;
}
.scan-tabs {
  display: flex;
  gap: 6px;
  margin: 8px 0 12px;
}
.scan-tab {
  flex: 1;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border, #d1d5db);
  background: var(--surface, #f9fafb);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.scan-tab.active {
  background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
  color: #fff;
  font-weight: 600;
}
.qr-reader {
  width: 100%;
  min-height: 280px;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}
.qr-reader video { width: 100% !important; border-radius: 8px; }
#qr-reader__scan_region,
#qr-reader__dashboard_section {
  max-width: 100% !important;
}
.native-scan-wrap {
  position: relative;
  width: 100%;
  min-height: 280px;
  flex: 1 1 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}
.native-scan-video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: contain;
  background: #000;
}
.native-scan-frame {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 28%;
  bottom: 28%;
  border: 2px solid rgba(56, 189, 248, 0.95);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  animation: scan-pulse 1.4s ease-in-out infinite;
}
@keyframes scan-pulse {
  0%, 100% { border-color: rgba(56, 189, 248, 0.55); }
  50% { border-color: rgba(56, 189, 248, 1); }
}
.scanner-dialog .scan-hint {
  font-weight: 600;
  color: var(--primary);
}
.qr-reader-file-host {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.qr-file-fallback {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.photo-capture-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.photo-input {
  width: 100%;
  min-height: 44px;
  font-size: 14px;
}
.camera-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 4px;
}
.camera-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  font-size: 16px; /* iOS 避免缩放 */
}
.captured-preview {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 8px;
  background: #111;
  border: 1px solid var(--border, #d1d5db);
}

/* ===== 手机端体验优化 v2.8 ===== */
input, select, button, textarea { font-size: 16px !important; }
button, .btn { min-height: 44px; }
/* 表格/卡片内操作按钮：手机可点，但不撑高行 */
.table-wrap .btn,
.table-wrap button,
.m-card .btn,
.m-card button,
.list-card .btn-xs,
.btn-xs {
  min-height: 36px !important;
  height: auto;
  font-size: 13px !important;
}

.top-nav .nav-item {
  min-height: 48px;
  font-size: 13px !important;
}
.top-nav .nav-item.active {
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}

.offline-banner.mirror-alert { background: #b91c1c; }
.offline-banner.old-data-alert { background: #b45309; cursor: pointer; }
.offline-banner.health-alert { background: #c2410c; }

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: #b45309;
  color: #fff;
  text-align: center;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  font-size: 14px !important;
}

.api-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 450;
  pointer-events: none;
}
.api-loading .loading-bar {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  animation: api-pulse 0.9s ease-in-out infinite;
}
@keyframes api-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.badge-free {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px !important;
  background: #ecfdf5;
  color: #047857;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 12px 0;
  padding-bottom: 4px;
}
.settings-tabs .tab-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  white-space: nowrap;
}

.guide { max-width: 720px; }
.guide-card {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0 16px;
}
.guide-card h3,
.guide-block h3 {
  font-size: 16px;
  margin: 0 0 8px;
}
.guide-block { margin: 0 0 18px; }
.guide ol, .guide ul { margin: 0 0 8px; padding-left: 22px; }
.guide li { margin: 0 0 8px; line-height: 1.5; }
.guide p { margin: 0 0 8px; line-height: 1.55; color: var(--text); }
.guide code {
  font-size: 13px;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
}

.date-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-range-row input[type="date"] {
  flex: 1;
  min-width: 0;
  width: auto;
}
.date-range-sep {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 640px) {
  /* 短确认框：底部小卡片，不要全屏 */
  .overlay-confirm {
    align-items: flex-end !important;
    padding: 0;
  }
  .dialog-confirm {
    width: 100%;
    max-width: 100%;
    height: auto !important;
    max-height: 55dvh;
    border-radius: 16px 16px 0 0 !important;
    padding: 20px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .dialog-confirm .dialog-actions {
    position: static !important;
    margin-top: 16px;
    padding: 0;
    border: none;
    background: transparent;
  }

  /* 长表单/明细/扫码：全屏 + 底部固定操作 */
  .dialog-sheet,
  .dialog-lg,
  .scanner-dialog,
  .dialog-image {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    max-height: 100vh; /* fallback */
    max-width: 100%;
    border-radius: 0;
    padding: 8px 10px;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
  .scanner-dialog .panel-title {
    margin: 2px 0 4px;
    font-size: 16px;
  }
  .scanner-dialog .scan-tabs {
    margin: 4px 0 6px;
  }
  .scanner-dialog .scan-hint,
  .scanner-dialog .panel-desc {
    margin-bottom: 6px;
    font-size: 13px !important;
  }
  .scanner-dialog .qr-reader,
  .scanner-dialog .native-scan-wrap {
    flex: 1 1 auto;
    min-height: min(58dvh, calc(100dvh - 220px));
    height: min(62dvh, calc(100dvh - 200px));
    border-radius: 0;
  }
  .scanner-dialog .qr-reader video,
  .scanner-dialog .native-scan-video {
    border-radius: 0 !important;
    object-fit: contain;
    min-height: 100%;
  }
  .scanner-dialog .native-scan-frame {
    top: 18%;
    bottom: 18%;
    left: 4%;
    right: 4%;
  }
  .scanner-dialog .qr-file-fallback {
    margin-top: 6px;
    padding-top: 6px;
  }
  .dialog-sheet .dialog-actions,
  .dialog-lg .dialog-actions,
  .scanner-dialog .dialog-actions,
  .dialog-image .dialog-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 10;
  }
  .overlay:not(.overlay-confirm) { align-items: stretch; }
  .scanner-dialog { max-width: 100%; }
  body { font-size: 16px; }
  .panel-title { font-size: 17px; }
  .panel-desc, .field-label, .hint { font-size: 14px !important; }
  .ledger-head-export {
    min-height: 32px;
    padding: 4px 8px;
    font-size: 13px;
  }
  .wage-head-month,
  .finance-head-month,
  .ledger-head-month {
    max-width: none;
    min-height: 36px !important;
    width: auto;
    flex: 1 1 9em;
    font-size: 16px !important;
    margin-left: 0;
  }
  .wage-toolbar-actions,
  .finance-toolbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .wage-toolbar-actions .btn,
  .finance-toolbar-actions .btn {
    width: 100%;
    min-height: 36px;
    padding: 6px 4px;
    font-size: 13px;
  }
  .wage-toolbar-actions .btn-generate,
  .finance-toolbar-actions .btn-generate {
    grid-column: 1 / -1;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
    font-size: 15px;
  }
  .btn-sm { min-height: 40px; font-size: 14px !important; }
  .app-header {
    padding-right: 64px; /* App 右上角刷新按钮 48dp+边距 */
  }
  .app-header-actions .btn-sm { min-height: 36px; padding: 6px 10px; font-size: 13px !important; }
  .table-wrap .btn-sm,
  .table-wrap .btn-xs,
  .m-card .btn-sm,
  .m-card .btn-xs,
  .list-card .btn-xs,
  .btn-xs {
    min-height: 36px !important;
    height: 36px;
    padding: 4px 10px !important;
    font-size: 13px !important;
  }
  .date-range-row {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }
  .date-range-row input[type="date"] {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 6px;
    font-size: 15px;
  }
  .date-range-sep {
    text-align: center;
    flex: 0 0 auto;
    font-size: 12px;
  }
}
.ledger-panel-head { flex-wrap: wrap; row-gap: 6px; }
.ledger-panel-head .panel-title { margin-right: 4px; }
/* 手机端：记工本头部 title 独占一行，月份选择器和导出按钮在下面 */
@media (max-width: 767px) {
  .ledger-panel-head .panel-title { flex: 1 1 100%; }
  .ledger-panel-head .ledger-head-month { order: 3; flex: 1 1 100%; max-width: 100%; }
  .ledger-panel-head .panel-help-btn { margin-left: auto; }
}

/* 记工本：顶部今日 vs 本月分色 */
.today-summary .stat-box.is-month .stat-label { color: #1e40af; }
.today-summary .stat-box.is-month .stat-value { color: #1e3a8a; }

/* 每个客户卡头：今日摘要 */
.ledger-entry-today {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 10px;
  margin: 6px 0 4px;
  border-radius: 10px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  color: #0f766e;
  font-size: 13px;
  line-height: 1.4;
}
.ledger-entry-card.has-today .ledger-entry-today { background: #ecfdf5; border-color: #86efac; color: #065f46; }
.let-today-lab { font-weight: 700; letter-spacing: .5px; }
.let-today-qty { font-weight: 700; font-size: 14px; }
.let-today-amt { margin-left: auto; font-weight: 700; font-size: 14px; }
.let-today-count { color: #0f766e; }
.let-today-none { color: #64748b; font-size: 12px; }

/* 工序列后面的「今日 N 件 · M 次」 */
.ledger-entry-today-hit {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.lp-today-label { font-weight: 700; color: #065f46; }
.lp-today-qty { font-weight: 700; font-size: 15px; color: #064e3b; }
.lp-today-amt { margin-left: auto; font-weight: 800; font-size: 15px; color: #0f766e; }
.lp-today-count { color: #0f766e; font-size: 12px; }
.lp-today-none { color: #64748b; font-size: 13px; }
@media (max-width: 767px) {
  .ledger-personal-today { padding: 10px; }
  .lp-today-qty, .lp-today-amt { font-size: 14px; }
  .ledger-entry-today { font-size: 12px; }
  .let-today-qty, .let-today-amt { font-size: 13px; }
  .ledger-entry-today-hit { font-size: 11px; }
}

/* ===== 记工本：卡内按款式分组 ===== */
.ledger-style-group {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  margin: 8px 0;
  overflow: hidden;
}
.ledger-style-group.has-today {
  border-color: #10b981;
  box-shadow: 0 0 0 1px rgba(16,185,129,.12), 0 4px 12px -6px rgba(16,185,129,.25);
}
.ledger-style-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%);
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
}
.ledger-style-code {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.ledger-style-code-label {
  color: #64748b;
  font-size: 12px;
}
.ledger-style-code strong {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: .3px;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ledger-style-today {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg,#ecfdf5 0%,#d1fae5 100%);
  border: 1px solid #6ee7b7;
  color: #047857;
  font-size: 12px;
  font-weight: 600;
}
.ledger-style-today .lst-amt {
  color: #065f46;
}
.ledger-style-today .lst-count {
  color: #047857;
  opacity: .9;
}
.ledger-style-none {
  justify-self: end;
  font-size: 12px;
  color: #94a3b8;
  padding: 3px 8px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 999px;
}
.ledger-style-month {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding-left: 6px;
  border-left: 1px dashed #e2e8f0;
}
.ledger-style-month .lsm-qty {
  color: #334155;
  font-size: 12px;
  font-weight: 600;
}
.ledger-style-month .lsm-amt {
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
}
.ledger-style-month .lsm-count {
  color: #64748b;
  font-size: 11px;
}
.ledger-style-body {
  padding: 4px 0 8px;
}
.ledger-style-body .ledger-cust-line {
  border-top: none;
  border-bottom: 1px dashed #f1f5f9;
  margin: 0 4px;
  padding: 6px 8px;
  border-radius: 0;
  background: transparent;
}
.ledger-style-body .ledger-cust-line:last-child {
  border-bottom: none;
}
/* 手机：款式头改两行布局，避免左右挤不下 */
@media (max-width: 767px) {
  .ledger-style-head {
    grid-template-columns: 1fr 1fr;
  }
  .ledger-style-code {
    grid-column: 1 / -1;
  }
  .ledger-style-today, .ledger-style-none {
    grid-column: 1 / span 1;
  }
  .ledger-style-month {
    grid-column: 2 / span 1;
    border-left: none;
    padding-left: 0;
  }
  .ledger-style-none {
    justify-self: start;
  }
  .ledger-style-code strong {
    max-width: 60vw;
  }
}
.lvs-btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 12px;
  color: #475569;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
}
.lvs-btn.active {
  background: #0f766e;
  color: #fff;
  box-shadow: 0 4px 10px -4px rgba(15, 118, 110, .45);
}
.ledger-dashboard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.dash-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 16px -10px rgba(15, 23, 42, .15);
}
.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg,#f8fafc 0%,#eef2f7 100%);
  border-bottom: 1px solid #e2e8f0;
}
.dash-cust {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}
.dash-cust strong {
  font-size: 15px;
  color: #0f172a;
  max-width: 50vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-last {
  font-size: 12px;
  color: #64748b;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.dash-card-body {
  padding: 8px 10px 6px;
}
.dash-style-block {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 10px;
  background: #fbfcfe;
  overflow: hidden;
}
.dash-style-block:last-child {
  margin-bottom: 4px;
}
.dash-style-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px dashed #e2e8f0;
}
.dash-style-code {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.dash-style-code-label {
  font-size: 12px;
  color: #64748b;
}
.dash-style-code strong {
  font-size: 14px;
  color: #0f172a;
  letter-spacing: .3px;
  max-width: 52vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-style-month {
  font-size: 12px;
  font-weight: 700;
  color: #0f766e;
  background: linear-gradient(180deg,#ecfdf5 0%,#d1fae5 100%);
  border: 1px solid #6ee7b7;
  padding: 3px 10px;
  border-radius: 999px;
}
.dash-style-days {
  padding: 4px 8px 0;
}
.dash-day-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed #e2e8f0;
}
.dash-day-row:last-child {
  border-bottom: none;
}
.dash-day-date {
  font-size: 12px;
  color: #64748b;
  padding-top: 4px;
  font-weight: 600;
  line-height: 1.3;
}
.dash-day-date.is-today {
  color: #0f766e;
  font-weight: 700;
}
.dash-day-date.is-yesterday {
  color: #4338ca;
}
.drc-actions .btn.btn-ghost.btn-xs {
  --btn-pad: 0 6px;
  font-size: 10px;
  height: 16px;
  line-height: 16px;
  min-height: 16px;
}
.dash-day-subtotal {
  align-self: center;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  color: #0f172a;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  margin-left: auto;
}
.dss-lab {
  color: #64748b;
}
.dss-qty {
  font-weight: 700;
  color: #0f172a;
}

@media (max-width: 767px) {
  .ledger-view-switch {
    margin-left: 6px;
    order: 99;
    width: 100%;
    margin-top: 6px;
    justify-content: space-between;
  }
  .ledger-panel-head {
    flex-wrap: wrap;
    align-items: center;
  }
  .lvs-btn {
    flex: 1;
    padding: 6px 12px;
    text-align: center;
  }
  .dash-cust strong {
    max-width: 56vw;
  }
  .dash-last {
    padding: 2px 8px;
    font-size: 11px;
  }
  .dash-day-row {
    grid-template-columns: 48px 1fr;
    gap: 6px;
  }
      .dash-row-chips {
    gap: 12px 8px;
  }
}
.dash-card.is-expanded .dash-day-row.is-history 

/* ===== 卡片级展开按钮 ===== */
.dash-card-more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 0;
  border: none;
  background: none;
  color: #666;
  font-size: 14px;
  cursor: pointer;
}
.dash-card-more:hover {
  color: #333;
}
.ddm-chevron {
  display: inline-block;
  margin-right: 4px;
  font-size: 16px;
}

/* ===== 当天记录表格横排 ===== */
.dash-row-grid {
  display: table;
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}
.dash-row-table {
  display: table-row;
}
.dash-row-cell {
  display: table-cell;
  width: 60px;
  height: 36px;
  border: 1px solid #e5e7eb;
  text-align: center;
  vertical-align: middle;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  background: #f9fafb;
}
.dash-day-subtotal {
  display: table-cell;
  width: 70px;
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  padding-left: 8px;
}

/* 展开后卡片内容可滚动 */
.dash-card.is-expanded .dash-card-body {
  max-height: 420px;
  overflow-y: auto;
  overflow-anchor: none;
}

/* 小计单元格内标签样式 */
.dash-day-subtotal .dss-lab {
  color: #6b7280;
  font-size: 12px;
  margin-right: 4px;
}
.dash-day-subtotal {
  font-weight: 600;
  color: #374151;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
}

/* ===== 我的记工（viewer 自助） ===== */
.my-records-head { flex-wrap: wrap; row-gap: 6px; column-gap: 8px; }
.my-records-head .panel-title { margin-right: 4px; }
.my-records-head .my-records-month {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  color: #111827;
}
@media (max-width: 767px) {
  .my-records-head .panel-title { flex: 1 1 100%; }
  .my-records-head .my-records-month { order: 3; flex: 1 1 100%; max-width: 100%; }
  .my-records-head .panel-help-btn { margin-left: auto; }
}

.my-records-day-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.my-records-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f7;
  gap: 10px;
}
.my-records-day-card.is-open .my-records-day-head { background: #eef2ff; border-bottom-color: #c7d2fe; }
.mrd-date { display: flex; align-items: baseline; gap: 6px; font-size: 15px; font-weight: 600; color: #111827; }
.mrd-date.is-today { color: #4f46e5; }
.mrd-date.is-yesterday { color: #6366f1; }
.mrd-dow { font-size: 12px; font-weight: 400; color: #9ca3af; }
.mrd-summary { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #374151; }
.mrd-qty b { color: #0f172a; font-size: 14px; }
.mrd-amt b { color: #b91c1c; font-size: 14px; }
.mrd-chevron { color: #9ca3af; font-size: 12px; min-width: 12px; text-align: center; }

.my-records-day-body {
  padding: 10px 14px 14px;
}
.mrd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: #374151;
}
.mrd-table th {
  text-align: left;
  font-weight: 500;
  color: #6b7280;
  font-size: 12px;
  padding: 6px 4px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafbfc;
  position: sticky;
  top: 0;
}
.mrd-table td {
  padding: 8px 4px;
  border-bottom: 1px dashed #f0f1f5;
  vertical-align: middle;
}
.mrd-table tr:last-child td { border-bottom: none; }
.mrd-customer { color: #111827; font-weight: 500; }
.mrd-style { color: #4338ca; }
.mrd-process { color: #065f46; }
.mrd-row:hover td { background: #fafbff; }
.mrd-note {
  margin: 8px 0 0;
  padding: 6px 10px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: #78350f;
}
.mrd-note .mrd-note-lab {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 6px;
  background: #f59e0b;
  color: #fff;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1.6;
}

@media (max-width: 767px) {
  .mrd-table thead { display: none; }
  .mrd-table, .mrd-table tbody, .mrd-table tr, .mrd-table td { display: block; width: 100%; box-sizing: border-box; }
  .mrd-table tr { padding: 4px 0; border-bottom: 1px solid #f0f1f5; }
  .mrd-table tr:last-child { border-bottom: none; }
  .mrd-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border: none;
    font-size: 13px;
  }
  .mrd-table td::before {
    content: attr(data-label);
    color: #9ca3af;
    font-size: 12px;
    font-weight: 400;
    flex-shrink: 0;
    margin-right: 10px;
  }
  .mrd-table td:nth-child(1)::before { content: '客户'; }
  .mrd-table td:nth-child(2)::before { content: '款号'; }
  .mrd-table td:nth-child(3)::before { content: '工序'; }
  .mrd-table td:nth-child(4)::before { content: '件数'; }
  .mrd-table td:nth-child(5)::before { content: '单价'; }
  .mrd-table td:nth-child(6)::before { content: '金额'; }
}

/* ===== 备份检查按钮 + 告警条 + 弹窗（顶栏 / 告警条 / 设置 Tab 三入口共用） ===== */
.backup-check-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.backup-check-btn .alert-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-left: 4px;
  border: 1px solid var(--bg, #fff);
}
.backup-check-btn.has-alert {
  color: var(--danger);
  font-weight: 700;
}

.backup-overdue-alert {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  cursor: pointer;
}
.backup-overdue-alert:hover { background: #fde68a; }

.backup-check-overlay { z-index: 320; }
.backup-check-modal {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 16px 18px 20px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.18);
}
.backup-check-modal .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.backup-check-modal .panel-title { margin: 0; font-size: 18px; font-weight: 700; }
.backup-check-modal .panel-close {
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}
.backup-check-modal .panel-close:hover { color: var(--danger); }
.backup-check-modal .backup-places {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 12px;
}
.backup-check-modal .backup-place {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  text-align: center;
}
.backup-check-modal .btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.backup-check-modal .hint { font-size: 13px; color: var(--muted); margin: 4px 0; }

@media (min-width: 480px) {
  .backup-check-modal { border-radius: 16px; }
}

@media (max-width: 767px) {
  .backup-check-modal .backup-places { grid-template-columns: 1fr; gap: 6px; }
  .backup-check-modal .btn-row { flex-direction: column; }
  .backup-check-modal .btn-row .btn { width: 100%; }
  .backup-check-btn { padding: 4px 6px; font-size: 13px; }
}

