:root {
  --red: #a8321f;
  --red-dark: #7e2416;
  --bg: #f6f4f0;
  --card: #ffffff;
  --line: #e5dfd6;
  --ink: #2b2b2b;
  --muted: #8a857c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #2a2018; color: #f2e9dd; display: flex; flex-direction: column; padding: 20px 0; }
.brand { padding: 8px 22px 20px; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.brand-text { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.brand-text span { color: #e0a458; }
.sidebar nav { flex: 1; }
.sidebar nav a { display: block; padding: 11px 22px; color: #d8cbbb; }
.sidebar nav a.active, .sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.side-foot { padding: 14px 22px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.who { margin-bottom: 8px; }
.who small { display: block; color: #a99a86; margin-top: 2px; }
.content { flex: 1; padding: 28px 36px; max-width: 1100px; }
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 28px 0 10px; color: var(--red-dark); }

.cards { display: flex; gap: 16px; margin-bottom: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 22px; min-width: 180px; }
.card .num { font-size: 24px; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; text-align: left; }
th { background: #faf7f2; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.income td { color: var(--red-dark); font-weight: 600; }
tr.cost td { color: #8a6a00; }
tr.profit td, tr.subtotal td { font-weight: 700; border-top: 2px solid var(--line); }
tr.ratio td { color: var(--muted); }
.neg { color: #b3261e !important; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #2a2018, #4a2f20); }
.login-card { background: #fff; border-radius: 14px; padding: 34px 38px; width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-logo { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; display: block; margin: 0 auto 12px; }
.login-card h1 { margin: 0 0 4px; color: var(--red-dark); }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card input { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.login-card button { width: 100%; padding: 11px; margin-top: 6px; background: var(--red); color: #fff; border: 0; border-radius: 8px; font-size: 15px; cursor: pointer; }
.login-card button:hover { background: var(--red-dark); }
.alert { background: #fdeceb; color: #b3261e; border: 1px solid #f5c6c2; padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.hint { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.7; }
code { background: #f3efe8; padding: 1px 5px; border-radius: 4px; }
.note { color: var(--muted); font-size: 12px; margin-top: 26px; }
.btn { font-size: 13px; border: 1px solid var(--red); padding: 3px 10px; border-radius: 6px; }
.btn:hover { background: var(--red); color: #fff; text-decoration: none; }
button.link { background: none; border: 0; color: #d8cbbb; cursor: pointer; padding: 0; font-size: 13px; }
button.link:hover { color: #fff; }

.switcher { margin: 12px 14px; padding: 10px 12px; background: rgba(255,255,255,.06); border-radius: 8px; }
.switch-title { font-size: 12px; color: #e0a458; margin-bottom: 6px; }
.switcher select { width: 100%; padding: 6px 8px; border-radius: 6px; border: 0; font-size: 12px; margin-bottom: 6px; }
.switcher button { width: 100%; padding: 6px; border: 0; border-radius: 6px; background: var(--red); color: #fff; font-size: 12px; cursor: pointer; }
.switcher form + form button { background: #3d5a3d; margin-top: 6px; }

.tag { padding: 2px 10px; border-radius: 10px; font-size: 12px; }
.tag.due { background: #fdeceb; color: #b3261e; }
.tag.warn { background: #fff4e0; color: #9a6a00; }
.tag.ok { background: #e8f3e8; color: #2e6b2e; }
.card .num.due { color: #b3261e; }

.cat-checks { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; }
.chk { font-size: 12px; color: var(--ink); }
.chk input { width: auto !important; margin-right: 3px; }

.warn-card { border-color: #e8c37a; background: #fffaf0; text-decoration: none; color: var(--ink); }
.warn-card:hover { border-color: var(--red); }
.menu-btn { display: none; margin: 10px 12px; background: var(--red); color: #fff; border: 0; padding: 9px 14px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.bar { height: 10px; background: var(--red); border-radius: 5px; min-width: 2px; }

.charts { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 320px; flex: 1; }
.chart-box h3 { margin: 0 0 10px; font-size: 14px; }
.donut { width: 140px; height: 140px; border-radius: 50%; margin: 0 auto 10px; }
.legend { list-style: none; padding: 0; margin: 0; font-size: 12px; color: var(--ink); }
.legend li { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

@media (max-width: 768px) {
  .menu-btn { display: block; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: none; padding: 10px 12px; }
  .sidebar.open { display: block; }
  .brand { padding: 6px 10px 12px; font-size: 17px; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar nav a { padding: 8px 12px; font-size: 13px; }
  .content { padding: 14px; }
  .cards { flex-direction: column; gap: 10px; }
  .card { min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar select, .toolbar input { max-width: 100%; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  h1 { font-size: 18px; }
}

/* 表单与录入 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 20px; }
.form-grid label { font-size: 12px; color: var(--muted); }
.form-grid input, .form-grid select { width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.form-actions { grid-column: 1 / -1; }
.form-actions button { background: var(--red); color: #fff; border: 0; padding: 9px 18px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.toolbar { margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.toolbar select, .toolbar input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; }
.toolbar button, .btn { font-size: 13px; }
.del { color: #b3261e; }
.meta { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }
.highlight { background: #fff7ec; }
.form-grid .chk { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; padding-top: 14px; }
.form-grid .chk input { width: auto; margin: 0; }

/* 工资条 */
.payslip { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 22px; max-width: 760px; }
.ps-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--red); padding-bottom: 12px; }
.ps-head .logo { width: 46px; height: 46px; border-radius: 8px; }
.ps-title { font-size: 20px; font-weight: 700; }
.ps-info { display: flex; flex-wrap: wrap; gap: 18px; padding: 14px 0; font-size: 14px; }
.ps-table { width: 100%; margin-top: 4px; }
.ps-table td { padding: 7px 10px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.ps-sub td { background: #faf4f0; font-weight: 700; }
.ps-foot { display: flex; flex-wrap: wrap; gap: 18px; padding-top: 12px; font-size: 13px; color: var(--muted); }

@media print {
  .sidebar, .toolbar, form, .no-print { display: none !important; }
  .content { padding: 0; max-width: 100%; }
  body { background: #fff; }
  table { border: 1px solid #999; }
  h1 { font-size: 18px; }
}
