/* ============ 结构层：外壳、侧栏、卡片、KPI、表格 ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px; flex: 0 0 208px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: #55504a; font: inherit; font-size: 14px;
  cursor: pointer; text-align: left; transition: .15s;
}
.nav-item span { font-size: 16px; opacity: .85; }
.nav-item:hover { background: #faf9f7; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; }
.who { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; padding: 0 28px 40px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 16px; position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 70%, rgba(246,245,242,0));
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .2px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.title-wrap { display: flex; align-items: center; gap: 10px; }
/* 标题右侧「＋」：无边框、无底色，只一个加粗的加号 */
.title-add {
  position: relative;
  width: 28px; height: 28px; flex: 0 0 28px;
  display: inline-grid; place-items: center;
  padding: 0; margin-left: 1px;
  font-family: inherit; font-size: 20px; font-weight: 800; line-height: 1;
  -webkit-text-stroke: .5px currentColor;   /* 让加号笔画更粗一点 */
  color: var(--accent); background: transparent;
  border: 0; border-radius: 8px; cursor: pointer;
  transition: color .15s, background .15s;
}
.title-add:hover { color: var(--accent-dark); background: rgba(47, 143, 123, .09); }
.title-add:active { background: rgba(47, 143, 123, .16); }

/* ---------- 新增「＋」按钮 ---------- */
.card-head-inline { align-items: center; margin-bottom: 12px; }
.card-head-inline .month-switch { margin-bottom: 0; }
.head-right { display: flex; align-items: center; gap: 10px; }

.add-fab {
  position: relative;
  width: 30px; height: 30px; flex: 0 0 30px;
  display: inline-grid; place-items: center;
  font: inherit; font-size: 17px; line-height: 1;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid #d5e8e2; border-radius: 9px;
  cursor: pointer; transition: .15s;
}
.add-fab:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.add-fab::after, .title-add::after {
  content: attr(data-tip);
  position: absolute; right: 0; top: calc(100% + 7px);
  background: #2c2a26; color: #fff; font-size: 12px; font-weight: 400;
  padding: 5px 9px; border-radius: 6px; white-space: nowrap;
  opacity: 0; transform: translateY(-3px); pointer-events: none;
  transition: .15s; z-index: 30; box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
.add-fab:hover::after, .title-add:hover::after { opacity: 1; transform: none; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(28,25,20,.03);
}
.card.narrow { max-width: 620px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.kpi-grid.kpi-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-label { font-size: 12px; color: var(--muted); letter-spacing: .3px; }
.kpi-value { font-size: 24px; font-weight: 650; margin-top: 6px; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  background: #fbfaf8; white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfbf9; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.compact td { padding: 8px 10px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--line-soft); border-radius: 999px; padding: 3px 9px;
  font-size: 12px; color: #5b564f; white-space: nowrap;
}
.ops { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }

.sum-bar {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  padding: 10px 0 14px; border-top: 1px solid var(--line-soft);
  font-size: 13px; color: #5b564f;
}
.sum-bar b { font-weight: 600; font-variant-numeric: tabular-nums; }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding-bottom: 12px; border-bottom: 1px solid var(--line-soft);
}
.fi { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.fi input, .fi select {
  font: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fdfcfa; color: var(--ink);
  min-width: 120px; outline: none;
}
.fi input:focus, .fi select:focus { border-color: var(--accent); background: #fff; }
.fi-actions { display: flex; gap: 8px; margin-left: auto; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding-top: 14px; }

/* ---------- 手机 ---------- */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row;
    align-items: center; padding: 8px 10px; gap: 6px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
  }
  .brand { display: none; }
  .nav { flex-direction: row; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; -ms-overflow-style: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { padding: 7px 9px; font-size: 13px; white-space: nowrap; border-radius: 8px; }
  .nav-item span { font-size: 14px; }
  .side-foot { margin: 0 0 0 auto; }
  .who { display: none; }
  .main { padding: 0 14px 32px; }
  .kpi-grid, .kpi-grid.kpi-3 { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 20px; }
  .topbar { padding: 10px 0 12px; }
  .card { padding: 16px 14px; }
  .card-head h2 { font-size: 14.5px; }
  .table th, .table td { padding: 9px 8px; }
  .fi { flex: 1 1 44%; }
  .fi input, .fi select { min-width: 0; width: 100%; }
  .fi-actions { margin-left: 0; width: 100%; }
  .fi-actions .btn { flex: 1; }
  .table th:nth-child(4), .table td:nth-child(4) { display: none; }
  /* 手机端：「＋」同样跟在标题后面，只是略小 */
  .title-add { width: 25px; height: 25px; flex: 0 0 25px; font-size: 20px; }
  .topbar-actions { gap: 6px; }
  /* 触屏没有 hover，隐藏气泡提示 */
  .add-fab::after, .title-add::after { display: none; }
}
