/* =========================================================================
 * 加班记 —— 浅色简洁主题
 * ========================================================================= */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --border: #e5e9f2;
  --border-strong: #d5dbe8;
  --text: #1d2534;
  --text-2: #4b5568;
  --muted: #828da3;
  --primary: #3b62f6;
  --primary-dark: #2b4ed8;
  --primary-soft: #eef2ff;
  --workday: #3b62f6;
  --restday: #e0912b;
  --holiday: #e04b52;
  --success: #159668;
  --success-soft: #e9f7f1;
  --danger: #e04b52;
  --danger-soft: #fdf0f0;
  --warn-soft: #fff7e9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 40, 66, .04), 0 6px 20px rgba(28, 40, 66, .05);
  --shadow-lg: 0 12px 42px rgba(24, 36, 62, .16);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: var(--primary); }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 28px;
  min-height: 70px; padding: 12px 30px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: var(--muted); }

.tabs { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.tab {
  border: 0; background: transparent; color: var(--text-2);
  padding: 8px 15px; border-radius: 9px; font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.top-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.month-picker {
  display: flex; align-items: center; gap: 2px;
  border: 1px solid var(--border); border-radius: 10px; padding: 2px;
  background: var(--surface);
}
.icon-btn {
  width: 28px; height: 28px; border: 0; background: transparent;
  border-radius: 7px; color: var(--text-2); font-size: 19px; line-height: 1;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.month-label {
  border: 0; background: transparent; min-width: 96px; padding: 4px 8px;
  font-weight: 600; font-variant-numeric: tabular-nums; border-radius: 7px;
}
.month-label:hover { background: var(--surface-2); }

.btn {
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 9px; padding: 8px 15px; font-weight: 500;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(59, 98, 246, .22); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: #f2c9cb; background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.plus { font-size: 16px; line-height: 1; }

/* ---------- 主体 ---------- */
.main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px 30px 36px; }
.statusbar {
  border-top: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 12px; padding: 9px 30px;
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
}
.statusbar b { color: var(--text-2); font-weight: 600; }
.statusbar .dot { color: var(--success); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px 24px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title { font-size: 16px; font-weight: 650; margin: 0; }
.section-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.hint { font-size: 12px; color: var(--muted); }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.segmented { display: inline-flex; background: #eef1f7; border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 5px 14px; border-radius: 7px; font-size: 13px; font-weight: 500;
}
.segmented button.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.spacer { flex: 1; }
.input, .select {
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); padding: 7px 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,98,246,.12); }
.input::placeholder { color: #aeb6c6; }
.search { min-width: 210px; }
.select { min-width: 118px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--primary-soft); color: var(--primary); border: 1px solid #d9e2ff;
  border-radius: 8px; padding: 5px 9px; font-size: 12px; font-weight: 600;
}
.filter-chip button { border: 0; background: transparent; color: inherit; font-size: 15px; line-height: 1; padding: 0 2px; }

/* ---------- 日历 ---------- */
.calendar { overflow: hidden; }
.cal-weekhead { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-weekhead div { padding: 9px 12px; font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; }
.cal-weekhead div.we { color: var(--holiday); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-cell {
  min-width: 0; min-height: 104px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 8px 9px; background: var(--surface); text-align: left;
  display: flex; flex-direction: column; gap: 4px; transition: background .12s;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:nth-last-child(-n+7) { border-bottom: 0; }
.cal-cell:hover { background: #f7f9ff; }
.cal-cell.other { background: #fbfcfe; }
.cal-cell.other .cal-daynum { color: #c2c9d6; }
.cal-cell.today .cal-daynum { background: var(--primary); color: #fff; border-radius: 7px; }
.cal-cell.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-daynum {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.cal-cell.weekend .cal-daynum { color: var(--restday); }
.cal-cell.today .cal-daynum { color: #fff; }
.cal-items { display: flex; flex-direction: column; gap: 3px; margin-top: 1px; }
.cal-badge {
  display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0;
  border-radius: 6px; padding: 2px 6px; font-size: 11px; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-badge .tb { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.cal-badge.workday { background: #eef2ff; color: #3654c9; }
.cal-badge.workday .tb { background: var(--workday); }
.cal-badge.restday { background: #fff5e6; color: #a5681a; }
.cal-badge.restday .tb { background: var(--restday); }
.cal-badge.holiday { background: #fdefef; color: #b9363c; }
.cal-badge.holiday .tb { background: var(--holiday); }
.cal-amount { margin-top: auto; min-width: 0; font-size: 11px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: 11px; color: var(--muted); }

/* ---------- 列表 / 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 760px; }
table.data th {
  background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600;
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid #f0f2f7; vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafbff; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.money.strong { color: var(--primary); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.note-cell { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.link-btn { border: 0; background: transparent; color: var(--primary); padding: 3px 6px; border-radius: 6px; font-size: 12px; }
.link-btn:hover { background: var(--primary-soft); }
.link-btn.del { color: var(--danger); }
.link-btn.del:hover { background: var(--danger-soft); }
.pill {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 20px;
  padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill .tb { width: 6px; height: 6px; border-radius: 50%; }
.pill.workday { background: #eef2ff; color: #3654c9; } .pill.workday .tb { background: var(--workday); }
.pill.restday { background: #fff5e6; color: #a5681a; } .pill.restday .tb { background: var(--restday); }
.pill.holiday { background: #fdefef; color: #b9363c; } .pill.holiday .tb { background: var(--holiday); }
.tag-cross { margin-left: 5px; font-size: 11px; color: var(--restday); border: 1px solid #f2d9ad; background: #fff9ee; border-radius: 5px; padding: 0 4px; }
.tfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.tfoot strong { font-size: 16px; color: var(--primary); font-variant-numeric: tabular-nums; }

.empty-state { padding: 62px 20px; text-align: center; color: var(--muted); }
.empty-ill {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 18px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.empty-ill svg { width: 30px; height: 30px; }
.empty-state h3 { margin: 0 0 6px; font-size: 15px; color: var(--text); font-weight: 600; }
.empty-state p { margin: 0 0 18px; font-size: 13px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { padding: 18px 20px; }
.stat-card .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat-card .value.accent { color: var(--primary); }
.stat-card .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.two-col { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
.bar-chart { padding: 8px 6px 4px; }
.bar-row { display: flex; align-items: center; gap: 9px; margin: 5px 0; }
.bar-day { width: 42px; font-size: 11px; color: var(--muted); text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.bar-track { flex: 1; height: 15px; background: #f1f4fa; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #6b8bff, #3b62f6); min-width: 2px; transition: width .35s; }
.bar-val { width: 84px; font-size: 11px; color: var(--text-2); text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.chart-legend { font-size: 11px; color: var(--muted); padding: 6px 12px 10px; }
.progress-line { display: flex; height: 8px; border-radius: 6px; overflow: hidden; background: #f1f4fa; margin-top: 6px; }
.progress-line span { display: block; height: 100%; }
.progress-line .workday { background: var(--workday); }
.progress-line .restday { background: var(--restday); }
.progress-line .holiday { background: var(--holiday); }
.legend-dots { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend-dots i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field label .req { color: var(--danger); margin-left: 2px; }
.field .input, .field .select, .field textarea { width: 100%; }
textarea { border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 11px; resize: vertical; min-height: 68px; outline: none; }
.field-help { font-size: 11px; color: var(--muted); }
.field-error { font-size: 11px; color: var(--danger); }
.rate-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.rate-card {
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 13px 14px;
  background: var(--surface); text-align: left; transition: all .15s;
}
.rate-card:hover { border-color: var(--primary); }
.rate-card.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px rgba(59,98,246,.1); }
.rate-card strong { display: block; font-size: 14px; }
.rate-card span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.type-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-opt {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 9px;
  padding: 9px 6px; font-size: 13px; font-weight: 500; text-align: center;
}
.type-opt .m { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.type-opt.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.type-opt.active .m { color: var(--primary); }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.checkline input { width: 15px; height: 15px; accent-color: var(--primary); }
.preview-box {
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px;
  padding: 14px 16px; margin-top: 16px;
}
.preview-box .pt { font-size: 12px; color: var(--muted); margin-bottom: 9px; font-weight: 600; }
.preview-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 3px 0; }
.preview-row span { color: var(--text-2); }
.preview-row b { font-variant-numeric: tabular-nums; }
.preview-total { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 9px; }
.preview-total b { color: var(--primary); font-size: 18px; }
.preview-warn { background: var(--warn-soft); color: #95651a; border: 1px solid #f6e2b9; border-radius: 8px; padding: 8px 11px; font-size: 12px; margin-top: 10px; }
.preview-error { background: var(--danger-soft); color: #b9363c; border: 1px solid #f4cfd1; border-radius: 8px; padding: 8px 11px; font-size: 12px; margin-top: 10px; }

.note { border-radius: 9px; padding: 11px 14px; font-size: 12px; line-height: 1.7; }
.note.info { background: var(--primary-soft); color: #3b4f9e; border: 1px solid #dfe7ff; }
.note.warn { background: var(--warn-soft); color: #8f6118; border: 1px solid #f4e3bf; }
.note.danger { background: var(--danger-soft); color: #a93b40; border: 1px solid #f3cdcf; }
.note b { font-weight: 650; }

.rule-section { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.rule-section:last-child { border-bottom: 0; }
.rule-section h3 { margin: 0 0 4px; font-size: 14px; font-weight: 650; }
.rule-section .desc { font-size: 12px; color: var(--muted); margin: 0 0 16px; }
.rule-actions { display: flex; align-items: center; gap: 12px; padding: 16px 24px; background: var(--surface-2); border-top: 1px solid var(--border); flex-wrap: wrap; }
.rate-display {
  display: flex; align-items: baseline; gap: 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-top: 14px;
}
.rate-display strong { font-size: 24px; color: var(--primary); font-variant-numeric: tabular-nums; }
.rate-display span { font-size: 12px; color: var(--muted); }
.inline-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- 设置页 ---------- */
.override-list { display: flex; flex-direction: column; }
.override-item { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid #f0f2f7; font-size: 13px; }
.override-item:last-child { border-bottom: 0; }
.override-item .od { font-weight: 600; font-variant-numeric: tabular-nums; width: 110px; }
.override-item .or { flex: 1; color: var(--muted); font-size: 12px; }
.data-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13px; border-bottom: 1px solid #f0f2f7; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22, 32, 52, .42);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 100; animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.dialog {
  background: var(--surface); border-radius: 15px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; animation: pop .18s ease-out; overflow: hidden;
}
.dialog.narrow { max-width: 420px; }
.dialog.wide { max-width: 720px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.dialog-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.close-btn { border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 7px; border-radius: 7px; }
.close-btn:hover { background: var(--surface-2); color: var(--text); }
.dialog-body { padding: 22px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.detail-list { display: flex; flex-direction: column; gap: 0; }
.detail-line { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid #f0f2f7; font-size: 13px; }
.detail-line:last-child { border-bottom: 0; }
.detail-line .k { color: var(--muted); }
.detail-line .v { font-weight: 600; text-align: right; }
.calc-steps { background: var(--surface-2); border-radius: 10px; padding: 13px 16px; margin-top: 14px; }
.calc-steps .step { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; color: var(--text-2); }
.calc-steps .step.final { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 9px; font-size: 14px; color: var(--text); font-weight: 600; }
.calc-steps .step.final b { color: var(--primary); font-size: 17px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; bottom: 26px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--text); color: #fff; border-radius: 9px; padding: 10px 15px;
  font-size: 13px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out;
  max-width: 340px; line-height: 1.5;
}
.toast.success { background: #147a56; }
.toast.error { background: #c23c43; }
.toast.warn { background: #a9711c; }

/* ---------- 补充细节 ---------- */
/* 小时工 / 用工模式的独立配色 */
.pill.mode-hourlyWorker { background: #e9f7f1; color: #13785a; }
.pill.mode-hourlyWorker .tb { background: var(--success); }
.cal-badge.hourlyWorker { background: #eaf7f2; color: #13785a; }
.cal-badge.hourlyWorker .tb { background: var(--success); }
.mode-switch button { padding: 5px 11px; }
.mode-cards .rate-card { padding: 10px 13px; }
.mode-cards .rate-card strong { font-size: 13px; }
.hours-mode-tag { display: inline-block; font-size: 10px; font-weight: 600; border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.hours-mode-tag.auto { background: var(--primary-soft); color: var(--primary); }
.hours-mode-tag.manual { background: var(--warn-soft); color: #95651a; border: 1px solid #f6e2b9; }
.entry-switch { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.entry-switch .segmented { flex-shrink: 0; }
.entry-switch .field-help { flex: 1 1 200px; }
.form-section { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.form-section-title { font-size: 12px; font-weight: 650; color: var(--text-2); margin-bottom: 12px; }
table.data.wide { min-width: 1080px; }
/* 录入表单较长大，适度收紧间距让实时预览尽量首屏可见 */
.dialog.wide { max-width: 760px; }
.dialog-body { padding: 18px 22px; }
#recordForm .form-grid { gap: 10px; }
#recordForm .field { gap: 4px; }
#recordForm .field-help { font-size: 10px; }
#recordForm textarea { min-height: 52px; }
#recordForm .form-section { margin-top: 10px; padding-top: 9px; }
#recordForm .form-section-title { margin-bottom: 8px; }
#recordForm .preview-box { margin-top: 10px; padding: 10px 14px; }
#recordForm .preview-row { padding: 2px 0; font-size: 12px; }
#recordForm .preview-total { margin-top: 6px; padding-top: 7px; }
#recordForm .type-opt { padding: 7px 6px; }
.bar-chart.scrollable { max-height: 320px; overflow-y: auto; }
.cal-cell.holiday-day .cal-daynum { color: var(--holiday); }
.cal-cell.today.holiday-day .cal-daynum { color: #fff; }
.override-form { display: grid; grid-template-columns: 1.1fr 1.1fr 1.4fr auto; gap: 14px; align-items: end; }
.override-form .btn { height: 35px; }
.dialog-body::-webkit-scrollbar, .bar-chart.scrollable::-webkit-scrollbar { width: 7px; }
.dialog-body::-webkit-scrollbar-thumb, .bar-chart.scrollable::-webkit-scrollbar-thumb { background: #d9dfea; border-radius: 6px; }

/* ---------- 响应式与可访问性基线 ---------- */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
@supports (padding: env(safe-area-inset-bottom)) {
  .statusbar { padding-bottom: calc(9px + env(safe-area-inset-bottom)); }
}
.table-wrap { -webkit-overflow-scrolling: touch; }

@media (max-width: 1080px) {
  .topbar { gap: 14px; padding: 12px 18px; }
  .brand-text span { display: none; }
  .tab { padding: 8px 10px; }
  .main { padding: 20px 18px 30px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .top-actions { margin-left: auto; }
  .month-picker .month-label { min-width: 78px; }
  .btn-primary { padding: 7px 10px; }
  .form-grid, .inline-fields, .rate-cards, .override-form { grid-template-columns: 1fr; }
  .type-picker { grid-template-columns: repeat(3, 1fr); }
  .main { padding: 16px 14px 28px; }
  .toolbar { gap: 8px; }
  .toolbar .spacer { display: none; }
  .toolbar .search { flex: 1 1 100%; min-width: 0; }
  #resultCount { flex: 1 1 100%; }
  .cal-cell { min-height: 68px; padding: 5px 4px; }
  .cal-badge { font-size: 10px; padding: 1px 3px; }
  .cal-amount { font-size: 10px; }
  .cal-weekhead div { padding: 7px 2px; }
  .statusbar { padding: 9px 18px; }
  .dialog { max-width: calc(100vw - 28px); }
  .dialog-body { padding: 16px; }
  .dialog-head, .dialog-foot { padding-left: 16px; padding-right: 16px; }
  .stat-grid { gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .value { font-size: 22px; }
  .rule-section, .rule-actions { padding-left: 16px; padding-right: 16px; }
  .rule-actions { flex-wrap: wrap; }
  .rule-actions > div { flex: 1 1 100%; }
  .card-pad { padding: 16px; }
  .data-actions { gap: 8px; }
  .bar-val { width: 74px; }
}

/* 手机：信息密度随宽度降级，而不是把功能藏起来 */
@media (max-width: 520px) {
  .topbar { padding: 10px 12px 0; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .brand-mark svg { width: 18px; height: 18px; }
  .brand-text strong { font-size: 15px; }
  .top-actions { gap: 8px; }
  .month-picker { padding: 1px; }
  .month-label { min-width: 68px; font-size: 13px; }
  .icon-btn { width: 26px; height: 26px; }
  .btn-primary { padding: 6px 10px; font-size: 13px; }
  .tabs {
    margin: 2px -12px 0; padding: 0 12px 6px; width: calc(100% + 24px);
    border-bottom: 1px solid var(--border);
  }
  .tab { flex: 0 0 auto; padding: 8px 11px; font-size: 13px; }
  .main { padding: 14px 12px 24px; }
  .statusbar { padding: 8px 12px; font-size: 11px; gap: 8px 14px; }
  .segmented button { padding: 5px 10px; font-size: 12px; }
  .select { min-width: 0; }
  .search { width: 100%; }
  .card-pad { padding: 14px; }
  .section-title { font-size: 15px; }

  /* 月历降为「日期 + 类型色点 + 金额」，仍可点进当天明细 */
  .cal-weekhead div { font-size: 10px; padding: 5px 0; }
  .cal-cell { min-height: 56px; padding: 4px 2px; align-items: center; }
  .cal-daynum { width: 22px; height: 22px; font-size: 12px; }
  .cal-items { flex-direction: row; justify-content: center; align-items: center; flex-wrap: wrap; width: 100%; gap: 3px; }
  .cal-badge {
    display: block; width: 6px; height: 6px; min-width: 6px; padding: 0;
    border-radius: 50%; font-size: 0; line-height: 0; overflow: hidden;
  }
  .cal-badge .tb, .cal-more { display: none; }
  .cal-badge.workday { background: var(--workday); }
  .cal-badge.restday { background: var(--restday); }
  .cal-badge.holiday { background: var(--holiday); }
  .cal-badge.hourlyWorker { background: var(--success); }
  .cal-amount {
    flex: 1 1 100%; text-align: center; font-size: 9px; letter-spacing: -.2px;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  /* 宽表转记录卡片：每格自带标签，不再横向拖表格 */
  table.data.wide { min-width: 0; width: 100%; }
  table.data.wide thead { display: none; }
  table.data.wide, table.data.wide tbody, table.data.wide tr, table.data.wide td { display: block; width: 100%; }
  table.data.wide tbody tr {
    border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
    padding: 10px 12px; background: var(--surface); box-shadow: var(--shadow);
  }
  table.data.wide tbody tr:last-child { margin-bottom: 0; }
  table.data.wide td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    border: 0; padding: 4px 0; white-space: normal; text-align: right;
  }
  table.data.wide td::before {
    content: attr(data-label); color: var(--muted); font-size: 12px;
    font-weight: 500; flex: 0 0 auto; text-align: left;
  }
  table.data.wide td[data-label="金额"] { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
  table.data.wide td[data-label="金额"] .money { font-size: 16px; color: var(--primary); }
  table.data.wide td .row-actions { justify-content: flex-end; flex-wrap: wrap; }
  table.data:not(.wide) { min-width: 560px; }
  .tfoot { padding: 10px 12px; font-size: 12px; }
  .tfoot strong { font-size: 15px; }

  /* 弹窗贴顶、单列、可滚动 */
  .modal-overlay { padding: 10px; align-items: flex-start; }
  .dialog { max-width: 100%; max-height: calc(100vh - 20px); border-radius: 12px; }
  .dialog-head { padding: 14px 16px; }
  .dialog-body { padding: 14px 16px; }
  .dialog-foot { padding: 12px 16px; flex-wrap: wrap; }
  .dialog-foot .btn { flex: 1 1 auto; min-height: 40px; }
  .dialog-foot .spacer { display: none; }
  .rate-cards, .mode-cards, .inline-fields, .form-grid, .override-form { grid-template-columns: 1fr; }
  .rate-card { padding: 10px 12px; }
  .type-picker { gap: 6px; }
  .type-opt { font-size: 12px; padding: 8px 2px; }
  .preview-row { gap: 8px; flex-wrap: wrap; }
  .preview-row b { text-align: right; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 19px; }
  .stat-card .sub { font-size: 10px; }
  .two-col { gap: 12px; }
  .bar-day { width: 34px; }
  .bar-val { width: 70px; font-size: 10px; }
  .rule-section { padding: 16px; }
  .rule-actions { padding: 14px 16px; }
  .rate-display { flex-wrap: wrap; }
  .data-actions .btn { flex: 1 1 140px; }
  .override-item { flex-wrap: wrap; gap: 6px; }
  .override-item .or { flex: 1 1 100%; }
  /* 手机端提示移到顶部：底部要留给弹窗的保存按钮 */
  .toast-root { top: 8px; bottom: auto; left: 12px; right: 12px; align-items: center; }
  .toast { max-width: 100%; text-align: center; }
  .toast-root .toast:not(:last-child) { display: none; }

  /* iOS Safari 在输入框字号 <16px 时会自动缩放整页 */
  .input, .select, textarea { font-size: 16px; }
  .btn, .icon-btn { min-height: 36px; }
  .link-btn { min-height: 32px; padding: 4px 8px; }
}

@media (max-width: 360px) {
  .brand-text strong { font-size: 14px; }
  .month-label { min-width: 58px; font-size: 12px; }
  .btn-primary { font-size: 12px; padding: 6px 8px; }
  .stat-grid { grid-template-columns: 1fr; }
  .cal-cell { min-height: 50px; }
  .cal-amount { font-size: 8px; }
  .segmented button { padding: 5px 7px; font-size: 11px; }
  .tab { padding: 7px 9px; font-size: 12px; }
}
