:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #1f2533;
  --muted: #8a93a6;
  --line: #e6eaf2;
  --primary: #3b6fff;
  --primary-soft: #eaf0ff;
  --danger: #e5484d;
  --green: #18a058;
  --amber: #f0a020;
  --shadow: 0 2px 10px rgba(31,37,51,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

/* Buttons */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { opacity: .9; color: #fff; }
.btn.danger { color: var(--danger); border-color: #f3c6c7; }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; padding: 18px 24px 4px; }
.kpi-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 6px; }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 14px 24px; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.chart-card h3 { margin: 0 0 10px; font-size: 14px; }
.chart-card canvas { max-height: 220px; }

/* Layout */
.layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; padding: 8px 24px 28px; align-items: start; }
.project-list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0 0 10px; font-size: 15px; }
.list-head input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.projects { max-height: 70vh; overflow: auto; }
.proj {
  padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.proj:hover { background: var(--primary-soft); }
.proj.active { background: var(--primary-soft); border-left: 3px solid var(--primary); }
.proj .pname { font-weight: 600; }
.proj .pmeta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; margin-top: 6px; }
.tag.进行中 { background: #eaf0ff; color: var(--primary); }
.tag.已完成 { background: #e7f7ee; color: var(--green); }
.tag.已暂停 { background: #fdf3e3; color: var(--amber); }

/* Detail */
.detail { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-height: 70vh; padding: 18px 20px; }
.empty { display: flex; align-items: center; justify-content: center; height: 60vh; color: var(--muted); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail-head h2 { margin: 0; }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; flex-wrap: wrap; }
.tab { border: none; background: none; padding: 8px 14px; cursor: pointer; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 6px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 500; }
.row-actions { display: flex; gap: 6px; }

/* Forms inside detail add rows */
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; align-items: center; }
.add-row input, .add-row select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.add-row input { flex: 1; min-width: 90px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(20,26,40,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: #fff; border-radius: 14px; width: 540px; max-width: 92vw; max-height: 88vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; }

/* Toast */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #1f2533; color: #fff; padding: 11px 20px; border-radius: 10px; z-index: 80; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 8px 0 18px; }
.stat { background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.stat .s-l { color: var(--muted); font-size: 12px; }
.stat .s-v { font-size: 19px; font-weight: 700; margin-top: 4px; }

@media (max-width: 920px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
