:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #667085;
  --line: #d8dde6;
  --primary: #176b5d;
  --primary-dark: #105349;
  --accent: #b54708;
  --danger: #b42318;
  --ok: #167647;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 12px 32px rgba(26, 33, 44, 0.08);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 20px;
}

p {
  color: var(--muted);
  margin: 8px 0 0;
}

.version-line {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.form-grid,
.entry-grid {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.entry-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.entry-grid.compact {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

input[readonly] {
  background: #f2f4f7;
}

.checkbox-line {
  align-content: end;
  grid-template-columns: auto 1fr;
}

.checkbox-line input {
  width: auto;
  min-height: 0;
}

button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.full,
.wide {
  grid-column: 1 / -1;
}

.demo-box {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  padding: 12px;
  background: #f2f4f7;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.tabs button {
  background: #fff;
  border-color: var(--line);
}

.tabs button.active {
  background: #e7f4ef;
  border-color: #84c7b7;
  color: var(--primary-dark);
}

.panel {
  width: min(1240px, calc(100% - 32px));
  margin: 16px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 160px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-stack {
  display: grid;
  gap: 12px;
}

.summary-groups {
  display: grid;
  gap: 14px;
}

.summary-group,
.summary-detail {
  display: grid;
  gap: 10px;
}

.summary-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.summary-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.summary-group-head span,
.empty-detail {
  color: var(--muted);
}

.selected-row td {
  background: #eef8f4;
}

.summary-stack h3 {
  margin: 4px 0 0;
  color: #344054;
  font-size: 16px;
  letter-spacing: 0;
}

.summary-total {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
}

.summary-total strong {
  color: var(--primary-dark);
}

.attendance-key-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.attendance-key-row input {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.subsection-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin: 18px 0 8px;
}

.subsection-head h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.subsection-head p {
  margin: 0;
  color: var(--muted);
}

.progress-ledger {
  min-width: 760px;
  background: #fff;
}

.progress-ledger + .progress-ledger {
  border-top: 10px solid #f4f2ea;
}

.progress-ledger-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #f7f5ee;
  color: #344054;
}

.progress-ledger-head b {
  font-size: 15px;
}

.progress-ledger-row {
  display: grid;
  grid-template-columns: 74px minmax(260px, 1.7fr) minmax(150px, 1fr) 90px 90px 100px;
  gap: 10px;
  align-items: center;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

.progress-ledger-row:nth-child(odd):not(.progress-ledger-row-head) {
  background: #f7f5ee;
}

.progress-ledger-row-head {
  padding-top: 9px;
  padding-bottom: 9px;
  background: #fbfbf8;
  color: #475467;
  font-size: 13px;
}

.progress-project {
  display: grid;
  gap: 4px;
}

.progress-project strong {
  font-size: 15px;
}

.progress-project small {
  color: var(--muted);
  line-height: 1.4;
}

.progress-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.progress-tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid #dbe7f6;
  border-radius: 4px;
  background: #eef6ff;
  color: #175cd3;
  font-size: 12px;
}

.progress-tag.accent {
  border-color: #efe2bd;
  background: #fff8e5;
  color: #93370d;
}

.progress-number,
.progress-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.progress-money.strong {
  color: #101828;
  font-weight: 700;
}

table {
  border-collapse: collapse;
  min-width: 100%;
  background: #fff;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: #344054;
  position: sticky;
  top: 0;
  z-index: 1;
}

td.actions {
  white-space: nowrap;
}

.small-input {
  min-width: 90px;
  width: 110px;
}

.payroll-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.payroll-slip-sheet {
  display: grid;
  gap: 16px;
  min-width: 980px;
}

.payroll-slip {
  border: 1px solid #101828;
  background: #fff;
  break-inside: avoid;
}

.payroll-slip-title {
  padding: 8px 0 6px;
  text-align: center;
  color: #101828;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.payroll-slip-table {
  table-layout: fixed;
  min-width: 100%;
  border-top: 1px solid #101828;
}

.payroll-slip-zhang .payroll-slip-table {
  min-width: 1220px;
}

.payroll-slip-table th,
.payroll-slip-table td {
  height: 42px;
  padding: 6px;
  border: 1px solid #101828;
  text-align: center;
  white-space: normal;
}

.payroll-slip-table th {
  position: static;
  background: #fff;
  color: #101828;
}

.payroll-slip-table .signature-head,
.payroll-slip-table .signature-confirm {
  width: 160px;
}

.payroll-slip-table .money-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.payroll-slip-table .strong {
  font-weight: 700;
}

.payroll-input {
  width: 100%;
  min-width: 0;
  text-align: center;
  padding: 6px 4px;
}

.payroll-fixed-value {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.signature-confirm {
  min-height: 46px;
}

.payroll-slip-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
}

.status.ok {
  background: #dcfae6;
  color: var(--ok);
}

.status.bad {
  background: #fee4e2;
  color: var(--danger);
}

.status.neutral {
  background: #eef2f6;
  color: var(--muted);
}

.status.wait {
  background: #fff3cd;
  color: var(--accent);
}

.notes-list {
  display: grid;
  gap: 12px;
}

.note-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  line-height: 1.7;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #101828;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 16px 32px rgba(16, 24, 40, 0.2);
}

@media (max-width: 860px) {
  body {
    font-size: 14px;
  }

  .login-shell {
    align-items: start;
    padding: 16px;
  }

  .login-panel {
    margin-top: 24px;
    padding: 20px;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 18px;
  }

  .entry-grid,
  .entry-grid.compact {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px 16px;
  }

  .topbar .ghost {
    align-self: flex-start;
  }

  .tabs {
    gap: 6px;
    padding: 10px 12px;
    scroll-snap-type: x mandatory;
  }

  .tabs button {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 12px;
    scroll-snap-align: start;
  }

  .panel {
    width: 100%;
    margin: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    padding: 14px;
  }

  .panel + .panel {
    border-top: 0;
  }

  .panel-head {
    gap: 10px;
    margin-bottom: 12px;
  }

  .panel-head p,
  .demo-box {
    font-size: 13px;
  }

  input,
  select,
  button {
    min-height: 44px;
    font-size: 16px;
  }

  label {
    font-size: 13px;
  }

  .toolbar {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .toolbar input,
  .toolbar select,
  .toolbar button {
    min-width: 0;
    width: 100%;
  }

  .summary-total {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .attendance-key-row,
  .subsection-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .summary-group-head,
  .summary-detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-detail-head button {
    width: 100%;
  }

  .table-wrap {
    margin-right: -14px;
    margin-left: -14px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  table {
    min-width: 720px;
  }

  th,
  td {
    padding: 9px 8px;
    font-size: 13px;
  }

  td.actions {
    min-width: 140px;
    white-space: normal;
  }

  td.actions button {
    width: 100%;
    margin: 2px 0;
  }

  .small-input {
    width: 100%;
    min-width: 82px;
  }

  .progress-ledger {
    min-width: 0;
  }

  .progress-ledger-head {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .progress-ledger-row {
    grid-template-columns: 1fr;
    gap: 7px;
    align-items: start;
    padding: 11px 12px;
  }

  .progress-ledger-row-head {
    display: none;
  }

  .progress-number,
  .progress-money {
    text-align: left;
  }

  .progress-tags::before,
  .progress-number::before,
  .progress-ledger-row:not(.progress-ledger-row-head) .progress-money::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
  }

  .progress-tags::before {
    content: "环节 ";
    align-self: center;
  }

  .progress-number::before {
    content: "数量 ";
  }

  .progress-ledger-row:not(.progress-ledger-row-head) .progress-money:nth-child(5)::before {
    content: "单价 ";
  }

  .progress-ledger-row:not(.progress-ledger-row-head) .progress-money:nth-child(6)::before {
    content: "金额 ";
  }

  .payroll-wrap {
    max-height: none;
    margin-right: -14px;
    margin-left: -14px;
    padding: 8px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .payroll-slip-sheet {
    min-width: 780px;
  }

  .payroll-slip-zhang {
    min-width: 1040px;
  }

  .payroll-slip-title {
    font-size: 16px;
  }

  .payroll-slip-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .payroll-slip-actions button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .login-shell {
    min-height: 100dvh;
    padding: 12px;
  }

  .login-panel {
    margin-top: 12px;
    padding: 18px;
  }

  .login-panel h1 {
    font-size: 21px;
  }

  .topbar {
    gap: 10px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .version-line,
  #userLine {
    font-size: 12px;
  }

  .tabs button {
    font-size: 14px;
  }

  .panel {
    padding: 12px;
  }

  .entry-grid {
    gap: 12px;
    margin-top: 16px;
  }

  .table-wrap,
  .payroll-wrap {
    margin-right: -12px;
    margin-left: -12px;
  }

  .progress-ledger-head,
  .progress-ledger-row {
    padding-right: 10px;
    padding-left: 10px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  body {
    background: #fff;
  }

  .topbar,
  .tabs,
  .panel:not(#payrollPanel),
  .no-print,
  .toast {
    display: none !important;
  }

  #payrollPanel {
    width: 100%;
    margin: 0;
    border: 0;
    padding: 0;
    box-shadow: none;
  }

  #payrollPanel .panel-head {
    margin-bottom: 4mm;
  }

  #payrollPanel .toolbar {
    display: none;
  }

  #payrollInfo {
    display: none;
  }

  .payroll-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    padding: 0;
  }

  .payroll-slip-sheet {
    display: block;
    min-width: 0;
  }

  .payroll-slip {
    margin: 0 0 8mm;
    border: 1px solid #000;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .payroll-slip-title {
    padding: 2mm 0 1.5mm;
    font-size: 16px;
  }

  .payroll-slip-table {
    width: 100%;
    table-layout: fixed;
  }

  .payroll-slip-table th,
  .payroll-slip-table td {
    height: 10mm;
    padding: 1.2mm;
    border: 1px solid #000;
    font-size: 10px;
    line-height: 1.2;
  }

  .payroll-slip-zhang .payroll-slip-table {
    min-width: 0;
  }

  .payroll-slip-zhang .payroll-slip-table th,
  .payroll-slip-zhang .payroll-slip-table td {
    font-size: 8.5px;
    padding: 1mm 0.6mm;
  }

  .payroll-slip-table .signature-head,
  .payroll-slip-table .signature-confirm {
    width: 38mm;
  }

  .payroll-input {
    border: 0;
    background: transparent;
    min-height: 0;
    padding: 0;
    font-size: 10px;
  }
}

/* payroll-six-per-page:start */
@media print {
  @page { size: A4 landscape; margin: 6mm; }
  #payrollPanel .panel-head { display: none !important; }
  .payroll-slip { margin: 0 0 3mm; }
  .payroll-slip:nth-child(6n):not(:last-child) {
    page-break-after: always;
    break-after: page;
  }
  .payroll-slip-title {
    padding: 1mm 0 0.8mm;
    font-size: 13px;
  }
  .payroll-slip-table th,
  .payroll-slip-table td {
    height: 7mm;
    padding: 0.7mm;
    font-size: 9px;
    line-height: 1.1;
  }
  .payroll-slip-table .signature-head,
  .payroll-slip-table .signature-confirm { width: 42mm; }
}
/* payroll-six-per-page:end */
/* payroll-print-v2:start */
@media print {
  @page { size: A4 landscape; margin: 6mm; }
  #payrollPanel .panel-head { display: none !important; }
  .payroll-slip-sheet { display: block; min-width: 0; }
  .payroll-slip {
    margin: 0 0 3.5mm;
    padding-bottom: 1.5mm;
    border: 0;
    border-bottom: 1px dashed #777;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .payroll-slip:nth-child(6n):not(:last-child) {
    margin-bottom: 0;
    page-break-after: always;
    break-after: page;
  }
  .payroll-slip-title { padding: 1mm 0 0.8mm; font-size: 12pt; }
  .payroll-slip-table { width: 100%; min-width: 0; table-layout: fixed; border-left: 1px solid #000; }
  .payroll-slip-table th, .payroll-slip-table td {
    height: 7mm;
    padding: 0.7mm;
    border: 1px solid #000;
    font-size: 9pt;
    line-height: 1.1;
  }
  .payroll-slip-zhang .payroll-slip-table th, .payroll-slip-zhang .payroll-slip-table td { font-size: 8pt; padding: 0.6mm 0.4mm; }
  .payroll-slip-table .signature-head, .payroll-slip-table .signature-confirm { width: 42mm; }
  .payroll-input { border: 0; background: transparent; min-height: 0; padding: 0; font-size: 9pt; }
}
/* payroll-print-v2:end */

/* payroll-border-fix:start */
@media print {
  .payroll-slip-table {
    border: 1.5pt solid #000 !important;
    border-collapse: collapse !important;
  }
  .payroll-slip-table tr > :first-child {
    border-left: 1.5pt solid #000 !important;
  }
  .payroll-slip-table tr > :last-child {
    border-right: 1.5pt solid #000 !important;
  }
}
/* payroll-border-fix:end */

/* payroll-layout-v3:start */
@media print {
  .payroll-slip {
    height: 31.5mm !important;
    margin: 0 0 1.5mm !important;
    padding-bottom: 1mm !important;
    border-left: 1.5pt solid #000 !important;
    border-right: 1.5pt solid #000 !important;
    border-bottom: 1px dashed #777 !important;
    box-sizing: border-box !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .payroll-slip:nth-child(6n):not(:last-child) {
    margin-bottom: 0 !important;
    break-after: page !important;
    page-break-after: always !important;
  }

  .payroll-slip-table {
    width: 100% !important;
    border: 1.5pt solid #000 !important;
    border-collapse: collapse !important;
    outline: 1pt solid #000;
    outline-offset: -1pt;
  }

  .payroll-slip-table th,
  .payroll-slip-table td {
    box-sizing: border-box !important;
  }

  .payroll-slip-table thead th {
    height: 6.2mm !important;
    padding: 0.4mm !important;
  }

  .payroll-slip-table tbody td {
    height: 8.5mm !important;
    padding: 0.8mm 0.5mm !important;
  }

  .payroll-slip-table tr > :first-child {
    border-left: 1.5pt solid #000 !important;
  }

  .payroll-slip-table tr > :last-child {
    border-right: 1.5pt solid #000 !important;
  }

  .payroll-slip-table .signature-head,
  .payroll-slip-table .signature-confirm {
    width: 50mm !important;
    min-width: 50mm !important;
  }
}
/* payroll-layout-v3:end */
