:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9e1ea;
  --text: #1f2937;
  --muted: #65758b;
  --blue: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: .58;
}

button.primary,
.login-panel button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.login-panel button.secondary {
  margin-top: 8px;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.expense-entry-mode .login-panel label,
.expense-entry-mode .login-panel button[type="submit"] {
  display: none;
}

.expense-entry-mode .login-panel button.secondary {
  margin-top: 18px;
  width: 100%;
  min-height: 44px;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

button.danger {
  color: var(--red);
  border-color: #fecaca;
}

.hidden {
  display: none !important;
}

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

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

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 8px;
  font-size: 28px;
  font-weight: 700;
}

.login-panel p,
.login-panel h1 {
  margin: 10px 0;
}

.login-panel label,
.field {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.login-panel input,
.field input,
.field select,
.field textarea,
.filters input,
.filters select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
}

.message {
  min-height: 22px;
  color: var(--red);
  margin-top: 10px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
  transition: grid-template-columns .18s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 76px 1fr;
}

.app-shell.sidebar-collapsed.sidebar-peek {
  grid-template-columns: 220px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  max-height: 100vh;
  background: #e8eef6;
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.side-title {
  min-height: 58px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 14px;
}

.side-title-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 800;
}

.side-title-text {
  min-width: 0;
  display: grid;
  gap: 4px;
  white-space: nowrap;
}

.side-title span,
.sub {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-toggle {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
}

#nav {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
}

.nav-group {
  display: grid;
  align-self: start;
  align-content: start;
  gap: 4px;
}

.nav-group-btn {
  width: 100%;
  min-height: 42px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: transparent;
  border-color: transparent;
  padding: 7px 10px;
}

.nav-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(37, 99, 235, .08);
  color: var(--blue);
  font-style: normal;
  font-weight: 800;
  font-size: 14px;
}

.nav-group-btn span {
  min-width: 0;
  display: grid;
  gap: 2px;
  flex: 1;
}

.nav-group-btn strong {
  font-size: 15px;
  font-weight: 700;
}

.nav-group-btn small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.nav-group-btn b {
  color: var(--muted);
  font-size: 14px;
  transition: transform .15s ease;
}

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

.nav-group-btn.active {
  background: #fff;
  border-color: var(--line);
  color: var(--blue);
}

.nav-submenu {
  display: grid;
  gap: 3px;
  margin-left: 10px;
  padding: 2px 0 4px 8px;
  border-left: 1px solid #cbd5e1;
}

.nav-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border-color: transparent;
  min-height: 32px;
  padding: 5px 10px;
  font-size: 14px;
}

.nav-btn.active {
  background: #fff;
  border-color: var(--line);
  color: var(--blue);
}

.app-shell.sidebar-collapsed:not(.sidebar-peek) .sidebar {
  padding-left: 10px;
  padding-right: 10px;
}

.app-shell.sidebar-collapsed:not(.sidebar-peek) .side-title {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-shell.sidebar-collapsed:not(.sidebar-peek) .side-title-main {
  justify-content: center;
}

.app-shell.sidebar-collapsed:not(.sidebar-peek) .side-title-text,
.app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-group-btn span,
.app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-group-btn b,
.app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-submenu {
  display: none;
}

.app-shell.sidebar-collapsed:not(.sidebar-peek) .sidebar-toggle {
  position: absolute;
  left: 56px;
  top: 16px;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .12);
}

.app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-group-btn {
  justify-content: center;
  padding: 7px 0;
}

.app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-icon {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

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

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

.tab-bar {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  padding: 8px 20px 0;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.work-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 108px;
  max-width: 180px;
  min-height: 34px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: #eef2f7;
  color: #475569;
  white-space: nowrap;
}

.work-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.work-tab b {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #64748b;
  font-style: normal;
  font-size: 15px;
}

.work-tab b:hover {
  background: #e2e8f0;
  color: var(--red);
}

.work-tab.active {
  background: #fff;
  color: var(--blue);
  border-bottom-color: #fff;
}

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

.account-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.account-switcher select {
  min-height: 34px;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
}

.content {
  min-width: 0;
  padding: 16px 20px 32px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-item,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-item {
  padding: 14px;
}

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

.summary-item strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.summary-grid.compact .summary-item strong {
  font-size: 18px;
  line-height: 1.3;
}

.panel {
  overflow: hidden;
}

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

.panel-head h2 {
  font-size: 16px;
  margin: 0;
}

.filters {
  padding: 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.filters input,
.filters select {
  width: 160px;
}

.more-filters {
  position: relative;
}

.more-filters summary {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  user-select: none;
}

.more-filters div {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: 560px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, .12);
}

.more-filters label {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  font-size: 13px;
}

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

th {
  background: #edf3fb;
  color: #334155;
  font-weight: 600;
}

.expense-review-table {
  table-layout: fixed;
  min-width: 1320px;
}

.expense-review-table th:nth-child(1),
.expense-review-table td:nth-child(1) {
  width: 46px;
}

.expense-review-table th:nth-child(2),
.expense-review-table td:nth-child(2) {
  width: 130px;
}

.expense-review-table th:nth-child(3),
.expense-review-table td:nth-child(3) {
  width: 86px;
}

.expense-review-table th:nth-child(4),
.expense-review-table td:nth-child(4) {
  width: 170px;
}

.expense-review-table th:nth-child(5),
.expense-review-table td:nth-child(5) {
  width: 230px;
}

.expense-review-table th:nth-child(6),
.expense-review-table td:nth-child(6) {
  width: 100px;
}

.expense-review-table th:nth-child(7),
.expense-review-table td:nth-child(7) {
  width: 106px;
}

.expense-review-table th:nth-child(8),
.expense-review-table td:nth-child(8) {
  width: 76px;
}

.expense-review-table th:nth-child(9),
.expense-review-table td:nth-child(9) {
  width: 70px;
}

.expense-review-table th:nth-child(10),
.expense-review-table td:nth-child(10) {
  width: 86px;
}

.expense-review-table th:nth-child(11),
.expense-review-table td:nth-child(11) {
  width: 116px;
}

.expense-review-table th:nth-child(12),
.expense-review-table td:nth-child(12) {
  width: 180px;
}

.expense-review-table th:nth-child(13),
.expense-review-table td:nth-child(13) {
  width: 120px;
}

.truncate-cell {
  max-width: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.truncate-cell.merchant,
.truncate-cell.item {
  white-space: nowrap;
}

tr.selected {
  background: #eff6ff;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #f8fbff;
}

.candidate-select-table tbody tr {
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

.candidate-select-table tbody tr:hover {
  background: #f8fbff;
}

.candidate-select-table tbody tr.selected:hover {
  background: #eff6ff;
}

.candidate-action-bar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.candidate-action-bar > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.candidate-top-scroll {
  height: 15px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.candidate-top-scroll > div {
  height: 1px;
}

.candidate-group-row {
  background: #fbfdff;
}

.candidate-group-row td {
  border-top: 1px solid #cbd7e6;
}

.candidate-group-row:hover {
  background: #f2f7ff;
}

.candidate-group-row td:last-child button {
  pointer-events: auto;
}

.candidate-detail-row td {
  background: #fff;
}

.candidate-detail-row td:nth-child(2),
.candidate-detail-row td:nth-child(3),
.candidate-detail-row td:nth-child(4) {
  color: #475569;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin: 0 4px 4px 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #334155;
  font-size: 12px;
  white-space: nowrap;
}

.mini-badge.amber {
  background: #fef3c7;
  color: #b45309;
}

.mini-badge.red {
  background: #fee2e2;
  color: #dc2626;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #334155;
  font-size: 12px;
}

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

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

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

.inline-select {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 4px 8px;
  font-size: 13px;
}

.invoice-status-card {
  display: grid;
  gap: 6px;
  min-width: 156px;
  max-width: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.invoice-status-top {
  display: grid;
  grid-template-columns: 10px auto 1fr;
  align-items: center;
  gap: 6px;
}

.invoice-status-top strong {
  font-size: 13px;
}

.invoice-status-top span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.invoice-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #94a3b8;
}

.invoice-progress {
  position: relative;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.invoice-progress i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #94a3b8;
}

.invoice-status-money {
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.invoice-status-card button {
  width: 100%;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.invoice-status-card button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}

.invoice-status-card button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.invoice-status-card.pending {
  background: #fff8eb;
  border-color: #fed7aa;
}

.invoice-status-card.pending .invoice-status-dot,
.invoice-status-card.pending .invoice-progress i {
  background: var(--amber);
}

.invoice-status-card.partial {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.invoice-status-card.partial .invoice-status-dot,
.invoice-status-card.partial .invoice-progress i {
  background: var(--blue);
}

.invoice-status-card.done {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.invoice-status-card.done .invoice-status-dot,
.invoice-status-card.done .invoice-progress i {
  background: var(--green);
}

.invoice-status-card.waived {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.invoice-status-card.waived .invoice-status-dot,
.invoice-status-card.waived .invoice-progress i {
  background: #64748b;
}

.invoice-status-card.error {
  background: #fff1f2;
  border-color: #fecdd3;
}

.invoice-status-card.error .invoice-status-dot,
.invoice-status-card.error .invoice-progress i {
  background: var(--red);
}

.invoice-modal-layout {
  display: grid;
  gap: 14px;
}

dialog.invoice-work-modal #modalBody {
  padding: 18px 20px;
}

dialog.invoice-work-modal .summary-grid.compact {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

dialog.invoice-work-modal .form-grid {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.invoice-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.invoice-detail-table {
  max-height: 300px;
}

.invoice-detail-table table {
  min-width: 980px;
}

.section-title {
  color: #0f172a;
  font-weight: 800;
}

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

dialog {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

dialog.large {
  width: min(1280px, calc(100vw - 48px));
}

dialog.invoice-work-modal {
  width: min(1500px, calc(100vw - 40px));
}

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

dialog::backdrop {
  background: rgba(15, 23, 42, .32);
}

#modalForm header,
#modalForm footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

#modalForm footer {
  border-top: 1px solid var(--line);
  border-bottom: none;
  justify-content: flex-end;
}

#modalForm h2 {
  margin: 0;
  font-size: 18px;
}

#modalBody {
  padding: 14px;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.detail-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.statement-table {
  min-width: 900px;
}

.statement-period {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  background: #f8fafc;
  border-top: 1px solid var(--line);
}

.statement-table tfoot td {
  position: sticky;
  bottom: 0;
  background: #f8fafc;
  border-top: 1px solid var(--line);
  font-weight: 700;
}

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

.recon-adjustment-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.recon-adjustment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recon-adjustment-head > div,
.recon-adjustment-row label {
  display: grid;
  gap: 4px;
}

.recon-adjustment-head small,
.recon-adjustment-row label > span,
.recon-total-summary span {
  color: var(--muted);
  font-size: 12px;
}

.recon-adjustment-rows {
  display: grid;
  gap: 8px;
}

.recon-adjustment-row {
  display: grid;
  grid-template-columns: 140px minmax(180px, 1fr) 150px minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.recon-adjustment-row button {
  min-height: 38px;
}

.recon-total-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.recon-total-summary > div {
  display: grid;
  gap: 4px;
  padding: 10px 12px 0;
}

.recon-total-summary .final {
  border-left: 1px solid var(--line);
}

.recon-total-summary .final strong {
  color: var(--blue);
  font-size: 18px;
}

.recon-total-summary .final strong.negative {
  color: var(--red);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.check-line,
.permission-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.check-line input,
.permission-item input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

.permission-checks span,
.permission-item span {
  display: grid;
  gap: 2px;
}

.permission-checks small,
.permission-item small {
  color: var(--muted);
  font-size: 12px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 12px;
  padding: 12px;
}

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

.role-card header,
.role-card footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.role-card header div {
  display: grid;
  gap: 4px;
}

.role-card header span {
  color: var(--muted);
  font-size: 12px;
}

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

.permission-item {
  padding: 8px;
  border: 1px solid #e5edf6;
  border-radius: 6px;
  background: #f8fafc;
}

.expense-claim-form {
  display: grid;
  gap: 12px;
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 118px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
}

.upload-zone strong {
  color: var(--text);
  font-size: 16px;
}

.upload-zone.drag-over {
  border-color: var(--blue);
  background: #eff6ff;
}

.receipt-preview {
  display: grid;
  gap: 8px;
}

.receipt-preview img {
  max-width: min(420px, 100%);
  max-height: 280px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pdf-preview {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.receipt-viewer {
  display: grid;
  gap: 10px;
}

.viewer-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.viewer-toolbar button,
.viewer-toolbar a {
  width: auto;
}

.receipt-viewer-stage {
  height: min(72vh, 760px);
  overflow: auto;
  display: grid;
  place-items: start center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.receipt-viewer-stage img {
  max-width: 100%;
  transform-origin: top center;
  transition: transform 0.12s ease;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.receipt-viewer-stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

.ocr-status {
  min-height: 30px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  background: #f8fafc;
}

.ocr-status.loading {
  color: #1d4ed8;
  background: #eff6ff;
}

.ocr-status.success {
  color: var(--green);
  background: #dcfce7;
}

.ocr-status.warning {
  color: var(--amber);
  background: #fef3c7;
}

.expense-correction-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.expense-correction-actions button {
  width: auto;
}

.modal-error {
  flex: 1;
  min-height: 22px;
  color: var(--red);
  font-size: 13px;
  text-align: left;
}

.expense-items-preview h3 {
  margin: 4px 0 8px;
  font-size: 15px;
}

.expense-status-tabs {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.expense-status-tabs button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  font-weight: 700;
}

.expense-status-tabs button.active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}

.expense-status-tabs span {
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--muted);
  font-size: 12px;
}

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

.payment-stage-tabs {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.payment-stage-tabs button {
  min-width: 120px;
  min-height: 38px;
  font-weight: 700;
}

.payment-stage-tabs button.active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}

.payment-bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.payment-bulk-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.payment-bulk-bar span {
  color: var(--muted);
  flex: 1;
}

.expense-card-list {
  display: grid;
  gap: 12px;
  padding: 12px;
}

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

.expense-card header,
.expense-card footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.expense-card header div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.expense-card header strong {
  font-size: 16px;
}

.expense-card header span {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-card-amount {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

.expense-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.expense-card dl div {
  display: grid;
  gap: 2px;
}

.expense-card dt {
  color: var(--muted);
  font-size: 12px;
}

.expense-card dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.expense-card-note {
  margin: 0;
  padding: 9px 10px;
  border-radius: 6px;
  color: #92400e;
  background: #fffbeb;
  font-size: 13px;
}

.expense-card footer {
  justify-content: flex-end;
  flex-wrap: wrap;
}

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

.expense-entry-mode .app-shell {
  grid-template-columns: 1fr;
}

.expense-entry-mode .sidebar,
.expense-entry-mode .tab-bar,
.expense-entry-mode .account-switcher,
.expense-entry-mode #refreshBtn {
  display: none;
}

.expense-entry-mode .workspace {
  grid-template-rows: auto 1fr;
}

.expense-entry-mode .topbar {
  padding: 14px 16px;
}

.expense-entry-mode .topbar h1 {
  font-size: 22px;
}

.expense-entry-mode .topbar p {
  font-size: 13px;
}

@media (max-width: 860px) {
  body {
    background: #eef2f7;
  }

  button {
    min-height: 40px;
  }

  .login-view {
    align-items: start;
    padding: 18px;
    padding-top: 9vh;
  }

  .login-panel {
    padding: 22px;
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .08);
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  .app-shell.sidebar-collapsed,
  .app-shell.sidebar-collapsed.sidebar-peek {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    height: auto;
    max-height: none;
    padding: 10px 12px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(232, 238, 246, .96);
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
    backdrop-filter: blur(10px);
    overflow: visible;
  }

  .side-title {
    min-height: 40px;
    align-items: center;
    padding: 0 0 8px;
  }

  .side-logo {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    border-radius: 7px;
    font-size: 15px;
  }

  .side-title-text strong {
    font-size: 17px;
  }

  .side-title-text span {
    font-size: 11px;
  }

  .sidebar-toggle {
    display: none;
  }

  .app-shell.sidebar-collapsed:not(.sidebar-peek) .side-title-text,
  .app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-group-btn span,
  .app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-group-btn b {
    display: grid;
  }

  .app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-submenu {
    display: grid;
  }

  .app-shell.sidebar-collapsed:not(.sidebar-peek) .sidebar-toggle {
    position: static;
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
    box-shadow: none;
  }

  .app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-group-btn {
    justify-content: flex-start;
    padding: 7px 10px;
  }

  .app-shell.sidebar-collapsed:not(.sidebar-peek) .nav-icon {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  #nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 2px 0 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #nav::-webkit-scrollbar {
    display: none;
  }

  .nav-group {
    flex: 0 0 142px;
    gap: 5px;
  }

  .nav-group-btn {
    min-height: 38px;
    padding: 6px 9px;
    border-color: #d9e1ea;
    background: rgba(255, 255, 255, .72);
  }

  .nav-group-btn strong {
    font-size: 14px;
  }

  .nav-group-btn small {
    display: none;
  }

  .nav-icon {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
    font-size: 13px;
  }

  .nav-submenu {
    margin-left: 0;
    padding: 4px;
    border-left: 0;
    border: 1px solid #dbe4ef;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .08);
  }

  .nav-btn {
    min-height: 34px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
  }

  .summary-grid,
  .form-grid,
  .checkbox-grid,
  .role-grid {
    grid-template-columns: 1fr;
  }

  .recon-adjustment-head {
    align-items: stretch;
    flex-direction: column;
  }

  .recon-adjustment-row,
  .recon-total-summary {
    grid-template-columns: 1fr;
  }

  .recon-total-summary .final {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: #f8fafc;
  }

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

  .topbar p {
    font-size: 12px;
    line-height: 1.4;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    justify-content: stretch;
  }

  .account-switcher {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: space-between;
  }

  .account-switcher select {
    min-width: 0;
    flex: 1;
  }

  .top-actions button {
    width: 100%;
  }

  .tab-bar {
    padding: 6px 12px 0;
    gap: 5px;
    background: #eef2f7;
  }

  .work-tab {
    min-width: 92px;
    max-width: 146px;
    min-height: 32px;
    padding: 5px 9px;
    font-size: 13px;
  }

  .content {
    padding: 10px;
  }

  .panel {
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .04);
  }

  .panel-head {
    align-items: flex-start;
    padding: 12px;
    flex-direction: column;
  }

  .panel-head h2 {
    font-size: 17px;
  }

  .row-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .row-actions > button:only-child {
    grid-column: 1 / -1;
  }

  .row-actions .primary,
  #newExpenseBtn {
    width: 100%;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
  }

  .filters input,
  .filters select,
  .filters button {
    width: 100%;
  }

  .filters input[id*="keyword"],
  .filters input[placeholder*="搜索"] {
    grid-column: 1 / -1;
  }

  .summary-grid.compact,
  .summary-grid {
    gap: 8px;
    margin-bottom: 10px;
  }

  dialog.invoice-work-modal .summary-grid.compact,
  dialog.invoice-work-modal .form-grid {
    grid-template-columns: 1fr;
  }

  .invoice-detail-table table {
    min-width: 720px;
  }

  .summary-item {
    padding: 12px;
  }

  .summary-item strong {
    font-size: 20px;
  }

  .table-wrap {
    border-top: 1px solid var(--line);
    background: #fff;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: 8px;
  }

  .empty {
    padding: 16px;
    text-align: left;
  }

  .expense-entry-mode .topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    flex-direction: row;
    align-items: center;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
  }

  .expense-entry-mode .topbar p {
    display: none;
  }

  .expense-entry-mode .content {
    padding: 10px;
  }

  .expense-entry-mode .panel-head {
    display: grid;
  }

  .expense-entry-mode .panel-head h2 {
    font-size: 18px;
  }

  .expense-card-list {
    padding: 10px;
    gap: 10px;
  }

  .expense-card {
    padding: 12px;
  }

  .expense-card dl {
    grid-template-columns: 1fr;
  }

  dialog,
  dialog.large,
  dialog.viewer-modal {
    width: calc(100vw - 12px);
    max-height: calc(100vh - 12px);
    border-radius: 8px;
  }

  #modalBody {
    max-height: calc(100vh - 138px);
    padding: 12px;
  }

  .upload-zone {
    min-height: 104px;
  }

  .receipt-preview img {
    max-height: 220px;
  }
}
