:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e0ea;
  --text: #172033;
  --muted: #667085;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
}

a.button-link {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: #eef2f7;
  color: var(--text);
  padding: 8px 12px;
  text-decoration: none;
}

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

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

a.button-link:hover {
  background: #e1e8f0;
}

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

button.secondary {
  background: #eef2f7;
  color: var(--text);
}

button.secondary:hover {
  background: #e1e8f0;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.08);
}

.login-box h1,
.page h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.muted {
  color: var(--muted);
}

.layout {
  height: 100vh;
  display: grid;
  grid-template-columns: 224px 1fr;
  overflow: hidden;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #d1d5db;
  padding: 18px 12px;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #1f2937;
}

.brand {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  padding: 8px 10px 20px;
}

.nav {
  display: grid;
  gap: 12px;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-title {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 9px;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.nav-group-title:hover {
  background: rgba(148, 163, 184, 0.08);
  color: #e5e7eb;
}

.nav-group-arrow {
  color: #94a3b8;
  transition: transform 0.16s ease;
}

.nav-group.open .nav-group-arrow {
  transform: rotate(90deg);
}

.nav-group-items {
  display: grid;
  gap: 4px;
  padding-left: 0;
}

.nav-group.collapsed .nav-group-items {
  display: none;
}

.nav button {
  width: 100%;
  margin: 0;
  text-align: left;
  background: transparent;
  color: #d1d5db;
}

.nav .nav-item {
  position: relative;
  margin: 0;
  padding: 9px 10px 9px 18px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 600;
}

.nav .nav-item:hover {
  background: rgba(148, 163, 184, 0.12);
  color: #fff;
}

.nav .nav-item.active {
  background: #1d4ed8;
  color: #fff;
}

.nav .nav-item.active::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 999px;
  background: #bfdbfe;
}

.empty-nav {
  padding: 8px 10px;
}

.main {
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page {
  padding: 22px 24px 40px;
}

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

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

.grid {
  display: grid;
  gap: 14px;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.compact-cards {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin: 14px 0;
}

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric {
  font-size: 28px;
  font-weight: 700;
  margin-top: 8px;
}

.compact-cards .metric {
  font-size: 22px;
}

.finance-view-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.finance-view-tab {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

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

.finance-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.finance-tab {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  text-align: left;
  text-decoration: none;
}

.finance-tab:hover,
.finance-tab.active {
  border-color: var(--primary);
  background: #eff6ff;
  color: #1d4ed8;
}

.finance-tab span {
  font-weight: 700;
}

.finance-tab strong {
  color: inherit;
  font-size: 22px;
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.filter-row,
.selection-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.filter-label {
  color: #344054;
  font-weight: 700;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 6px 10px;
}

.check-pill input,
.selection-bar input,
.employee-check,
.user-check {
  width: auto;
}

.data-init-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.data-init-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.data-init-option input {
  width: auto;
  margin-top: 3px;
}

.data-init-option small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
}

.toolbar.tight {
  margin-bottom: 0;
}

.approval-role-hint {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
}

.selection-bar {
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
}

.table-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
}

.page-size-control,
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-size-control select {
  width: auto;
  min-width: 96px;
}

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.employee-table-wrap {
  min-height: min(calc(54px + var(--employee-page-size, 20) * 48px), 70vh);
}

.finance-document-table-wrap {
  min-height: 390px;
}

.finance-subject-cell {
  width: 260px;
  max-width: 260px;
  white-space: normal;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.finance-ledger-subject-cell {
  width: 320px;
  min-width: 260px;
  max-width: 320px;
}

.finance-ledger-subject-person {
  font-weight: 700;
  color: var(--text);
}

.finance-ledger-subject-separator {
  margin: 0 4px;
  color: var(--muted);
}

.finance-ledger-subject-text {
  color: var(--text);
}

.loan-offset-hint {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
}

.finance-complete-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.finance-complete-summary div {
  display: grid;
  gap: 4px;
}

.finance-complete-summary span {
  color: var(--muted);
  font-size: 13px;
}

.finance-complete-summary strong {
  color: var(--text);
  font-size: 18px;
}

.finance-complete-summary .payable strong {
  color: #1d4ed8;
  font-size: 22px;
}

.finance-complete-summary.has-offset {
  border-color: #93c5fd;
  background: #eff6ff;
}

.finance-complete-summary p {
  grid-column: 1 / -1;
  margin: 0;
  color: #1d4ed8;
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #344054;
  font-weight: 600;
}

.column-filter {
  min-width: 96px;
  padding: 5px 7px;
  font-size: 12px;
}

.filterable-th {
  position: relative;
  overflow: visible;
}

.th-title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.column-filter-toggle {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  color: #667085;
  line-height: 16px;
  opacity: 0.75;
}

.column-filter-toggle::before {
  content: "▾";
  display: block;
  font-size: 12px;
  line-height: 16px;
}

.column-filter-toggle:hover,
.column-filter-toggle.active {
  background: #dbeafe;
  color: var(--primary);
  opacity: 1;
}

.column-filter-pop {
  position: absolute;
  z-index: 15;
  top: calc(100% + 4px);
  left: 8px;
  width: 260px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
}

.excel-filter {
  display: grid;
  gap: 8px;
}

.excel-filter-search {
  width: 100%;
  padding: 7px 9px;
  font-size: 13px;
}

.excel-filter-actions,
.excel-filter-footer {
  display: flex;
  gap: 6px;
  align-items: center;
}

.excel-filter-actions button,
.excel-filter-footer button {
  padding: 5px 8px;
  font-size: 12px;
}

.excel-filter-options {
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px;
  background: #f8fafc;
}

.excel-filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
}

.excel-filter-option:hover {
  background: #eef2f7;
}

.excel-filter-option[hidden],
.excel-filter-option.is-filter-hidden {
  display: none;
}

.excel-filter-option input {
  width: auto;
}

.excel-filter-option span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.excel-filter-footer {
  justify-content: flex-end;
}

tr:last-child td {
  border-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  color: #344054;
  font-weight: 600;
}

.full-field {
  grid-column: 1 / -1;
}

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

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f7;
  color: #344054;
  font-size: 12px;
}

.badge.ok {
  background: #dcfce7;
  color: var(--ok);
}

.badge.warn {
  background: #fef3c7;
  color: var(--warn);
}

.badge.danger {
  background: #fee2e2;
  color: var(--danger);
}

.finance-status-cell {
  min-width: 176px;
  display: grid;
  gap: 5px;
}

.finance-status-pill {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f7;
  color: #344054;
}

.finance-status-pill.department {
  background: #dbeafe;
  color: #1d4ed8;
}

.finance-status-pill.finance,
.finance-status-pill.pay {
  background: #fef3c7;
  color: #b45309;
}

.finance-status-pill.general {
  background: #ede9fe;
  color: #6d28d9;
}

.finance-status-pill.done {
  background: #dcfce7;
  color: var(--ok);
}

.finance-status-pill.returned {
  background: #fee2e2;
  color: var(--danger);
}

.finance-step-flow {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: nowrap;
}

.finance-step-flow span {
  min-width: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 1px 5px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.finance-step-flow span.done {
  border-color: #86efac;
  background: #f0fdf4;
  color: var(--ok);
}

.finance-step-flow span.current {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
}

.finance-step-flow span.returned {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.finance-status-note {
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
}

.message {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #eff6ff;
  color: #1e40af;
}

.message.error {
  background: #fef2f2;
  color: #b91c1c;
}

.org-manager {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 14px;
  align-items: start;
}

.org-tree-panel,
.org-detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.org-tree-panel {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 100px);
  overflow: auto;
}

.org-tree-head {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.org-tree-head input {
  padding: 7px 9px;
}

.org-tree {
  display: grid;
  gap: 4px;
}

.org-node {
  width: 100%;
  min-height: 34px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.org-node:hover,
.org-node.active {
  background: #eef4ff;
  color: #1d4ed8;
}

.org-node span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-children {
  display: grid;
  gap: 3px;
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.org-children.small {
  margin-left: 24px;
}

.company-node {
  margin-top: 8px;
  font-weight: 700;
}

.department-node {
  font-weight: 600;
}

.leaf-node {
  min-height: 30px;
  color: #344054;
  font-size: 13px;
}

.org-detail-panel h2,
.org-detail-panel h3 {
  margin: 0;
}

.org-detail-panel h3 {
  margin-top: 16px;
  font-size: 14px;
}

.org-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.org-detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

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

@media (max-width: 860px) {
  .org-manager {
    grid-template-columns: 1fr;
  }

  .org-tree-panel {
    position: static;
    max-height: none;
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(980px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.modal.finance-modal {
  width: min(1240px, calc(100vw - 24px));
  background: #f8fafc;
}

.modal.wide-modal {
  width: min(1180px, calc(100vw - 24px));
}

.modal.small-modal {
  width: min(560px, 100%);
}

.print-preview-modal {
  width: min(760px, 100%);
}

.modal-head {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.finance-modal .modal-head {
  padding: 14px 18px;
}

.finance-modal-subtitle {
  margin-top: 4px;
  font-size: 12px;
}

.modal-body {
  padding: 16px;
}

.finance-modal .modal-body {
  padding: 18px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.attachment-uploader {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.attachment-uploader input {
  width: min(420px, 100%);
}

.attachment-uploader select {
  width: 140px;
}

.attachment-groups {
  display: grid;
  gap: 12px;
}

.attachment-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.attachment-group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.attachment-empty {
  padding: 8px 0;
}

.attachment-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.finance-attachment-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.attachment-row-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

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

.image-preview {
  padding: 8px;
}

.image-preview img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  margin: 0 auto;
  object-fit: contain;
}

.pdf-preview iframe {
  display: block;
  width: 100%;
  height: min(760px, 78vh);
  min-height: 560px;
  border: 0;
}

.excel-preview,
.unsupported-preview {
  padding: 10px;
}

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

.excel-preview-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.excel-preview-table {
  min-width: 0;
  border: 0;
}

.excel-preview-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  white-space: nowrap;
  font-size: 12px;
}

.completion-attachment-section {
  display: grid;
  gap: 8px;
}

.complete-attachment-preview {
  margin-top: 10px;
}

.print-preview-body {
  background: #eef2f7;
  display: grid;
  justify-items: center;
}

.a5-print-page {
  width: 210mm;
  min-height: 148mm;
  background: #fff;
  color: #111827;
  padding: 5mm;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  font-size: 9px;
  overflow: hidden;
}

.a5-print-page h1 {
  margin: 0;
  text-align: center;
  font-size: 16px;
  letter-spacing: 2px;
}

.a5-print-page h2 {
  margin: 6px 0 3px;
  font-size: 11px;
}

.print-doc-no {
  margin: 3px 0 5px;
  text-align: right;
  color: #344054;
}

.print-info-table,
.print-lines-table {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-collapse: collapse;
  margin-bottom: 4px;
  table-layout: fixed;
}

.print-info-table th,
.print-info-table td,
.print-lines-table th,
.print-lines-table td {
  border: 1px solid #111827;
  padding: 2px 3px;
  vertical-align: middle;
  word-break: break-word;
}

.print-info-table th,
.print-lines-table th {
  background: #f3f4f6;
  font-weight: 700;
}

.print-info-table th {
  width: 12%;
}

.print-lines-table.compact {
  font-size: 7px;
}

.print-lines-table.compact th,
.print-lines-table.compact td {
  padding: 1px 2px;
}

.amount-cell {
  text-align: right;
}

.print-sign-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.finance-print-template {
  border: 1.5px solid #000;
  font-family: "SimSun", "Songti SC", "Microsoft YaHei", sans-serif;
}

.print-template-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  border-bottom: 1.5px solid #000;
  padding-bottom: 4px;
  margin-bottom: 5px;
}

.print-template-head h1 {
  grid-column: 1 / -1;
}

.template-table {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0 0 5px;
  border: 1.5px solid #000;
  font-size: 9px;
}

.template-table th,
.template-table td {
  border: 1px solid #000;
  padding: 2px 3px;
  height: 20px;
  line-height: 1.2;
  vertical-align: middle;
  word-break: break-word;
  color: #000;
}

.template-table th {
  background: #fff;
  font-weight: 700;
  text-align: center;
}

.expense-top-table th,
.travel-top-table th {
  width: 8%;
}

.expense-project-col {
  width: 14%;
}

.expense-category-col {
  width: 12%;
}

.expense-digit-col {
  width: 6%;
}

.expense-remark-col {
  width: 18%;
}

.expense-lines-table td {
  height: 22px;
}

.expense-lines-table .digit-cell {
  text-align: center;
  font-family: "Times New Roman", serif;
}

.expense-summary-table td {
  height: 26px;
}

.travel-print {
  font-size: 7.5px;
}

.travel-lines-table {
  font-size: 6.5px;
}

.travel-lines-table th,
.travel-lines-table td {
  padding: 1px 1.5px;
  height: 18px;
  text-align: center;
}

.travel-lines-table th:nth-child(1),
.travel-lines-table th:nth-child(2) {
  width: 8.5%;
}

.travel-lines-table th:nth-child(3),
.travel-lines-table th:nth-child(4) {
  width: 7%;
}

.travel-lines-table th:nth-child(n+5) {
  width: 6.2%;
}

.loan-template-table,
.receipt-template-table {
  font-size: 10px;
}

.loan-template-table th,
.receipt-template-table th {
  width: 18%;
}

.loan-template-table td,
.receipt-template-table td {
  height: 28px;
}

.loan-template-table .large-cell,
.receipt-template-table .large-cell {
  height: 48px;
}

.loan-template-table .signature-row th,
.loan-template-table .signature-row td {
  height: 44px;
}

.receipt-template-table tr:nth-child(2) td:last-child {
  height: 52px;
}

.receipt-template-table {
  height: 118mm;
}

.receipt-template-table td,
.receipt-template-table th {
  height: 18mm;
}

.receipt-template-table .receipt-date-row td {
  height: 12mm;
  text-align: left;
}

.receipt-template-table .stamp-cell {
  height: 32mm;
}

.receipt-template-table .receipt-amount-digits {
  height: 13mm;
  font-size: 9px;
  letter-spacing: 1px;
}

textarea {
  resize: vertical;
}

.finance-editor-page {
  max-width: 1280px;
  margin: 0 auto;
}

.finance-editor-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.finance-editor-title h1 {
  margin: 0 0 6px;
}

.finance-editor-title p {
  margin: 0;
}

.finance-editor-body {
  display: grid;
  gap: 14px;
}

.finance-support-sections {
  display: grid;
  gap: 12px;
}

.finance-support-sections > h3 {
  margin: 4px 0 0;
}

.finance-sheet {
  display: grid;
  gap: 14px;
}

.finance-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.finance-section-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.finance-section-head p {
  margin: 0;
}

.finance-basic-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 1fr;
  gap: 12px;
}

.finance-basic-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.finance-basic-grid.four-tight {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.filter-card {
  display: grid;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.stats-filter-actions {
  align-items: end;
  padding-top: 22px;
}

.finance-stats-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.finance-stats-pager select {
  width: auto;
  min-width: 92px;
}

.inline-label {
  color: var(--muted);
  font-weight: 600;
}

.button-link.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.summary-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
}

.summary-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.finance-ledger-total-row td {
  background: #f8fafc;
  border-top: 2px solid var(--line);
  font-weight: 700;
}

.finance-reason {
  margin-top: 12px;
}

.finance-payment-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.self-payment-card {
  margin-top: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  padding: 12px;
}

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

.self-payment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.self-payment-grid div {
  display: grid;
  gap: 4px;
}

.self-payment-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.self-payment-grid strong {
  min-height: 20px;
  color: #172033;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.finance-section-head.compact {
  margin-bottom: 10px;
}

.payment-batch-head,
.payment-batch-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.payment-batch-rows {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.payment-batch-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1.1fr 100px 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.payment-batch-row label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.payment-batch-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.payment-batch-row input {
  min-width: 0;
}

.finance-lines-table-wrap {
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.finance-lines-table {
  min-width: 0;
  border: 0;
}

.finance-lines-table th {
  background: #f8fafc;
  font-size: 12px;
}

.finance-lines-table th,
.finance-lines-table td {
  padding: 8px;
  vertical-align: middle;
}

.finance-lines-table input,
.finance-lines-table select {
  min-width: 0;
  padding: 7px 8px;
}

.finance-lines-table input[type="number"] {
  min-width: 0;
}

.finance-lines-table .amount-col {
  width: 130px;
}

.line-total-input {
  background: #f8fafc;
  font-weight: 700;
}

.subsidy-amount-input {
  background: #f8fafc;
}

.finance-lines-table button {
  white-space: nowrap;
}

.travel-lines {
  display: grid;
  gap: 0;
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.travel-line-card {
  width: 100%;
  min-width: 980px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  padding: 0;
}

.travel-line-card:last-child {
  border-bottom: 0;
}

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

.travel-line-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.travel-line-grid.route {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.travel-line-grid.fees {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

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

.travel-line-grid .field label {
  font-size: 12px;
  color: var(--muted);
}

.travel-line-table-head {
  display: grid;
  grid-template-columns:
    minmax(60px, 0.8fr)
    minmax(52px, 0.8fr)
    minmax(66px, 0.9fr)
    minmax(92px, 1fr)
    minmax(92px, 1fr)
    repeat(5, minmax(66px, 0.9fr))
    minmax(54px, 0.8fr)
    minmax(62px, 0.85fr)
    minmax(70px, 0.95fr)
    minmax(78px, 1fr)
    minmax(58px, 0.75fr);
  gap: 4px;
  align-items: center;
  width: 100%;
  min-width: 980px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.travel-line-table-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.travel-line-one-row {
  display: grid;
  grid-template-columns:
    minmax(60px, 0.8fr)
    minmax(52px, 0.8fr)
    minmax(66px, 0.9fr)
    minmax(92px, 1fr)
    minmax(92px, 1fr)
    repeat(5, minmax(66px, 0.9fr))
    minmax(54px, 0.8fr)
    minmax(62px, 0.85fr)
    minmax(70px, 0.95fr)
    minmax(78px, 1fr)
    minmax(58px, 0.75fr);
  gap: 4px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
}

.travel-line-one-row input {
  min-width: 0;
  padding: 6px 4px;
}

.travel-line-one-row .travel-line-index {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

.travel-line-one-row button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12px;
}

.travel-line-one-row input[type="date"] {
  font-size: 12px;
  padding-left: 4px;
  padding-right: 0;
}

.finance-form-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.06);
}

.finance-total {
  color: var(--muted);
}

.finance-total strong {
  margin-left: 8px;
  color: #172033;
  font-size: 24px;
  letter-spacing: 0;
}

.finance-total span {
  color: #172033;
  font-weight: 700;
}

.finance-approver-form {
  display: grid;
  gap: 12px;
}

.finance-approver-field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.finance-approver-field label {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-weight: 700;
}

@media (max-width: 820px) {
  .finance-editor-head {
    grid-template-columns: 1fr;
  }

  .finance-basic-grid,
  .finance-basic-grid.three,
  .self-payment-grid,
  .travel-line-grid.route,
  .travel-line-grid.fees,
  .travel-line-grid.subsidy,
  .payment-batch-row {
    grid-template-columns: 1fr;
  }

  .finance-form-footer {
    align-items: stretch;
    flex-direction: column;
  }
}

@page {
  size: A5 landscape;
  margin: 0;
}

@media print {
  body {
    background: #fff;
  }

  body > *:not(.print-preview-backdrop),
  .no-print,
  .print-preview-backdrop > .modal-head {
    display: none !important;
  }

  .print-preview-backdrop {
    position: static;
    display: block;
    background: #fff;
  }

  .print-preview-modal {
    width: auto;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

  .print-preview-body {
    padding: 0;
    background: #fff;
  }

  .a5-print-page {
    width: 210mm;
    min-height: 148mm;
    padding: 5mm;
    box-shadow: none;
    page-break-after: always;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .finance-tabs {
    grid-template-columns: 1fr 1fr;
  }

  .finance-basic-grid,
  .finance-basic-grid.three,
  .finance-basic-grid.four-tight,
  .stats-cards,
  .stats-summary-grid {
    grid-template-columns: 1fr;
  }

  .finance-view-tabs {
    width: 100%;
  }

  .finance-view-tab {
    flex: 1;
    justify-content: center;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    overflow: visible;
  }

  .main {
    height: auto;
    overflow: visible;
  }

  .nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
  }

  .nav button {
    width: auto;
    white-space: nowrap;
  }

  .topbar {
    padding: 0 14px;
  }

  .page {
    padding: 16px 14px 32px;
  }
}
