/* =========================================================
 * style.css —— 轻工作台 · 简洁现代主题
 * ========================================================= */

/* ---------- 设计变量 ---------- */
:root {
  --bg: #eef1f7;
  --card: #ffffff;
  --ink: #1b2233;
  --sub: #697086;
  --muted: #98a0b3;
  --line: #e6eaf2;
  --primary: #4f6ef7;
  --primary-deep: #3d5ce0;
  --primary-soft: #eef1fe;
  --ok: #16a34a;
  --ok-soft: #e9f7ef;
  --warn: #f59e0b;
  --warn-soft: #fdf3e0;
  --bad: #e5484d;
  --bad-soft: #fdecec;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 30px -14px rgba(16, 24, 40, 0.14);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --ring: rgba(79, 110, 247, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
h1, h2, h3, p { margin: 0; }
svg { flex: none; }

::selection { background: rgba(79, 110, 247, 0.22); }

/* 细滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cdd3e2; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b4bcd1; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 应用骨架 ---------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: 236px;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 20px 14px 16px;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #4f6ef7, #7c5cf0);
  color: #fff; font-size: 21px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 6px 14px -6px rgba(79, 110, 247, 0.7);
}
.brand-tx { display: flex; flex-direction: column; line-height: 1.3; }
.brand-tx strong { font-size: 16px; letter-spacing: 0.5px; }
.brand-tx span { font-size: 11.5px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; border: 0; background: transparent;
  padding: 10.5px 12px; border-radius: 12px;
  font-size: 14px; color: #4a5268; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: #f2f4fa; color: var(--ink); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-deep); font-weight: 600; }
.nav-ic { width: 20px; height: 20px; }
.badge {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 600; min-width: 20px; height: 20px;
  border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.side-foot {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 10px 2px; border-top: 1px dashed var(--line);
}
.sf-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.side-foot svg { width: 15px; height: 15px; }
.sf-row .st-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #98a0b3;
}
.sf-row[data-state="db"] .st-dot {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}
.sf-row[data-state="db"] { color: #4d8a63; }
.sf-row[data-state="err"] .st-dot { background: #e5484d; }
.sf-row[data-state="err"] { color: #b24a4d; }
.sf-row[data-state="sync"] .st-dot {
  background: #f59e0b;
  animation: stPulse 1.1s ease infinite;
}
@keyframes stPulse { 50% { opacity: 0.3; } }
.side-reset {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; text-align: left; padding: 2px 0;
  transition: color 0.15s;
}
.side-reset:hover { color: var(--bad); }

.main { margin-left: 236px; min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 14px 24px 10px;
  background: linear-gradient(to bottom, var(--bg) 78%, rgba(238, 241, 247, 0));
}
.top-tx h1 { font-size: 23px; font-weight: 700; letter-spacing: 0.3px; }
.top-tx p { font-size: 13px; color: var(--sub); margin-top: 2px; }
.top-date {
  font-size: 13px; color: var(--sub);
  background: var(--card); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 999px;
  box-shadow: var(--shadow-sm); white-space: nowrap;
}

.views { flex: 1; padding: 4px 24px 20px; }

.view { display: none; }
.view.active { display: block; animation: fadeUp 0.24s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px 0;
}
.card-title { font-size: 15.5px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.card-bd { padding: 10px 18px 14px; }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 11px;
  padding: 9.5px 16px; font-size: 14px; font-weight: 500;
  background: #eef1f7; color: #4a5268;
  transition: all 0.15s; white-space: nowrap;
}
.btn:hover { background: #e3e8f2; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, #4f6ef7, #6a58f0); color: #fff;
  box-shadow: 0 8px 18px -8px rgba(79, 110, 247, 0.75);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--sub); }
.btn.ghost:hover { border-color: #cdd6ea; background: #f7f8fc; color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.danger:hover { background: #fbdbdc; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted);
  transition: all 0.15s;
}
.icon-btn:hover { background: #eef0f6; color: var(--ink); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.icon-btn svg { width: 17px; height: 17px; }

.input, .select, .textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px;
  padding: 9.5px 13px; background: #fff; outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}
.input::placeholder, .textarea::placeholder { color: #b3bac9; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3.5px var(--ring);
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.7; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.field > label { font-size: 13px; font-weight: 600; color: #4a5268; }
.field .hint { font-size: 12px; color: var(--muted); }

/* 分段选择器 */
.seg {
  display: inline-flex; background: #eef1f7; border-radius: 11px; padding: 3px; gap: 2px;
}
.seg-btn {
  border: 0; background: transparent; padding: 6.5px 16px;
  border-radius: 8.5px; font-size: 13.5px; font-weight: 500; color: var(--sub);
  transition: all 0.15s;
}
.seg-btn.active {
  background: #fff; color: var(--ink); font-weight: 600;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.1);
}

/* 标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  line-height: 1.7;
}
.pri-high { background: var(--bad-soft); color: var(--bad); }
.pri-mid  { background: var(--warn-soft); color: #b26a00; }
.pri-low  { background: #eef1f7; color: var(--sub); }
.due-tag  { background: #eef3ff; color: #3d5ce0; }
.due-tag.overdue { background: var(--bad-soft); color: var(--bad); }
.due-tag.today  { background: var(--warn-soft); color: #b26a00; }

/* 进度条 */
.progress { height: 7px; background: #eef1f7; border-radius: 99px; overflow: hidden; flex: 1; }
.prog-bar {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #4f6ef7, #7c5cf0);
  transition: width 0.35s ease;
}

/* 空状态 */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; color: var(--muted);
  padding: 30px 16px; border: 1.5px dashed #d7ddef; border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
}
.empty .emo { font-size: 34px; }
.empty p { font-size: 13.5px; }
.empty .sub { font-size: 12.5px; }

/* ---------- 待办 ---------- */
.todo-wrap { display: flex; flex-direction: column; gap: 12px; }
.todo-add { display: flex; gap: 10px; padding: 12px 18px; align-items: center; }
.todo-add .input { flex: 1; padding: 11px 14px; }
.prio-wrap { display: flex; gap: 6px; }
.prio-btn {
  border: 1.5px solid var(--line); background: #fff;
  font-size: 12.5px; border-radius: 9px; padding: 7px 11px; color: var(--sub);
  transition: all 0.12s; white-space: nowrap;
}
.prio-btn[data-v="high"]:hover, .prio-btn[data-v="high"].on { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.prio-btn[data-v="mid"]:hover,  .prio-btn[data-v="mid"].on  { border-color: var(--warn); color: #b26a00; background: var(--warn-soft); }
.prio-btn[data-v="low"]:hover,  .prio-btn[data-v="low"].on  { border-color: #98a0b3; color: var(--sub); background: #eef1f7; }

.todo-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.todo-head .prog-tx { font-size: 13px; color: var(--sub); white-space: nowrap; }
.todo-head .prog-tx b { color: var(--ink); }
.todo-mid { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 18px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: #fff; color: var(--sub);
  font-size: 12.5px; border-radius: 999px; padding: 5px 13px;
  transition: all 0.13s;
}
.chip:hover { border-color: #c9d2e5; color: var(--ink); }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-deep); font-weight: 600; }

.todo-list { list-style: none; margin: 0; padding: 4px 10px 10px; }
.todo-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  transition: background 0.13s;
}
.todo-item:hover { background: #f6f8fc; }
.todo-item + .todo-item { border-top: 1px dashed #ccc; }
.todo-item.done { opacity: 0.62; }

.todo-check {
  width: 22px; height: 22px; border-radius: 50%; flex: none; margin-top: 2px;
  border: 2px solid #c3cadd; background: #fff; display: grid; place-items: center;
  transition: all 0.16s; color: transparent; padding: 0;
}
.todo-check:hover { border-color: var(--primary); }
.todo-item.done .todo-check { background: linear-gradient(135deg, #4f6ef7, #6a58f0); border-color: transparent; color: #fff; }
.todo-check svg { width: 12px; height: 12px; }

.todo-main { flex: 1; min-width: 0; }
.todo-text {
  font-size: 14.5px; word-break: break-word; cursor: text;
  transition: color 0.15s;
}
.todo-item.done .todo-text {color: var(--muted-light); }
.todo-edit-input {
  width: 100%; font-size: 14.5px; padding: 5px 8px;
  border: 1.5px solid var(--primary); border-radius: 8px; outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}
.todo-meta { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.todo-side { display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.todo-item:hover .todo-side { opacity: 1; }

/* ---------- 笔记 ---------- */
.note-toolbar { display: flex; gap: 10px; align-items: center; padding: 16px 18px; }
.note-toolbar .search-box { position: relative; flex: 1; max-width: 380px; }
.search-box svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.search-box .input { padding-left: 36px; }
.note-count { font-size: 12.5px; color: var(--muted); }

.note-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 12px; padding: 6px 18px 14px;
}
.note-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px 12px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.15s;
  border-top: 3px solid var(--primary);
  display: flex; flex-direction: column; min-height: 122px;
}
.note-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #d5dcf0; }
.note-card[hidden] { display: none; }
.nc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nc-title { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.nc-del { opacity: 0; }
.note-card:hover .nc-del { opacity: 1; }
.nc-prev {
  margin-top: 8px; font-size: 13px; color: var(--sub); flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word; white-space: pre-line;
}
.nc-time { margin-top: 6px; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(23, 30, 50, 0.42);
  display: grid; place-items: center; padding: 20px;
  animation: fadeIn 0.18s ease;
  backdrop-filter: blur(2px);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 540px; max-height: 88vh; overflow: auto;
  background: var(--card); border-radius: 18px; box-shadow: 0 24px 70px -18px rgba(16, 24, 40, 0.45);
  animation: popIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  padding: 20px 22px;
}
.modal-card.wide { max-width: 800px; max-height: 900px; }
@keyframes popIn { from { opacity: 0; transform: scale(0.96) translateY(10px); } to { opacity: 1; transform: none; } }
.m-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.m-title { font-size: 17px; font-weight: 700; }
.m-ft { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.m-field { margin-bottom: 13px; }
.m-field > label { display: block; font-size: 13px; font-weight: 600; color: #4a5268; margin-bottom: 6px; }
.color-pick { display: flex; gap: 8px; }
.cpick {
  width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid transparent;
  transition: transform 0.12s;
}
.cpick:hover { transform: scale(1.15); }
.cpick.on { border-color: var(--ink); box-shadow: inset 0 0 0 3px #fff; }

/* ---------- 记账 ---------- */
.fin-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.fs-card { padding: 16px 18px; border-radius: var(--radius); position: relative; overflow: hidden; }
.fs-card::after {
  content: ''; position: absolute; right: -22px; top: -22px;
  width: 86px; height: 86px; border-radius: 50%; opacity: 0.09;
}
.fs-card .fs-label { font-size: 12.5px; color: var(--sub); display: flex; align-items: center; gap: 6px; }
.fs-card .fs-val { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: 0.2px; font-variant-numeric: tabular-nums; }
.fs-card .fs-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fs-val.pos { color: var(--ok); }
.fs-val.neg { color: var(--bad); }
.fs-card.income { background: linear-gradient(135deg, #ffffff, #f2fbf5); }
.fs-card.expense { background: linear-gradient(135deg, #ffffff, #fff6f0); }
.fs-card.balance { background: linear-gradient(135deg, #ffffff, #f2f4ff); }
.fs-card.income::after { background: var(--ok); }
.fs-card.expense::after { background: var(--bad); }
.fs-card.balance::after { background: var(--primary); }

.fin-layout { display: grid; grid-template-columns: 400px 1fr; gap: 12px; align-items: start; margin-top: 12px; }
.fin-form-card { position: sticky; top: 92px; }
.fin-form { padding: 4px 20px 20px; }
.fin-form .ff-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.fin-form .ff-top select { width: auto; }
.ff-amount-row { display: flex; align-items: center; gap: 6px; margin: 12px 0; }
.ff-amount-row .cur { font-size: 21px; font-weight: 700; color: var(--sub); }
.amount-input {
  flex: 1; border: none; outline: none; font-size: 30px; font-weight: 700;
  padding: 2px 0; background: transparent; letter-spacing: 0.5px;
  border-bottom: 2px solid transparent; transition: border 0.15s;
  font-variant-numeric: tabular-nums;
}
.amount-input:focus { border-color: var(--primary); }
.amount-input::placeholder { color: #c6ccda; }
.amount-input[type="number"]::-webkit-outer-spin-button,
.amount-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.ff-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.cat-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-pill {
  border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  padding: 6px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.13s; color: #4a5268;
}
.cat-pill:hover { border-color: #c9d2e5; }
.cat-pill.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-deep); font-weight: 600; }
.cat-pill .emo { font-size: 15px; }

.fin-list-card .card-bd { padding-top: 10px; }
.month-hd { display: flex; align-items: center; gap: 10px; }
.month-hd .sel { margin-left: auto; }

.day-hd {
  font-size: 12px; color: var(--muted); font-weight: 600;
  margin: 14px 2px 2px; display: flex; align-items: center; gap: 8px;
}
.day-hd::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.day-hd .day-sum { font-weight: 400; margin-left: auto; }
.fin-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 12px; transition: background 0.13s;
}
.fin-item:hover { background: #f6f8fc; }
.fin-item + .fin-item { border-top: 1px dashed #edf0f7; }
.fi-emo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-size: 18px;
  background: #f2f4fa;
}
.fi-main { flex: 1; min-width: 0; }
.fi-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.fi-cat { font-size: 11px; color: var(--muted); font-weight: 400; }
.fi-note { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.fi-date { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.fi-amt { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fi-amt.pos { color: var(--ok); }
.fi-amt.neg { color: var(--ink); }
.fin-item.expense .fi-amt.neg::before { content: '−'; }

/* ---------- 看板 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  padding: 12px 14px; border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px;
}
.stat-ic {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 20px;
}
.stat-ic.b { background: var(--primary-soft); }
.stat-ic.g { background: var(--ok-soft); }
.stat-ic.r { background: var(--bad-soft); }
.stat-ic.y { background: var(--warn-soft); }
.stat-val { font-size: 19px; font-weight: 700; line-height: 1.2; letter-spacing: 0.2px; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.stat-sub .u { color: var(--ok); font-weight: 600; }
.stat-sub .d { color: var(--bad); font-weight: 600; }

.chart-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 12px; margin-top: 12px; }
.chart-card { padding-bottom: 14px; }
.chart-card .card-bd { padding-top: 10px; }
.cc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.chart-card.wide { grid-column: 1 / -1; }

/* 图表内部 */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 4px 2px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--sub); }
.legend-item i.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend-item b { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 2px; }
.legend-item em { font-style: normal; color: var(--muted); margin-left: 2px; font-size: 11.5px; }
.chart-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 34px 10px; color: var(--muted); text-align: center;
}
.chart-empty span { font-size: 26px; }
.chart-empty p { font-size: 12.5px; }

.donut-flex { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut-flex .donut-svg { flex: 0 0 196px; }
.donut-flex .legend { flex: 1; flex-direction: column; gap: 0; min-width: 150px; padding-top: 2px; }
.donut-flex .legend-item {
  display: grid; grid-template-columns: 10px 1fr auto auto;
  align-items: center; gap: 8px; padding: 5px 8px; border-radius: 9px;
}
.donut-flex .legend-item:hover { background: #f5f7fc; }
.donut-flex .legend-item .dot { width: 10px; height: 10px; border-radius: 50%; }
.donut-flex .legend-item b { font-variant-numeric: tabular-nums; text-align: right; min-width: 60px; }
.donut-flex .legend-item em { font-style: normal; color: var(--muted); font-size: 12px; text-align: right; min-width: 36px; }
.legend-col { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 2px; }
.stat-val.pos { color: var(--ok); }
.stat-val.neg { color: var(--bad); }
.clickable { transition: transform 0.15s, box-shadow 0.15s; }
.clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(229,72,77,0.15); }
.clickable.active-filter { box-shadow: 0 0 0 2px var(--bad), 0 4px 12px rgba(229,72,77,0.15); }
.clickable.active-filter.pos-filter { box-shadow: 0 0 0 2px var(--ok), 0 4px 12px rgba(22,163,74,0.15); }

/* 首页引导 */
.welcome {
  text-align: center; padding: 36px 24px 24px;
}
.welcome .big { font-size: 52px; line-height: 1; }
.welcome h2 { font-size: 22px; margin: 14px 0 8px; }
.welcome p { color: var(--sub); max-width: 480px; margin: 0 auto; font-size: 14px; }
.quick-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-item { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-radius: 10px; }
.recent-item:hover { background: #f5f7fc; }
.recent-item + .recent-item { border-top: 1px dashed #edf0f7; }
.ri-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ri-tx { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* ---------- 待办：完成反馈 / 改期 / 跟进 ---------- */
.follow-tag { background: #eef6ff; color: #2563c4; }
.crt-tag {
  background: transparent; color: var(--muted); font-weight: 400;
  border: 1px dashed #d7ddef;
}
.todo-fb-list {
  margin-top: 7px; background: #f4f6fb; border: 1px solid #d7ddef;
  border-radius: 9px; padding: 6px 10px; cursor: pointer;
}
.todo-fb-item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: 3px 0;
}
.todo-fb-item + .todo-fb-item { border-top: 1px dashed #e4e7ee; }
.todo-fb-text { font-size: 12.5px; color: #1b2233; flex: 1; word-break: break-word; line-height: 1.5; }
.todo-fb-time { font-size: 11px; color: #98a0b3; white-space: nowrap; }
.todo-fb-more { font-size: 11.5px; color: var(--primary); text-align: center; margin-top: 4px; }
.todo-fb-list:hover { border-color: #c4d0ee; background: #eef2fc; }
.fb-badge {
  position: absolute; top: -4px; right: -4px; background: var(--primary); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.icon-btn { position: relative; }
.fb-item { padding: 8px 0; border-bottom: 1px dashed #edf0f7; }
.fb-item:last-child { border-bottom: none; }
.fb-content { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.fb-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.fb-time { font-size: 11.5px; color: var(--muted); }
@media (hover: none) {
  .todo-item .todo-side { opacity: 1; }
}
.modal-hint { font-size: 12.5px; color: var(--muted); margin: -6px 0 12px; }
.m-line { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(14px);
  background: #1c2438; color: #fff; font-size: 13.5px;
  padding: 10px 20px; border-radius: 999px;
  box-shadow: 0 14px 34px -10px rgba(10, 16, 30, 0.5);
  opacity: 0; pointer-events: none; z-index: 200;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #a12d31; }
.toast.ok { background: #1c2438; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .fin-layout { grid-template-columns: 1fr; }
  .fin-form-card { position: static; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 880px) {
  .sidebar {
    position: static; width: auto; flex-direction: column;
    padding: 10px 12px 6px;
  }
  .brand { padding: 4px 6px 10px; }
  .brand-tx { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .nav-item { padding: 8px 13px; white-space: nowrap; justify-content: center; }
  .nav-tx { font-size: 13px; }
  /* 窄窗口下保留数据库状态与「退出登录」，其余脚注项收起 */
  .side-foot {
    display: flex; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 4px 14px;
    padding: 6px 6px 2px; border-top: 1px dashed var(--line);
  }
  .side-foot > .sf-row:not(#db-status):not(.sf-user) { display: none; }
  .side-reset { display: none; }
  .sf-user .sf-user-name { max-width: 140px; }
  .main { margin-left: 0; }
  .chart-grid, .cc-row { grid-template-columns: 1fr; }
  .topbar { padding: 16px 18px 10px; align-items: center; }
  .views { padding: 4px 18px 30px; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .fin-sum { grid-template-columns: 1fr; }
  .todo-add { flex-wrap: wrap; }
  .todo-add .input { flex: 1 1 100%; }
  .note-grid { grid-template-columns: 1fr; }
  .top-date { display: none; }
}

/* =========================================================
 * 发票进销项管理模块
 * ========================================================= */
.inv-wrap { display: flex; flex-direction: column; gap: 12px; }
.inv-wrap .stat-grid { margin: 0; }

.itab-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.itab-bar .chip { font-size: 13.5px; padding: 7px 16px; }

/* —— 表格 —— */
.tbl-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 880px; }
.inv-wrap table.tbl th:first-child { width: 240px; }
.inv-wrap table.tbl td:first-child { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-wrap table.tbl td:first-child .td-sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-wrap table.tbl th:nth-child(3), .inv-wrap table.tbl td:nth-child(3) { width: 90px; white-space: nowrap; }
.inv-wrap table.tbl th:nth-child(4), .inv-wrap table.tbl td:nth-child(4) { width: 60px; white-space: nowrap; }
.tbl th { white-space: nowrap; }
.tbl th {
  background: #f6f8fc; text-align: left; padding: 9px 12px;
  color: #5a6278; font-weight: 600; font-size: 12.5px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 9px 12px; border-bottom: 1px dashed #edf0f7; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.tbl td:first-child { white-space: normal; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #f7f9fd; }
.tbl td.tnum, .tbl th.tnum { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.t-ops { white-space: nowrap; text-align: right; }
.td-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.tbl-note { font-size: 11.5px; color: var(--muted); padding: 10px 16px 12px; }

.stk { font-weight: 700; }
.stk.pos { color: var(--ok); }
.stk.neg { color: var(--bad); }
.stk.zero { color: var(--muted); }

/* —— 发票登记表单（紧凑多行布局） —— */
.inv-form { display: flex; flex-direction: column; padding: 4px 20px 20px; }
.inv-form .ff-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.ff-row3 { display: grid; grid-template-columns: 1fr 1fr 120px; gap: 10px; margin-bottom: 6px; }
.ff-row3 .field { margin-bottom: 0; }
.inv-detail-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0 6px; border-top: 1px solid var(--line); margin-top: 6px;
}
.idh-h { font-size: 14px; font-weight: 700; }
.idh-r { font-size: 12px; color: var(--muted); }

.inv-lines-wrap { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ln-head {
  display: grid; grid-template-columns: minmax(140px, 1.3fr) minmax(80px, 1fr) 120px 120px 32px;
  gap: 6px; padding: 8px 12px 6px; background: #f6f8fc;
}
.ln-c-prod, .ln-c-name, .ln-c-qty, .ln-c-price {
  font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap;
}
.ln-c-qty, .ln-c-price { text-align: center; }
.ln-row {
  display: grid; grid-template-columns: minmax(140px, 1.3fr) minmax(80px, 1fr) 120px 120px 32px;
  gap: 6px; align-items: center; padding: 6px 12px;
  border-top: 1px dashed #edf0f7;
}
.ln-row:first-child { border-top: 0; }
.ln-row .input { padding: 6px 8px; border-radius: 8px; font-size: 13px; }
.ln-row .ln-name { background: #fafbfe; color: var(--sub); }

/* ± 按钮组 */
.qty-ctrl, .price-ctrl {
  display: flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden;
}
.qty-btn {
  width: 28px; border: none; background: #f5f7fc; font-size: 16px; font-weight: 600;
  cursor: pointer; color: var(--sub); display: grid; place-items: center;
  transition: background 0.12s, color 0.12s;
}
.qty-btn:hover { background: #eef1f7; color: var(--ink); }
.qty-val {
  width: 52px; border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  text-align: center; font-size: 13.5px; font-variant-numeric: tabular-nums;
  padding: 4px 0; background: #fff;
}
.qty-val:focus { outline: none; background: #f8faff; }
/* 隐藏数字输入框的原生上下箭头 */
.qty-val::-webkit-inner-spin-button,
.qty-val::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qty-val { -moz-appearance: textfield; appearance: textfield; }

#inv-lines { overflow-x: auto; }
#inv-lines > .ln-row { min-width: 520px; }

.ln-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.ln-count { font-size: 12px; color: var(--muted); background: #f1f3f9; border-radius: 999px; padding: 4px 12px; }

.inv-total {
  margin-top: 10px; background: #f5f7fc; border: 1px solid #e8ecf5;
  border-radius: 12px; padding: 10px 14px; font-size: 13px; color: #5a6278;
}
.inv-total b { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }

/* —— 发票台账 —— */
.inv-ledger-sum { padding: 0 20px 10px; font-size: 12.5px; color: var(--muted); }
.inv-ledger-sum b { color: var(--ink); font-variant-numeric: tabular-nums; }

.inv-item { border-bottom: 1px dashed #edf0f7; }
.inv-item:last-child { border-bottom: 0; }
.inv-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border-radius: 12px; cursor: pointer;
  flex-wrap: wrap;
}
.inv-row:hover { background: #f6f8fc; }
.ir-main { flex: 1; min-width: 240px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ir-no { font-size: 14px; }
.ir-date, .ir-party, .ir-kind { font-size: 12px; color: var(--muted); }
.ir-sums { text-align: right; font-variant-numeric: tabular-nums; }
.ir-sums b { font-size: 15px; }
.ir-sums em { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.ir-caret { color: var(--muted); font-size: 11px; }
.ir-detail { overflow-x: auto; border-top: 1px dashed var(--line); padding: 4px 8px 10px; }
.ir-detail table.tbl { min-width: 560px; }

.tag-in { background: #eef3ff; color: #3d5ce0; }
.tag-out { background: #e9f7ef; color: #12804a; }
.tag-linked { background: #f0e6ff; color: #6b21a8; font-size: 10px; }
.tag-s-pending { background: #fef3cd; color: #856404; }
.tag-s-verified { background: #d4edda; color: #155724; }
.tag-s-invalid { background: #f8d7da; color: #721c24; }

@media (max-width: 640px) {
  .ir-sums { flex: 1 1 100%; text-align: left; }
  .tbl th, .tbl td { padding: 8px 8px; }
}

/* —— 记账：发票号码徽标与操作 —— */
.fi-name { flex-wrap: wrap; }
.fi-inv {
  font-size: 11px; font-weight: 500; color: #3d5ce0;
  background: #eef3ff; padding: 1px 8px; border-radius: 999px;
  white-space: nowrap; max-width: 190px;
  overflow: hidden; text-overflow: ellipsis; display: inline-block;
  vertical-align: middle;
}
.fi-acts { display: flex; gap: 2px; }

/* 商品库存表加宽，横向滚动查看 */
.inv-wrap .tbl { min-width: 980px; }
.inv-wrap .fi-inv { max-width: 210px; }

/* —— 记账本：分类统计弹窗 —— */
.cat-stat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-stat-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cs-emo {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 15px;
}
.cs-name { width: 56px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-bar { flex: 1; height: 8px; background: #eef1f7; border-radius: 99px; overflow: hidden; }
.cs-bar i { display: block; height: 100%; border-radius: 99px; transition: width 0.4s ease; }
.cs-amt { font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 80px; text-align: right; }
.cs-pct { width: 36px; text-align: right; color: var(--muted); font-size: 12px; }

/* —— 日记博客列表样式 —— */
.note-blog {
  padding: 12px 16px 14px;
  border-left: 3px solid var(--primary);
  margin-bottom: 2px;
  background: #fff;
  transition: background 0.15s;
}
.note-blog:hover { background: #f8f9fc; }
.note-blog.archived { opacity: 0.5; border-left-style: dashed; }
.note-blog.archived:hover { opacity: 0.7; }

.nb-title {
  font-size: 16px; font-weight: 700; margin: 0 0 6px; line-height: 1.4;
}
.nb-title a {
  color: var(--link); text-decoration: none; cursor: pointer;
}
.nb-title a:hover { text-decoration: underline; }

.nb-summary {
  font-size: 13px; color: #697086; line-height: 1.6; margin: 0;
}
.nb-read {
  color: var(--link); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.nb-read:hover { text-decoration: underline; }

.nb-body {
  font-size: 14px; color: var(--text); line-height: 1.8; margin: 0 0 6px;
  white-space: pre-wrap; word-break: break-word;
}

.nb-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-top: 8px; padding-top: 6px;
  border-top: 1px solid #f0f1f5;
}
.nb-date { font-variant-numeric: tabular-nums; }
.nb-actions { display: flex; gap: 2px; }

.archive-tag {
  background: #e0e7ff; color: #4338ca; font-size: 10px;
  padding: 1px 6px; border-radius: 4px; margin-left: 6px; font-weight: 500;
  display: inline-block; vertical-align: middle;
}
.done-tag {
  background: #dcfce7; color: #15803d; font-size: 10px;
  padding: 1px 6px; border-radius: 4px; margin-left: 6px; font-weight: 500;
  display: inline-block; vertical-align: middle;
}
.done-btn.on { color: var(--ok); }

/* —— 日记：按月份分组 —— */
.note-month { margin: 0 0 4px; }
.nm-hd {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 14px 6px; padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
}
.nm-label { font-size: 13px; font-weight: 700; color: var(--text); }
.nm-count { font-size: 11px; color: var(--muted); }
.note-blog-list {
  padding: 0 10px;
}

/* —— 发票台账：分页 —— */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 12px 4px; font-size: 13px; color: var(--sub);
  border-top: 1px dashed var(--line); margin-top: 6px;
}
.pager .pg-info { font-variant-numeric: tabular-nums; }
.pager .pg-size { width: auto; padding: 3px 6px; font-size: 12px; }

/* —— 仪表盘：进销项概览卡片 —— */
.inv-snapshot { display: flex; flex-direction: column; gap: 0; }
.is-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.is-row:last-child { border-bottom: 0; }
.is-label { color: var(--sub); }
.is-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.is-val.pos { color: var(--ok); }
.is-val.neg { color: var(--bad); }

/* =========================================================
 * 登录鉴权
 * ========================================================= */

/* 未登录时锁住整页，只显示登录遮罩 */
html.auth-locked body > *:not(.auth-overlay) { display: none !important; }
html.auth-locked, html.auth-locked body { overflow: hidden; }

.auth-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1000px 520px at 12% -8%, #dfe6ff 0%, rgba(238, 241, 247, 0) 62%),
    radial-gradient(900px 520px at 92% 108%, #e6e2ff 0%, rgba(238, 241, 247, 0) 60%),
    var(--bg);
  animation: fadeIn 0.2s ease;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-overlay.auth-overlay-out { opacity: 0; transition: opacity 0.2s ease; pointer-events: none; }

.auth-card {
  width: 100%; max-width: 390px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 26px 70px -22px rgba(16, 24, 40, 0.4);
  padding: 26px 24px 20px;
  animation: popIn 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.auth-brand .brand-tx { display: flex; flex-direction: column; line-height: 1.3; }
.auth-brand .brand-tx strong { font-size: 16px; letter-spacing: 0.5px; }

.auth-title { font-size: 20px; font-weight: 700; }
.auth-sub { font-size: 13px; color: var(--sub); margin: 5px 0 18px; }
.auth-form .field { margin-bottom: 12px; }
.auth-form .input { padding: 11px 14px; font-size: 16px; }
.auth-submit { width: 100%; padding: 12px 16px; font-size: 15px; margin-top: 4px; }
.auth-submit:disabled { opacity: 0.7; cursor: default; }

.auth-err {
  background: var(--bad-soft); color: var(--bad);
  border-radius: 10px; padding: 9px 12px; font-size: 13px;
  margin-bottom: 10px;
}
.auth-foot { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 16px; }

/* 侧边栏：登录用户 + 退出 + 手机版入口 */
.sf-user { gap: 7px; }
.sf-user .sf-user-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--sub); font-size: 11.5px;
}
.side-logout {
  border: 0; background: transparent; color: var(--muted);
  font-size: 11.5px; padding: 2px 6px; border-radius: 7px;
  transition: color 0.15s, background 0.15s;
}
.side-logout:hover { color: var(--bad); background: var(--bad-soft); }
.side-mobile-link {
  font-size: 11.5px; color: var(--muted); text-decoration: none;
  padding: 2px 0;
}
.side-mobile-link:hover { color: var(--primary); }
