:root{
  --bg: #f5f7fb;
  --surface: #ffffff;
  --primary: #4f6ef7;
  --primary-dark: #3b56d6;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e8f0;
  --danger: #e5484d;
  --success: #1a9d6b;
  --shadow: 0 10px 30px rgba(31,36,48,.08);
  --radius: 16px;
}
*{ box-sizing: border-box; }
html, body{ margin:0; padding:0; }
body{
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
.muted{ color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- 登录页 ---------- */
.auth-page{
  display:flex; align-items:center; justify-content:center;
  min-height:100vh;
  background: linear-gradient(135deg,#eef2ff 0%,#f5f7fb 60%);
  padding:24px;
}
.auth-card{
  width:100%; max-width:400px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:40px 32px;
}
.brand{ text-align:center; margin-bottom:28px; }
.brand-logo{ font-size:48px; }
.brand-name{ font-size:22px; margin:12px 0 4px; }
.brand-sub{ color: var(--muted); font-size:14px; margin:0; }
.auth-form .field{ display:block; margin-bottom:18px; }
.field-label{ display:block; font-size:13px; color: var(--muted); margin-bottom:6px; }
.field input{
  width:100%; padding:12px 14px;
  border:1px solid var(--border); border-radius:10px;
  font-size:15px; outline:none;
  background:#fbfcfe;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus{ border-color: var(--primary); box-shadow:0 0 0 3px rgba(79,110,247,.15); }
.form-error{ color:#e5484d; font-size:13px; margin:0 0 12px; }
.btn{
  cursor:pointer; border:none; border-radius:10px;
  font-size:15px; padding:12px 18px; font-weight:600;
  transition: background .2s, transform .05s;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{ background: var(--primary); color:#fff; }
.btn-primary:hover{ background: var(--primary-dark); }
.btn-block{ width:100%; }
.btn-ghost{ background:transparent; color: var(--muted); padding:7px 14px; font-size:13px; border-radius:8px; }
.btn-ghost:hover{ background: rgba(0,0,0,.04); color: var(--text); }
.auth-hint{ text-align:center; color: var(--muted); font-size:12px; margin:18px 0 0; }

/* ---------- 顶栏 ---------- */
.topbar{
  background: var(--surface);
  border-bottom:1px solid var(--border);
  position:sticky; top:0; z-index:10;
}
.topbar-inner{
  max-width:960px; margin:0 auto; padding:12px 20px;
  display:flex; align-items:center; justify-content:space-between;
}
.topbar-left{ display:flex; align-items:center; gap:12px; }
.topbar-right{ display:flex; align-items:center; gap:12px; }
.topbar-brand{ font-weight:700; font-size:15px; white-space:nowrap; }
.topbar-module{
  font-weight:600; font-size:14px;
  color: var(--primary); background: rgba(79,110,247,.08);
  padding:5px 14px; border-radius:999px; white-space:nowrap;
}

/* ---------- 容器 ---------- */
.container{ max-width:960px; margin:0 auto; padding:32px 20px; }
.welcome{ margin-bottom:28px; }
.welcome h2{ margin:0 0 4px; font-size:24px; }

/* ---------- 模块卡片网格 ---------- */
.card-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(260px,1fr));
  gap:20px;
}
.module-card{
  display:flex; align-items:center; gap:16px;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:22px;
  text-decoration:none; color:inherit;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.module-card:hover{
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 14px 36px rgba(31,36,48,.12);
}
.module-icon{ font-size:36px; flex-shrink:0; }
.module-body{ flex:1; }
.module-title{ margin:0 0 4px; font-size:17px; }
.module-desc{ margin:0; font-size:13px; color: var(--muted); }
.module-arrow{ font-size:22px; color: var(--primary); }

/* ---------- 模块占位页 ---------- */
.module-page{
  min-height:60vh;
  display:flex; align-items:center; justify-content:center;
}
.placeholder{ text-align:center; max-width:460px; }
.placeholder-icon{ font-size:56px; }
.placeholder h2{ margin:12px 0 8px; }

/* ---------- 账单模块 ---------- */
.topbar-module-sep{ color: var(--muted); margin: 0 8px; font-weight: 400; }
.link-back{
  display:inline-flex; align-items:center; gap:4px;
  color: var(--muted); text-decoration:none; font-size:13px; font-weight:500;
  padding:5px 10px; border-radius:8px;
  transition: background .18s, color .18s;
}
.link-back:hover{ color: var(--primary); background: rgba(79,110,247,.06); }
.link-back:active{ transform: translateY(1px); }

.tabs{ display:flex; gap:8px; flex-wrap:wrap; margin: 8px 0 24px; border-bottom:1px solid var(--border); }
.tab{
  cursor:pointer; border:none; background:transparent;
  padding:10px 14px; font-size:15px; color:var(--muted);
  border-bottom:2px solid transparent; margin-bottom:-1px; font-weight:600;
}
.tab:hover{ color: var(--text); }
.tab.active{ color: var(--primary); border-bottom-color: var(--primary); }

.section{ display:none; }
.section.active{ display:block; }
.section h3{ margin: 0 0 14px; font-size:19px; }
.section-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; gap:12px; flex-wrap:wrap; }
.section-head h3{ margin:0; }

.kpi-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:16px; margin-bottom:28px; }
.kpi{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px; box-shadow:var(--shadow); }
.kpi-val{ font-size:26px; font-weight:700; }
.kpi-label{ color:var(--muted); font-size:13px; margin-top:4px; }
.kpi.warn .kpi-val{ color:#e5890b; }
.kpi.danger .kpi-val{ color:#e5484d; }
.kpi.ok .kpi-val{ color:#1a9d6b; }

.module-table{ width:100%; border-collapse:collapse; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow); }
.module-table th, .module-table td{ padding:12px 14px; text-align:left; font-size:14px; border-bottom:1px solid var(--border); }
.module-table th{ background:#fafbff; color:var(--muted); font-weight:600; font-size:13px; }
.module-table tr:last-child td{ border-bottom:none; }
.module-table tbody tr:hover{ background:#f8f9ff; }
.num{ text-align:right; font-variant-numeric:tabular-nums; }

.badge{ display:inline-block; padding:2px 10px; border-radius:999px; font-size:12px; font-weight:600; }
.badge-paid{ background:rgba(26,157,107,.12); color:#1a9d6b; }
.badge-unpaid{ background:rgba(229,137,11,.14); color:#c9770a; }
.badge-overdue{ background:rgba(229,72,77,.14); color:#e5484d; }
.badge-none{ background:rgba(120,130,145,.14); color:#6b7686; }
.plan-toggle{ cursor:pointer; transition: opacity .15s, transform .1s; }
.plan-toggle:hover{ opacity:.75; transform: scale(1.08); }
.plan-toggle:active{ transform: scale(.95); }

.toolbar{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; align-items:flex-end; }
.toolbar .field{ margin:0; }
.toolbar select, .toolbar input{ padding:9px 12px; border:1px solid var(--border); border-radius:10px; font-size:14px; background:#fbfcfe; outline:none; }
.toolbar select:focus, .toolbar input:focus{ border-color:var(--primary); }
.toolbar .field-label{ font-size:12px; margin-bottom:4px; }

.bar-chart{ display:flex; align-items:flex-end; gap:10px; height:220px; padding:20px 16px 16px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); overflow-x:auto; }
.bar-col{ display:flex; flex-direction:column; align-items:center; gap:6px; min-width:42px; flex:1; }
.bar-col.selected .bar{ background:linear-gradient(180deg,#f0883e,var(--primary-dark)); box-shadow:0 0 0 2px rgba(240,136,62,.25); }
.bar-col.selected .bar-val{ color:#e5484d; }
.bar-col.selected .bar-lbl{ color:var(--primary-dark); font-weight:700; }

/* 月份范围筛选控件：分段按钮 + 月份选择器 */
.range-filter{ display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.range-filter.standalone{ margin-bottom:20px; }
.seg{ display:inline-flex; background:#eef1f8; border-radius:12px; padding:4px; gap:2px; }
.seg-btn{
  border:none; background:transparent; cursor:pointer;
  padding:8px 18px; font-size:14px; font-weight:600; color:var(--muted);
  border-radius:9px; transition: background .18s, color .18s, box-shadow .18s;
  white-space:nowrap;
}
.seg-btn:hover{ color:var(--text); }
.seg-btn.active{ background:#fff; color:var(--primary); box-shadow:0 2px 8px rgba(31,36,48,.12); }
.range-inputs{ display:inline-flex; align-items:center; gap:8px; }
.month-input{
  padding:9px 12px; border:1px solid var(--border); border-radius:10px;
  font-size:14px; background:#fbfcfe; outline:none; color:var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.month-input:focus{ border-color:var(--primary); box-shadow:0 0 0 3px rgba(79,110,247,.15); }
.range-sep{ color:var(--muted); font-size:14px; }
.cell-empty{ color:#c2c8d0; font-style:normal; }
.row-empty td:first-child{ color:var(--muted); }
.row-empty td{ background:rgba(0,0,0,.015); }
.bar{ width:100%; max-width:46px; background:linear-gradient(180deg,var(--primary),var(--primary-dark)); border-radius:6px 6px 0 0; min-height:2px; transition:height .3s; }
.bar-val{ font-size:12px; color:var(--text); font-weight:600; white-space:nowrap; }
.bar-lbl{ font-size:11px; color:var(--muted); }

.row-actions{ display:flex; gap:8px; }
.btn-sm{ padding:6px 10px; font-size:13px; border-radius:8px; }
.btn-danger{ background:#fff; color:#e5484d; border:1px solid #f3c2c4; }
.btn-danger:hover{ background:#fdeced; }
.btn-outline{ background:#fff; color:var(--primary); border:1px solid var(--border); }
.btn-outline:hover{ background:rgba(79,110,247,.06); }

.banner{ padding:12px 16px; border-radius:12px; margin-bottom:16px; font-size:14px; }
.banner-info{ background:rgba(79,110,247,.08); color:var(--primary-dark); }
.banner-warn{ background:rgba(229,137,11,.12); color:#9a5b05; }
.banner-danger{ background:rgba(229,72,77,.10); color:#b3261e; }

.entry-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:14px; }
.entry-card{ background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:14px; }
.entry-card .ec-name{ font-weight:600; font-size:14px; margin-bottom:4px; }
.entry-card .ec-info{ display:flex; justify-content:space-between; font-size:12px; color:var(--muted); margin-bottom:10px; }
.entry-card input{ width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:8px; font-size:14px; margin-bottom:8px; background:#fbfcfe; outline:none; }
.entry-card input:focus{ border-color:var(--primary); }
.entry-card select{ width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:8px; font-size:13px; background:#fbfcfe; }
.plan-month{ margin-bottom:22px; }
.plan-month h4{ margin:0 0 10px; font-size:15px; }
.plan-row{ display:flex; align-items:center; justify-content:space-between; padding:10px 14px; background:var(--surface); border:1px solid var(--border); border-radius:10px; margin-bottom:8px; }
.plan-row .pr-left{ display:flex; align-items:center; gap:12px; }
.plan-row .pr-day{ font-size:12px; color:var(--muted); }
.plan-row.done{ border-color:rgba(26,157,107,.4); }
.plan-row.pending{ border-color:rgba(229,137,11,.4); }

.empty{ text-align:center; color:var(--muted); padding:40px; }

/* ---------- 透视表（可横滚） ---------- */
.pivot-wrap{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  border-radius: var(--radius);
  border:1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.pivot-wrap .module-table{
  border:none; box-shadow:none; border-radius:0; margin:0;
  min-width:max-content;
}
.pivot-wrap th,
.pivot-wrap td{
  white-space:nowrap;
  padding:10px 12px;
  font-size:13px;
}
.pivot-wrap th{
  background:#f5f7fa;
  color:var(--text);
  font-weight:600;
  position:sticky;
  top:0;
  z-index:1;
}
.pivot-wrap tbody tr:last-child td{ border-bottom:none; }
.pivot-wrap .pivot-total-row{ background:#f0f3ff !important; }
.pivot-wrap .pivot-total-row td{ font-weight:700; color:var(--text); }
.pivot-wrap .pivot-grand{ color:var(--primary) !important; font-weight:700 !important; }

/* 模态框 */
.modal-mask{ position:fixed; inset:0; background:rgba(20,24,35,.45); display:none; align-items:center; justify-content:center; padding:20px; z-index:50; }
.modal-mask.active{ display:flex; }
.modal{ background:var(--surface); border-radius:var(--radius); padding:24px; width:100%; max-width:420px; box-shadow:var(--shadow); }
.modal h3{ margin:0 0 16px; }
.modal .field{ display:block; margin-bottom:14px; }
.modal .field-label{ font-size:13px; color:var(--muted); margin-bottom:6px; display:block; }
.modal .field input, .modal .field select{ width:100%; padding:10px 12px; border:1px solid var(--border); border-radius:10px; font-size:14px; background:#fbfcfe; outline:none; }
.modal .field input:focus, .modal .field select:focus{ border-color:var(--primary); }
.modal-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:8px; }
