/* ===== 门店排班系统 样式（PC + 移动端响应式） ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --red: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ---- 顶部栏 ---- */
.topbar {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { font-weight: 700; white-space: nowrap; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tab {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.8);
  padding: 6px 14px;
  font-size: 15px;
  cursor: pointer;
  border-radius: 8px;
  white-space: nowrap;
}
.tab.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.clock { font-size: 13px; color: rgba(255,255,255,.85); }

/* ---- 按钮/输入 ---- */
.btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background .15s;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
button.btn.danger { color: var(--red); border-color: #fecaca; }
input, select, textarea {
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }

/* ---- 页面布局 ---- */
.page { max-width: 1400px; margin: 0 auto; padding: 14px; }
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.flex-spacer { flex: 1; }
.month-picker { display: flex; align-items: center; gap: 8px; }
.month-label { font-weight: 700; font-size: 16px; }

/* ---- 汇总卡片 ---- */
.summary-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.summary-card {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 110px;
}
.summary-card b { font-size: 20px; color: var(--primary); }
.summary-card.income b { color: var(--green); }
.summary-card.expense b { color: var(--red); }
.summary-card span { font-size: 12px; color: var(--muted); }

/* ---- 周选项卡 ---- */
.week-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.week-tab {
  border: 1px solid var(--border);
  background: var(--card);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}
.week-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- 排班表 ---- */
.table-wrap { overflow: auto; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: max-content; min-width: 100%; }
th, td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: center;
  font-size: 13px;
  white-space: nowrap;
}
thead th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 5;
  font-weight: 600;
}
th.name-col, td.name-col {
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 4;
  text-align: left;
  font-weight: 600;
  min-width: 76px;
}
thead th.name-col { z-index: 6; background: #f8fafc; }
th.weekend, td.weekend { background: #fef2f2; }
th.hours-col, td.hours-col { background: #eff6ff; font-weight: 600; }
td.sched-cell { cursor: pointer; min-width: 86px; }
td.sched-cell:hover { background: #dbeafe; }
td.sched-cell .time-pair { display: flex; flex-direction: column; gap: 1px; }
td.sched-cell .t { font-size: 12px; color: var(--primary-dark); font-weight: 600; }
td.sched-cell.empty .time-pair { color: var(--muted); font-size: 11px; }
.dist-btn {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f8fafc;
  cursor: pointer;
}
.dist-btn:hover { background: var(--primary); color: #fff; }

/* ---- 账务 ---- */
.fin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  background: var(--card);
  padding: 12px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.upload-btn {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
  color: var(--primary);
  position: relative;
  font-size: 14px;
  gap: 6px;
}
.upload-btn img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.fin-list { display: flex; flex-direction: column; gap: 8px; }
.fin-item {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.fin-item .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.fin-item .fin-main { flex: 1; min-width: 140px; }
.fin-item .fin-item-name { font-weight: 600; }
.fin-item .fin-meta { font-size: 12px; color: var(--muted); }
.fin-item .fin-amount { font-weight: 700; }
.fin-item.income .fin-amount { color: var(--green); }
.fin-item.expense .fin-amount { color: var(--red); }
.fin-del { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }

/* ---- 分析 ---- */
.ana-card {
  background: var(--card);
  border-radius: 10px;
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.ana-card h4 { margin-bottom: 10px; }
.slot-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.slot-label { width: 110px; font-size: 13px; color: var(--muted); }
.slot-bar-bg { flex: 1; height: 16px; background: #e2e8f0; border-radius: 8px; overflow: hidden; }
.slot-bar { height: 100%; background: var(--primary); border-radius: 8px; }
.slot-count { width: 46px; text-align: right; font-size: 13px; }

/* ---- 弹窗 ---- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 12px;
}
.modal-box {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal-box.small { max-width: 420px; }
.modal-box.wide { max-width: 1100px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px; }
.edit-grid { display: grid; grid-template-columns: 80px 1fr; gap: 10px; align-items: center; margin-bottom: 12px; }
.edit-grid select { width: 100%; }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.quick-input { width: 100%; margin-top: 8px; }

/* ---- 排班分布图 ---- */
.dist-chart { width: 100%; overflow-x: auto; }
.dist-chart svg { display: block; width: 100%; height: auto; min-width: 520px; }

/* ---- 设置页 ---- */
.page h3 { margin: 18px 0 10px; font-size: 16px; }
.manage-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.staff-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.staff-chip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 8px 6px 14px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow);
}
.staff-chip button { border: none; background: #fee2e2; color: var(--red); width: 20px; height: 20px; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 1; }
.switch-row { display: flex; align-items: center; gap: 6px; font-size: 14px; }

/* ---- 登录 ---- */
#login-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.login-box {
  background: #fff; border-radius: 14px; padding: 28px;
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-box h2 { text-align: center; color: var(--text); }
.login-box input { padding: 10px; }
.login-msg { color: var(--red); font-size: 13px; text-align: center; min-height: 18px; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff;
  padding: 10px 20px; border-radius: 8px;
  font-size: 14px; z-index: 300;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  max-width: 90vw;
}
.hint { font-size: 12px; color: var(--muted); margin: 8px 0; }
.date-input { width: 140px; }

/* ================= 移动端适配 ================= */
@media (max-width: 720px) {
  body { font-size: 14px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 6px; }
  .clock { display: none; }
  .page { padding: 10px; }
  .tabs .tab { padding: 6px 10px; font-size: 14px; }

  /* 周选项卡横向滚动 */
  .week-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }

  .summary-card { padding: 8px 12px; min-width: 90px; flex: 1; }
  .summary-card b { font-size: 17px; }

  /* 排班表格：横向滚动操作 */
  .table-wrap { border-radius: 8px; }
  th, td { padding: 5px 6px; font-size: 12px; }
  td.sched-cell { min-width: 76px; }
  th.hours-col, td.hours-col { font-size: 12px; }

  .fin-form { grid-template-columns: 1fr 1fr; }
  .fin-form input, .fin-form select { width: 100%; }
  .fin-form .upload-btn { grid-column: 1 / -1; }
  .fin-form .btn { grid-column: 1 / -1; padding: 10px; }

  .modal { padding: 8px; align-items: flex-end; }
  .modal-box { max-height: 92vh; border-radius: 14px 14px 0 0; }
  .edit-grid { grid-template-columns: 70px 1fr; }
  .manage-row input, .manage-row select { flex: 1; min-width: 120px; }
}
