:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #687589;
  --line: #dce4ef;
  --blue: #1463f3;
  --cyan: #11b7d7;
  --purple: #6c42e8;
  --green: #18a66a;
  --orange: #ff8a00;
  --nav: #06192b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 480px;
  background:
    radial-gradient(circle at 18% 20%, rgba(17,183,215,.26), transparent 30%),
    radial-gradient(circle at 72% 74%, rgba(255,138,0,.22), transparent 28%),
    linear-gradient(135deg, #06192b 0%, #0d3b86 54%, #1aa4d8 100%);
}

.auth-visual {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 72px;
  color: #fff;
}

.auth-visual img {
  width: 92px;
  height: 92px;
  border-radius: 24px;
  background: #fff;
  object-fit: cover;
  box-shadow: 0 18px 50px rgba(0,0,0,.2);
}

.auth-visual h1 {
  margin: 22px 0 14px;
  font-size: 48px;
  letter-spacing: 0;
}

.auth-visual p {
  max-width: 560px;
  color: rgba(255,255,255,.84);
  font-size: 17px;
  line-height: 1.8;
}

.auth-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.auth-badges span {
  padding: 9px 14px;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 13px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  background: rgba(255,255,255,.96);
  box-shadow: -18px 0 70px rgba(6,25,43,.18);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 10px;
  background: #edf3fb;
  margin-bottom: 26px;
}

.auth-tabs button {
  color: #53657c;
  background: transparent;
}

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

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form h2 {
  margin-bottom: 4px;
  font-size: 26px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--ink);
}

.auth-form label span {
  color: var(--muted);
  font-size: 13px;
}

.auth-form input {
  height: 44px;
}

.auth-form button[type="submit"] {
  height: 44px;
  margin-top: 4px;
}

.sidebar {
  background: var(--nav);
  color: #d9e8ff;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #fff;
  object-fit: cover;
}

.brand strong {
  display: block;
  color: #fff;
  font-size: 17px;
}

.brand span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #8facce;
}

nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

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

.nav-btn {
  border: 0;
  width: 100%;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: transparent;
  color: #c9dbef;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
}

.nav-btn.active,
.nav-btn:hover {
  background: #1572f7;
  color: #fff;
}

.nav-parent {
  color: #e5f0ff;
  font-weight: 700;
}

.nav-parent:hover {
  background: rgba(255,255,255,.08);
}

.nav-children {
  display: none;
  padding: 2px 0 6px 16px;
  border-left: 1px solid rgba(255,255,255,.12);
  margin-left: 21px;
}

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

.nav-child {
  height: 34px;
  border-radius: 7px;
  padding: 0 10px;
  color: #b9d0ea;
  font-size: 13px;
}

.nav-child .nav-ico {
  width: 18px;
  font-size: 13px;
  opacity: .9;
}

.nav-arrow {
  margin-left: auto;
  opacity: .65;
  transition: transform .16s ease;
}

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

.nav-ico {
  width: 22px;
  text-align: center;
  font-size: 17px;
}

.main {
  min-width: 0;
  padding: 24px 28px 40px;
}

.topbar {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 26px; }
h2 { font-size: 20px; }

.account-select {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

label {
  color: var(--muted);
  font-size: 13px;
}

select, input, textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  padding-top: 9px;
  resize: vertical;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
}

button.ghost {
  color: var(--blue);
  background: #edf4ff;
}

.file-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.file-link:hover {
  text-decoration: underline;
}

.invoice-file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  text-align: left;
}

.invoice-file-link span {
  overflow-wrap: anywhere;
}

.invoice-file-thumb {
  width: 52px;
  height: 38px;
  flex: 0 0 52px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.invoice-file-preview {
  display: grid;
  gap: 14px;
}

.invoice-file-meta {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fbff;
}

.invoice-file-meta span {
  color: var(--muted);
}

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

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

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

.metric {
  padding: 18px;
  min-height: 108px;
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  word-break: break-word;
}

.panel {
  padding: 18px;
}

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

.panel-head h2 {
  margin: 0;
}

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

.search-input {
  min-height: 38px;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: #0f2745;
  background: #fff;
}

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

.panel {
  overflow-x: auto;
}

.panel.ledger-panel {
  overflow: visible;
}

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

th {
  color: #50627a;
  background: #f8fafd;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #0a6b47;
  background: #e7f8ef;
  font-size: 12px;
}

.badge.danger {
  color: #a61b1b;
  background: #fee2e2;
}

.payroll-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
  color: #50627a;
  font-weight: 700;
}

.payroll-summary span {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.payroll-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.payroll-table-wrap table {
  min-width: 1680px;
}

.payroll-month-wrap table {
  min-width: 1180px;
}

.modal-card.payroll-detail-card {
  width: min(1320px, calc(100vw - 32px));
}

.modal-card.payroll-sheet-card {
  width: min(1500px, calc(100vw - 32px));
}

.payroll-sheet-head {
  display: grid;
  grid-template-columns: 220px auto 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.payroll-sheet-head strong {
  justify-self: end;
  color: #0f2745;
}

.payroll-sheet-wrap table {
  min-width: 1900px;
}

.payroll-sheet-wrap input {
  width: 100%;
  min-width: 82px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
}

.payroll-sheet-wrap input[name="employeeName"],
.payroll-sheet-wrap input[name="department"],
.payroll-sheet-wrap input[name="bankName"] {
  min-width: 120px;
}

.payroll-sheet-wrap input[name="bankCard"] {
  min-width: 170px;
}

.payroll-table-wrap th,
.payroll-table-wrap td {
  white-space: nowrap;
}

.wecom-attendance-wrap {
  width: 100%;
  max-height: calc(100vh - 330px);
  overflow: auto;
  border: 1px solid var(--line);
}

.wecom-attendance-table {
  min-width: 7600px;
  border-collapse: separate;
  border-spacing: 0;
}

.wecom-attendance-table th,
.wecom-attendance-table td {
  min-width: 118px;
  white-space: nowrap;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.wecom-attendance-table thead th {
  position: sticky;
  z-index: 3;
  background: #1769e8;
  color: #fff;
  text-align: center;
}

.wecom-attendance-table thead tr:first-child { height: 42px; }
.wecom-attendance-table thead tr:nth-child(2) { height: 42px; }
.wecom-attendance-table thead tr:first-child th { top: 0; }
.wecom-attendance-table thead tr:nth-child(2) th { top: 42px; }
.wecom-attendance-table thead tr:first-child th:nth-child(1),
.wecom-attendance-table tbody td:nth-child(1) { position: sticky; left: 0; min-width: 150px; z-index: 2; }
.wecom-attendance-table thead tr:first-child th:nth-child(2),
.wecom-attendance-table tbody td:nth-child(2) { position: sticky; left: 150px; min-width: 150px; z-index: 2; }
.wecom-attendance-table thead tr:first-child th:nth-child(3),
.wecom-attendance-table tbody td:nth-child(3) { position: sticky; left: 300px; min-width: 130px; z-index: 2; }
.wecom-attendance-table tbody td:nth-child(-n+3) { background: #fff; }
.wecom-attendance-table thead tr:first-child th:nth-child(-n+3) { z-index: 5; }

.employee-reference-wrap,
.employee-contract-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.employee-reference-wrap table {
  min-width: 1900px;
}

.employee-reference-wrap th:nth-child(1),
.employee-reference-wrap td:nth-child(1) {
  position: sticky;
  left: 0;
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  text-align: center;
  z-index: 3;
}

.employee-reference-wrap th:nth-child(2),
.employee-reference-wrap td:nth-child(2) {
  position: sticky;
  left: 48px;
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  z-index: 3;
}

.employee-reference-wrap th:nth-child(3),
.employee-reference-wrap td:nth-child(3) {
  position: sticky;
  left: 126px;
  width: 90px;
  min-width: 90px;
  max-width: 90px;
  z-index: 3;
}

.employee-reference-wrap th:nth-child(4),
.employee-reference-wrap td:nth-child(4) {
  position: sticky;
  left: 216px;
  width: 110px;
  min-width: 110px;
  max-width: 110px;
  z-index: 3;
}

.employee-reference-wrap th:nth-child(5),
.employee-reference-wrap td:nth-child(5) {
  position: sticky;
  left: 326px;
  width: 90px;
  min-width: 90px;
  max-width: 90px;
  z-index: 3;
  box-shadow: 2px 0 0 var(--line);
}

.employee-reference-wrap tbody td:nth-child(-n+5) {
  background: #fff;
}

.employee-reference-wrap thead th:nth-child(-n+5) {
  z-index: 5;
  background: #f5f7fb;
}

.employee-contract-wrap table {
  min-width: 1050px;
}

.employee-reference-wrap th,
.employee-reference-wrap td,
.employee-contract-wrap th,
.employee-contract-wrap td {
  white-space: nowrap;
  vertical-align: middle;
}

.employee-reference-wrap th,
.employee-contract-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.employee-reference-wrap td:nth-child(8) {
  min-width: 280px;
  white-space: normal;
}

.warn-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #9a4b00;
  background: #fff3df;
  font-size: 12px;
}

.small-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.voucher-summary-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.voucher-summary-table {
  min-width: 1280px;
  border-collapse: separate;
  border-spacing: 0;
}

.voucher-summary-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid #d9e2f2;
}

.voucher-summary-table td {
  vertical-align: top;
}

.voucher-group-row td {
  background: #eef7ff;
  border-top: 1px solid #d2e6ff;
  font-weight: 600;
}

.voucher-entry-row td {
  background: #fff;
  color: #20324d;
}

.voucher-entry-row td:first-child,
.voucher-entry-row td:nth-child(2) {
  color: #6a7890;
}

.voucher-total-row td {
  background: #f8fbff;
  border-bottom: 2px solid #d9e2f2;
  color: #0f2745;
  font-weight: 700;
}

.voucher-no-line {
  display: flex;
  gap: 10px;
  align-items: center;
  white-space: nowrap;
}

.voucher-row-actions {
  min-width: 320px;
}

.voucher-row-actions .small-btn {
  margin: 0 4px 4px 0;
}

.amount-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.muted {
  color: #6a7890;
  font-size: 12px;
  font-weight: 400;
}

.voucher-summary-foot {
  padding: 12px 14px;
  color: #50627a;
  font-size: 13px;
  background: #fbfdff;
}

.contract-sheet {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.contract-sheet table {
  min-width: 1320px;
}

.contract-sheet th {
  background: #f3f7ff;
  color: #19345d;
  white-space: nowrap;
}

.contract-sheet td {
  vertical-align: top;
}

.contract-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 18px;
}

.asset-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.asset-table-wrap table {
  min-width: 980px;
  border-collapse: collapse;
  border: 1px solid #7ea3ef;
}

.asset-table-wrap th {
  background: #4f78d7;
  color: #fff;
  border-bottom: 1px solid #335fb8;
  border-right: 1px solid rgba(255,255,255,0.25);
  font-weight: 700;
  white-space: nowrap;
}

.asset-table-wrap td {
  border-right: 1px solid #d7e3ff;
  border-bottom: 1px solid #9ab8f4;
  white-space: nowrap;
}

.asset-table-wrap tbody tr:nth-child(odd) td {
  background: #e7eefc;
}

.asset-table-wrap tbody tr:nth-child(even) td {
  background: #fff;
}

.asset-ledger-table table {
  min-width: 1320px;
}

.danger-btn {
  color: #b42318;
  background: #fff1f0;
}

.danger-btn:hover {
  background: #fee4e2;
}

.formal-report {
  overflow-x: auto;
  padding: 6px 0 2px;
}

.formal-report table {
  min-width: 1080px;
  border: 1px solid #7b8794;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

.formal-report th,
.formal-report td {
  border: 1px solid #7b8794;
  padding: 8px 10px;
  color: #10233f;
}

.formal-report th {
  text-align: center;
  background: #f5f7fb;
  font-weight: 800;
}

.formal-report td:nth-child(2),
.formal-report td:nth-child(6),
.formal-report th:nth-child(2),
.formal-report th:nth-child(6) {
  width: 58px;
  text-align: center;
}

.formal-report td:nth-child(3),
.formal-report td:nth-child(4),
.formal-report td:nth-child(7),
.formal-report td:nth-child(8) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.formal-report.narrow-report table {
  min-width: 760px;
  max-width: 980px;
}

.formal-report.narrow-report td:nth-child(2),
.formal-report.narrow-report th:nth-child(2) {
  width: 70px;
  text-align: center;
}

.formal-report.narrow-report td:nth-child(3),
.formal-report.narrow-report td:nth-child(4) {
  text-align: right;
}

.formal-report.subject-balance-report table {
  width: max-content;
  min-width: max(100%, 1360px);
  table-layout: auto;
}

.formal-report.subject-balance-report {
  max-height: calc(100vh - 180px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.formal-report.subject-balance-report thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #f5f7fb;
  box-shadow: 0 1px 0 #7b8794;
}

.formal-report.subject-balance-report th,
.formal-report.subject-balance-report td {
  white-space: nowrap;
}

.formal-report.subject-balance-report th:nth-child(1),
.formal-report.subject-balance-report td:nth-child(1) {
  min-width: 92px;
  text-align: left;
}

.formal-report.subject-balance-report th:nth-child(2),
.formal-report.subject-balance-report td:nth-child(2) {
  width: 320px !important;
  min-width: 320px !important;
  max-width: none;
  text-align: left;
}

.formal-report.subject-balance-report th:nth-child(3),
.formal-report.subject-balance-report td:nth-child(3),
.formal-report.subject-balance-report th:nth-child(7),
.formal-report.subject-balance-report td:nth-child(7) {
  min-width: 92px;
  text-align: center;
}

.formal-report.subject-balance-report th:nth-child(4),
.formal-report.subject-balance-report td:nth-child(4),
.formal-report.subject-balance-report th:nth-child(5),
.formal-report.subject-balance-report td:nth-child(5),
.formal-report.subject-balance-report th:nth-child(6),
.formal-report.subject-balance-report td:nth-child(6),
.formal-report.subject-balance-report th:nth-child(8),
.formal-report.subject-balance-report td:nth-child(8),
.formal-report.subject-balance-report th:nth-child(9),
.formal-report.subject-balance-report td:nth-child(9),
.formal-report.subject-balance-report th:nth-child(10),
.formal-report.subject-balance-report td:nth-child(10) {
  min-width: 128px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.formal-report.subject-balance-report .subject-code-col {
  width: 110px;
}

.formal-report.subject-balance-report .subject-name-col {
  width: 320px;
}

.formal-report.subject-balance-report .subject-kind-col {
  width: 120px;
}

.formal-report.subject-balance-report .subject-money-col {
  width: 140px;
}

.formal-report.general-ledger-report table,
.formal-report.detail-ledger-report table {
  width: max-content;
  min-width: max(100%, 1280px);
  table-layout: auto;
}

.formal-report.general-ledger-report th,
.formal-report.general-ledger-report td,
.formal-report.detail-ledger-report th,
.formal-report.detail-ledger-report td {
  white-space: nowrap;
}

.formal-report.general-ledger-report th:nth-child(1),
.formal-report.general-ledger-report td:nth-child(1),
.formal-report.detail-ledger-report th:nth-child(2),
.formal-report.detail-ledger-report td:nth-child(2) {
  width: 96px !important;
  min-width: 96px !important;
  text-align: center;
}

.formal-report.detail-ledger-report th:nth-child(1),
.formal-report.detail-ledger-report td:nth-child(1),
.formal-report.general-ledger-report th:nth-child(3),
.formal-report.general-ledger-report td:nth-child(3) {
  width: 104px !important;
  min-width: 104px !important;
  text-align: center;
}

.formal-report.general-ledger-report th:nth-child(2),
.formal-report.general-ledger-report td:nth-child(2),
.formal-report.detail-ledger-report th:nth-child(4),
.formal-report.detail-ledger-report td:nth-child(4) {
  width: 300px !important;
  min-width: 300px !important;
  max-width: none;
  text-align: left;
}

.formal-report.general-ledger-report th:nth-child(4),
.formal-report.general-ledger-report td:nth-child(4),
.formal-report.detail-ledger-report th:nth-child(3),
.formal-report.detail-ledger-report td:nth-child(3) {
  width: 260px !important;
  min-width: 260px !important;
  max-width: none;
  text-align: left;
}

.formal-report.general-ledger-report th:nth-child(5),
.formal-report.general-ledger-report td:nth-child(5),
.formal-report.general-ledger-report th:nth-child(6),
.formal-report.general-ledger-report td:nth-child(6),
.formal-report.general-ledger-report th:nth-child(7),
.formal-report.general-ledger-report td:nth-child(7),
.formal-report.general-ledger-report th:nth-child(8),
.formal-report.general-ledger-report td:nth-child(8),
.formal-report.general-ledger-report th:nth-child(9),
.formal-report.general-ledger-report td:nth-child(9),
.formal-report.general-ledger-report th:nth-child(11),
.formal-report.general-ledger-report td:nth-child(11),
.formal-report.detail-ledger-report th:nth-child(5),
.formal-report.detail-ledger-report td:nth-child(5),
.formal-report.detail-ledger-report th:nth-child(6),
.formal-report.detail-ledger-report td:nth-child(6),
.formal-report.detail-ledger-report th:nth-child(8),
.formal-report.detail-ledger-report td:nth-child(8) {
  width: 138px !important;
  min-width: 138px !important;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.formal-report.general-ledger-report th:nth-child(10),
.formal-report.general-ledger-report td:nth-child(10),
.formal-report.detail-ledger-report th:nth-child(7),
.formal-report.detail-ledger-report td:nth-child(7),
.formal-report.detail-ledger-report th:nth-child(9),
.formal-report.detail-ledger-report td:nth-child(9) {
  width: 80px !important;
  min-width: 80px !important;
  text-align: center;
}

.formal-report.general-ledger-report .ledger-code-col {
  width: 96px;
}

.formal-report.general-ledger-report .ledger-name-col,
.formal-report.detail-ledger-report .ledger-subject-col {
  width: 300px;
}

.formal-report.general-ledger-report .ledger-kind-col {
  width: 140px;
}

.formal-report.general-ledger-report .ledger-period-col,
.formal-report.detail-ledger-report .ledger-date-col {
  width: 104px;
}

.formal-report.general-ledger-report .ledger-summary-col,
.formal-report.detail-ledger-report .ledger-summary-col {
  width: 260px;
}

.formal-report.detail-ledger-report .ledger-aux-col {
  width: 170px;
}

.formal-report.detail-ledger-report .ledger-cashflow-col {
  width: 220px;
}

.formal-report.general-ledger-report .ledger-money-col,
.formal-report.detail-ledger-report .ledger-money-col {
  width: 138px;
}

.formal-report.general-ledger-report .ledger-side-col,
.formal-report.detail-ledger-report .ledger-side-col,
.formal-report.detail-ledger-report .ledger-status-col {
  width: 80px;
}

.formal-report.detail-ledger-report table {
  min-width: max(100%, 1180px);
}

.formal-report.detail-ledger-report .ledger-code-col {
  width: 92px;
}

.formal-report.detail-ledger-report .ledger-name-col {
  width: 260px;
}

.formal-report.detail-ledger-report .ledger-period-col,
.formal-report.detail-ledger-report .ledger-voucher-col {
  width: 96px;
}

.formal-report.detail-ledger-report .ledger-summary-col {
  width: 280px;
}

.formal-report.detail-ledger-report .ledger-money-col {
  width: 130px;
}

.formal-report.detail-ledger-report .ledger-side-col {
  width: 76px;
}

.formal-report.detail-ledger-report th:nth-child(1),
.formal-report.detail-ledger-report td:nth-child(1),
.formal-report.detail-ledger-report th:nth-child(3),
.formal-report.detail-ledger-report td:nth-child(3),
.formal-report.detail-ledger-report th:nth-child(4),
.formal-report.detail-ledger-report td:nth-child(4),
.formal-report.detail-ledger-report th:nth-child(8),
.formal-report.detail-ledger-report td:nth-child(8) {
  text-align: center;
}

/* Final detail-ledger layout guard: keep the subject guide in flow and keep the table stable. */
.detail-ledger-layout {
  display: flex !important;
  align-items: flex-start !important;
  gap: 14px !important;
}

.detail-ledger-nav {
  position: sticky !important;
  top: 12px !important;
  flex: 0 0 210px !important;
  width: 210px !important;
  max-height: calc(100vh - 24px) !important;
}

.detail-ledger-content {
  flex: 1 1 auto !important;
  min-width: 0 !important;
}

.formal-report.detail-ledger-report {
  width: 100%;
  overflow-x: auto;
}

.formal-report.detail-ledger-report table {
  width: 100% !important;
  min-width: 1120px !important;
  table-layout: fixed !important;
}

.formal-report.detail-ledger-report .ledger-code-col {
  width: 82px !important;
}

.formal-report.detail-ledger-report .ledger-name-col {
  width: 190px !important;
}

.formal-report.detail-ledger-report .ledger-period-col {
  width: 82px !important;
}

.formal-report.detail-ledger-report .ledger-voucher-col {
  width: 86px !important;
}

.formal-report.detail-ledger-report .ledger-summary-col {
  width: 320px !important;
}

.formal-report.detail-ledger-report .ledger-money-col {
  width: 118px !important;
}

.formal-report.detail-ledger-report .ledger-side-col {
  width: 64px !important;
}

.formal-report.detail-ledger-report th,
.formal-report.detail-ledger-report td {
  padding: 8px 10px !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

.formal-report.detail-ledger-report th:nth-child(6),
.formal-report.detail-ledger-report td:nth-child(6),
.formal-report.detail-ledger-report th:nth-child(7),
.formal-report.detail-ledger-report td:nth-child(7),
.formal-report.detail-ledger-report th:nth-child(9),
.formal-report.detail-ledger-report td:nth-child(9) {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.formal-report.detail-ledger-report th:nth-child(2),
.formal-report.detail-ledger-report td:nth-child(2),
.formal-report.detail-ledger-report th:nth-child(5),
.formal-report.detail-ledger-report td:nth-child(5) {
  text-align: left;
  white-space: normal;
}

.formal-report.detail-ledger-report th:nth-child(6),
.formal-report.detail-ledger-report td:nth-child(6),
.formal-report.detail-ledger-report th:nth-child(7),
.formal-report.detail-ledger-report td:nth-child(7),
.formal-report.detail-ledger-report th:nth-child(9),
.formal-report.detail-ledger-report td:nth-child(9) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.formal-report.detail-ledger-report table,
.formal-report.customer-summary-ledger-report table {
  min-width: max(100%, 1320px);
  table-layout: fixed;
}

.formal-report.detail-ledger-report .ledger-code-col {
  width: 86px;
}

.formal-report.detail-ledger-report .ledger-name-col {
  width: 220px;
}

.formal-report.detail-ledger-report .ledger-period-col,
.formal-report.detail-ledger-report .ledger-voucher-col,
.formal-report.customer-summary-ledger-report .ledger-date-col,
.formal-report.customer-summary-ledger-report .ledger-voucher-col {
  width: 118px;
}

.formal-report.detail-ledger-report .ledger-summary-col,
.formal-report.customer-summary-ledger-report .ledger-summary-col {
  width: 360px;
}

.formal-report.detail-ledger-report .ledger-money-col,
.formal-report.customer-summary-ledger-report .ledger-money-col {
  width: 150px;
}

.formal-report.detail-ledger-report .ledger-side-col,
.formal-report.customer-summary-ledger-report .ledger-side-col {
  width: 76px;
}

.formal-report.customer-summary-ledger-report .ledger-customer-col {
  width: 180px;
}

.formal-report.customer-summary-ledger-report .ledger-subject-col {
  width: 260px;
}

.formal-report.detail-ledger-report td:nth-child(5),
.formal-report.customer-summary-ledger-report td:nth-child(5) {
  white-space: normal;
  line-height: 1.5;
}

.formal-report.detail-ledger-report td b,
.formal-report.customer-summary-ledger-report td b {
  font-weight: 800;
  color: #06214a;
}

.summary-ledger-title {
  margin-top: 28px;
}

.ledger-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid #d7e3f4;
  border-radius: 10px;
  background: #f8fbff;
}

.ledger-filter-bar label {
  color: #536680;
  font-size: 13px;
  font-weight: 700;
}

.ledger-filter-bar select {
  width: min(520px, 100%);
  height: 38px;
  border: 1px solid #cfdced;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: #0f2745;
  font-weight: 700;
}

.ledger-subject-picker {
  position: relative;
  width: min(560px, 100%);
}

.ledger-subject-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #cfdced;
  border-radius: 8px;
  background: #fff;
  color: #0f2745;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
}

.ledger-subject-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 35;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border: 1px solid #cfdced;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 39, 69, .16);
}

.ledger-subject-menu button {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #163453;
  text-align: left;
  cursor: pointer;
}

.ledger-subject-option,
.ledger-subject-parent {
  padding: 0 10px;
  font-weight: 800;
}

.ledger-subject-parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ledger-subject-child {
  padding: 0 12px 0 26px;
  font-size: 13px;
}

.ledger-subject-children {
  display: none;
  margin: 2px 0 6px 10px;
  border-left: 1px solid #d7e3f4;
}

.ledger-subject-group.open .ledger-subject-children {
  display: block;
}

.ledger-subject-menu button:hover,
.ledger-subject-menu button.active {
  background: #eaf2ff;
  color: #0b63f6;
}

.detail-ledger-layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
}

.detail-ledger-content {
  flex: 1 1 auto;
  min-width: 0;
}

.detail-ledger-nav {
  position: sticky;
  z-index: 20;
  top: 12px;
  flex: 0 0 210px;
  width: 210px;
  max-height: calc(100vh - 24px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 10px;
  border: 1px solid #d4e0ef;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 39, 69, 0.08);
}

.detail-ledger-nav-list {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.detail-ledger-quick {
  position: fixed;
  z-index: 60;
  left: 248px;
  bottom: 24px;
  display: grid;
  gap: 8px;
  width: 112px;
}

.detail-ledger-quick button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #cfe0f6;
  border-radius: 9px;
  background: #ffffff;
  color: #1463f3;
  box-shadow: 0 10px 24px rgba(15, 39, 69, 0.12);
}

.detail-ledger-quick button:first-child {
  background: #1769f5;
  color: #ffffff;
  border-color: #1769f5;
}

.detail-ledger-nav-all {
  flex: 0 0 auto;
  margin-bottom: 8px;
}

.detail-ledger-nav button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: #24415f;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.detail-ledger-nav button:hover {
  background: #eef5ff;
  color: #0b63f6;
}

.detail-ledger-nav button.active {
  background: #1769f5;
  color: #fff;
}

.detail-ledger-nav details {
  margin-top: 4px;
}

.detail-ledger-nav summary {
  list-style: none;
}

.detail-ledger-nav summary::-webkit-details-marker {
  display: none;
}

.detail-ledger-nav details > div {
  margin: 4px 0 6px 10px;
  padding-left: 8px;
  border-left: 1px solid #d8e4f2;
}

.detail-ledger-nav details > div button {
  font-weight: 600;
  color: #526b87;
}

.detail-ledger-nav .back-top {
  flex: 0 0 auto;
  margin-top: 10px;
  background: #edf4ff;
  color: #0b63f6;
  text-align: center;
}

.formal-report.detail-ledger-report table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}

.formal-report.detail-ledger-report th,
.formal-report.detail-ledger-report td {
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.formal-report.detail-ledger-report .ledger-code-col {
  width: 7% !important;
}

.formal-report.detail-ledger-report .ledger-name-col {
  width: 15% !important;
}

.formal-report.detail-ledger-report .ledger-period-col {
  width: 6% !important;
}

.formal-report.detail-ledger-report .ledger-voucher-col {
  width: 6% !important;
}

.formal-report.detail-ledger-report .ledger-summary-col {
  width: 31.5% !important;
}

.formal-report.detail-ledger-report .ledger-money-col {
  width: 9.5% !important;
}

.formal-report.detail-ledger-report .ledger-side-col {
  width: 4.5% !important;
}

.formal-report.detail-ledger-report th:nth-child(1),
.formal-report.detail-ledger-report td:nth-child(1),
.formal-report.detail-ledger-report th:nth-child(3),
.formal-report.detail-ledger-report td:nth-child(3),
.formal-report.detail-ledger-report th:nth-child(4),
.formal-report.detail-ledger-report td:nth-child(4),
.formal-report.detail-ledger-report th:nth-child(8),
.formal-report.detail-ledger-report td:nth-child(8) {
  text-align: center !important;
  white-space: nowrap !important;
}

.formal-report.detail-ledger-report th:nth-child(2),
.formal-report.detail-ledger-report td:nth-child(2),
.formal-report.detail-ledger-report th:nth-child(5),
.formal-report.detail-ledger-report td:nth-child(5) {
  text-align: left !important;
  white-space: nowrap !important;
}

.formal-report.detail-ledger-report th:nth-child(6),
.formal-report.detail-ledger-report td:nth-child(6),
.formal-report.detail-ledger-report th:nth-child(7),
.formal-report.detail-ledger-report td:nth-child(7),
.formal-report.detail-ledger-report th:nth-child(9),
.formal-report.detail-ledger-report td:nth-child(9) {
  text-align: right !important;
  white-space: nowrap !important;
  font-variant-numeric: tabular-nums;
}

.report-adjust-input {
  width: 120px;
  max-width: 100%;
  height: 30px;
  border: 1px solid #c8d5e6;
  border-radius: 6px;
  padding: 0 8px;
  text-align: right;
  font: inherit;
  color: #0f2745;
  background: #fbfdff;
}

.report-adjust-input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: #2563eb;
  background: #fff;
}

.subject-opening-wrap {
  width: 100%;
  max-height: calc(100vh - 250px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.subject-opening-wrap table {
  min-width: 820px;
  margin: 0;
}

.subject-annual-section {
  margin-top: 22px;
}

.subject-annual-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 10px;
}

.subject-annual-title h3 { margin: 0; }
.subject-annual-title span { color: #64748b; font-size: 13px; }
.subject-annual-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.subject-annual-wrap table { min-width: 980px; margin: 0; }

/* General ledger must fit the viewport, including ending balance. */
.formal-report.general-ledger-report { overflow-x: hidden !important; }
.formal-report.general-ledger-report table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}
.formal-report.general-ledger-report th,
.formal-report.general-ledger-report td {
  min-width: 0 !important;
  padding: 8px 6px !important;
  overflow: hidden;
  text-overflow: ellipsis;
}
.formal-report.general-ledger-report th:nth-child(1) { width: 7% !important; }
.formal-report.general-ledger-report th:nth-child(2) { width: 12% !important; }
.formal-report.general-ledger-report th:nth-child(3) { width: 15% !important; }
.formal-report.general-ledger-report th:nth-child(4) { width: 12% !important; }
.formal-report.general-ledger-report th:nth-child(5),
.formal-report.general-ledger-report th:nth-child(9) { width: 7% !important; }
.formal-report.general-ledger-report th:nth-child(6),
.formal-report.general-ledger-report th:nth-child(7),
.formal-report.general-ledger-report th:nth-child(8),
.formal-report.general-ledger-report th:nth-child(10) { width: 10% !important; }

.subject-opening-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eaf2ff;
  color: #12325e;
  box-shadow: 0 1px 0 #cddbf0;
}

.subject-opening-wrap td {
  vertical-align: middle;
}

.subject-cell,
.subject-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border-radius: 8px;
  padding: 4px 8px;
}

.subject-level-parent {
  font-weight: 800;
}

.subject-level-child {
  margin-left: 24px;
  font-weight: 600;
}

.subject-level-child .subject-code-text,
.subject-child-code {
  color: #475569;
}

.subject-name-cell em {
  margin-left: auto;
  color: #64748b;
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
}

.subject-spacer {
  display: inline-block;
  width: 30px;
}

.subject-expand {
  width: 28px;
  min-height: 28px;
  border-radius: 8px;
  background: #e9f1ff;
  color: #155bd5;
  font-weight: 900;
}

.subject-category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

.subject-cat-资产 {
  background: #edf7ff;
  color: #075985;
}

.subject-cat-负债 {
  background: #fff1f2;
  color: #9f1239;
}

.subject-cat-权益 {
  background: #f0fdf4;
  color: #166534;
}

.subject-cat-成本 {
  background: #fff7ed;
  color: #9a3412;
}

.subject-cat-损益 {
  background: #f5f3ff;
  color: #5b21b6;
}

.subject-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.subject-table-top {
  scroll-margin-top: 20px;
}

.subject-float-top {
  position: fixed;
  right: 28px;
  bottom: 88px;
  z-index: 90;
  min-height: 40px;
  padding: 0 16px;
  box-shadow: 0 12px 30px rgba(21, 114, 247, .22);
}

.opening-inline-input {
  width: 130px;
  height: 32px;
  border: 1px solid #c8d5e6;
  border-radius: 6px;
  padding: 0 8px;
  text-align: right;
  color: #0f2745;
  background: #fbfdff;
  font: inherit;
}

.opening-inline-input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.16);
  border-color: #2563eb;
  background: #fff;
}

.opening-summary-input {
  border-color: #d7e3f4;
  background: #eef5ff;
  color: #155bd5;
  font-weight: 800;
  cursor: not-allowed;
}

.voucher-meta {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.voucher-editor {
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.voucher-editor table {
  min-width: 0;
  table-layout: fixed;
}

.voucher-editor td,
.voucher-editor th {
  white-space: normal;
}

.voucher-editor input,
.voucher-editor select {
  width: 100%;
  min-width: 0;
  height: 36px;
}

.voucher-editor tfoot td {
  background: #f8fbff;
  font-weight: 700;
}

.voucher-modal-card {
  width: min(1080px, calc(100vw - 48px));
}

.voucher-meta-wide {
  grid-template-columns: minmax(240px, 1fr) auto auto;
}

.voucher-editor-wide {
  width: 100%;
}

.voucher-editor-wide .voucher-col-summary { width: 24%; }
.voucher-editor-wide .voucher-col-subject { width: 34%; }
.voucher-editor-wide .voucher-col-direction { width: 13%; }
.voucher-editor-wide .voucher-col-amount { width: 15%; }
.voucher-editor-wide .voucher-col-action { width: 14%; }

.voucher-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.voucher-actions .small-btn {
  flex: 1 1 auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.detail-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
}

.detail-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.hero {
  padding: 24px;
  border-radius: 14px;
  background: linear-gradient(120deg, #f8fbff 0%, #eaf8ff 45%, #fff8ed 100%);
  border: 1px solid var(--line);
}

.hero h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.hero p {
  color: var(--muted);
  margin-bottom: 0;
}

.feature-grid {
  margin-top: 16px;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.feature {
  padding: 18px;
}

.feature b {
  display: block;
  margin-bottom: 8px;
}

.feature p {
  color: var(--muted);
  margin-bottom: 14px;
}

.assistant-shell {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
}

.assistant-rail,
.assistant-chat {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(20, 32, 51, .06);
}

.assistant-rail {
  padding: 18px;
}

.assistant-rail > p {
  color: var(--muted);
  line-height: 1.7;
}

.assistant-cats,
.assistant-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.assistant-cat,
.conversation-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  background: #f8fbff;
  color: var(--ink);
}

.assistant-cat b,
.conversation-item b {
  display: block;
  margin-bottom: 4px;
}

.assistant-cat span,
.conversation-item span {
  color: var(--muted);
  font-size: 12px;
}

.assistant-cat.active,
.conversation-item.active {
  border-color: rgba(20,99,243,.35);
  background: linear-gradient(135deg, rgba(20,99,243,.10), rgba(17,183,215,.08));
  color: var(--blue);
}

.assistant-chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.chat-messages {
  overflow: auto;
  padding: 20px;
  background: linear-gradient(180deg, #fbfdff, #f4f7fb);
}

.chat-msg {
  max-width: 760px;
  margin-bottom: 14px;
}

.chat-msg span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.chat-msg p {
  display: inline-block;
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  line-height: 1.7;
}

.chat-msg.user {
  margin-left: auto;
  text-align: right;
}

.chat-msg.user p {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.chat-msg.pending p {
  color: var(--muted);
}

.chat-empty,
.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.chat-form textarea {
  min-height: 52px;
  max-height: 140px;
  resize: vertical;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 21, 36, .42);
  z-index: 60;
}

.hidden { display: none !important; }

.page-loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(238, 243, 250, .42);
  backdrop-filter: blur(1px);
  z-index: 55;
  pointer-events: none;
}

.page-loading-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 148px;
  padding: 14px 18px;
  border: 1px solid #d7e3f4;
  border-radius: 14px;
  background: rgba(255, 255, 255, .96);
  color: #0b1f3d;
  box-shadow: 0 18px 50px rgba(13, 36, 76, .14);
}

.route-loading-panel {
  min-height: 180px;
  display: grid;
  place-items: center;
}

.inline-loading {
  box-shadow: none;
}

.page-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #d8e6ff;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: page-spin .78s linear infinite;
}

@keyframes page-spin {
  to { transform: rotate(360deg); }
}

.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 20px 70px rgba(8, 22, 40, .25);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: #eff3f9;
  color: var(--ink);
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, 1fr);
}

.form-field {
  display: grid;
  gap: 6px;
}

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

.sync-progress {
  display: none;
  grid-column: 1 / -1;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid #d7e5fb;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbff, #eef6ff);
}

.sync-progress.active {
  display: block;
}

.sync-progress-company {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  text-align: center;
}

.sync-progress-company span {
  color: var(--muted);
  font-size: 13px;
}

.sync-progress-company strong {
  color: #08214a;
  font-size: 18px;
  line-height: 1.35;
}

.sync-progress-head {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  text-align: center;
  color: #0b2b5e;
}

.sync-progress-head span {
  color: var(--blue);
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.sync-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe8fb;
}

.sync-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width .45s ease;
}

.sync-progress-text {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #10243e;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  z-index: 80;
}

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { padding: 40px 24px; }
  .auth-visual h1 { font-size: 38px; }
  .auth-card { padding: 34px 24px; }
  #app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; max-height: 52vh; }
  nav { grid-template-columns: repeat(2, 1fr); }
  .topbar { align-items: stretch; flex-direction: column; }
  .cards, .feature-grid { grid-template-columns: 1fr; }
  .assistant-shell { grid-template-columns: 1fr; }
  .assistant-chat { min-height: 620px; }
  .chat-form { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-ledger-nav {
    position: static;
    width: auto;
    max-height: 360px;
  }
}

.modal-card.voucher-modal-card {
  width: min(1120px, calc(100vw - 40px));
  padding: 26px;
}

.modal-card.voucher-modal-card .voucher-meta {
  grid-template-columns: minmax(260px, 1fr) auto auto;
}

.modal-card.voucher-modal-card .voucher-editor {
  overflow: visible;
}

.modal-card.voucher-modal-card .voucher-editor table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.modal-card.voucher-modal-card .voucher-editor th,
.modal-card.voucher-modal-card .voucher-editor td {
  padding: 10px;
  white-space: normal;
}

.modal-card.voucher-modal-card .voucher-editor input,
.modal-card.voucher-modal-card .voucher-editor select {
  min-width: 0;
  width: 100%;
}

.modal-card.voucher-modal-card .voucher-col-summary { width: 24%; }
.modal-card.voucher-modal-card .voucher-col-subject { width: 34%; }
.modal-card.voucher-modal-card .voucher-col-direction { width: 12%; }
.modal-card.voucher-modal-card .voucher-col-amount { width: 14%; }
.modal-card.voucher-modal-card .voucher-col-action { width: 16%; }

.modal-card.voucher-modal-card .voucher-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-card.voucher-modal-card .voucher-actions .small-btn {
  flex: 1 1 88px;
}

@media (max-width: 760px) {
  .modal-card.voucher-modal-card {
    width: calc(100vw - 20px);
    padding: 18px;
  }
  .modal-card.voucher-modal-card .voucher-meta {
    grid-template-columns: 1fr;
  }
  .modal-card.voucher-modal-card .voucher-editor {
    overflow-x: auto;
  }
}

.modal-card.voucher-paper-card {
  width: min(1280px, calc(100vw - 32px));
  padding: 18px 22px 14px;
  border-radius: 4px;
  background: #fff;
}

.voucher-paper-card #modalTitle {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 500;
}

.voucher-paper-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 4px 0 8px;
}

.voucher-title-block h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.voucher-title-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.voucher-head-actions {
  display: flex;
  gap: 10px;
}

.voucher-paper-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 10px;
}

.voucher-paper-meta label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.voucher-paper-meta input {
  width: 108px;
  height: 30px;
  min-height: 30px;
  border: 0;
  border-bottom: 1px solid #b9d8df;
  border-radius: 0;
  background: transparent;
}

.voucher-paper-wrap {
  border: 1px solid #aac9d0;
  overflow: visible;
}

.voucher-paper-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: #fff;
}

.voucher-paper-table th {
  height: 38px;
  padding: 6px;
  border-right: 1px solid #20aebe;
  background: #39bfcc;
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.voucher-paper-table th:last-child,
.voucher-paper-table td:last-child {
  border-right: 0;
}

.voucher-paper-table td {
  height: 48px;
  padding: 0;
  border-top: 1px solid #c4cdd5;
  border-right: 1px solid #c4cdd5;
  vertical-align: middle;
}

.voucher-paper-table tbody tr:nth-child(even) td {
  background: #f7f9fc;
}

.voucher-paper-table tfoot td {
  height: 44px;
  padding: 0 10px;
  background: #effcff;
  font-weight: 700;
}

.paper-col-no { width: 4%; }
.paper-col-summary { width: 14%; }
.paper-col-subject { width: 21%; }
.paper-col-auxiliary { width: 18%; }
.paper-col-cashflow { width: 14%; }
.paper-col-money { width: 10%; }
.paper-col-actions { width: 9%; }

.paper-seq {
  color: #697386;
  text-align: center;
}

.voucher-paper-table textarea,
.voucher-paper-table select,
.voucher-paper-table input {
  width: 100%;
  height: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.voucher-paper-table textarea {
  padding: 10px 10px;
  resize: none;
}

.voucher-paper-table select,
.voucher-paper-table input {
  padding: 0 8px;
}

.paper-auxiliary-picker {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 5px 24px 5px 8px;
}

.paper-auxiliary-picker::after {
  content: "⌄";
  position: absolute;
  right: 8px;
  top: 50%;
  color: #40556f;
  transform: translateY(-55%);
  pointer-events: none;
}

.paper-auxiliary-display {
  width: 100%;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.paper-auxiliary-picker select {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.subject-nature {
  padding: 0 10px 8px;
  color: #6f7d95;
  font-size: 12px;
  line-height: 1.35;
}

.voucher-paper-table input[name="debitAmount"],
.voucher-paper-table input[name="creditAmount"] {
  text-align: right;
  font-weight: 700;
  letter-spacing: .08em;
}

.paper-credit-cell {
  display: grid;
  grid-template-columns: 1fr;
  height: 100%;
  position: relative;
}

.credit-suggest {
  position: absolute;
  right: 8px;
  top: calc(100% - 5px);
  z-index: 20;
  display: grid;
  gap: 6px;
  min-width: 168px;
  padding: 9px;
  border: 1px solid #b9d8df;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(8, 22, 40, .16);
}

.credit-suggest span {
  color: var(--muted);
  font-size: 12px;
}

.credit-suggest button {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: #eaf8fb;
  color: #0d7f8c;
  font-size: 12px;
  font-weight: 700;
}

.print-preview-card {
  width: min(1180px, calc(100vw - 32px));
}

.print-preview-shell,
.print-preview-frame {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: 70vh;
  overflow: auto;
}

.print-preview-frame {
  width: 100%;
  height: 70vh;
}

.print-preview-shell html,
.print-preview-shell body {
  display: block;
}

.print-preview-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #476079;
  font-size: 14px;
}

.inline-field input {
  width: 92px;
  height: 36px;
  border: 1px solid #d5e0ef;
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
}

.inline-field input[type="month"] {
  width: 128px;
  min-width: 128px;
  padding-right: 8px;
}

.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.report-tabs button {
  min-height: 34px;
  padding: 0 14px;
  background: #eef5ff;
  color: #1a5bd7;
}

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

#reportDetail {
  margin-top: 16px;
}

.report-title {
  margin: 8px 0 14px;
  text-align: center;
}

.report-title h3 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: 4px;
}

.report-title div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.cash-flow-report-shell {
  width: min(100%, 980px);
  margin: 0 auto;
}

.cash-flow-report-shell .report-title,
.cash-flow-report-shell .formal-report,
.cash-flow-report-shell .formal-report table {
  width: 100%;
}

.cash-flow-report-shell .report-title div {
  padding: 0 10px;
  box-sizing: border-box;
}

.cash-flow-report table {
  min-width: 760px;
  max-width: none;
  table-layout: fixed;
}

.cash-flow-report th:first-child,
.cash-flow-report td:first-child {
  width: auto;
}

.cash-flow-report th:nth-child(3),
.cash-flow-report td:nth-child(3) {
  width: 180px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media print {
  body > * {
    display: none !important;
  }
  #modal,
  #modal * {
    display: revert !important;
    visibility: visible !important;
  }
  #modal {
    position: static !important;
    inset: auto !important;
    padding: 0 !important;
    background: #fff !important;
  }
  .modal-card.print-preview-card {
    width: 100% !important;
    max-height: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
  .modal-close,
  #modalTitle,
  .print-preview-actions {
    display: none !important;
  }
  .print-preview-shell {
    border: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
}

.paper-row-actions {
  text-align: center;
  white-space: nowrap;
}

.icon-btn {
  width: 26px;
  min-height: 26px;
  margin: 0 2px;
  padding: 0;
  border: 1px solid #d8e2ee;
  border-radius: 50%;
  background: #fff;
  color: #526070;
  font-size: 13px;
}

.icon-btn:hover {
  border-color: #39bfcc;
  color: #0d8c9a;
}

.voucher-paper-foot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 12px 0 8px;
  color: #697386;
  font-size: 13px;
}

.voucher-paper-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 2px;
}

.voucher-paper-toolbar button {
  min-width: 86px;
  min-height: 34px;
}

@media (max-width: 900px) {
  .modal-card.voucher-paper-card {
    width: calc(100vw - 18px);
    padding: 18px;
  }
  .voucher-paper-wrap {
    overflow-x: auto;
  }
  .voucher-paper-table {
    min-width: 980px;
  }
  .voucher-paper-meta,
  .voucher-paper-head,
  .voucher-paper-toolbar {
    flex-wrap: wrap;
  }
}

.modal-card.tax-login-card {
  width: min(960px, calc(100vw - 40px));
}

.tax-login-shell {
  display: grid;
  grid-template-columns: 1fr 380px;
  min-height: 470px;
  overflow: hidden;
  border: 1px solid #d8e4f3;
  border-radius: 18px;
  background: #fff;
}

.tax-login-hero {
  padding: 42px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(0, 92, 185, .94), rgba(28, 132, 226, .9)),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.35), transparent 32%);
}

.tax-login-hero small {
  display: inline-block;
  margin-bottom: 80px;
  font-weight: 800;
  letter-spacing: .12em;
}

.tax-login-hero h3 {
  margin: 0 0 18px;
  font-size: 34px;
  line-height: 1.2;
}

.tax-login-hero p {
  max-width: 440px;
  margin: 0;
  color: rgba(255,255,255,.86);
  line-height: 1.8;
}

.tax-login-panel {
  padding: 30px;
  background: #f8fbff;
}

.tax-login-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}

.tax-login-tabs button {
  min-height: 36px;
  padding: 0;
  border: 1px solid #cfe0f4;
  background: #fff;
  color: #325072;
}

.tax-login-tabs button.active {
  background: #1769e8;
  border-color: #1769e8;
  color: #fff;
}

.tax-login-panel label {
  display: block;
  margin: 12px 0 6px;
  color: #536477;
  font-size: 13px;
  font-weight: 700;
}

.tax-login-panel input {
  width: 100%;
  min-height: 40px;
}

.tax-code-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
}

.tax-code-row span {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid #cfe0f4;
  border-radius: 10px;
  background: repeating-linear-gradient(135deg, #eef5ff 0 8px, #fff 8px 16px);
  color: #1769e8;
  font-weight: 800;
}

.tax-auth-steps {
  display: grid;
  gap: 10px;
  margin: 20px 0 6px;
}

.tax-auth-steps div {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #d8e6f6;
  border-radius: 12px;
  background: #fff;
}

.tax-auth-steps b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e8f1ff;
  color: #1769e8;
}

.tax-auth-steps span {
  color: #536477;
  line-height: 1.5;
}

.tax-login-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.tax-login-actions button {
  flex: 1;
}

.tax-login-note {
  margin: 16px 0 0;
  color: #7a8798;
  font-size: 12px;
  line-height: 1.7;
}

.auxiliary-sheet {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 22px;
  align-items: start;
}

.auxiliary-block {
  border: 1px solid #9cb8f3;
  background: #fff;
  overflow: hidden;
}

.auxiliary-block-title {
  background: #3868c9;
  color: #fff;
  font-weight: 800;
  padding: 9px 12px;
  letter-spacing: 0;
}

.auxiliary-block table {
  margin: 0;
  border-collapse: collapse;
}

.auxiliary-block th {
  background: #dce8ff;
  color: #1348a8;
  border: 1px solid #9cb8f3;
  font-weight: 800;
}

.auxiliary-block td {
  height: 32px;
  border: 1px solid #b8c9ef;
}

.auxiliary-block tbody tr:nth-child(even) td {
  background: #dbe5fb;
}

.auxiliary-note {
  margin-top: 14px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.check-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #d7e3f5;
  border-radius: 10px;
  background: #f8fbff;
  color: #10233f;
  font-weight: 700;
}

.check-card input {
  width: 16px;
  height: 16px;
}

.notice-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid #d7e3f5;
  border-radius: 12px;
  background: #f8fbff;
}

.notice-card span {
  color: #536477;
}

.modal-card.voucher-data-card {
  width: min(1280px, calc(100vw - 48px));
  padding: 26px;
}

.voucher-data-head {
  display: grid;
  grid-template-columns: minmax(360px, .85fr) minmax(520px, 1.15fr);
  gap: 16px;
  align-items: stretch;
}

.voucher-data-head .notice-card {
  margin: 0;
}

.voucher-data-upload {
  display: grid;
  grid-template-columns: 1.2fr .8fr 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid #d7e3f5;
  border-radius: 12px;
  background: #fbfdff;
}

.voucher-data-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(520px, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.voucher-data-panel {
  min-width: 0;
  border: 1px solid #d7e3f5;
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}

.wide-table {
  overflow: auto;
}

.wide-table table {
  min-width: 720px;
  table-layout: fixed;
}

.wide-table th,
.wide-table td {
  white-space: normal;
  vertical-align: middle;
}

.wide-table .file-link {
  display: inline-block;
  max-width: 260px;
  overflow-wrap: anywhere;
  line-height: 1.45;
  text-align: left;
}

.recognition-notice {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border: 1px solid #d7e3f5;
  border-radius: 10px;
  background: #f8fbff;
  color: #536477;
  font-size: 13px;
}

.recognition-notice.success {
  border-color: #b7ebc6;
  background: #f0fff4;
  color: #08723f;
}

.recognition-notice.warn {
  border-color: #ffd6a8;
  background: #fff8ec;
  color: #9a5b00;
}

@media (max-width: 820px) {
  .modal-card.voucher-data-card {
    width: calc(100vw - 20px);
    padding: 18px;
  }
  .voucher-data-head,
  .voucher-data-upload,
  .voucher-data-grid {
    grid-template-columns: 1fr;
  }
  .auxiliary-sheet {
    grid-template-columns: 1fr;
  }
  .tax-login-shell {
    grid-template-columns: 1fr;
  }
  .tax-login-hero {
    padding: 28px;
  }
  .tax-login-hero small {
    margin-bottom: 28px;
  }
}

.receipt-voucher-toolbar { align-items: center; margin: 12px 0; }
.receipt-voucher-table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.receipt-voucher-table { min-width: 1080px; }
.receipt-voucher-table th, .receipt-voucher-table td { white-space: nowrap; vertical-align: middle; }
.receipt-voucher-table td:nth-child(7), .receipt-voucher-table td:nth-child(8) { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.payroll-payment-head {
  grid-template-columns: minmax(150px, .7fr) minmax(170px, .8fr) minmax(280px, 1.5fr);
}
.payroll-payment-voucher-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}
.payroll-payment-voucher-table th:nth-child(1) { width: 76px; }
.payroll-payment-voucher-table th:nth-child(2) { width: 31%; }
.payroll-payment-voucher-table th:nth-child(3) { width: 18%; }
.payroll-payment-voucher-table th:nth-child(4) { width: 16%; }
.payroll-payment-voucher-table th:nth-child(5) { width: 130px; }
.payroll-payment-voucher-table th:nth-child(6) { width: 76px; }
.payroll-payment-voucher-table select,
.payroll-payment-voucher-table input {
  width: 100%;
  min-width: 0;
}
.payroll-payment-table-wrap {
  overflow-x: hidden;
  overflow-y: auto;
}
.compact-number { width: 120px; min-width: 120px; }
.modal-card.income-carryover-card { width: min(1180px, calc(100vw - 48px)); }
.confirm-check { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-weight: 600; color: var(--ink); }
.confirm-check input { width: 18px; height: 18px; }

.column-settings {
  display: grid;
  gap: 16px;
}

.column-settings-group {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.column-settings-group legend {
  padding: 0 6px;
  font-weight: 700;
  color: var(--ink);
}

.column-settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
  margin-bottom: 12px;
}

.column-settings-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.column-settings-grid input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .column-settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.text-danger { color: #c62828 !important; }

.voucher-reversal-row,
.voucher-reversal-row .muted,
.voucher-reversal-row .amount-cell,
.voucher-reversal-row .badge {
  color: #c62828 !important;
}

/* Complete database backup controls in Settings > Archive. */
.backup-notice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid #cfe0f5;
  background: #f5f9ff;
  color: #48617f;
  line-height: 1.7;
}

.backup-notice strong {
  flex: 0 0 auto;
  color: #0f2742;
}
