:root {
  --navy: #17365d;
  --navy-2: #24527f;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #dfe5ed;
  --text: #1f2937;
  --muted: #6b7280;
  --orange: #ef8a17;
  --orange-dark: #c96f0d;
  --ok: #16834b;
  --danger: #c62828;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--navy-2); }

.topbar { height: 60px; background: var(--navy); color: #fff; display: flex; align-items: center; padding: 0 18px; gap: 18px; position: sticky; top: 0; z-index: 20; }
.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav button { background: transparent; border: 0; color: #dbe7f5; padding: 8px 12px; border-radius: 6px; white-space: nowrap; }
.nav button.active { background: #fff; color: var(--navy); font-weight: 600; }
.top-action { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: 7px 12px; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 27px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.stat-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat-highlight .stat-value { color: var(--orange-dark); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 14px; font-size: 17px; color: var(--navy); }
.card h3 { margin: 16px 0 10px; font-size: 15px; color: var(--navy); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 6px; padding: 8px 13px; }
.btn:hover { border-color: var(--navy-2); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-orange { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.btn-orange:hover { background: var(--orange-dark); }
.btn-danger { color: var(--danger); border-color: #f0c7c7; }
.btn-sm { padding: 5px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea { border: 1px solid #cfd7e2; border-radius: 6px; padding: 8px 10px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(36,82,127,.18); border-color: var(--navy-2); }
input[type="number"] { min-width: 90px; }
label.field { display: inline-flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f7f9fc; color: var(--muted); font-size: 13px; font-weight: 600; }
td.amount { font-weight: 700; color: var(--navy); }
.tag { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 12px; background: #eef3f8; color: var(--navy-2); }
.tag.pdf { background: #e9f1fa; color: #1d5a94; }
.tag.manual { background: #fff3e2; color: #9a5a08; }
.tag.reimbursed { background: #e8f6ee; color: var(--ok); }
.tag.void { background: #fdeaea; color: var(--danger); }

.tabs-panel { display: none; }
.tabs-panel.active { display: block; }
.target-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.target-buttons .btn.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper input { width: 90px; text-align: center; }

.toast { position: fixed; right: 18px; bottom: 18px; background: #1f2937; color: #fff; padding: 11px 15px; border-radius: 7px; z-index: 100; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }

.dialog-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.42); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 16px; }
.dialog { background: #fff; border-radius: 10px; padding: 20px; width: min(700px, 100%); max-height: 86vh; overflow: auto; }
.dialog h2 { margin: 0 0 12px; color: var(--navy); font-size: 18px; }

.batch-table input { min-width: 0; width: 100%; }
.batch-table select { min-width: 0; width: 100%; }
.batch-table th:nth-child(1), .batch-table td:nth-child(1) { width: 150px; }
.batch-table th:nth-child(2), .batch-table td:nth-child(2) { width: 120px; }
.batch-table th:nth-child(3), .batch-table td:nth-child(3) { width: 130px; }
.batch-table th:nth-child(4), .batch-table td:nth-child(4) { width: 160px; }
.batch-table th:nth-child(5), .batch-table td:nth-child(5) { width: 90px; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #eef2f7; }
.login-card { width: min(420px, calc(100% - 32px)); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px; box-shadow: 0 12px 32px rgba(23,54,93,.08); }
.login-card h1 { margin: 0 0 6px; font-size: 22px; color: var(--navy); }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-card input { width: 100%; margin-bottom: 14px; }
.login-card .btn { width: 100%; }

.report-page { background: #fff; min-height: 100vh; padding: 24px; }
.report-shell { max-width: 900px; margin: 0 auto; }
.report-head { border-bottom: 2px solid var(--navy); padding-bottom: 14px; margin-bottom: 18px; }
.report-head h1 { margin: 0; color: var(--navy); font-size: 22px; }
.report-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.report-meta div { background: #f7f9fc; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.report-meta strong { display: block; font-size: 18px; color: var(--navy); margin-top: 3px; }
.report-actions { display: flex; gap: 10px; margin-bottom: 18px; }
.report-note { color: var(--muted); font-size: 13px; margin-top: 18px; }

.print-page { background: #fff; color: #000; padding: 0; }
.print-actions { max-width: 140mm; margin: 16px auto; display: flex; gap: 10px; }
.sheet { width: 140mm; min-height: 198mm; margin: 0 auto 10mm; padding: 10mm; border: 1px dashed #bbb; page-break-after: always; break-after: page; background: #fff; }
.sheet:last-child { page-break-after: auto; break-after: auto; }
.cover-sheet { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.cover-sheet h1 { font-size: 26px; margin-bottom: 32px; }
.cover-grid { width: 100%; border-collapse: collapse; }
.cover-grid td { border: 1px solid #333; padding: 12px; font-size: 16px; }
.pdf-sheet { padding: 0; display: flex; align-items: flex-start; justify-content: center; }
.pdf-sheet embed { width: 100%; height: 178mm; border: 0; }
.manual-sheet h2 { font-size: 17px; margin: 0 0 10px; }
.manual-sheet table { min-width: 0; font-size: 13px; }
.manual-sheet th, .manual-sheet td { padding: 5px 6px; border: 1px solid #333; }
.manual-sheet th { background: #fff; color: #000; }
.manual-sheet tr { page-break-inside: avoid; break-inside: avoid; }

@page { size: A5; margin: 10mm; }
@media print {
  body { background: #fff; }
  .topbar, .wrap > .card, .stats, .nav, .print-actions, .report-actions, .toast { display: none !important; }
  .report-page { padding: 0; }
  .report-shell { max-width: none; }
  .sheet { width: auto; min-height: 0; margin: 0; padding: 0; border: 0; page-break-after: always; break-after: page; }
  .pdf-sheet embed { height: 178mm; }
  .manual-sheet { border: 0; }
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 12px; }
  .nav { order: 3; width: 100%; }
  .wrap { padding: 12px; }
  .report-meta { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .stat-value { font-size: 23px; }
  .card { padding: 14px; }
  .btn { padding: 9px 11px; }
}
