/* Apple 风格简洁界面 */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --danger: #ff3b30;
  --success: #34c759;
  --warning: #ff9f0a;
  --border: #e3e3e6;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶部导航 */
.topbar {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { font-weight: 600; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: rgba(0, 0, 0, 0.04); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.badge {
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.05);
  padding: 4px 10px;
  border-radius: 999px;
}

/* 布局 */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
.muted { color: var(--text-secondary); }

/* 卡片 */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.center-card { text-align: center; padding: 48px 24px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-danger { background: #c62828; color: #fff; }
.btn-danger:hover { background: #a11c1c; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-disabled { background: #e5e5ea; color: #8e8e93; cursor: not-allowed; }
.btn-disabled:hover { background: #e5e5ea; color: #8e8e93; }
.btn-ghost:hover { background: rgba(0, 113, 227, 0.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 0;
}
.btn-link.danger { color: var(--danger); }

/* 表单 */
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field span { color: var(--text-secondary); font-size: 13px; }
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="email"],
select,
textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 160px; }

/* 个人佣金添加行：用户/月份/金额/保存 单行并排，不折行 */
.commission-add-row { flex-wrap: nowrap; align-items: flex-end; }
.commission-add-row > * { min-width: 0; }
.commission-add-row .field:last-child { flex: 0 0 auto; }
.commission-add-row select,
.commission-add-row input { width: 100%; }

/* 总佣金重算行：重算月份 + 显眼按钮 单行并排 */
.overall-recalc-row { flex-wrap: nowrap; }
.overall-recalc-row .field { flex: 0 1 auto; min-width: 0; }
.overall-recalc-row .field:last-child { flex: 0 0 auto; }

/* 提示 */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fff0f0; color: #c0392b; border: 1px solid #ffd7d5; }
.alert-success { background: #eefaf1; color: #1e7e34; border: 1px solid #cdeed6; }
.alert-warning { background: #fff7ec; color: #b25700; border: 1px solid #ffe4c2; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f2;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.amount-income { color: var(--success); font-variant-numeric: tabular-nums; }
.amount-expense { color: var(--text); font-variant-numeric: tabular-nums; }
.amount-negative { color: var(--danger); font-variant-numeric: tabular-nums; }

/* 徽标 */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
}
.tag-blue { background: rgba(0, 113, 227, 0.12); color: #0a63b8; }
.tag-red { background: rgba(255, 59, 48, 0.12); color: #c0342b; }
.tag-green { background: rgba(52, 199, 89, 0.14); color: #1e7e34; }
.tag-orange { background: rgba(255, 159, 10, 0.16); color: #b25700; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-label small { font-size: 11px; color: var(--text-secondary); }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-secondary); margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.stat-card-accent { background: linear-gradient(135deg, #1c1c1e, #2c2c2e); }
.stat-card-accent .stat-label { color: #a1a1a6; }
.stat-card-accent .stat-value { color: #ffffff; }

/* 表盘期间切换 */
.period-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.period-toggle { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); }
.period-toggle a { padding: 6px 18px; border-radius: 999px; font-size: 14px; color: var(--text-secondary); }
.period-toggle a:hover { text-decoration: none; }
.period-toggle a.active { background: var(--accent); color: #fff; }

/* 流水筛选条：四组选项同一行并列，窄屏横向滚动 */
.filter-bar { overflow-x: auto; margin-bottom: 14px; }
.filter-form { display: flex; align-items: flex-end; gap: 14px; white-space: nowrap; }
.filter-form .field { margin-bottom: 0; }
.filter-form .field span { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.filter-form select { min-width: 96px; }

/* 对账差异明细：左右对照 */
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.diff-col { min-width: 0; }
.diff-head { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.diff-title { font-size: 15px; margin: 14px 0 8px; }

/* 明细行悬停显示"修改" */
.diff-col table tbody tr .edit-tx { visibility: hidden; }
.diff-col table tbody tr:hover .edit-tx { visibility: visible; }
.diff-col td .edit-tx { padding: 0; }

/* 对账明细编辑弹窗 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-backdrop[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); padding: 20px; width: min(760px, 92vw); max-height: 88vh; overflow: auto; }
.modal-card .form-actions .btn-ghost.tx-cancel { display: inline-flex; }
.empty.small { font-size: 13px; padding: 18px 0; }
@media (max-width: 720px) { .diff-grid { grid-template-columns: 1fr; } }

/* 账户拖拽手柄 */
.drag-handle { cursor: grab; user-select: none; -webkit-user-select: none; width: 28px; text-align: center; font-size: 16px; }
.drag-handle:active { cursor: grabbing; }

/* 表单分段选项（类型/来源/收付方式） */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-option { display: inline-flex; flex-shrink: 0; }
.seg-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg-option span { display: inline-block; padding: 6px 18px; border-radius: 8px; font-size: 14px; color: var(--text-secondary); cursor: pointer; white-space: nowrap; line-height: 1.4; }
.seg-option input:checked + span { background: var(--accent); color: #fff; }

/* 登录页 */
.auth-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 380px; padding: 32px; }
.auth-title { font-size: 24px; font-weight: 700; text-align: center; margin: 0 0 4px; }
.auth-sub { color: var(--text-secondary); text-align: center; margin: 0 0 24px; }

/* 其他 */
.inline-form { display: inline; }
.flex-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-actions { display: flex; gap: 12px; margin-top: 6px; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav input[type="month"] { padding: 6px 10px; }
.ledger-switch select { max-width: 220px; }
.field-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.field-hint { color: var(--text-secondary); font-size: 12px; }
.error-code { font-size: 64px; font-weight: 800; margin: 0 0 8px; color: var(--text-secondary); }
.empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
}
.table-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }
