:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e4e7ec;
  --text: #1f2329;
  --muted: #8a919f;
  --primary: #2563eb;
  --primary-weak: #eaf1ff;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

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

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

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-layer {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 1000;
}
.login-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 36px 32px; width: 320px;
  text-align: center; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin-bottom: 8px; }
.login-card input {
  width: 100%; padding: 10px 12px; margin: 16px 0;
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px;
}
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 52px;
}
.brand { font-weight: 600; font-size: 16px; }
.topbar-actions { display: flex; gap: 8px; }

/* ---------- 布局 ---------- */
.layout { display: flex; height: calc(100vh - 52px); }

.sidebar {
  width: 240px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; font-weight: 600; border-bottom: 1px solid var(--border);
}
.expo-list { list-style: none; flex: 1; overflow-y: auto; padding: 8px; }
.expo-list li {
  padding: 10px 12px; border-radius: var(--radius); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2px;
}
.expo-list li:hover { background: var(--primary-weak); }
.expo-list li.active { background: var(--primary-weak); color: var(--primary); font-weight: 500; }
.expo-list li .count { color: var(--muted); font-size: 12px; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); }

.main { flex: 1; overflow-y: auto; padding: 24px; }

.empty-state { text-align: center; color: var(--muted); margin-top: 120px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ---------- 展会头 ---------- */
.expo-head { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.expo-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.expo-title-row h2 { font-size: 20px; }
.expo-meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.quant-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.quant-card {
  flex: 1; min-width: 120px; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; background: var(--bg);
}
.quant-card .label { color: var(--muted); font-size: 12px; }
.quant-card .value { font-size: 18px; font-weight: 600; margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 6px 2px 10px; border-radius: 20px;
  background: var(--primary-weak); color: var(--primary);
  font-size: 12px; font-weight: 400;
}
.chip-del {
  border: none; background: transparent; color: var(--primary);
  cursor: pointer; font-size: 11px; line-height: 1; padding: 0 2px; opacity: 0.6;
}
.chip-del:hover { opacity: 1; }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.spacer { flex: 1; }
.filters { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.filter-item { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; cursor: pointer; }
.select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* ---------- 按钮 ---------- */
.btn-primary {
  background: var(--primary); color: #fff; border: none;
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
.btn-primary:hover { opacity: 0.9; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
.btn-ghost:hover { background: var(--bg); }
.btn-ghost.small { padding: 4px 8px; font-size: 12px; }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-danger-solid {
  background: var(--danger); color: #fff; border: none;
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
.btn-danger-solid:hover { opacity: 0.9; }

/* 应用内提示条（替代原生 alert） */
#toast {
  position: fixed; left: 50%; bottom: 40px;
  transform: translateX(-50%) translateY(16px);
  background: #1f2329; color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 13px; max-width: 80vw;
  opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 3000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 任务树（WBS 大纲表：固定列对齐 + 树形缩进） ---------- */
.task-tree {
  display: flex; flex-direction: column; gap: 3px;
  max-width: 1080px;
}
.task-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 190px 78px 52px 92px 96px;
  gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px;
}
.task-row.main { border-left: 3px solid var(--primary); }
.task-row:hover { border-color: var(--primary); box-shadow: var(--shadow); }

.cell-title { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; }
.t-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.task-row.main .t-name { font-weight: 600; }

.guide-v { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 1px dashed #d3d9e2; pointer-events: none; }
.guide-h { position: absolute; top: 50%; width: 11px; border-top: 1px dashed #d3d9e2; pointer-events: none; }

.cell-raci { display: flex; flex-wrap: wrap; gap: 3px; }
.cell-due { font-size: 12px; color: var(--muted); }

.cell-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity 0.12s; }
.task-row:hover .cell-actions { opacity: 1; }
.cell-actions button { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 12px; padding: 3px 5px; border-radius: 4px; }
.cell-actions button:hover { background: var(--bg); color: var(--text); }

@media (max-width: 980px) {
  .task-row { grid-template-columns: 1fr 78px 92px 96px; }
  .cell-raci, .cell-pri { display: none; }
}
.badge {
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500;
  background: var(--bg); color: var(--muted);
}
.badge.st-未开始 { background: #f1f5f9; color: #475569; }
.badge.st-进行中 { background: #dbeafe; color: #1d4ed8; }
.badge.st-已完成 { background: #dcfce7; color: #15803d; }
.badge.st-已延期 { background: #fee2e2; color: #b91c1c; }
.badge.st-已取消 { background: #f1f5f9; color: #94a3b8; }

.pri-high { color: var(--danger); font-weight: 600; }
.pri-mid { color: var(--warn); font-weight: 600; }
.pri-low { color: var(--muted); }
.pri-紧急 { color: var(--danger); font-weight: 600; }
.pri-高 { color: var(--warn); font-weight: 600; }
.pri-中 { color: var(--ok); font-weight: 600; }
.pri-低 { color: var(--muted); }

.raci-chips { display: flex; gap: 4px; }
.raci-chip { font-size: 11px; padding: 1px 5px; border-radius: 4px; background: var(--bg); color: var(--muted); }
.raci-chip.filled { background: var(--primary-weak); color: var(--primary); }

.due { font-size: 12px; color: var(--muted); }
.due.overdue { color: var(--danger); font-weight: 600; }
.due.soon { color: var(--warn); font-weight: 600; }

.toggle {
  width: 20px; height: 20px; border: none; background: transparent;
  cursor: pointer; color: var(--muted); font-size: 12px; line-height: 1;
  flex-shrink: 0;
}
.toggle.leaf { cursor: default; opacity: 0.4; }
.type-tag { font-size: 11px; color: var(--muted); margin-left: 4px; flex-shrink: 0; }

/* ---------- 弹窗 ---------- */
.modal-layer {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.modal {
  background: var(--panel); border-radius: 12px; width: 520px; max-width: 92vw;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; font-family: inherit;
}
.form-row textarea { min-height: 60px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.raci-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.raci-grid .form-row { margin-bottom: 0; }
.raci-grid label { text-align: center; font-weight: 600; }

.attach-list { list-style: none; margin-top: 8px; }
.attach-list li { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.attach-list a { color: var(--primary); text-decoration: none; }

/* 响应式 */
@media (max-width: 768px) {
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: 16px; }
}
