:root {
  --primary: #2f6bff;
  --primary-dark: #1f4fd8;
  --bg: #f4f6fb;
  --sidebar: #16233c;
  --sidebar-hover: #22345a;
  --card: #ffffff;
  --text: #1f2a3d;
  --muted: #7b8794;
  --border: #e8ecf3;
  --success: #17b26a;
  --warning: #f79009;
  --danger: #e5484d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- 布局 ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--sidebar);
  color: #cfd8e8;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
}

.sidebar .brand {
  padding: 20px 22px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  letter-spacing: 1px;
}

.sidebar .brand small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #8a9ab5;
  margin-top: 4px;
  letter-spacing: 0;
}

.sidebar .menu { flex: 1; padding: 12px 0; overflow-y: auto; }

.sidebar .menu-group {
  padding: 14px 22px 6px;
  font-size: 11px;
  color: #6b7c99;
  letter-spacing: 1px;
}

.sidebar .menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  color: #cfd8e8;
  font-size: 14px;
  border-left: 3px solid transparent;
}

.sidebar .menu a:hover { background: var(--sidebar-hover); color: #fff; }

.sidebar .menu a.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--primary);
  font-weight: 600;
}

.main { flex: 1; margin-left: 220px; min-width: 0; }

.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .page-title { font-size: 16px; font-weight: 600; }
.topbar .user-box { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }

.content { padding: 22px 24px 40px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 18px;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-body { padding: 18px; }
.card-body.tight { padding: 12px 18px; }

/* ---------- 统计卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-card .icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
}

.stat-card .label { color: var(--muted); font-size: 12px; }
.stat-card .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bg-blue { background: linear-gradient(135deg, #2f6bff, #6d9bff); }
.bg-green { background: linear-gradient(135deg, #17b26a, #4ad991); }
.bg-orange { background: linear-gradient(135deg, #f79009, #ffc26b); }
.bg-purple { background: linear-gradient(135deg, #7a5af8, #b39dff); }
.bg-red { background: linear-gradient(135deg, #e5484d, #ff8a8d); }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: #fafbfe; font-weight: 600; color: #4a5568; font-size: 13px; white-space: nowrap; }
.table tbody tr:hover { background: #fbfcff; }
.table td.nowrap, .table th.nowrap { white-space: nowrap; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 18px;
}

.tag-blue { background: #e8f0ff; color: #2f6bff; }
.tag-green { background: #e6f7ee; color: #17b26a; }
.tag-orange { background: #fff3e0; color: #d97706; }
.tag-red { background: #fdecec; color: #e5484d; }
.tag-gray { background: #f1f3f7; color: #6b7280; }

.level-A { background: #fdecec; color: #e5484d; }
.level-B { background: #fff3e0; color: #d97706; }
.level-C { background: #e8f0ff; color: #2f6bff; }
.level-D { background: #f1f3f7; color: #6b7280; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: #fff; border-color: #f5c2c2; color: var(--danger); }
.btn-danger:hover { background: #fdecec; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-link { border: none; background: none; color: var(--primary); padding: 0; }

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 18px;
}

.form-item label { display: block; font-size: 13px; margin-bottom: 5px; color: #4a5568; }
.form-item .req { color: var(--danger); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filter-bar .form-item { margin: 0; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #16233c 0%, #2f6bff 100%);
}

.login-card {
  width: 380px;
  background: #fff;
  border-radius: 12px;
  padding: 34px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.login-card h1 { font-size: 21px; margin: 0 0 6px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* ---------- 其它 ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a {
  padding: 9px 18px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
}
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

.empty {
  padding: 50px 0;
  text-align: center;
  color: var(--muted);
}

.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; }
.pagination a, .pagination span {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-success { background: #e6f7ee; color: #0f7a45; border: 1px solid #b7ebcd; }
.alert-error { background: #fdecec; color: #b42318; border: 1px solid #f7c5c5; }
.alert-warning { background: #fff6e6; color: #b54708; border: 1px solid #fbd9a5; }
.alert-info { background: #e8f0ff; color: #1f4fd8; border: 1px solid #c4d7ff; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 18px 14px; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -25px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
}
.timeline .meta { font-size: 12px; color: var(--muted); }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }

.invite-box {
  background: #f7f9ff;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  word-break: break-all;
}

.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.small { font-size: 12px; }
.mb0 { margin-bottom: 0; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ---------- H5 手机端 ---------- */
.menu-toggle, .sidebar-close, .mobile-tabbar, .mobile-nav-mask { display: none; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.login-card.bind-card { width: 520px; max-width: 100%; }
body.nav-open { overflow: hidden; }

/* ---------- 任务管理 ---------- */
.rank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.rank-grid .card { margin-bottom: 0; }
.check-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 16px; font-size: 14px; }
.check-box {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: 2px solid currentColor; border-radius: 5px;
  font-size: 15px; font-weight: 700; line-height: 1;
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-head { padding: 8px 4px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfe; border-radius: 6px; }
.calendar-cell { min-height: 98px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: #fff; overflow: hidden; }
.calendar-cell.other { background: #fafbfe; opacity: .65; }
.calendar-cell.today { border-color: var(--primary); box-shadow: 0 0 0 1px rgba(47, 107, 255, .2); }
.calendar-day { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
.calendar-count { font-size: 11px; font-weight: 400; color: var(--primary); }
.calendar-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.work-tag {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 1px 5px; border-radius: 4px; background: #e8f0ff; color: #2f6bff; font-size: 11px;
}

@media (max-width: 768px) {
  body { -webkit-text-size-adjust: 100%; }
  .app-wrapper { display: block; }

  .sidebar {
    width: 76%;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 1050;
    box-shadow: 4px 0 24px rgba(10, 18, 34, .24);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand { position: relative; padding: 16px 18px; }
  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 12px;
    top: 14px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: var(--sidebar-hover);
    color: #fff;
    font-size: 22px;
    line-height: 1;
  }
  .sidebar .sidebar-foot { display: none; }
  .mobile-nav-mask.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 34, .45);
    z-index: 1040;
  }

  .main { margin-left: 0; }
  .topbar { height: 52px; padding: 0 12px; gap: 8px; }
  .menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
  }
  .menu-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; }
  .topbar .page-title { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .user-box { flex-shrink: 0; gap: 10px; font-size: 12px; }
  .topbar .user-box span, .topbar .user-box a[href="/profile"] { display: none; }
  .content { padding: 12px 12px 84px; }

  .card { border-radius: 8px; margin-bottom: 12px; }
  .card-header { padding: 12px; flex-wrap: wrap; font-size: 14px; }
  .card-header .small { flex: 1 1 100%; }
  .card-body { padding: 12px; }
  .card-body.tight { padding: 8px 12px; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-card .icon { width: 36px; height: 36px; font-size: 17px; }
  .stat-card .value { font-size: 19px; }

  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .filter-bar { gap: 8px; }
  .filter-bar .form-item { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .filter-bar > .btn { flex: 1 1 calc(50% - 8px); }
  .form-control, .form-select { font-size: 16px; }
  .btn { min-height: 38px; padding: 7px 12px; font-size: 14px; }
  .btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }

  .tabs { flex-wrap: nowrap; overflow-x: auto; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
  .tabs a { flex: 0 0 auto; padding: 10px 14px; white-space: nowrap; }

  .table-scroll .table { min-width: 520px; }
  .table-scroll[data-cols="6"] .table,
  .table-scroll[data-cols="7"] .table { min-width: 720px; }
  .table-scroll[data-cols="8"] .table,
  .table-scroll[data-cols="9"] .table,
  .table-scroll[data-cols="10"] .table,
  .table-scroll[data-cols="11"] .table { min-width: 900px; }
  .table th, .table td { padding: 8px 10px; }

  .kv { grid-template-columns: 88px minmax(0, 1fr); }
  .invite-box { flex-wrap: wrap; }
  .invite-box span { flex: 1 1 100%; }
  .pagination { justify-content: flex-start; flex-wrap: wrap; }
  .empty { padding: 32px 0; }

  .modal-dialog { margin: 10px; }
  .modal-body { max-height: calc(100vh - 190px); overflow-y: auto; }
  .modal-footer .btn { flex: 1; }

  .mobile-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(16, 24, 40, .06);
  }
  .mobile-tabbar a {
    flex: 1;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: 11px;
    text-decoration: none;
  }
  .mobile-tabbar a svg { width: 20px; height: 20px; }
  .mobile-tabbar a.active { color: var(--primary); font-weight: 600; }
  .mobile-tabbar a:hover { color: var(--primary); }

  .login-page { padding: 14px; align-items: flex-start; }
  .login-card, .login-card.bind-card { width: 100%; max-width: 100%; padding: 24px 20px; margin: 10px 0; }
  .login-page .row { --bs-gutter-x: 0; }
  .login-page .row > .col { flex: 0 0 100%; width: 100%; margin-bottom: 6px; }

  .rank-grid { grid-template-columns: 1fr; }
  .calendar-grid { gap: 3px; }
  .calendar-head { padding: 5px 2px; font-size: 11px; }
  .calendar-cell { min-height: 62px; padding: 3px; border-radius: 5px; }
  .calendar-day { font-size: 11px; }
  .calendar-count { display: none; }
  .calendar-tags { gap: 2px; margin-top: 2px; }
  .work-tag { font-size: 10px; padding: 1px 3px; }
  .check-btn { width: 100%; justify-content: center; }
}
