:root {
  --primary: #1a5fb4;
  --primary-dark: #124c93;
  --primary-light: #eaf2fb;
  --accent: #c0392b;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1f2d3d;
  --text-sub: #6b7a8c;
  --green: #27ae60;
  --orange: #e67e22;
  --red: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 42, 67, 0.06), 0 6px 20px rgba(16, 42, 67, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f3d7c 0%, #1a5fb4 55%, #2f7ed1 100%);
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 18px; padding: 44px 40px;
  width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-logo { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.logo-emblem {
  width: 56px; height: 56px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, #1a5fb4, #124c93); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
}
.logo-emblem.small { width: 40px; height: 40px; font-size: 20px; border-radius: 10px; }
.login-title { font-size: 21px; font-weight: 700; color: var(--text); }
.login-sub { font-size: 14px; color: var(--text-sub); margin-top: 2px; }
.login-desc {
  text-align: center; color: var(--primary); font-weight: 600; letter-spacing: 1px;
  padding: 12px 0; margin-bottom: 22px; border-bottom: 1px dashed var(--border);
}
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-card {
  border: 1.5px solid var(--border); border-radius: 12px; padding: 16px;
  text-align: center; transition: all .18s; background: #fff;
}
.role-card:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); }
.role-card .r-icon { font-size: 30px; margin-bottom: 8px; }
.role-card .r-name { font-weight: 700; font-size: 15px; }
.role-card .r-desc { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.login-hint { text-align: center; color: var(--text-sub); font-size: 12px; margin-top: 22px; }

/* ===== 顶栏 ===== */
.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: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--text-sub); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  background: var(--primary-light); color: var(--primary-dark);
  padding: 6px 14px; border-radius: 20px; font-weight: 600; font-size: 13px;
}

/* ===== 布局 ===== */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 220px; background: #fff; border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; justify-content: space-between;
  flex: none;
}
.side-item {
  padding: 12px 16px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
  font-weight: 500; color: var(--text); transition: all .15s;
}
.side-item:hover { background: #f0f4f9; }
.side-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.side-foot { font-size: 11px; color: var(--text-sub); padding: 0 16px; }
.content { flex: 1; padding: 24px; overflow-x: hidden; }

/* ===== 卡片 ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.page-head { margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 700; }
.page-desc { color: var(--text-sub); margin-top: 4px; font-size: 13px; }

/* ===== 统计卡 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.stat-card .s-num { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-card .s-label { color: var(--text-sub); margin-top: 8px; font-size: 13px; }
.stat-card.c-green { border-color: var(--green); } .stat-card.c-green .s-num { color: var(--green); }
.stat-card.c-orange { border-color: var(--orange); } .stat-card.c-orange .s-num { color: var(--orange); }
.stat-card.c-red { border-color: var(--red); } .stat-card.c-red .s-num { color: var(--red); }
.stat-card.c-blue { border-color: var(--primary); } .stat-card.c-blue .s-num { color: var(--primary); }
.stat-card.c-gray { border-color: #9aa7b5; } .stat-card.c-gray .s-num { color: #5b6b7c; }
.stat-card.dash-card { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.stat-card.dash-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.stat-card.dash-card .s-label { display: flex; align-items: center; justify-content: space-between; }

/* ===== 工具栏 ===== */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar .spacer { flex: 1; }
.sup-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-sub); cursor: pointer; white-space: nowrap; user-select: none; }
.sup-toggle input { accent-color: var(--primary); cursor: pointer; }
.view-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.view-tab {
  padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; color: var(--text-sub); transition: all .15s;
}
.view-tab:hover { border-color: var(--primary); color: var(--primary); }
.view-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* ===== 表格 ===== */
.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 12px 16px; font-size: 13px; color: var(--text-sub);
  background: #f7f9fc; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid #f0f2f6; font-size: 13px; }
tr:hover td { background: #f8fbfe; }
.task-no { font-family: Consolas, monospace; font-weight: 700; color: var(--primary-dark); }
.task-name-cell { max-width: 300px; }
.task-name-cell .tn { font-weight: 600; cursor: pointer; }
.task-name-cell .tn:hover { color: var(--primary); }
.task-name-cell .tc { color: var(--text-sub); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }

/* 状态标签 */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-待签领 { background: #fff4e5; color: #b9760b; }
.badge-执行中 { background: #e8f0fb; color: var(--primary-dark); }
.badge-待交付 { background: #f0e7fb; color: #7a3cb5; }
.badge-已办结 { background: #e6f6ec; color: #1e8e4e; }
.badge-已超期 { background: #fde8e6; color: #c0392b; }
.badge-supervise { background: #fde8e6; color: #c0392b; border: 1px solid #f5c6c0; }

/* ===== 按钮 ===== */
.btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; font-weight: 500; transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: #fff; color: var(--red); border-color: #f3c6c0; }
.btn.danger:hover { border-color: var(--red); background: #fde8e6; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn.ghost { border-color: transparent; color: var(--text-sub); }
.btn.ghost:hover { color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 表单 ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field label .req { color: var(--red); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; outline: none; transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 80px; }
.field .tip { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* 子任务条目 */
.item-row {
  display: grid; grid-template-columns: 1fr 180px 160px 40px; gap: 8px; align-items: center; margin-bottom: 8px;
}
.item-row input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.item-del { color: var(--red); background: none; border: none; font-size: 20px; line-height: 1; }

/* ===== 详情抽屉 ===== */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,30,50,0.45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 640px; max-width: 96vw;
  background: #fff; z-index: 50; box-shadow: -10px 0 40px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-head .dh-title { font-size: 17px; font-weight: 700; }
.drawer-close { background: none; border: none; font-size: 26px; color: var(--text-sub); line-height: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }

.detail-section { margin-bottom: 22px; }
.detail-section h3 { font-size: 14px; font-weight: 700; color: var(--primary-dark); margin-bottom: 10px; padding-left: 10px; border-left: 3px solid var(--primary); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.kv { font-size: 13px; }
.kv .k { color: var(--text-sub); }
.kv .v { font-weight: 600; margin-top: 2px; }
.kv-link { cursor: pointer; padding: 4px 6px; border-radius: 6px; transition: background .15s; }
.kv-link:hover { background: var(--bg); }
.kv-link .v { color: var(--primary); }
.content-box {
  background: #f7f9fc; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-size: 13px; line-height: 1.7; white-space: pre-wrap;
}

/* 子任务列表 */
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-li { background: #f7f9fc; border-radius: 8px; padding: 10px 14px; font-size: 13px; border-left: 3px solid var(--primary); }
.item-li .il-leader { color: var(--text-sub); font-size: 12px; margin-top: 4px; }

/* 时间线 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-item::before {
  content: ''; position: absolute; left: -21px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary-light);
}
.tl-item .tl-head { font-size: 13px; font-weight: 600; }
.tl-item .tl-time { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.tl-item .tl-body { font-size: 13px; margin-top: 6px; color: #33475b; }

/* 附件 */
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; }
.attach-chip { background: #f0f4f9; border-radius: 6px; padding: 5px 10px; font-size: 12px; color: var(--primary-dark); }

/* 抽屉底部操作 */
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex-wrap: wrap; }
.msg-box { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

/* Toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #1f2d3d; color: #fff; padding: 10px 22px; border-radius: 8px;
  z-index: 100; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 空状态 */
.empty { text-align: center; color: var(--text-sub); padding: 60px 0; font-size: 14px; }
.empty .e-icon { font-size: 48px; margin-bottom: 12px; }

/* 响应式 */
@media (max-width: 900px) {
  .sidebar { width: 72px; } .side-item { padding: 12px 8px; text-align: center; font-size: 12px; }
  .side-foot { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 120px 40px; }
  .item-row .item-deadline { display: none; }
  .kv-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}

/* ===== 移动端菜单按钮与侧边遮罩（桌面默认隐藏） ===== */
.menu-btn {
  display: none; width: 40px; height: 40px; flex: none;
  border: none; background: none; font-size: 22px; line-height: 1;
  color: var(--text); border-radius: 8px;
}
.menu-btn:hover { background: var(--primary-light); }
.side-mask { display: none; }

/* ===== 移动端适配（手机 ≤768px） ===== */
@media (max-width: 768px) {
  /* 顶栏 */
  .menu-btn { display: flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand { gap: 8px; flex: 1; min-width: 0; }
  .brand-sub { display: none; }
  .brand-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .logo-emblem.small { width: 34px; height: 34px; font-size: 17px; }
  .user-chip { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 5px 10px; font-size: 12px; }
  #logoutBtn { padding: 6px 10px; }

  /* 侧边栏抽屉化 */
  .sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0;
    width: 260px; z-index: 70;
    transform: translateX(-105%); transition: transform .25s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,0.18); padding: 12px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .side-item { text-align: left; font-size: 14px; padding: 14px 16px; }
  .sidebar .side-foot { display: block; }
  .side-mask { display: block; position: fixed; inset: 60px 0 0 0; background: rgba(15,30,50,0.42); z-index: 65; }

  /* 内容区 */
  .layout { display: block; }
  .content { padding: 12px; }
  .page-title { font-size: 17px; }

  /* 统计卡：2 列 */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .s-num { font-size: 22px; }

  /* 表格：横向滚动 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 640px; }

  /* 表单单列 */
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .item-row { grid-template-columns: 1fr; gap: 6px; }
  .item-row .item-deadline, .item-row .item-leader { display: block; }
  .item-row .item-del { position: absolute; top: 0; right: 0; }
  .kv-grid { grid-template-columns: 1fr; }

  /* 详情抽屉全屏 */
  .drawer { width: 100%; max-width: 100vw; }
  .drawer-head { padding: 14px 16px; }
  .drawer-body { padding: 16px; }
  .drawer-foot { padding: 12px 16px; position: sticky; bottom: 0; background: #fff; }

  /* 触控目标加大 */
  .btn { min-height: 40px; padding: 8px 14px; }
  .btn.sm { min-height: 34px; }
  .field input, .field select, .field textarea { font-size: 16px; }
  .view-tab { padding: 8px 14px; }

  /* 工具栏 */
  .toolbar { gap: 8px; }
}
