:root {
  --c-bg: #f4f6f3;
  --c-panel: #ffffff;
  --c-primary: #2f7d32;
  --c-primary-d: #1f5a22;
  --c-accent: #e8a33d;
  --c-text: #1f2a24;
  --c-muted: #6b7a72;
  --c-border: #e1e7e1;
  --c-danger: #c0392b;
  --c-ok: #2f7d32;
  --c-warn: #d98324;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(31, 90, 34, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--c-primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 10px;
  border: 1px solid var(--c-border); border-radius: 8px; background: #fff; color: var(--c-text);
  width: 100%; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--c-primary); }
label { display: block; font-size: 13px; color: var(--c-muted); margin-bottom: 4px; }
.hidden { display: none !important; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2f7d32 0%, #1f5a22 60%, #143d16 100%);
  padding: 16px;
}
.login-card {
  background: #fff; width: 100%; max-width: 380px; border-radius: 16px; padding: 32px 28px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 18px; }
.login-logo .badge {
  width: 56px; height: 56px; border-radius: 14px; background: var(--c-primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 28px;
}
.login-logo h1 { font-size: 19px; margin: 12px 0 2px; }
.login-logo p { color: var(--c-muted); margin: 0; font-size: 12px; }
.login-card .field { margin-bottom: 14px; }
.btn {
  border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  background: var(--c-primary); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--c-primary-d); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; padding: 12px; }
.btn-ghost { background: #eef2ee; color: var(--c-text); }
.btn-ghost:hover { background: #e2e8e2; }
.btn-danger { background: var(--c-danger); }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.login-hint { font-size: 12px; color: var(--c-muted); margin-top: 14px; text-align: center; }
.err-msg { color: var(--c-danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #1f3326; color: #cfe3d2; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 18px 18px; font-weight: 700; font-size: 16px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 8px;
}
.sidebar .brand .dot { width: 28px; height: 28px; border-radius: 8px; background: var(--c-accent); display:inline-flex; align-items:center; justify-content:center; color:#1f3326; font-size:16px;}
.side-nav { padding: 10px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 8px;
  color: #cfe3d2; cursor: pointer; margin-bottom: 4px; font-size: 14px;
}
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav a.active { background: var(--c-primary); color: #fff; }
.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot button { margin-top: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 600; font-size: 16px; }
.topbar .menu-btn { display: none; background: none; border: none; font-size: 22px; color: var(--c-text); }
.content { padding: 20px; }

/* ---------- 看板 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card { background: var(--c-panel); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--c-border); }
.stat-card .k { font-size: 13px; color: var(--c-muted); }
.stat-card .v { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--c-primary-d); }
.stat-card .v small { font-size: 14px; font-weight: 500; color: var(--c-muted); }
.stat-card.accent .v { color: var(--c-accent); }
.stat-card.warn .v { color: var(--c-warn); }
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.panel { background: var(--c-panel); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--c-border); }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.panel canvas { max-width: 100%; }

/* ---------- 工具栏 / 列表 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: flex-end; }
.toolbar .field { margin: 0; min-width: 140px; flex: 1; }
.toolbar .actions { display: flex; gap: 8px; }
.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--c-border); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
th { background: #f7f9f7; color: var(--c-muted); font-weight: 600; position: sticky; top: 0; }
tbody tr:hover { background: #fafcf9; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.tag-cash { background: #e8f3e8; color: #1f5a22; }
.tag-transfer { background: #fdf0e0; color: #b9761a; }
.pagination { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--c-muted); }
.pagination button { padding: 6px 12px; }

/* ---------- 弹窗表单 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20,40,25,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 14px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--c-border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .close { background: none; border: none; font-size: 22px; color: var(--c-muted); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.result-box { background: #f3f8f3; border: 1px dashed var(--c-primary); border-radius: 10px; padding: 12px 14px; margin-top: 4px; }
.result-box .row { display: flex; justify-content: space-between; padding: 3px 0; }
.result-box .row b { color: var(--c-primary-d); font-size: 15px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-btn { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ---------- 扫码页（移动端） ---------- */
.scan-body { background: #eef2ee; }
.scan-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.scan-head { background: linear-gradient(135deg, #2f7d32, #1f5a22); color: #fff; padding: 16px; text-align: center; }
.scan-head h1 { margin: 0; font-size: 18px; }
.scan-head p { margin: 4px 0 0; font-size: 12px; opacity: .9; }
.scan-body-inner { padding: 14px; flex: 1; }
.scan-card { background: #fff; border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.scan-card h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 6px; }
.scan-card .field { margin-bottom: 12px; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 10px; border: 1px solid var(--c-border); background: #fff; border-radius: 8px; font-weight: 600; color: var(--c-muted); }
.seg button.on { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.scale-btn { width: 100%; background: #2b5fa6; color: #fff; border: none; padding: 12px; border-radius: 10px; font-weight: 600; margin-bottom: 6px; }
.scale-btn:disabled { opacity: .6; }
.scale-note { font-size: 12px; color: var(--c-muted); text-align: center; }
.hist-box { background: #f3f8f3; border-radius: 10px; padding: 12px; font-size: 13px; }
.hist-box .hrow { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed #d7e3d7; }
.hist-box .hrow:last-child { border-bottom: none; }
.hist-box .cum { font-weight: 700; color: var(--c-primary-d); margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #1f3326; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s; z-index: 100; pointer-events: none; }
.toast.show { opacity: 1; }
