/* ============ 外贸每日任务表 样式 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --good: #16a34a;
  --mid: #f59e0b;
  --bad: #ef4444;
  --today: #eff6ff;
}

html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  transition: background .15s, border-color .15s;
}
button:hover { border-color: var(--primary); color: var(--primary); }
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { background: var(--primary-hover); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 10px; }
button.ghost:hover { color: var(--primary); background: rgba(37, 99, 235, .08); }
button.mini { padding: 4px 10px; font-size: 13px; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); color: var(--bad); }

input, select {
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--primary); }

/* ---------- 登录页 ---------- */
#view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eff6ff 0%, #f1f5f9 55%, #eef2ff 100%);
}
.login-card {
  background: var(--card);
  width: 360px;
  padding: 40px 36px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .12);
  text-align: center;
}
.login-card .logo { font-size: 42px; }
.login-card h1 { font-size: 22px; margin: 10px 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card button { width: 100%; padding: 11px; }
.msg { font-size: 13px; margin-top: 10px; min-height: 18px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--good); }

/* ---------- 主界面头部 ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-size: 16px; white-space: nowrap; }
.brand b { color: var(--primary); }
.month-nav { display: flex; align-items: center; gap: 6px; }
#month-label { font-size: 15px; font-weight: 600; min-width: 110px; text-align: center; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#me-name { font-weight: 600; margin-right: 4px; }

/* ---------- 员工标签 ---------- */
#tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
  overflow-x: auto;
  background: var(--bg);
}
.tab {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 7px 14px;
  border-radius: 10px 10px 0 0;
  font-size: 13px;
}
.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.tab .me { font-style: normal; color: var(--good); }
.tab.active .me { color: #bbf7d0; }
.tab .off { font-style: normal; color: var(--bad); font-size: 12px; }
.tab.active .off { color: #fecaca; }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg);
}
.hint { color: var(--muted); font-size: 12px; flex: 1; }
.sync { color: var(--muted); font-size: 12px; }

/* ---------- 表格 ---------- */
.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 175px);
  background: var(--card);
  border-top: 1px solid var(--border);
}
#task-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1400px;
  font-size: 13px;
}
#task-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: center;
  font-weight: 600;
  line-height: 1.3;
}
#task-table thead th .lbl { display: block; }
#task-table thead th .sub {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}
/* 表头分组配色: FB蓝 / IG粉 / 广告橙 / 结果绿 */
#task-table thead th.grp-fb { background: #eff6ff; border-top: 3px solid #2563eb; }
#task-table thead th.grp-fb .lbl { color: #1d4ed8; }
#task-table thead th.grp-ig { background: #fdf2f8; border-top: 3px solid #db2777; }
#task-table thead th.grp-ig .lbl { color: #be185d; }
#task-table thead th.grp-ads { background: #fff7ed; border-top: 3px solid #f97316; }
#task-table thead th.grp-ads .lbl { color: #c2410c; }
#task-table thead th.grp-res { background: #f0fdf4; border-top: 3px solid #22c55e; }
#task-table thead th.grp-res .lbl { color: #15803d; }
#task-table tbody td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-all;
}
#task-table tbody tr:nth-child(even) td { background: #fcfdfe; }
#task-table tbody tr.today td { background: var(--today); }
#task-table tbody tr.today td.day-cell { box-shadow: inset 3px 0 0 var(--primary); }
#task-table tbody tr.today:nth-child(even) td { background: var(--today); }

td.day-cell b { font-size: 14px; display: block; }
td.day-cell span { color: var(--muted); font-size: 11px; }

td.cell.empty { color: #cbd5e1; }
td.cell.editable { cursor: text; }
td.cell.editable:hover { outline: 2px solid rgba(37, 99, 235, .35); outline-offset: -2px; }
td.cell.editing { background: #fefce8 !important; padding: 0; }
td.cell.below { color: var(--bad); font-weight: 600; }
td.cell.editing input {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  padding: 5px 8px;
  background: #fefce8;
  font: inherit;
  text-align: center;
}
td.rate-cell { text-align: center; }
.pill {
  display: inline-block;
  min-width: 46px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  cursor: help;
}
.pill.good { background: var(--good); }
.pill.mid { background: var(--mid); }
.pill.bad { background: var(--bad); }

#task-table tfoot td {
  border: 1px solid var(--border);
  background: #f1f5f9;
  font-weight: 700;
  padding: 8px;
  text-align: center;
  position: sticky;
  bottom: 0;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow: auto;
  padding: 20px 24px;
}
.modal-card.narrow { max-width: 380px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h3 { font-size: 17px; }
.modal-close { border: none; background: transparent; font-size: 16px; color: var(--muted); }
.modal-close:hover { color: var(--bad); }

.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.add-row input { flex: 1; min-width: 130px; }

.emp-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.emp-table th, .emp-table td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  font-size: 13px;
}
.emp-table th { background: #f8fafc; }
.emp-table td input[type="text"], .emp-table td input[type="password"] { width: 100%; padding: 6px 8px; font-size: 13px; }
.emp-table td select { padding: 6px 8px; font-size: 13px; }
.emp-table td .mini-row { display: flex; gap: 6px; align-items: center; }
.emp-table td button { padding: 5px 10px; font-size: 12px; }

.sum-box { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.sum-box h4 { font-size: 14px; margin-bottom: 8px; }
#sum-line { display: flex; flex-wrap: wrap; gap: 8px; }
.sum-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
}
.sum-item b { color: var(--primary); }

/* ---------- 目标设置 ---------- */
.hint2 { font-size: 12px; color: var(--muted); margin-bottom: 14px; line-height: 1.6; }
.hint2 b { color: var(--text); }
#target-list { margin-bottom: 8px; }
.target-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.target-row span { flex: 1; font-size: 13px; color: var(--text); }
.target-row input { width: 100px; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .3);
}

/* ---------- 移动端 ---------- */
@media (max-width: 900px) {
  header { gap: 8px; }
  .user-box { margin-left: 0; width: 100%; justify-content: flex-end; }
  .brand { width: 100%; }
  .table-wrap { max-height: none; }
}
