:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --text: #1c2b26;
  --text-2: #5f6e68;
  --text-3: #93a09a;
  --brand: #0F6E56;
  --brand-2: #0a5240;
  --brand-light: #e1f5ee;
  --danger: #c23a3a;
  --danger-light: #fceaea;
  --warn: #b06a10;
  --warn-light: #faf1df;
  --border: #e2e7e4;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 40, 30, .07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; background: var(--surface); outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; }

/* ---------- 登录 ---------- */
#login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #e1f5ee 0%, #f4f6f5 55%);
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow);
  padding: 40px 36px; width: 100%; max-width: 380px; text-align: center;
}
.login-logo {
  width: 60px; height: 60px; border-radius: 16px; background: var(--brand);
  color: #fff; font-size: 30px; font-weight: 600; line-height: 60px; margin: 0 auto 14px;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--text-2); font-size: 12px; margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-err { color: var(--danger); font-size: 12px; min-height: 18px; }

/* ---------- 布局 ---------- */
#main-view { display: flex; min-height: 100vh; }
#sidebar {
  width: 200px; background: #0d3328; color: #cfe6dd; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 20;
}
.side-brand {
  padding: 20px 18px 16px; font-size: 16px; font-weight: 600; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: #1D9E75; display: inline-block; }
#side-nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.side-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: #b9d4c9; padding: 9px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 2px;
}
.side-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-item.active { background: var(--brand); color: #fff; font-weight: 500; }
.side-group-title {
  font-size: 11px; color: #6f9484; padding: 12px 12px 4px; letter-spacing: 1px;
}
.side-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side-foot .btn-ghost { color: #9dbfb2; border-color: transparent; margin-top: 6px; padding: 2px 0; }
#content { flex: 1; margin-left: 200px; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  height: 52px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 10;
}
#topbar-title { font-weight: 600; font-size: 15px; }
#topbar-actions { display: flex; align-items: center; gap: 10px; }
.top-user { color: var(--text-2); font-size: 12px; }
#view { padding: 20px 22px 80px; max-width: 1100px; width: 100%; }

/* ---------- 按钮 ---------- */
.btn-primary {
  background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 9px 18px;
}
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 14px; color: var(--text-2);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: none; border: 1px solid var(--danger); color: var(--danger); border-radius: 8px; padding: 7px 14px; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

/* ---------- 卡片与网格 ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card h3 { font-size: 14px; margin-bottom: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.metric {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
}
.metric .m-label { color: var(--text-2); font-size: 12px; }
.metric .m-value { font-size: 24px; font-weight: 600; margin-top: 2px; }
.metric .m-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.metric.warn .m-value { color: var(--danger); font-size: 15px; line-height: 1.4; }

/* ---------- 列表 ---------- */
.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.row-item:hover { background: var(--surface-2); }
.row-item .ri-main { min-width: 0; }
.row-item .ri-title { font-size: 14px; }
.row-item .ri-sub { color: var(--text-3); font-size: 12px; }
.row-item .ri-amount { font-weight: 600; white-space: nowrap; }
.row-item .ri-tags { display: flex; gap: 6px; margin-top: 3px; }
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--surface-2);
  color: var(--text-2);
}
.tag.inv { background: var(--brand-light); color: var(--brand); }
.tag.deleted { background: var(--danger-light); color: var(--danger); }

/* ---------- 筛选条 ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center;
}
.filter-bar input, .filter-bar select { width: auto; padding: 7px 10px; font-size: 13px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-item label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.form-item.full { grid-column: 1 / -1; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 16px;
  padding: 6px 14px; font-size: 13px; color: var(--text-2);
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.upload-box {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 18px;
  text-align: center; color: var(--text-3); cursor: pointer; font-size: 13px;
}
.upload-box:hover { border-color: var(--brand); color: var(--brand); }
.upload-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.upload-previews img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
}
.ocr-panel {
  background: var(--brand-light); border-radius: 8px; padding: 10px 14px; font-size: 12px;
  margin-top: 8px; color: var(--brand-2);
}
.ocr-panel b { font-weight: 600; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-2); font-weight: 500; white-space: nowrap; }
td .btn-sm { margin-right: 4px; }

/* ---------- 图表 ---------- */
.trend-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.trend-bar {
  width: 100%; max-width: 34px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px;
}
.trend-month { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.trend-val { font-size: 10px; color: var(--text-2); }
.hbar-row { margin-bottom: 10px; }
.hbar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 3px; }
.hbar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar > div { height: 100%; background: var(--brand); border-radius: 4px; }

/* ---------- 弹窗 ---------- */
#modal-mask {
  position: fixed; inset: 0; background: rgba(10, 30, 22, .45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#modal-box {
  background: var(--surface); border-radius: 14px; padding: 22px;
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
}
#modal-box h3 { margin-bottom: 14px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
#lightbox-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 60;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 20px;
}
#lightbox-img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1c2b26; color: #fff; border-radius: 8px; padding: 10px 20px; font-size: 13px;
  box-shadow: var(--shadow); animation: fadein .2s;
}
.toast.err { background: var(--danger); }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

/* ---------- 底部导航（手机）/ FAB（全端通用悬浮加号） ---------- */
#bottom-nav { display: none; }
#fab {
  display: block; position: fixed; right: 26px; bottom: 26px; z-index: 21;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: #D85A30; color: #fff; font-size: 25px; line-height: 1;
  box-shadow: 0 4px 12px rgba(216, 90, 48, .4);
  transition: transform .12s ease;
}
#fab:hover { transform: scale(1.08); }
.empty { text-align: center; color: var(--text-3); padding: 30px 0; font-size: 13px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; color: var(--text-2); font-size: 13px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  #sidebar { display: none; }
  #content { margin-left: 0; }
  #view { padding: 14px 14px 110px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  #topbar { padding: 0 14px; }
  #topbar-actions .top-user { display: none; }
  #bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bn-item {
    background: none; border: 0; color: var(--text-3); font-size: 11px;
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 10px; min-width: 56px;
  }
  .bn-item .bn-ico { font-size: 17px; line-height: 1; font-family: sans-serif; }
  .bn-item.active { color: var(--brand); font-weight: 600; }
  #fab { right: 18px; bottom: 84px; width: 54px; height: 54px; font-size: 26px; }
  table { display: block; overflow-x: auto; }
}
