:root {
  --bg: #090b11;
  --card: #12161f;
  --card-2: #171c27;
  --line: rgba(255, 255, 255, 0.075);
  --text: #e9edf6;
  --muted: #8a93a8;
  --yes: #4c8dff;
  --no: #ff7a59;
  --profit: #38d39f;
  --warn: #e8b339;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.small { font-size: 11.5px; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(76, 141, 255, 0.13), transparent 55%), #090b11;
  padding: 20px;
}
.login-box {
  width: min(100%, 400px);
  padding: 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.login-brand { color: var(--yes); font-weight: 750; letter-spacing: 0.08em; font-size: 15px; }
.login-brand small { color: var(--muted); font-size: 11px; }
.login-box h1 { margin: 22px 0 4px; font-size: 24px; }
.login-hint { margin: 0 0 22px; color: var(--muted); font-size: 12.5px; }
.login-box label { display: block; margin: 14px 0 6px; font-size: 12px; color: #c2cadb; font-weight: 600; }
.login-box input {
  width: 100%; padding: 11px 13px; border-radius: 9px;
  border: 1px solid var(--line); background: #0d1119; color: var(--text); outline: none;
}
.login-box input:focus { border-color: rgba(76, 141, 255, 0.6); }
.login-box .primary { width: 100%; margin-top: 22px; }
.login-error { margin: 12px 0 0; color: #ff9d9d; font-size: 12px; }
.login-tip { margin: 16px 0 0; color: #5f6879; font-size: 11px; line-height: 1.6; }
.back-link { display: inline-block; margin-top: 14px; color: var(--muted); font-size: 12px; }
.back-link:hover { color: var(--text); }

.primary {
  padding: 10px 18px; border: none; border-radius: 9px;
  background: linear-gradient(100deg, #2f6fe0, #5b9bff);
  color: #fff; font-weight: 650;
}
.primary:hover { filter: brightness(1.12); }
.ghost {
  padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05);
  color: #cbd3e2; font-size: 12.5px; font-weight: 600;
}
.ghost:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.yes-text { color: #9cc1ff; }
.no-text { color: #ffab91; }
.warn-text { color: var(--warn); }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px;
  border-right: 1px solid var(--line);
  background: #0d1017;
  padding: 22px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { padding: 0 8px 22px; color: var(--yes); font-weight: 750; letter-spacing: 0.06em; }
.side-brand small { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.2em; }
.sidebar nav { display: flex; flex-direction: column; gap: 5px; }
.nav-btn {
  text-align: left; padding: 10px 13px; border-radius: 9px;
  border: 1px solid transparent; background: none; color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav-btn.active { background: rgba(76, 141, 255, 0.13); border-color: rgba(76, 141, 255, 0.28); color: #a9c8ff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.side-link { background: none; border: none; padding: 0; text-align: left; color: var(--muted); font-size: 12px; }
.side-link:hover { color: var(--text); }
.side-status { color: #4e5768; font-size: 10.5px; }

.content { flex: 1; min-width: 0; padding: 26px 30px 50px; max-width: 1400px; }
.content-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.content-head h1 { margin: 0; font-size: 23px; }
.content-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.conn { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--profit); }
.conn.bad i { background: #ff6b6b; }

/* ---------- 概览 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  padding: 16px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; gap: 4px;
}
.stat span { color: var(--muted); font-size: 11.5px; }
.stat b { font-size: 26px; font-weight: 750; }
.stat small { color: #5f6879; font-size: 10.5px; }

.panel {
  padding: 20px 22px; margin-bottom: 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 14.5px; }
.badge { padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; background: rgba(56, 211, 159, 0.1); color: #7fe0b6; }
.badge.closed { background: rgba(232, 179, 57, 0.1); color: var(--warn); }
.badge.settled { background: rgba(255, 255, 255, 0.06); color: #b9c0cf; }
.cur-project strong { font-size: 17px; }
.cur-project p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.quick-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.quick-actions > span { color: var(--muted); font-size: 12px; margin-right: 4px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #c2cadb; font-weight: 600; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid textarea, .filters input, .filters select, .modal input {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: #0d1119; color: var(--text); outline: none; font-weight: 400; resize: vertical;
}
.form-grid input:focus, .form-grid textarea:focus, .filters input:focus, .modal input:focus { border-color: rgba(76, 141, 255, 0.6); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- 表格 ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input { width: 160px; }
.filters select { min-width: 110px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; padding: 10px 12px; color: var(--muted); font-size: 11px; font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }
.tag-y { color: #9cc1ff; background: rgba(76, 141, 255, 0.12); padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 700; }
.tag-n { color: #ffab91; background: rgba(255, 122, 89, 0.12); padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 700; }
.tag-void { color: #b9c0cf; background: rgba(255, 255, 255, 0.07); padding: 2px 8px; border-radius: 5px; font-size: 11px; }
.tag-off { color: #ff9d9d; background: rgba(255, 107, 107, 0.1); padding: 2px 8px; border-radius: 5px; font-size: 11px; }
.tag-on { color: #7fe0b6; background: rgba(56, 211, 159, 0.1); padding: 2px 8px; border-radius: 5px; font-size: 11px; }
.pos-delta { color: var(--profit); font-weight: 700; }
.neg-delta { color: #ff9d9d; font-weight: 700; }
.row-btn { padding: 4px 9px; border-radius: 6px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: #cbd3e2; font-size: 11px; margin-right: 5px; }
.row-btn:hover { background: rgba(255, 255, 255, 0.13); color: #fff; }
.row-btn.danger { color: #ffb3b3; }
.empty-row { text-align: center; color: var(--muted); padding: 30px 0; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 12px; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.65); padding: 20px; }
.modal { width: min(100%, 400px); padding: 24px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.modal h2 { margin: 0 0 16px; font-size: 17px; }
.modal label { display: block; margin: 12px 0 6px; color: #c2cadb; font-size: 12px; }
.modal input { width: 100%; }
.modal p { color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  padding: 11px 20px; border-radius: 10px; background: #1c2230;
  border: 1px solid rgba(255, 255, 255, 0.14); box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 107, 107, 0.45); color: #ffb3b3; }
.toast.ok { border-color: rgba(56, 211, 159, 0.4); color: #a8ecd0; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex: none; padding: 14px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { flex-direction: row; align-items: center; margin-top: 12px; }
  .content { padding: 20px 16px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
}
