* { box-sizing: border-box; }
:root {
  --bg:#f5f6f8; --card:#fff; --text:#1f2329; --muted:#8a9099;
  --border:#e3e6eb; --primary:#c8352d; --primary-hover:#a82a23;
  --ok:#1a7f37; --err:#c8352d;
}
body { margin:0; background:var(--bg); color:var(--text);
  font:14px/1.6 -apple-system,"Segoe UI","Microsoft YaHei",sans-serif; }
a { color:#1a5fb4; text-decoration:none; }
a:hover { text-decoration:underline; }

header { background:#fff; border-bottom:1px solid var(--border); padding:14px 28px;
  display:flex; align-items:center; justify-content:space-between; }
header h1 { margin:0; font-size:19px; }
header nav { display:flex; gap:18px; align-items:center; color:var(--muted); font-size:13px; }
main { max-width:1560px; margin:20px auto; padding:0 20px; }

.card { background:var(--card); border:1px solid var(--border); border-radius:10px;
  padding:22px 26px; margin-bottom:18px; box-shadow:0 1px 3px rgba(0,0,0,.03); }
.card h2 { margin:0 0 16px; font-size:17px; }
.card h2 small { font-weight:normal; color:var(--muted); font-size:12px; }
h3 { font-size:14px; margin:0 0 10px; }

label { display:block; margin:12px 0; font-weight:600; font-size:13px; }
input, textarea, select { width:100%; margin-top:6px; padding:9px 11px;
  border:1px solid var(--border); border-radius:6px; font:inherit; background:#fff; color:var(--text); }
textarea { resize:vertical; }
input:focus, textarea:focus { outline:none; border-color:var(--primary); }

button { padding:9px 20px; border:1px solid var(--border); background:#fff; color:var(--text);
  border-radius:6px; cursor:pointer; font:inherit; }
button:hover { background:#f0f1f3; }
button:disabled { opacity:.5; cursor:not-allowed; }
button.primary { background:var(--primary); color:#fff; border-color:var(--primary); }
button.primary:hover { background:var(--primary-hover); }
button.danger { background:#fff; color:var(--err); border-color:var(--err); }
button.danger:hover { background:#fdf0ef; }
button.primary.danger { background:var(--err); color:#fff; }
.actions { display:flex; gap:12px; justify-content:flex-end; margin-top:20px; }

.clear-row { display:flex; justify-content:flex-end; margin-top:-4px; }
.clear-row button { padding:2px 10px; font-size:12px; color:var(--muted); }

.grid3 { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; align-items:start; }
.grid3 .card { margin-bottom:0; }
.wide { width:100%; margin-top:14px; }
.publish-actions { display:flex; gap:10px; margin-top:14px; }
.publish-actions button { flex:1; margin-top:0; }
.publish-actions button.danger:not(.primary) { background:#fff; color:var(--err); border-color:var(--err); }
.placeholder { padding:36px 16px; text-align:center; color:var(--muted); font-size:13px;
  background:#fafbfc; border:1px dashed var(--border); border-radius:8px; }
#preview-images { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; }
.preview-fig { margin:0; }
.preview-fig img { width:100%; max-height:420px; object-fit:contain; display:block;
  border:1px solid var(--border); border-radius:6px; background:#fafbfc; }
.preview-fig figcaption { text-align:center; font-size:12px; color:var(--muted); margin-top:4px; }
h3 small { font-weight:normal; color:var(--muted); font-size:12px; }
#preview-notice { white-space:pre-wrap; background:#f7f8fa; padding:14px; border-radius:6px;
  border:1px solid var(--border); font:inherit; min-height:90px; }

/* 合作人输入行 */
#sale-tip { font-weight:normal; color:var(--muted); font-size:12px; }
.sale-row { display:flex; gap:6px; align-items:center; margin-top:6px; }
.sale-row .sale-input { flex:1; margin:0; }
.sale-row button { flex:0 0 auto; padding:6px 12px; }
.sale-row .sale-add { color:var(--primary); border-color:var(--primary); }
.sale-row .sale-del { color:var(--muted); }
.sale-row button[hidden] { display:none; }

table { width:100%; border-collapse:collapse; font-size:13px; }
th, td { padding:8px 10px; border-bottom:1px solid var(--border); text-align:left; }
th { width:150px; color:var(--muted); font-weight:600; }
td input { margin:0; }
.inline-form { display:flex; gap:10px; align-items:center; }
.inline-form input, .inline-form select { margin:0; width:auto; flex:1; }
.row-form { display:inline-flex; gap:6px; margin-right:8px; align-items:center; }
.row-form button { padding:5px 10px; font-size:12px; }

.hint { color:var(--muted); font-size:12px; margin-top:16px; }

.alert { padding:10px 14px; border-radius:6px; margin:12px 0; }
.alert.err { background:#fdf0ef; color:var(--err); border:1px solid #f5c9c6; }
.alert.ok { background:#eaf7ee; color:var(--ok); border:1px solid #bfe3c9; }

.auth-page { display:flex; align-items:center; justify-content:center; min-height:100vh; }
.auth-card { width:360px; background:#fff; padding:34px; border:1px solid var(--border);
  border-radius:12px; box-shadow:0 4px 20px rgba(0,0,0,.05); }
.auth-card h1 { margin:0; font-size:22px; }
.auth-card .sub { color:var(--muted); margin:4px 0 22px; font-size:13px; }
.auth-card button { width:100%; margin-top:10px; }
.links { text-align:center; margin-top:18px; font-size:13px; }

@media (max-width:1100px){
  .grid3 { grid-template-columns:1fr; }
  .inline-form { flex-wrap:wrap; }
  th { width:110px; }
}

/* 导航当前页 */
header nav a.active { color:var(--primary); font-weight:600; }

.toolbar { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:16px; }
.toolbar input[type=text], .toolbar input:not([type]) { width:240px; margin:0; }
.toolbar .muted { color:var(--muted); font-size:12px; }
.inline-check { display:inline-flex; align-items:center; gap:6px; margin:0; font-weight:normal; }
.inline-check input { width:auto; margin:0; }
.table-wrap { overflow-x:auto; }
.table-wrap th { width:auto; white-space:nowrap; position:relative; }
.table-wrap th .th-label { cursor:pointer; user-select:none; }
.table-wrap th .th-label:hover { color:var(--primary,#c8352d); }
.table-wrap th[draggable=true] { cursor:grab; }
.table-wrap th .th-resize { position:absolute; right:0; top:0; width:6px; height:100%;
  cursor:col-resize; }
.table-wrap th .th-resize:hover { background:var(--border); }

.img-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:14px; }
.img-card { border:1px solid var(--border); border-radius:8px; overflow:hidden; background:#fafbfc; }
.img-card.archived { opacity:.55; }
.img-card img { width:100%; height:170px; object-fit:cover; display:block; background:#eee; }
.img-missing { width:100%; height:170px; background:#fafbfc; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:10px; color:var(--muted); font-size:12px; text-align:center; }
.img-missing button { padding:4px 10px; font-size:12px; }
.img-name { padding:8px; font-size:13px; text-align:center; font-weight:600;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.img-name em { color:var(--err); font-style:normal; font-size:11px; }
.img-actions { display:flex; gap:5px; justify-content:center; padding:0 8px 10px; flex-wrap:wrap; }
.img-actions button, .img-actions a { padding:4px 9px; font-size:12px; border:1px solid var(--border);
  border-radius:4px; background:#fff; cursor:pointer; }

.modal { position:fixed; inset:0; background:rgba(0,0,0,.4); display:flex; align-items:center;
  justify-content:center; z-index:50; }
.modal[hidden] { display:none; }
.modal-card { background:#fff; border-radius:10px; padding:24px; width:520px; max-height:86vh;
  overflow-y:auto; }
.modal-card h2 { margin-top:0; }

.perm-box { display:flex; gap:16px; align-items:center; flex-wrap:wrap; margin:12px 0; padding:10px;
  background:#fafbfc; border-radius:6px; font-size:13px; }
.perm-box label, .perm-edit label { display:inline-flex; align-items:center; gap:4px;
  margin:0; font-weight:normal; white-space:nowrap; }
.perm-box input, .perm-edit input { width:auto; margin:0; }
.perm-edit { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.perm-edit button { padding:3px 8px; font-size:11px; }

/* 队群配置 */
.team-card { border:1px solid var(--border); border-radius:8px; padding:16px 18px; margin-bottom:16px; }
.team-card h3 { margin:0 0 4px; }
.member-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:4px 10px;
  margin-top:6px; padding:10px; background:#fafbfc; border:1px solid var(--border); border-radius:6px; }
.member-item { display:inline-flex; align-items:center; gap:4px; margin:0; font-weight:normal; font-size:13px; }
.member-item input { width:auto; margin:0; }

/* ---------- 手机底部 Tab（默认隐藏，仅窄屏显示） ---------- */
.mtab { display:none; }

@media (max-width:760px){
  header { padding:10px 16px; }
  header h1 { font-size:17px; }
  main { margin:12px auto; padding:0 12px 84px; }   /* 底部留白给 Tab */
  .card { padding:16px 14px; margin-bottom:12px; }
  .card h2 { font-size:16px; }
  header nav span { display:none; }                  /* 桌面顶部用户名在手机隐藏 */

  /* 三栏在手机上硬堆叠 */
  .grid3 { grid-template-columns:1fr; gap:12px; }
  .grid3 .card { margin-bottom:12px; }
  /* 图片/预览双列 */
  .img-grid, #preview-images { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .member-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  /* 弹窗全宽 */
  .modal-card { width:calc(100% - 24px); padding:18px; }
  /* 触控按钮：最小 44px 高 */
  button, .publish-actions button { min-height:44px; padding:10px 16px; }
  .sale-row button, .img-actions button, .img-actions a, .row-form button,
  .perm-edit button, .clear-row button, .img-missing button { min-height:32px; padding:6px 12px; }
  input, textarea, select { font-size:16px; }        /* 防 iOS 输入框自动放大 */
  .toolbar input[type=text], .toolbar input:not([type]) { width:100%; }
  .team-card { padding:14px; }

  /* 业绩表卡片化：隐藏表头，每行变卡片，单元格前加字段标签 */
  .table-wrap table, .table-wrap tbody { display:block; width:100%; }
  .table-wrap thead { display:none; }
  .table-wrap tr { display:block; background:#fff; border:1px solid var(--border);
    border-radius:8px; padding:8px 12px; margin-bottom:10px; }
  .table-wrap td { display:flex; gap:8px; border:0; padding:5px 0; font-size:13px; }
  .table-wrap td::before { content:attr(data-label); flex:0 0 76px; color:var(--muted);
    font-size:12px; font-weight:600; }
  .table-wrap td:last-child { border-top:1px solid var(--border); margin-top:6px; padding-top:10px; }
  .table-wrap td:last-child::before { content:'操作'; }
  .table-wrap td button { min-height:36px; }

  /* 底部 Tab */
  .mtab { display:flex; position:fixed; left:0; right:0; bottom:0; z-index:60;
    background:#fff; border-top:1px solid var(--border);
    padding:6px 4px calc(6px + env(safe-area-inset-bottom,0px)); }
  .mtab-item { flex:1; display:flex; flex-direction:column; align-items:center;
    justify-content:center; gap:2px; min-height:52px; color:var(--muted);
    text-decoration:none; font-size:11px; font-weight:400; }
  .mtab-item svg { width:22px; height:22px; }
  .mtab-item.active { color:var(--primary); }
  .mtab-me { position:relative; }
  .mtab-me summary { list-style:none; display:flex; flex-direction:column;
    align-items:center; gap:2px; cursor:pointer; }
  .mtab-me summary::-webkit-details-marker { display:none; }
  .mtab-user { padding:6px 0 10px; color:var(--primary); font-weight:600; border-bottom:1px solid var(--border); }
  .mtab-menu { position:absolute; bottom:56px; right:4px; width:150px;
    background:#fff; border:1px solid var(--border); border-radius:10px;
    box-shadow:0 -2px 12px rgba(0,0,0,.1); padding:6px; }
  .mtab-menu a { display:block; padding:10px 12px; min-height:44px; line-height:24px;
    color:var(--text); text-decoration:none; font-size:14px; border-radius:6px; }
  .mtab-menu a:hover { background:#f5f6f8; }
}

