:root {
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #EFF4FF;
  --text: #1A1A1A;
  --text-2: #5A6472;
  --text-3: #8A94A6;
  --border: #E6EAF0;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --success: #16A34A;
  --success-light: #EFFAF3;
  --warning: #D97706;
  --warning-light: #FFF7E8;
  --gray-light: #F1F3F6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-hover: 0 4px 12px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }

/* ---------- 顶部栏 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
}
.brand-mark.big { width: 48px; height: 48px; font-size: 22px; border-radius: 12px; }
.brand-name { font-size: 16px; font-weight: 600; }

.mainnav { display: flex; gap: 4px; margin-left: auto; }
.mainnav a {
  color: var(--text-2);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.mainnav a:hover { background: var(--gray-light); text-decoration: none; }
.mainnav a.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 500; }

.userbox { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.ub-text { display: flex; flex-direction: column; line-height: 1.25; }
.uname { font-size: 13px; font-weight: 500; }
.urole { font-size: 11px; color: var(--text-3); }
.logout { font-size: 12px; color: var(--text-3); padding: 4px 8px; }
.pwd-link { font-size: 12px; color: var(--primary); padding: 4px 6px; }

/* ---------- 布局 ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flex-spacer { flex: 1; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head-sub { font-size: 12px; color: var(--text-3); }
.card-more { font-size: 12px; }

.empty { color: var(--text-3); font-size: 13px; padding: 12px 0; }
.empty-card { text-align: center; color: var(--text-3); padding: 40px 0; }
.done-text { color: var(--success); }

.tip { color: var(--text-3); font-size: 12px; margin-top: 10px; }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-danger { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); }

/* ---------- 首页 ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { text-decoration: none; border-color: #CBD5E1; box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.stat-num { font-size: 24px; font-weight: 600; }
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-card.stat-warn .stat-num { color: var(--warning); }
.stat-card.stat-danger .stat-num { color: var(--danger); }

.duty-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.duty-list { display: flex; flex-direction: column; gap: 8px; }
.duty-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
}
.duty-name { font-weight: 500; }
.duty-note { font-size: 12px; color: var(--text-3); margin-left: auto; }

.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-item {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
}
.task-item:hover { border-color: #CBD5E1; text-decoration: none; background: #F8FAFC; }
.task-item-top { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.task-item-title { font-weight: 500; font-size: 13.5px; }
.task-item-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.task-item-assignee { font-size: 12px; color: var(--text-2); margin-left: auto; }

.proj-list { display: flex; flex-direction: column; gap: 12px; }
.proj-item { display: block; color: var(--text); }
.proj-item:hover { text-decoration: none; }
.proj-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.proj-name { font-weight: 500; font-size: 13.5px; }
.proj-count { font-size: 12px; color: var(--text-2); flex-shrink: 0; }
.proj-item-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.progress {
  height: 6px;
  background: var(--gray-light);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar { height: 100%; background: var(--primary); border-radius: 3px; }

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.week-day {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  min-height: 86px;
}
.week-day.is-today { border-color: var(--primary); background: var(--primary-light); }
.wd-label { display: block; font-size: 11px; color: var(--text-3); }
.wd-names { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.wd-name {
  font-size: 11px;
  background: var(--gray-light);
  border-radius: 4px;
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.is-today .wd-name { background: #fff; }
.wd-none { font-size: 11px; color: var(--text-3); }

/* ---------- 徽章 / 标签 ---------- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.5;
}
.st-pending { background: var(--gray-light); color: #5F5E5A; }
.st-in_progress { background: var(--primary-light); color: var(--primary-dark); }
.st-pending_verify { background: var(--warning-light); color: var(--warning); }
.st-done { background: var(--success-light); color: var(--success); }
.st-closed { background: var(--success-light); color: var(--success); }
.badge-urgent { background: var(--danger-light); color: var(--danger); }
.badge-overdue { background: var(--danger-light); color: var(--danger); }
.badge-stopped { background: var(--gray-light); color: var(--text-3); }

.shift-day { background: var(--primary-light); color: var(--primary-dark); }
.shift-night { background: #EEEDFE; color: #3C3489; }
.shift-holiday { background: var(--warning-light); color: var(--warning); }
.shift-emergency { background: var(--danger-light); color: var(--danger); }

.tag {
  display: inline-block;
  font-size: 11px;
  color: var(--text-2);
  background: var(--bg);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 4px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: #CBD5E1; background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #791F1F; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.seg { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; }
.seg a { font-size: 12px; padding: 4px 12px; border-radius: 6px; color: var(--text-2); }
.seg a.on { background: var(--card); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.seg a:hover { text-decoration: none; }

.pager { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.pager-label { font-weight: 500; font-size: 14px; }

/* ---------- 表单 ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin: 14px 0 6px;
}
.req { color: var(--danger); }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24, 95, 165, 0.12);
}
textarea { resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }

.form-card { max-width: 720px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.form-row label { margin-top: 14px; }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input { width: auto; min-width: 130px; flex: 0 1 auto; }
.filter-bar input[type=search] { flex: 1 1 180px; }

.inline-form { display: inline-block; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table .muted { color: var(--text-3); }
.table .tc { text-align: center; }
.task-title { font-weight: 500; color: var(--text); }
.task-title:hover { color: var(--primary); }
.task-sub { margin-top: 3px; }
.overdue { color: var(--danger); font-weight: 500; }
.overdue-sub { color: var(--danger); font-size: 11px; }
.cell-user { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }

.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 7px 0; font-size: 13px; vertical-align: top; }
.kv td:first-child { color: var(--text-2); width: 88px; }

/* ---------- 任务 tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
}
.tabs a {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ---------- 任务详情 ---------- */
.back-link { font-size: 13px; color: var(--text-2); }
.detail-title { margin-top: 6px; }
.detail-body { margin-top: 14px; }
.detail-body p { color: var(--text); margin-top: 4px; white-space: pre-wrap; }
.verify-note {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--warning-light);
  color: var(--warning);
  border-radius: 8px;
  font-size: 13px;
}
.verify-note.ok { background: var(--success-light); color: var(--success); }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 8px 0; }
.tl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--text-3);
}
.tl-dot.tl-pending { background: #888780; }
.tl-dot.tl-in_progress { background: var(--primary); }
.tl-dot.tl-pending_verify { background: #EF9F27; }
.tl-dot.tl-closed { background: var(--success); }
.tl-body { flex: 1; }
.tl-action { font-weight: 500; font-size: 13px; }
.tl-meta { font-size: 12px; color: var(--text-3); margin-left: 8px; }
.tl-note { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.flow-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 12px;
}
.fs {
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--gray-light);
  color: var(--text-3);
}
.fs.on { background: var(--primary); color: #fff; font-weight: 500; }
.fs.done { background: var(--success-light); color: var(--success); }
.fs-arrow { color: var(--text-3); }

.verify-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.verify-form label { margin-top: 0; }

/* ---------- 排班看板（单周表格） ---------- */
.sched-group { margin-bottom: 24px; }
.sched-group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
  padding-left: 2px;
}
.sched-group-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.sched-group-count {
  font-size: 12px;
  color: var(--text-3);
}

.week-board {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.wb-head, .wb-row {
  display: grid;
  grid-template-columns: 120px repeat(5, 1fr);
  align-items: stretch;
}
.wb-head {
  background: var(--gray-light);
  border-bottom: 1px solid var(--border);
}
.wb-name-cell {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  border-right: 1px solid var(--border);
}
.wb-row .wb-name-cell {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.wb-row:last-child .wb-name-cell { border-bottom: none; }
.wb-row.is-me .wb-name-cell {
  background: var(--primary-light);
  color: var(--primary-dark);
}
.wb-name {
  font-size: 14px;
  font-weight: 600;
}
.wb-day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 0;
  border-right: 1px solid var(--border);
}
.wb-day-head:last-child { border-right: none; }
.wb-wd { font-size: 12px; color: var(--text-2); font-weight: 500; }
.wb-date { font-size: 15px; font-weight: 600; color: var(--text); }
.wb-day-head.is-today {
  background: var(--primary-light);
}
.wb-day-head.is-today .wb-wd { color: var(--primary); }
.wb-day-head.is-today .wb-date { color: var(--primary-dark); }

.wb-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.wb-row:last-child .wb-cell { border-bottom: none; }
.wb-cell:last-child { border-right: none; }
.wb-cell.is-today { background: var(--primary-light); }

.wb-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
}
.wb-state.is-present {
  background: var(--success-light);
  color: var(--success);
}
.wb-state.is-absent {
  background: var(--danger-light);
  color: var(--danger);
}

.sched-legend {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-2);
  flex-wrap: wrap;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}
.lg-dot.is-present { background: var(--success-light); border: 1px solid var(--success); }
.lg-dot.is-absent { background: var(--danger-light); border: 1px solid var(--danger); }
.lg-dot.is-today { background: var(--primary-light); border: 1px solid var(--primary); }

/* 排班编辑（勾选请假） */
.wb-cell-toggle {
  cursor: pointer;
  transition: background .12s;
}
.wb-cell-toggle:hover { background: var(--gray-light); }
.wb-cell-toggle:has(.absent-check:checked) { background: var(--danger-light); }
.absent-check {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--danger);
  cursor: pointer;
}

/* ---------- 项目卡 ---------- */
.proj-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.proj-card { color: var(--text); display: block; }
.proj-card:hover { text-decoration: none; border-color: #CBD5E1; }
.proj-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.proj-card-name { font-weight: 600; font-size: 14px; }
.proj-card-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.proj-card-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { font-size: 18px; margin-top: 12px; }
.login-brand p { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.login-tip { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 16px; }

/* ---------- 手机端 ---------- */
@media (max-width: 860px) {
  .week-grid { grid-template-columns: repeat(2, 1fr); }
  .week-col:nth-child(n+7) { grid-column: span 2; }
  .proj-cards { grid-template-columns: 1fr; }
  .week-board { overflow-x: auto; }
  .wb-head, .wb-row { min-width: 460px; }
}

@media (max-width: 768px) {
  .topbar { position: static; }
  .topbar-inner { height: 52px; }
  .brand-name { font-size: 15px; }
  .userbox .ub-text, .userbox .logout { display: none; }
  .mainnav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    margin: 0;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    z-index: 100;
    justify-content: space-around;
  }
  .mainnav a {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    font-size: 12px;
    border-radius: 8px;
  }
  .container { padding: 14px 12px 90px; }

  .grid-2 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .duty-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: 0; }

  h1 { font-size: 18px; }

  .week-strip { grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .week-day { min-height: 74px; padding: 6px 3px; }
  .wd-name { font-size: 10px; }

  .mg-cell { min-height: 58px; padding: 3px 4px; }
  .mg-name { font-size: 10px; }

  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }
  .table tr:last-child { border-bottom: none; }
  .table td { border-bottom: none; padding: 3px 0; }
  .table td.muted::before { content: "任务 #"; color: var(--text-3); font-size: 11px; }

  .task-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .task-table td:nth-child(1) { display: none; }

  .pager { flex-wrap: wrap; }
  .tabs { -webkit-overflow-scrolling: touch; }
}
