:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.04);
  --transition: 0.15s ease;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration:none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }
a.del { color: var(--danger); }
a.del:hover { color: var(--danger-hover); }

/* ── 顶部导航 ── */
.topbar {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 56px;
}
.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.topbar nav {
  display:flex;
  gap:2px;
  flex-wrap:wrap;
}
.topbar nav a {
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 12.5px;
  color: rgba(255,255,255,.75);
  transition: all var(--transition);
  font-weight: 500;
  white-space: nowrap;
}
.topbar nav a:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
}
.topbar nav a.active {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-weight: 600;
}

/* ── 容器 ── */
.container {
  max-width: 1120px;
  margin: 28px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── 卡片 ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
}

/* ── 表单 ── */
#form-card {
  background: linear-gradient(to bottom, #f8fafc 0%, #fff 100%);
  border-color: var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px 20px;
}
.field { display:flex; flex-direction:column; gap:5px; }
.field.full { grid-column:1 / -1; }
.field label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}
.field .req { color: var(--danger); margin-left: 1px; }
.field input, .field select {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: all var(--transition);
  font-family: inherit;
}
.field input:hover, .field select:hover { border-color: #cbd5e1; }
.field input:focus, .field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.field input[readonly] {
  background: #f8fafc;
  color: var(--text-muted);
  border-style: dashed;
  font-weight: 500;
}

.btn-row { display:flex; gap:10px; align-items:center; margin-top:6px; flex-wrap:wrap; }

.btn-primary {
  padding: 9px 22px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: 0.3px;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(59,130,246,.3); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  padding: 9px 22px;
  background: #fff;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; }

.btn-sm {
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 6px;
}

/* ── 批量录入行 ── */
.batch-row {
  margin-bottom: 10px;
  padding: 12px 16px;
  background: #f0f7ff;
  border: 1px dashed var(--primary);
  border-radius: var(--radius-sm);
}
.batch-row-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr 0.8fr 0.8fr 1fr 1fr 60px;
  gap: 8px;
  align-items: center;
}
.batch-row-grid select,
.batch-row-grid input {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  font-family: inherit;
  width: 100%;
}
.batch-row-grid select:focus,
.batch-row-grid input:focus {
  border-color: var(--primary);
}
.batch-row-grid input[readonly] {
  background: #f8fafc;
  color: var(--text-muted);
}

/* ── 筛选行 ── */
.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}
.filter-row select, .filter-row input {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  font-family: inherit;
}
.filter-row select:focus, .filter-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59,130,246,.08);
}
.filter-row span { color: var(--text-muted); font-size:13px; }

/* ── 表格 ── */
.table-wrap { overflow-x:auto; border-radius: var(--radius-sm); border: 1px solid var(--border-light); }

table { width:100%; border-collapse:collapse; font-size:13.5px; }
thead { background: #f8fafc; }
th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  white-space: nowrap;
}
/* 长文本列：备注/地址/日志等允许换行 */
td.td-wrap, td.left {
  white-space: normal;
  word-break: break-word;
  min-width: 140px;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

td.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
}
td.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: 13.5px;
}
td.actions { white-space:nowrap; }
td.actions a {
  margin-right: 12px;
  font-size: 13px;
  font-weight: 500;
}

tfoot tr td {
  border-top: 2px solid var(--primary);
}

/* ── 统计卡片 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.stat-card {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  transition: all var(--transition);
}
.stat-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── 弹窗 ── */
.modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.modal-overlay {
  position: absolute; inset:0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  width: 580px;
  max-width: 92vw;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal-content h3 {
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 600;
}
.price-add-row {
  display: flex; gap: 10px; margin-top: 14px; align-items:center;
}
.price-add-row select,
.price-add-row input {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.price-add-row select:focus,
.price-add-row input:focus { border-color: var(--primary); }

/* ── 时间段切换标签 ── */
.period-tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
}
.period-tab {
  padding: 6px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
  font-family: inherit;
}
.period-tab:hover {
  color: var(--text);
}
.period-tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ── 排名徽章 ── */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
}
.rank-1 { background: #fef3c7; color: #d97706; }
.rank-2 { background: #e2e8f0; color: #64748b; }
.rank-3 { background: #fed7aa; color: #c2410c; }
.rank-other { background: #f8fafc; color: #94a3b8; }

/* ── 对账单元信息 ── */
.recon-meta {
  padding: 8px 14px;
  background: #f0f7ff;
  border-radius: 6px;
  display: inline-block;
}

/* ── 响应式 ── */
@media (max-width: 768px) {
  .form-grid { grid-template-columns:1fr; }
  .topbar { padding:10px 14px; gap:12px; }
  .topbar h1 { font-size:14px; }
  .topbar nav a { padding:4px 10px; font-size:11.5px; }
  .card { padding: 18px 16px; }
  .stats-grid { grid-template-columns:1fr 1fr; }
  .batch-row-grid { grid-template-columns:1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns:1fr; }
  .filter-row { flex-direction: column; align-items: stretch; }
}

/* ── 导航栏登出链接 ── */
.topbar nav .logout-link {
  margin-left: auto;
  background: rgba(255,255,255,.1);
  color: #fca5a5;
  font-weight: 600;
}
.topbar nav .logout-link:hover {
  background: rgba(239,68,68,.25);
  color: #fff;
}

/* ── 登录页 ── */
.login-body {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 50%, #3b82f6 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}
.login-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #1e3a5f;
  letter-spacing: 1px;
}
.login-header p {
  font-size: 13.5px;
  color: #64748b;
  margin-top: 6px;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  text-align: center;
  margin-bottom: 20px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-field label {
  font-size: 12.5px;
  font-weight: 500;
  color: #475569;
}
.login-field input {
  padding: 12px 15px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: all 0.15s ease;
  font-family: inherit;
}
.login-field input:focus {
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.login-btn {
  padding: 13px;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  letter-spacing: 2px;
  margin-top: 6px;
}
.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(30,64,175,.35);
}
.login-btn:active {
  transform: translateY(0);
}

@media (max-width: 480px) {
  .login-card {
    padding: 32px 24px;
  }
  .login-header h1 {
    font-size: 20px;
  }
}

/* ── 修改密码页 ── */
.cp-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 20px;
}

.cp-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border-light);
}

.cp-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1e3a5f;
  text-align: center;
  margin-bottom: 28px;
  letter-spacing: 1px;
}

.cp-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  text-align: center;
  margin-bottom: 20px;
}

.cp-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  text-align: center;
  margin-bottom: 20px;
}

.cp-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.cp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cp-field label {
  font-size: 12.5px;
  font-weight: 500;
  color: #475569;
}
.cp-field input {
  padding: 12px 15px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: all 0.15s ease;
  font-family: inherit;
}
.cp-field input:focus {
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.cp-btn {
  padding: 13px;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  letter-spacing: 2px;
  margin-top: 6px;
}
.cp-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(30,64,175,.35);
}
.cp-btn:active {
  transform: translateY(0);
}

@media (max-width: 480px) {
  .cp-card {
    padding: 32px 24px;
  }
  .cp-card h2 {
    font-size: 18px;
  }
}

/* ── 分页 ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.page-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.page-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover:not(:disabled):not(.active) {
  background: #eff6ff;
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(59,130,246,.25);
  cursor: default;
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f1f5f9;
}

.page-ellipsis {
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

@media (max-width: 480px) {
  .pagination {
    flex-direction: column;
    align-items: center;
  }
}

/* ════════════════════════════════════════════════════════════
   整改（2026-09-30）：全局美化增强 + PC/移动端自适应
   ════════════════════════════════════════════════════════════ */

/* ── 卡片质感提升 ── */
.card {
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 10px 30px -16px rgba(15,23,42,.16);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: 0 2px 4px rgba(15,23,42,.05), 0 16px 40px -18px rgba(15,23,42,.22); }

/* ── 表格表头吸附（长表格滚动时表头固定） ── */
.table-wrap { position: relative; }
thead { position: sticky; top: 0; z-index: 5; }

/* ── 表格操作链接可点区域加大 ── */
td.actions a {
  display: inline-block;
  padding: 4px 2px;
  margin-right: 10px;
}

/* ── 导航与容器：平板以下 ── */
@media (max-width: 1024px) {
  .container { max-width: 100%; padding: 0 14px; margin: 16px auto; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar h1 { font-size: 15px; }
  .topbar nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 4px;
    width: 100%;
  }
  .topbar nav a {
    text-align: center;
    padding: 7px 6px;
    font-size: 12px;
    border-radius: 8px;
  }
  .topbar nav .logout-link { grid-column: 1 / -1; }
}

/* ── 手机：导航 3 列 ── */
@media (max-width: 520px) {
  .topbar nav { grid-template-columns: repeat(3, 1fr); }
  .topbar h1 { font-size: 14px; }
}

/* ── 表格移动端紧凑 ── */
@media (max-width: 768px) {
  .table-wrap { border-radius: 10px; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 10px; }
  .card { padding: 18px 14px; }
  .card h2 { font-size: 14px; margin-bottom: 14px; }
  .stat-value { font-size: 18px; }
  .stat-card { padding: 12px 14px; }
}

/* ── 表单/按钮/筛选 手机适配 ── */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-row select, .filter-row input { width: 100%; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-primary, .btn-ghost { width: 100%; text-align: center; }
  .field input, .field select { font-size: 15px; } /* 防iOS缩放 */
  .tabs-bar { width: 100%; }
  .tabs-bar .tab-btn { flex: 1; padding: 10px 6px; }
}

/* ── 统计卡片 2 列（手机） ── */
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* ── 弹窗手机全屏 ── */
@media (max-width: 600px) {
  .modal-content {
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: 18px 16px;
  }
  .modal-content h3 { font-size: 15px; }
}

/* ── 对账/利润/统计页 图表容器最小高度（防ECharts塌陷） ── */
.chart-box, .chart-container { min-height: 320px; }
@media (max-width: 600px) {
  .chart-box, .chart-container { min-height: 240px; }
}

/* ── 打印预览区移动端：单据内容保持可滚动 ── */
@media (max-width: 768px) {
  .print-preview { overflow-x: auto; }
}
