:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --ink: #1f2a26;
  --ink-2: #55635d;
  --ink-3: #8b968f;
  --line: #e3ded4;
  --brand: #2b4b43;
  --brand-2: #3f6a5d;
  --gold: #b98a3e;
  --red: #b3453c;
  --green: #2f7a52;
  --amber: #b07d22;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 42, 38, .06), 0 8px 24px rgba(31, 42, 38, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.err { color: var(--red); min-height: 20px; margin: 6px 0 0; font-size: 13px; }
.hint { color: var(--ink-3); font-size: 12px; margin-top: 14px; }
code { background: #f0ede6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 15% 0%, rgba(43, 75, 67, .10), transparent 60%),
    radial-gradient(700px 380px at 95% 100%, rgba(185, 138, 62, .12), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px 22px;
  box-shadow: var(--shadow);
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .3px; }
.brand p { margin: 2px 0 0; font-size: 12px; }
.brand-mark {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  color: #f7f3e8;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}
.brand-mark.sm { width: 34px; height: 34px; flex-basis: 34px; font-size: 16px; border-radius: 9px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
/* 注意：input:not([type]) 必须带上。手写的 <input data-f="x"> 不带 type 时也要撑满，
   否则浏览器给它默认 150px 宽，会跟左边的标签挤在同一行。 */
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfcf9;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(63, 106, 93, .12);
}
textarea { resize: vertical; min-height: 70px; font-size: 13px; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f7f5f0; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #f8f5ec; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--red); border-color: #e8cdc9; }
.btn.danger:hover { background: #fbf1f0; }
.btn.block { width: 100%; padding: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- 布局 ---------------- */
.layout { display: grid; grid-template-columns: 216px 1fr; min-height: 100%; }

.sidebar {
  background: #fbfaf6;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand { display: flex; gap: 10px; align-items: center; padding: 2px 6px 16px; }
.side-title { font-weight: 600; font-size: 14px; }
.side-sub { font-size: 11px; color: var(--ink-3); }

#nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
#nav .nav-group { font-size: 11px; color: var(--ink-3); padding: 12px 8px 4px; letter-spacing: .5px; }
#nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13px;
}
#nav a:hover { background: #f1eee7; color: var(--ink); }
#nav a.active { background: var(--brand); color: #f8f5ec; }
#nav a .badge {
  background: #e7e2d7; color: var(--ink-2);
  border-radius: 999px; padding: 0 7px; font-size: 11px;
}
#nav a.active .badge { background: rgba(255, 255, 255, .2); color: #fff; }

.side-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.who { font-size: 12px; color: var(--ink-2); padding: 0 6px 8px; }
.who b { display: block; color: var(--ink); font-size: 13px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, .9);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page { padding: 20px 24px 60px; }

/* ---------------- 卡片 / 表格 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.card .sub { color: var(--ink-3); font-size: 12px; margin: 0 0 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { font-size: 12px; color: var(--ink-3); }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 2px; letter-spacing: .5px; }
.stat .v small { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 4px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { width: 220px; }
.toolbar select { width: auto; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-3); font-weight: 500; font-size: 12px; background: #fbfaf6; white-space: nowrap; }
tbody tr:hover { background: #fcfbf7; }
td.num { font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--ink-3); padding: 34px 0; font-size: 13px; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag.gray { background: #f1efe9; color: var(--ink-2); }
.tag.green { background: #e8f3ec; color: var(--green); }
.tag.amber { background: #fbf2e0; color: var(--amber); }
.tag.red { background: #fbeceb; color: var(--red); }
.tag.blue { background: #e9eff7; color: #35597f; }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
.form-grid .req::after { content: " *"; color: var(--red); }
.form-grid .help { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.section-title {
  grid-column: 1 / -1;
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  padding-top: 8px; border-top: 1px dashed var(--line);
  margin-top: 4px;
}
.section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px;
}
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #f8f5ec; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translate(-50%, 20px);
  background: #21302b;
  color: #f6f3ea;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #6d2a24; }

/* ---------------- 弹层 ---------------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(24, 32, 29, .38);
  display: grid; place-items: center;
  padding: 24px;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(20, 30, 26, .25);
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--panel); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: var(--panel); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

/* ================= 易用性改造新增 ================= */

/* ---- 导航图标 ---- */
#nav a { gap: 8px; justify-content: flex-start; }
#nav a > span:first-of-type { flex: 1; }
.nav-ico {
  width: 16px; height: 16px; flex: 0 0 16px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .8;
}
#nav a.active .nav-ico { opacity: 1; }

/* ---- 面包屑 ---- */
.title-wrap { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.crumbs { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { margin: 0 6px; color: var(--line); }

/* ---- 每页说明条 ---- */
.guide { padding: 12px 16px; border-left: 3px solid var(--brand); }
.guide .g-row { display: flex; gap: 10px; font-size: 13px; line-height: 1.75; }
.guide .g-row b { flex: 0 0 7.6em; color: var(--ink-2); font-weight: 600; }
.guide .g-row span { color: var(--ink-3); }
.guide .g-row a { color: var(--brand-2); }

/* ---- 页签 ---- */
.tab-badge {
  display: inline-block; margin-left: 5px;
  background: #e7e2d7; color: var(--ink-2);
  border-radius: 999px; padding: 0 6px; font-size: 11px;
}
.tabs button.on .tab-badge { background: rgba(255, 255, 255, .22); color: #fff; }
.node-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.node-head h3 { margin: 0 0 2px; font-size: 16px; }

/* ---- chips（多选 / 关联） ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 28px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #f8f5ec; }
.chip.locked { opacity: .5; cursor: not-allowed; }
.chip .x { font-size: 13px; line-height: 1; color: var(--ink-3); }
.chip.on .x { color: #fff; }
.picker-list {
  list-style: none; margin: 8px 0 0; padding: 0;
  max-height: 240px; overflow: auto;
  border: 1px solid var(--line); border-radius: 8px;
}
.picker-list li { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.picker-list li:last-child { border-bottom: 0; }
.picker-list li:hover { background: #f7f5ef; }

/* ---- 图片列表 ---- */
.img-list { display: flex; flex-direction: column; gap: 10px; }
.img-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.img-item .thumb {
  width: 96px; height: 68px; flex: 0 0 96px;
  object-fit: cover; border-radius: 6px; background: #f1efe9;
}
.img-item .thumb.broken { display: grid; place-items: center; font-size: 10px; color: var(--ink-3); text-align: center; }
.img-item .cap { flex: 1; min-width: 0; }

/* ---- 键值行 / 开关 ---- */
.kv-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.kv-row input:first-child { flex: 1; }
.kv-row input[type=number] { width: 110px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.switch input { width: auto; }
.switch-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }

/* ---- 高级 JSON 逃生门 ---- */
.adv { margin-top: 8px; }
.adv summary { font-size: 12px; color: var(--ink-3); cursor: pointer; }
.adv textarea { margin-top: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* ---- 吸底保存 ---- */
.sticky-save {
  position: sticky; bottom: 0; z-index: 2;
  background: var(--panel); border-top: 1px solid var(--line);
  padding-top: 12px; margin-top: 10px;
}

/* ---- 对齐：必填标记与栅格间距 ---- */
.form-grid label { margin-bottom: 0; }
.form-grid .req::after { content: " *"; color: var(--red); }

/* ---- 组合控件里的次级小标签（时间/费用后面的补充说明框） ---- */
.mini-label {
  display: block; font-size: 11px; color: var(--ink-3);
  margin: 10px 0 4px;
}

/* ---------- 近 7 天走势（纯 div 柱状图） ---------- */
.tr {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 140px;
  padding: 10px 4px 0;
  border-bottom: 1px solid var(--line);
}
.tr-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.tr-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}
.tr-bar {
  display: block;
  width: 12px;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
}
.tr-bar.pv { background: var(--green); }
.tr-bar.ai { background: #8fbfa4; }
.tr-x {
  margin-top: 6px;
  text-align: center;
  font-size: 11px;
  color: #8a8275;
  white-space: nowrap;
  overflow: hidden;
}
.tr-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
  font-size: 12px;
  color: #6b6459;
}
.tr-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 5px;
}
.tr-dot.pv { background: var(--green); }
.tr-dot.ai { background: #8fbfa4; }
