/* 账本管家 · 桌面端样式 */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #8a94a6;
  --line: #e8ecf3;
  --primary: #3b6ef6;
  --exp: #f45a52;
  --inc: #2fa97a;
  --sidebar: #101a2e;
  --shadow: 0 6px 24px rgba(23, 42, 84, .07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[v-cloak] { display: none; }
html, body { min-height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
#app { display: flex; min-height: 100vh; align-items: stretch; }
a { cursor: pointer; color: var(--primary); text-decoration: none; }
button {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: .15s;
}
button:hover { border-color: #c6d2ea; background: #f8faff; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: #2d5ce0; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.link { border: none; background: none; color: var(--primary); padding: 2px 6px; }
button.link.danger { color: var(--exp); }
input, select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; background: #fff; color: var(--ink); outline: none;
  font-family: inherit;
}
input:focus, select:focus { border-color: var(--primary); }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-expense { color: var(--exp); font-weight: 600; }
.c-income { color: var(--inc); font-weight: 600; }
.pos { color: var(--inc) !important; }
.neg { color: var(--exp) !important; }
.spacer { flex: 1; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 208px; background: var(--sidebar); color: #c6d0e2;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 22px 20px; font-size: 18px; color: #fff; }
.logo .muted { display: block; color: #70809c; font-size: 11px; margin-top: 2px; }
.logo > span:first-child, .logo { }
.sidebar nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: #aeb9cc; padding: 11px 14px; border-radius: 9px; font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 14px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.sidebar-foot a { color: #8494ad; font-size: 13px; }
.sidebar-foot a:hover { color: #fff; }

/* ---------- 主区域 ---------- */
.content { flex: 1; min-width: 0; padding: 0 26px 40px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 0 18px; position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.topbar h1 { font-size: 21px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.toolbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar.wrap { flex-wrap: wrap; }
.search-input { width: 240px; }
.seg { display: inline-flex; background: #e8ecf5; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 6px 14px; border-radius: 7px; font-size: 13px; }
.seg button.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.seg.big button { padding: 10px 28px; font-size: 15px; font-weight: 600; }
.seg.big button.active.exp { background: var(--exp); color: #fff; }
.seg.big button.active.inc { background: var(--inc); color: #fff; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow);
  border-top: 3px solid transparent;
}
.kpi.expense { border-top-color: var(--exp); }
.kpi.income { border-top-color: var(--inc); }
.kpi.net { border-top-color: var(--primary); }
.kpi-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.kpi-value.small { font-size: 20px; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 8px; }
.kpi-sub em { font-style: normal; margin-left: 6px; }
.delta-up { color: var(--exp); }
.delta-down { color: var(--inc); }

/* ---------- 卡片/图表 ---------- */
.card {
  background: var(--card); border-radius: 14px; padding: 18px 20px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.card.no-pad { padding: 0; overflow: hidden; }
.card h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-md { height: 320px; }
.chart-sm { height: 260px; }

/* ---------- 表格 ---------- */
.data-table, .mini-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td, .mini-table th, .mini-table td {
  padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px;
}
.data-table thead th { background: #f9fafd; color: #667085; font-weight: 600; white-space: nowrap; }
.data-table tbody tr:hover { background: #f8faff; cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }
.mini-table td, .mini-table th { padding: 9px 8px; }
.cat-tag, .kind-tag {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px;
  background: #eef2fb; color: #40507a;
}
.kind-tag.expense { background: #fdeceb; color: var(--exp); }
.kind-tag.income { background: #e6f7f0; color: var(--inc); }
.empty { text-align: center; color: var(--muted); padding: 34px !important; }
.result-bar { margin: -6px 0 12px 4px; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin: 4px 0 20px; }

/* ---------- 热力图 ---------- */
.hm-grid {
  display: grid; grid-auto-flow: column; grid-auto-columns: 13px;
  grid-template-rows: repeat(7, 13px); gap: 3px;
  overflow-x: auto; padding-bottom: 6px; justify-content: start;
}
.hm-cell {
  width: 13px; height: 13px; border-radius: 3px;
  font-size: 0; line-height: 13px; text-align: center; cursor: default;
}
.hm-cell:not(.empty) { font-size: 8px; }
.hm-cell.empty { background: transparent; }
.hm-legend { margin-top: 10px; display: flex; align-items: center; gap: 4px; }
.hm-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }

/* ---------- 预算 ---------- */
.budget-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.budget-form input[type=number] { width: 130px; }
.progress { height: 8px; background: #edf0f6; border-radius: 5px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--inc); border-radius: 5px; transition: width .4s; }
.progress .bar.warn { background: #f9a826; }
.progress .bar.over { background: var(--exp); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16,26,46,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 16px; padding: 26px 28px; width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.modal.wide { width: 640px; }
.modal h2 { font-size: 18px; margin-bottom: 18px; }
.modal input, .modal select { width: 100%; margin: 7px 0 14px; }
.modal .seg { width: 100%; margin-bottom: 18px; }
.modal .seg button { flex: 1; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.token-modal p { margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid label { display: block; font-size: 13px; color: #475066; }
.form-grid .span-2 { grid-column: span 2; }
.amount-input { font-size: 20px !important; font-weight: 700; }
.margin-b { margin: 10px 0; }
.result-pre {
  background: #0f172a; color: #b6e2c8; border-radius: 10px; padding: 12px 14px;
  font-size: 12px; overflow: auto; max-height: 260px; margin-top: 12px; white-space: pre-wrap;
}
.token-pre { color: #ffd98a; }

.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%);
  background: #101a2e; color: #fff; padding: 11px 22px; border-radius: 24px;
  z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.3); font-size: 13px;
}

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
