:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --primary: #4f6ef7;
  --primary-d: #3b56d6;
  --text: #1f2430;
  --muted: #8a93a6;
  --line: #e8ebf2;
  --red: #ef4444;
  --green: #16a34a;
  --amber: #f59e0b;
  --shadow: 0 6px 20px rgba(31, 36, 48, .08);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 70px; /* 给底部导航留位 */
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #5b7cfa 0%, #7a5cf0 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: 20px; padding: 32px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.brand { text-align: center; margin-bottom: 22px; }
.brand .logo { font-size: 44px; }
.brand h1 { margin: 6px 0 2px; font-size: 24px; }
.brand .sub { color: var(--muted); margin: 0; font-size: 13px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--primary); }
.demo-hint {
  margin-top: 18px; padding: 12px; background: #f3f5ff;
  border-radius: 10px; font-size: 12px; color: #556; text-align: center; line-height: 1.8;
}

/* ---------- 通用按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-d); }
.btn-block { width: 100%; margin-top: 20px; padding: 13px; font-size: 16px; }
.btn-danger { color: var(--red); border-color: #f3c7c7; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-left .logo { font-size: 22px; }
.app-name { font-weight: 700; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.bell {
  position: relative; background: none; border: none; font-size: 22px; padding: 0;
}
.badge {
  position: absolute; top: -4px; right: -6px;
  background: var(--red); color: #fff; font-size: 11px;
  min-width: 17px; height: 17px; line-height: 17px; border-radius: 9px;
  text-align: center; padding: 0 4px;
}
.user-chip { display: flex; align-items: center; gap: 6px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600;
}
.uname { font-size: 13px; }
.role-tag { font-size: 11px; padding: 2px 7px; border-radius: 8px; color: #fff; }
.role-boss { background: #f59e0b; }
.role-employee { background: #10b981; }
.user-info { display: flex; flex-direction: column; gap: 1px; }
.user-name-row { display: flex; align-items: center; gap: 6px; }
.logout-link { font-size: 11px; color: var(--muted); text-decoration: none; line-height: 1.3; }
.logout-link:active { color: var(--primary); }

/* ---------- 通知面板 ---------- */
.notif-panel {
  position: absolute; top: 56px; right: 12px; width: 320px; max-width: 90vw;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); z-index: 60; overflow: hidden;
}
.notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.notif-head .link { background: none; border: none; color: var(--primary); font-size: 13px; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-item.unread { background: #f6f8ff; }
.notif-msg { font-size: 14px; }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.notif-empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- 统计卡片 ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  padding: 14px 12px 4px;
}
.stat-card {
  background: #fff; border-radius: 12px; padding: 14px 8px; text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .num { font-size: 22px; font-weight: 700; }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-pending .num { color: var(--primary); }
.stat-done .num { color: var(--green); }
.stat-overdue .num { color: var(--red); }
.stat-soon .num { color: var(--amber); }

/* ---------- 过滤 ---------- */
.filters {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px;
  position: sticky; top: 56px; background: var(--bg); z-index: 10;
}
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 7px 14px; border-radius: 20px; font-size: 13px;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 任务卡片 ---------- */
.task-list { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.task-card {
  background: #fff; border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); border-left: 4px solid var(--line);
}
.task-card.p-high { border-left-color: var(--red); }
.task-card.p-medium { border-left-color: var(--amber); }
.task-card.p-low { border-left-color: #9ca3af; }
.task-card.is-done { opacity: .65; }
.task-card.is-overdue { border-left-color: var(--red); }
.tc-top { display: flex; justify-content: space-between; gap: 10px; }
.tc-title { font-weight: 600; font-size: 16px; }
.tc-title .seq {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  background: #eef1ff; color: var(--primary);
  font-size: 12px; font-weight: 700; margin-right: 8px; vertical-align: middle;
}
.tc-title .done-mark { color: var(--green); margin-right: 4px; }
.tc-desc { color: #555; font-size: 13px; margin: 6px 0; white-space: pre-wrap; }
.tc-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.tc-meta b { color: var(--text); font-weight: 600; }
.deadline-overdue { color: var(--red); font-weight: 600; }
.deadline-soon { color: var(--amber); font-weight: 600; }
.pill { padding: 2px 8px; border-radius: 8px; font-size: 11px; }
.pill-high { background: #fde8e8; color: var(--red); }
.pill-medium { background: #fef3e2; color: #b9740b; }
.pill-low { background: #eef0f3; color: #6b7280; }
.pill-status-pending { background: #e8eeff; color: var(--primary); }
.pill-status-done { background: #e6f6ec; color: var(--green); }
.tc-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tc-actions .btn { padding: 7px 12px; font-size: 13px; }

/* ---------- 悬浮按钮 ---------- */
.fab {
  position: fixed; right: 18px; bottom: 80px; z-index: 40;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 28px; line-height: 1;
  box-shadow: 0 8px 24px rgba(79,110,247,.45);
}
.fab:active { background: var(--primary-d); }
.fab-secondary { background: #10b981; font-size: 18px; box-shadow: 0 8px 24px rgba(16,185,129,.4); right: 86px; }

/* ---------- 底部导航 ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding: 6px 0; box-shadow: 0 -2px 12px rgba(0,0,0,.05);
}
.bottomnav .bn {
  flex: 1; background: none; border: none; display: flex; flex-direction: column;
  align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0;
}
.bottomnav .bn span { font-size: 11px; }
.bottomnav .bn.active { color: var(--primary); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
/* 关键：让 HTML 的 hidden 属性真正生效（否则上面的 display:flex 会覆盖 hidden） */
.modal[hidden] { display: none; }
@media (min-width: 600px) { .modal { align-items: center; } }
.modal-card {
  background: #fff; width: 100%; max-width: 460px; border-radius: 18px 18px 0 0;
  padding: 18px; max-height: 90vh; overflow-y: auto;
}
@media (min-width: 600px) { .modal-card { border-radius: 18px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 17px; margin-bottom: 12px; }
.modal-head .x { background: none; border: none; font-size: 20px; color: var(--muted); }
.modal label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.modal input, .modal textarea, .modal select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; outline: none; font-family: inherit;
}
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ---------- 任务清单行（发布任务） ---------- */
.row-inline { display: flex; gap: 10px; }
.row-inline label { flex: 1; }
.rows-label { font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.task-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: #fafbfe; }
.row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.row-no {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 600;
}
.row-del { background: none; border: none; color: var(--red); font-size: 12px; }
.task-row .row-title {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; outline: none; margin-bottom: 8px;
}
.task-row .row-desc {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; outline: none; resize: vertical; font-family: inherit;
}
.task-row .row-title:focus, .task-row .row-desc:focus { border-color: var(--primary); }
.add-row-btn { width: 100%; color: var(--primary); border: 1px dashed #b9c4f5; background: #f6f8ff; }

/* ---------- 负责人多选 ---------- */
.field-label { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.assignee-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.assignee-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 20px;
  background: #fff; font-size: 13px; cursor: pointer; user-select: none;
}
.assignee-chip input[type="checkbox"] {
  width: 16px !important; height: 16px; flex: 0 0 auto; padding: 0 !important;
  accent-color: var(--primary); margin: 0;
}
.assignee-chip:has(input:checked) { border-color: var(--primary); background: #eef1ff; color: var(--primary); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(31,36,48,.92); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}

.empty-hint { text-align: center; color: var(--muted); padding: 30px; }

/* 桌面端优化 */
@media (min-width: 720px) {
  body { padding-bottom: 0; }
  .stats { max-width: 900px; margin: 0 auto; }
  .filters, .task-list { max-width: 900px; margin-left: auto; margin-right: auto; }
  .fab { bottom: 30px; }
  .bottomnav { display: none; }
}
