* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f4f6fb; color: #1f2733; }

/* 侧边栏 */
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 210px;
  background: #1f2733; color: #cdd5e0; padding: 20px 0; display: flex; flex-direction: column; }
.sidebar .brand { font-size: 20px; font-weight: 700; color: #fff; padding: 0 22px 18px; line-height: 1.3; }
.sidebar .brand small { font-size: 12px; font-weight: 400; color: #8b97a8; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; }
.sidebar nav a { color: #cdd5e0; text-decoration: none; padding: 11px 22px; font-size: 14px; }
.sidebar nav a:hover { background: #2a3442; }
.sidebar nav a.active { background: #4f7cff; color: #fff; }
.sidebar .side-foot { padding: 14px 22px; font-size: 12px; color: #8b97a8; border-top: 1px solid #2a3442; }
.sidebar .side-foot a { color: #8b97a8; display: block; margin-top: 6px; }

main.with-side { margin-left: 210px; padding: 26px 30px; }

/* 页面 */
.page h2 { margin: 0 0 16px; font-size: 22px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head h2 { margin: 0; }
.actions { display: flex; gap: 10px; }
.muted { color: #8b97a8; font-size: 13px; }

/* 按钮 */
.btn { background: #4f7cff; color: #fff; border: none; padding: 8px 16px; border-radius: 8px;
  text-decoration: none; font-size: 14px; cursor: pointer; display: inline-block; }
.btn:hover { background: #3f6af0; }
.btn.ghost { background: #fff; color: #4f7cff; border: 1px solid #cdd5e0; }
.btn.ghost:hover { background: #eef3ff; }
.link { background: none; border: none; color: #4f7cff; cursor: pointer; padding: 0 4px; font-size: 13px; }
.link.danger { color: #e05656; }

/* 卡片 / KPI */
.card { background: #fff; border-radius: 12px; padding: 18px 20px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(20,30,50,.06); }
.card h3 { margin: 0 0 14px; font-size: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(20,30,50,.06); }
.kpi-label { font-size: 13px; color: #8b97a8; }
.kpi-val { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi-val.warn { color: #f5b53d; }
.kpi-val.pos { color: #2fa86a; }
.kpi-val.neg { color: #e05656; }
.kpi-val input { width: 100%; border: 1px solid #d8dee8; border-radius: 8px; padding: 6px 10px;
  font-size: 22px; font-weight: 700; color: #1f2733; background: #fff; box-sizing: border-box; }
.kpi-val input:focus { outline: none; border-color: #4f7cff; }

/* 表格 */
.table-wrap { background: #fff; border-radius: 12px; padding: 6px; box-shadow: 0 1px 3px rgba(20,30,50,.06); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef1f6; white-space: nowrap; }
th { background: #f7f9fc; font-weight: 600; color: #5a6678; }
tr:last-child td { border-bottom: none; }
.empty { text-align: center; color: #8b97a8; padding: 28px; }
.ops a, .ops button { margin-right: 8px; }
.mask { color: #8b97a8; }

/* 表单 */
.card-form { max-width: 560px; background: #fff; border-radius: 12px; padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(20,30,50,.06); }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: #5a6678; margin-bottom: 6px; }
.form-row input { width: 100%; padding: 9px 12px; border: 1px solid #d8dee8; border-radius: 8px; font-size: 14px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; padding: 34px 36px; border-radius: 14px; width: 320px; box-shadow: 0 6px 24px rgba(20,30,50,.12); }
.login-card h2 { margin: 0 0 4px; }
.login-card label { display: block; font-size: 13px; color: #5a6678; margin: 14px 0 6px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid #d8dee8; border-radius: 8px; font-size: 14px; }
.login-card button { width: 100%; margin-top: 20px; }

/* 提示 */
.flash { margin-bottom: 16px; }
.flash div { background: #fff4e5; color: #b9772a; padding: 10px 14px; border-radius: 8px; font-size: 14px; }

/* 行内编辑表格 */
.hint { color: #8b97a8; font-size: 13px; margin: -6px 0 14px; }
.filter { padding: 8px 12px; border: 1px solid #cdd5e0; border-radius: 8px; font-size: 14px; background: #fff; }
.filter#fSearch { min-width: 220px; }
.grid .col-plus { width: 44px; text-align: center; padding: 6px; }
.grid .col-ops { width: 70px; text-align: center; }
.grid td.cell { cursor: text; }
.grid td.cell:hover { background: #f3f7ff; }
.grid .cell-text { display: block; min-height: 20px; padding: 2px 4px; border-radius: 4px;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 编辑框固定尺寸：不随内容变长变宽 */
.grid .cell-input, .grid .cell-select {
  width: 160px; height: 32px; padding: 6px 8px; border: 1px solid #4f7cff; border-radius: 6px;
  font-size: 14px; background: #fff; color: #1f2733; box-sizing: border-box;
}
.grid .cell-input[type=number] { width: 110px; }
.grid .cell-input-date { width: 140px; padding-right: 28px; }
/* fixed 表格下，输入框/下拉框自适应单元宽度 */
.grid.fixed td.cell input.cell-input,
.grid.fixed td.cell select.cell-select,
.grid.fixed td.cell .date-wrap input.cell-input-date {
  width: 100%; max-width: 100%;
}
/* 日期 + 今天 按钮 单元 */
.grid .date-wrap { display: inline-flex; align-items: center; gap: 4px; }
.grid .btn-today {
  border: 1px solid #cdd5e0; background: #fff; color: #4f7cff; font-size: 12px;
  padding: 4px 8px; border-radius: 6px; cursor: pointer; height: 28px;
}
.grid .btn-today:hover { background: #eef3ff; }
/* 表格列宽固定（不再被 select / 长内容撑大） */
.grid.fixed { table-layout: fixed; width: 100%; }
.grid.fixed th, .grid.fixed td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid.fixed td.cell .cell-text { max-width: 100%; }
/* 按字段名匹配列宽（fallback 用 */
.grid.fixed col.col-store, .grid.fixed col.col-store_name { width: 130px; }
.grid.fixed col.col-platform { width: 70px; }
.grid.fixed col.col-shipped, .grid.fixed col.col-refunded, .grid.fixed col.col-signed,
.grid.fixed col.col-account_type { width: 80px; }
.grid.fixed col.col-date { width: 130px; }
.grid.fixed col.col-amount, .grid.fixed col.col-gmv, .grid.fixed col.col-deposit,
.grid.fixed col.col-refund, .grid.fixed col.col-promo_cost,
.grid.fixed col.col-comp_comp, .grid.fixed col.col-fine,
.grid.fixed col.col-competitor_price { width: 90px; }
.grid.fixed col.col-order_no, .grid.fixed col.col-tracking_no, .grid.fixed col.col-daifa_no { width: 150px; }
.grid.fixed col.col-note, .grid.fixed col.col-image, .grid.fixed col.col-login_account,
.grid.fixed col.col-account, .grid.fixed col.col-name { width: 180px; }
.grid.fixed col.col-competitor_url, .grid.fixed col.col-purchase_url1,
.grid.fixed col.col-purchase_url2, .grid.fixed col.col-purchase_url3,
.grid.fixed col.col-password { width: 220px; }
/* 竞品分析图片单元格 */
.grid .cell .img-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid .cell .thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.grid .cell .thumb { position: relative; width: 46px; height: 46px; border-radius: 6px; overflow: hidden; border: 1px solid #e3e8f0; background: #f7f9fc; }
.grid .cell .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .cell .thumb .x { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px;
  border-radius: 50%; border: none; background: #e05656; color: #fff; font-size: 12px; line-height: 1;
  cursor: pointer; padding: 0; }
.grid .cell .upload-btn { display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; height: 46px; padding: 0 10px; border: 1px dashed #cdd5e0; border-radius: 6px;
  color: #4f7cff; cursor: pointer; font-size: 13px; background: #fff; }
.grid .cell .upload-btn:hover { background: #eef3ff; }
.grid .cell-select { cursor: pointer; }
.grid tr.draft td { background: #fbfcff; }
.grid tr.draft:hover td { background: #f4f8ff; }
.grid .plus {
  width: 30px; height: 30px; line-height: 1; border-radius: 50%;
  border: 1px solid #4f7cff; background: #4f7cff; color: #fff;
  font-size: 20px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.grid .plus:hover { background: #3f6af0; }
/* 最后一行的「+ 新增」按钮（圆点状） */
.grid .col-plus .add-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: #4f7cff; color: #fff; border: none;
  font-size: 18px; font-weight: 600; line-height: 1; padding: 0;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
}
.grid .col-plus .add-btn:hover { background: #3f6af0; }
.grid .col-plus .add-btn:active { transform: scale(0.92); }
/* 空表提示行：去掉首格 + 的左内边距让 + 居中 */
.grid tr.empty-row .col-plus { padding: 12px 0; }
.grid tr.draft .ops, .grid tr.draft .col-ops { color: #b9c2d0; }

/* ============= 用户管理页 ============= */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; line-height: 1.6; }
.badge.owner   { background: #eaf1ff; color: #4f7cff; }
.badge.member  { background: #eef1f6; color: #5a6678; }
.badge.enabled { background: #e7f6ee; color: #2fa86a; }
.badge.disabled{ background: #fdeaea; color: #e05656; }

/* ============= 筛选条 + 顶部仪表盘 ============= */
.filter-bar { padding: 14px 16px; margin-bottom: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .filter-lbl { font-size: 13px; color: #5a6678; }
.filters .filter-sep { color: #8b97a8; }
.filter-hint { margin-left: auto; font-size: 12px; }

.kpi-panel { margin-top: 6px; }
.kpi-panel h3 { margin-bottom: 10px; }
.kpi-panel h3 .small { font-size: 12px; font-weight: normal; margin-left: 6px; }
.kpi-panel p.small { font-size: 12px; margin: 8px 0 0; }
.kpis.dashboard-kpis { margin-bottom: 14px; }
.kpi-bystore { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.kpi-bystore th, .kpi-bystore td { padding: 8px 10px; border-bottom: 1px solid #eef1f6; text-align: left; }
.kpi-bystore thead th { background: #f7f9fc; color: #5a6678; font-weight: 600; }
.kpi-bystore a { color: #4f7cff; text-decoration: none; font-weight: 600; }
.kpi-bystore a:hover { text-decoration: underline; }

.kpi .kpi-val a { color: inherit; text-decoration: none; }
.kpi .kpi-val a:hover { text-decoration: underline; }

/* ============= 财务报表（独立风格） ============= */
.finance-page { max-width: 1200px; margin: 0 auto; }
.finance-page .section { padding: 18px 22px; margin-bottom: 16px; }
.finance-page .section h3 { font-size: 16px; margin: 0 0 14px; color: #1f2733; }
.finance-page .section h3 .small { font-size: 12px; font-weight: 400; color: #8b97a8; margin-left: 8px; }
.finance-page .section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.finance-page .section-head h3 { margin: 0; }

/* KPI 网格：4 列（财务总览，7 项 → 4+3）/ 6 列（经营数据汇总，6 项一行） */
.finance-page .kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.finance-page .kpi-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }

/* 财务 KPI 卡片：含 label / val / sub 三行，扁平化无大阴影 */
.finance-page .kpi {
  background: #fff;
  border: 1px solid #eef1f6;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color .15s, box-shadow .15s;
}
.finance-page .kpi:hover { border-color: #d8e0f0; box-shadow: 0 2px 8px rgba(20,30,50,.06); }
.finance-page .kpi-label { font-size: 12px; color: #8b97a8; }
.finance-page .kpi-val { font-size: 22px; font-weight: 700; color: #1f2733; line-height: 1.3; margin-top: 2px; }
.finance-page .kpi-sub { font-size: 11px; color: #aab2bf; margin-top: 4px; }
.finance-page .kpi.pos  .kpi-val { color: #2fa86a; }
.finance-page .kpi.warn .kpi-val { color: #f0a020; }
.finance-page .kpi.neg  .kpi-val { color: #e05656; }
.finance-page .kpi.primary .kpi-val { color: #4f7cff; }

/* 初始资金卡：内嵌 ¥ + 紧凑输入框 */
.finance-page .kpi.editable { cursor: text; }
.finance-page .kpi.editable .kpi-val {
  display: flex; align-items: baseline; gap: 2px;
}
.finance-page .kpi.editable .kpi-val .prefix { color: #8b97a8; font-size: 18px; font-weight: 700; }
.finance-page .kpi.editable .kpi-val input {
  flex: 1; min-width: 0; width: 100%;
  border: 1px solid transparent;
  background: #f7f9fc;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 22px; font-weight: 700; color: #1f2733;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, background .15s;
  box-sizing: border-box;
  -moz-appearance: textfield;
}
.finance-page .kpi.editable .kpi-val input::-webkit-outer-spin-button,
.finance-page .kpi.editable .kpi-val input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.finance-page .kpi.editable .kpi-val input:hover { border-color: #cdd5e0; background: #fff; }
.finance-page .kpi.editable .kpi-val input:focus { border-color: #4f7cff; background: #fff; }

/* 财务说明文字 */
.finance-page .hint { margin: -4px 0 18px; }

/* 店铺回款表 */
.finance-page #repayTable { font-size: 14px; }
.finance-page #repayTable th, .finance-page #repayTable td { padding: 10px 12px; }
.finance-page #repayTable .col-plus { width: 44px; text-align: center; padding: 6px; }
.finance-page #repayTable .col-ops { width: 80px; text-align: center; }

