:root {
  --bg: #f4f6f4;
  --card: #ffffff;
  --border: #dde4de;
  --border-light: #edf1ed;
  --text: #1f2a24;
  --subtext: #6b7e72;
  --muted: #b8c4bc;
  --accent: #167a5c;
  --accent-dark: #115e47;
  --accent-light: #e3f2ec;
  --success: #12805c;
  --danger: #c84b4b;
  --secondary-bg: #f2f5f2;
  --orange: #de9e3e;
  --orange-dark: #b07620;
  --weekend: #d67a4a;
  --shadow: 0 6px 20px rgba(20, 45, 33, 0.07);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 18px 40px;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(150deg, var(--accent), var(--accent-dark));
  box-shadow: 0 3px 8px rgba(22, 122, 92, 0.3);
}
.brand h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: 0.5px; }
.perkm-pill {
  background: var(--accent-light);
  color: var(--accent-dark);
  border: 1px solid #cfe6dc;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* 页签 */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 5px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  flex: 1;
  min-width: 72px;
  border: none;
  background: transparent;
  color: var(--subtext);
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.tab:hover { background: var(--secondary-bg); color: var(--text); }
.tab.active {
  background: linear-gradient(150deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 10px rgba(22, 122, 92, 0.28);
}

/* 视图与卡片 */
.view { display: none; }
.view.active { display: block; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

/* 月份导航与日历 */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.month-label { font-size: 17px; font-weight: 700; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--secondary-bg);
  color: var(--accent-dark);
  font-size: 20px;
  line-height: 1;
}
.icon-btn:hover { background: var(--accent-light); }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekhead {
  text-align: center;
  font-size: 12.5px;
  color: var(--subtext);
  font-weight: 600;
  padding: 4px 0;
}
.weekhead.weekend { color: var(--weekend); }
.daycell {
  position: relative;
  min-height: 62px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--card);
  padding: 6px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
}
.daycell.blank { border: none; background: transparent; box-shadow: none; }
.daycell:not(.blank):hover { border-color: var(--accent); background: var(--accent-light); }
.daycell.selected { border-color: var(--accent); background: var(--accent-light); box-shadow: 0 0 0 1px var(--accent) inset; }
.daycell.today .daynum::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--orange);
  margin-left: 4px;
  vertical-align: middle;
}
.daynum { font-size: 13.5px; font-weight: 600; color: var(--text); }
.daycell.weekend .daynum { color: var(--weekend); }
.day-km { font-size: 11.5px; color: var(--accent-dark); font-weight: 600; line-height: 1.1; }
.day-amt { font-size: 10.5px; color: var(--orange-dark); line-height: 1.1; }

/* 表单 */
.day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.day-title { font-size: 16px; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; flex: 1; }
.field-label { font-size: 13px; color: var(--subtext); font-weight: 600; }
.field-row { display: flex; gap: 12px; }
.input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 122, 92, 0.14);
}
.input::placeholder { color: var(--muted); }
.input.readonly { background: var(--secondary-bg); color: var(--accent-dark); font-weight: 600; }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23167A5C' stroke-width='2' fill='none' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }

.info-line {
  min-height: 20px;
  font-size: 13px;
  color: var(--subtext);
  background: var(--secondary-bg);
  border-radius: 9px;
  padding: 8px 11px;
  margin-bottom: 13px;
}
.info-line:empty { display: none; }

/* 按钮 */
.btn-row { display: flex; gap: 12px; margin-top: 4px; }
.primary-btn, .danger-btn, .ghost-btn {
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.primary-btn { flex: 1; background: linear-gradient(150deg, var(--accent), var(--accent-dark)); color: #fff; box-shadow: 0 4px 12px rgba(22,122,92,0.28); }
.primary-btn:hover { filter: brightness(1.06); }
.danger-btn { background: #fff; color: var(--danger); border-color: #e6c2c2; }
.danger-btn:hover { background: #fbeeee; }
.ghost-btn { background: var(--secondary-bg); color: var(--subtext); border-color: var(--border); }
.ghost-btn:hover { background: var(--accent-light); color: var(--accent-dark); }

/* 汇总 */
.sum-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sum-title { font-size: 17px; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--secondary-bg); border: 1px solid var(--border-light); border-radius: 12px; padding: 14px 10px; text-align: center; }
.stat-num { font-size: 21px; font-weight: 700; color: var(--accent-dark); }
.stat-label { font-size: 12.5px; color: var(--subtext); margin-top: 3px; }
.chart-wrap { width: 100%; margin-bottom: 8px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }

.drill-list { display: grid; gap: 8px; margin-top: 10px; }
.drill-item {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--card);
  transition: all 0.15s ease;
}
.drill-item.clickable:hover { border-color: var(--accent); background: var(--accent-light); }
.drill-item .di-name { font-weight: 600; }
.drill-item .di-val { color: var(--subtext); font-size: 13.5px; }
.drill-item .di-val b { color: var(--accent-dark); }

/* 项目表 */
.table-wrap { overflow-x: auto; }
.pj-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pj-table th, .pj-table td { padding: 10px 9px; text-align: left; border-bottom: 1px solid var(--border-light); white-space: nowrap; }
.pj-table th { color: var(--subtext); font-weight: 600; background: var(--secondary-bg); }
.pj-table td.del-cell { text-align: center; color: var(--danger); cursor: pointer; font-weight: 600; }
.pj-table td.del-cell:hover { background: #fbeeee; }
.pj-table td.edit-cell { text-align: center; color: var(--accent-dark); cursor: pointer; font-weight: 600; }
.pj-table td.edit-cell:hover { background: var(--accent-light); }
.pj-table td.action-cell { text-align: center; }
.empty-tip { color: var(--muted); text-align: center; padding: 22px 0; font-size: 14px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(22, 32, 27, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 50;
}
.modal {
  background: #fff; border-radius: 16px; padding: 22px;
  width: 100%; max-width: 360px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.25);
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.modal-text { color: var(--subtext); font-size: 14.5px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .ghost-btn, .modal-actions .danger-btn { padding: 9px 18px; }

/* 提示 */
.toast {
  position: fixed; left: 50%; bottom: 34px;
  transform: translateX(-50%);
  background: rgba(26, 38, 32, 0.94);
  color: #fff; padding: 11px 20px;
  border-radius: 999px; font-size: 14px;
  z-index: 60; max-width: 88%; text-align: center;
}

/* 手机适配 */
@media (max-width: 640px) {
  .app { padding: 13px 12px 32px; }
  .brand h1 { font-size: 18px; }
  .perkm-pill { font-size: 12px; padding: 6px 11px; }
  .card { padding: 15px; border-radius: 12px; }
  .tab { padding: 9px 4px; font-size: 14px; min-width: 64px; }
  .daycell { min-height: 52px; padding: 5px 2px; }
  .day-km { font-size: 10.5px; }
  .day-amt { font-size: 9.5px; }
  .field-row { gap: 10px; }
  .stat-grid { gap: 8px; }
  .stat { padding: 11px 6px; }
  .stat-num { font-size: 17px; }
  .stat-label { font-size: 11.5px; }
  .primary-btn, .danger-btn, .ghost-btn { padding: 11px 14px; }
}

@media (max-width: 380px) {
  .calendar { gap: 4px; }
  .daycell { min-height: 46px; border-radius: 8px; }
  .field-row { flex-direction: column; gap: 0; }
}
