:root {
  --bg: #f5f6f4;
  --card: #fff;
  --text: #171a1f;
  --muted: #6f7782;
  --line: #e6e9e7;
  --green: #3b82f6;
  --green-dark: #1d4ed8;
  --danger: #c84c4c;
}

@font-face {
  font-family: "tabler-icons";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/vendor/tabler-icons/fonts/tabler-icons.woff2?v3.43.0") format("woff2");
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--green-dark); text-decoration: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: #fbfcfb;
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  transition: width 160ms ease, padding 160ms ease;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; min-width: 0; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: white;
}
.brand-text {
  white-space: nowrap;
}
.sidebar-toggle {
  width: 34px;
  min-width: 34px;
  padding: 0;
  flex-shrink: 0;
}
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 7px;
  color: #29313a;
}
.sidebar nav a i {
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar nav a.active, .sidebar nav a:hover { background: #eaf2ff; color: var(--green-dark); }
.user { margin-top: auto; display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.logout-form { margin: 0; }

.main {
  margin-left: 220px;
  padding: 20px 25px 30px;
  transition: margin-left 160ms ease;
}
html.sidebar-collapsed .sidebar {
  width: 76px;
  padding-left: 12px;
  padding-right: 12px;
}
html.sidebar-collapsed .main {
  margin-left: 76px;
}
html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .sidebar nav a span,
html.sidebar-collapsed .user strong,
html.sidebar-collapsed .logout-form {
  display: none;
}
html.sidebar-collapsed .sidebar-top {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  margin-bottom: 24px;
}
html.sidebar-collapsed .brand {
  justify-content: center;
}
html.sidebar-collapsed .sidebar-toggle {
  margin: 2px 0;
}
html.sidebar-collapsed .sidebar nav a {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
html.sidebar-collapsed .user {
  justify-content: center;
}
.login-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 360px; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 28px; }
.login-brand { margin-bottom: 18px; }

.page-title { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; }
.page-title h1 { margin: 6px 0 4px; font-size: 24px; }
.page-title p, .crumb { margin: 0; color: var(--muted); font-size: 13px; }
.page-title-meta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.page-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--green-dark);
  font-weight: 500;
}
.page-back-link i {
  font-size: 15px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { font-size: 16px; margin: 0 0 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-note { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.split { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.stack-form { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; max-width: 860px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-form .card:last-child { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-stack { display: grid; gap: 14px; }
.wide { grid-column: 1 / -1; }

label { display: grid; gap: 6px; color: #3f4752; font-size: 13px; }
label:has(> input[required]),
label:has(> input[data-required="true"]),
label:has(> select[required]),
label:has(> textarea[required]) {
  position: relative;
}
label:has(> input[required]) > .label-text::after,
label:has(> input[data-required="true"]) > .label-text::after,
label:has(> select[required]) > .label-text::after,
label:has(> textarea[required]) > .label-text::after {
  content: "*";
  margin-left: 4px;
  color: var(--danger);
  font-size: 14px;
  line-height: 1;
}
.label-text {
  display: inline-flex;
  align-items: center;
}
label:has(> select) {
  position: relative;
}
label:has(> input[placeholder*="搜索"]) {
  position: relative;
}
label:has(> input[placeholder*="搜索"])::before {
  content: "\eb1c";
  font-family: "tabler-icons";
  position: absolute;
  left: 10px;
  bottom: 9px;
  color: #7b858e;
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}
label:has(> select)::after {
  content: "\ea5f";
  font-family: "tabler-icons";
  position: absolute;
  right: 12px;
  bottom: 9px;
  color: #7b858e;
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
}
input, select, textarea {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  background: white;
  color: var(--text);
  font: inherit;
}
input[placeholder*="搜索"] {
  padding-left: 34px;
}
input[type="date"],
input[type="month"],
input[data-picker="year"] {
  cursor: pointer;
}
.custom-picker {
  display: grid;
  gap: 6px;
}
.custom-picker-trigger {
  width: 100%;
  justify-content: space-between;
  background: white;
  text-align: left;
}
.custom-picker-label {
  flex: 1;
}
.custom-picker-trigger.placeholder {
  color: var(--muted);
}
.custom-picker-icon {
  color: var(--muted);
  font-size: 16px;
  flex-shrink: 0;
}
.custom-picker-error {
  display: none;
  color: var(--danger);
  font-size: 12px;
}
.custom-picker.invalid .custom-picker-trigger {
  border-color: #f0c7c7;
  box-shadow: 0 0 0 3px rgba(200, 76, 76, 0.12);
}
.custom-picker.invalid .custom-picker-error {
  display: block;
}
.custom-picker-native {
  display: none;
}
.custom-picker-panel {
  position: absolute;
  z-index: 40;
  width: 280px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: 0 12px 30px rgba(23, 26, 31, 0.12);
}
.custom-picker-panel.hidden {
  display: none;
}
.custom-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.custom-picker-nav {
  width: 32px;
  min-width: 32px;
  padding: 0;
  font-size: 18px;
}
.custom-picker-nav:disabled,
.custom-picker-cell:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.custom-picker-weekdays,
.custom-picker-days,
.custom-picker-months,
.custom-picker-years {
  display: grid;
  gap: 6px;
}
.custom-picker-weekdays {
  margin-bottom: 8px;
}
.custom-picker-weekdays,
.custom-picker-days {
  grid-template-columns: repeat(7, 1fr);
}
.custom-picker-months {
  grid-template-columns: repeat(3, 1fr);
}
.custom-picker-years {
  grid-template-columns: repeat(3, 1fr);
}
.custom-picker-weekdays span {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.custom-picker-cell,
.custom-picker-spacer {
  height: 34px;
  min-width: 0;
  width: 100%;
}
.custom-picker-cell {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  font: inherit;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.custom-picker-cell:hover {
  border-color: #9dd9ca;
  background: #f6fbf9;
}
.custom-picker-cell:disabled:hover {
  border-color: var(--line);
  background: white;
}
.custom-picker-cell.selected {
  border-color: var(--green);
  background: var(--green);
  color: white;
}
.custom-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-color: white;
  background-image: none;
}
select:focus {
  outline: none;
  border-color: #9dd9ca;
  box-shadow: 0 0 0 3px rgba(47, 184, 157, 0.12);
}
input:focus, textarea:focus {
  outline: none;
  border-color: #9dd9ca;
  box-shadow: 0 0 0 3px rgba(47, 184, 157, 0.12);
}
textarea { min-height: 92px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; height: auto; }
.compact { width: 96px; min-width: 96px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.filters label.filter-active input,
.filters label.filter-active select {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}
.filters .custom-picker.filter-active .custom-picker-trigger {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}
.card > .filters:only-child {
  margin-bottom: 0;
}
.filters label {
  width: auto;
  min-width: 128px;
  max-width: 220px;
}
.filters input, .filters select {
  width: auto;
  min-width: 128px;
  max-width: 220px;
}
.filters input[type="month"],
.filters input[type="date"],
.filters input[data-picker="year"],
.filters select {
  min-width: 140px;
}
.filters input[name="q"],
.filters input[name="employee"] {
  min-width: 180px;
}
.filter-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}
.filter-actions.push-right {
  margin-left: auto;
}
.filter-actions .button {
  min-width: 76px;
}
.filter-reset-button {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: #bfd4fb;
  color: var(--green-dark);
  background: #eaf2ff;
  border-radius: 7px;
}
.filter-reset-button.hidden {
  display: none;
}
.button, button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 13px;
  background: white;
  color: #26313b;
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.button.primary, button.primary { background: var(--green); border-color: var(--green); color: white; }
.button.primary:hover, button.primary:hover { background: var(--green-dark); }
.button.theme-outline, button.theme-outline {
  border-color: var(--green);
  color: var(--green-dark);
  background: white;
}
.button.theme-outline:hover, button.theme-outline:hover {
  border-color: var(--green-dark);
  background: #eaf2ff;
}
.danger-button { border-color: #f0c7c7; color: var(--danger); }
.link {
  border: 0;
  background: transparent;
  padding: 0;
  height: auto;
  color: var(--green-dark);
}
.link.danger { color: var(--danger); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.table-wrap table {
  border: 0;
}
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 10px; text-align: left; vertical-align: middle; }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: #fafbfa;
  white-space: nowrap;
}
tbody tr:hover { background: #fbfcfb; }
tbody tr:last-child td { border-bottom: 0; }
td { white-space: nowrap; }
td:first-child, th:first-child { padding-left: 14px; }
td:last-child, th:last-child { padding-right: 14px; }
.num { text-align: left; white-space: nowrap; }
.empty-state-row td {
  padding: 28px 14px;
  text-align: center;
}
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.empty-state i {
  font-size: 20px;
  color: #94a3b8;
}
.strong { font-weight: 700; }
.actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.actions form { display: inline; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: #edf0ef;
  color: #52606b;
  font-size: 12px;
}
.tag.ok, .tag.confirmed { background: #eaf2ff; color: #1d4ed8; }
.tag.paid { background: #e7f0ff; color: #2b62ad; }
.tag.draft { background: #fff5d9; color: #946800; }
.tag.muted { background: #f0f1f2; color: #737a82; }
.calendar-tag.holiday {
  background: #f3f4f6;
  color: #5a6470;
}
.calendar-tag.paid_holiday {
  background: #ffe7e0;
  color: #b74b32;
}
.calendar-tag.makeup_workday {
  background: #eaf2ff;
  color: #1d4ed8;
}

.flash { margin-bottom: 16px; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--line); background: white; }
.flash.success { border-color: #bfd4fb; color: #1d4ed8; }
.flash.error, .error-text { color: var(--danger); }
.ok-text { color: var(--green-dark); }
.result-list { margin: 0 0 16px; padding-left: 18px; }

.payroll-entry-table {
  min-width: 1320px;
}
.payroll-entry-table th,
.payroll-entry-table td {
  padding: 8px 8px;
}
.payroll-entry-table th:first-child,
.payroll-entry-table td:first-child {
  width: 46px;
  text-align: center;
}
.table-empty-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 164px;
  padding: 20px;
}
.table-empty-panel .empty-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.table-empty-panel .empty-state i {
  font-size: 18px;
}
.payroll-entry-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
}
.payroll-entry-table .compact {
  width: 92px;
  min-width: 92px;
}
.payroll-entry-table td:nth-child(8) input {
  min-width: 92px;
}
.payroll-entry-table td:nth-child(2),
.payroll-entry-table td:nth-child(3) {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-head { display: flex; justify-content: space-between; align-items: center; }
.status-actions { display: flex; gap: 8px; align-items: center; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; text-align: left; }
.summary-card .net { color: var(--green-dark); font-size: 22px; }

@media print {
  .sidebar, .page-title, .status-actions { display: none; }
  .main { margin: 0; padding: 0; }
  body { background: white; }
  .card { break-inside: avoid; }
}

@media (max-width: 900px) {
  .sidebar { position: static; width: auto; }
  .main { margin: 0; padding: 20px; max-width: none; }
  .grid-form, .split, .detail-grid { grid-template-columns: 1fr; }
  .filters label,
  .filters input,
  .filters select {
    width: 100%;
    max-width: none;
  }
}
